Commit 2e1f93f0 authored by Dave Cridland's avatar Dave Cridland Committed by Guus der Kinderen

OF-1309 Move to using DomainPairs exclusively

parent 528f8cd8
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -12,18 +12,6 @@ public class DomainPair { ...@@ -12,18 +12,6 @@ public class DomainPair {
this.remote = remote; this.remote = remote;
} }
public int hashCode() {
return toString().hashCode();
}
public boolean equals(Object other) {
if (other instanceof DomainPair) {
DomainPair domainPair = (DomainPair)other;
return domainPair.local.equals(this.local) && domainPair.remote.equals(this.remote);
}
return false;
}
public String toString() { public String toString() {
return "{" + local + " -> " + remote + "}"; return "{" + local + " -> " + remote + "}";
} }
...@@ -35,4 +23,22 @@ public class DomainPair { ...@@ -35,4 +23,22 @@ public class DomainPair {
public String getRemote() { public String getRemote() {
return remote; return remote;
} }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DomainPair that = (DomainPair) o;
if (!local.equals(that.local)) return false;
return remote.equals(that.remote);
}
@Override
public int hashCode() {
int result = local.hashCode();
result = 31 * result + remote.hashCode();
return result;
}
} }
/* /*
* Copyright (C) 2005-2008 Jive Software. All rights reserved. * Copyright (C) 2005-2008 Jive Software. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.jivesoftware.openfire.session; package org.jivesoftware.openfire.session;
import java.util.Collection; import java.util.Collection;
/** /**
* Server-to-server communication is done using two TCP connections between the servers. One * Server-to-server communication is done using two TCP connections between the servers. One
* connection is used for sending packets while the other connection is used for receiving packets. * connection is used for sending packets while the other connection is used for receiving packets.
* The <tt>OutgoingServerSession</tt> represents the connection to a remote server that will only * The <tt>OutgoingServerSession</tt> represents the connection to a remote server that will only
* be used for sending packets.<p> * be used for sending packets.<p>
* *
* Once the connection has been established with the remote server and at least a domain has been * Once the connection has been established with the remote server and at least a domain has been
* authenticated then a new route will be added to the routing table for this connection. For * authenticated then a new route will be added to the routing table for this connection. For
* optimization reasons the same outgoing connection will be used even if the remote server has * optimization reasons the same outgoing connection will be used even if the remote server has
* several hostnames. However, different routes will be created in the routing table for each * several hostnames. However, different routes will be created in the routing table for each
* hostname of the remote server. * hostname of the remote server.
* *
* @author Gaston Dombiak * @author Gaston Dombiak
*/ */
public interface OutgoingServerSession extends ServerSession { public interface OutgoingServerSession extends ServerSession {
/** /**
* Returns a collection with all the domains, subdomains and virtual hosts that where * Authenticates a subdomain of this server with the specified remote server over an exsiting
* authenticated. The remote server will accept packets sent from any of these domains, * outgoing connection. If the existing session was using server dialback then a new db:result
* subdomains and virtual hosts. * is going to be sent to the remote server. But if the existing session was TLS+SASL based
* * then just assume that the subdomain was authenticated by the remote server.
* @return domains, subdomains and virtual hosts that where validated. *
*/ * @param domain the locally domain to authenticate with the remote server.
Collection<String> getAuthenticatedDomains(); * @param hostname the domain of the remote server.
* @return True if the domain was authenticated by the remote server.
/** */
* Adds a new authenticated domain, subdomain or virtual host to the list of boolean authenticateSubdomain(String domain, String hostname);
* authenticated domains for the remote server. The remote server will accept packets
* sent from this new authenticated domain. /**
* * Checks to see if a pair of domains has previously been authenticated.
* @param domain the new authenticated domain, subdomain or virtual host to add. *
*/ * Since domains are authenticated as pairs, authenticating A->B does
void addAuthenticatedDomain(String domain); * not imply anything about A-->C or D->B.
*
/** * @param local the local domain (previously: authenticated domain)
* Returns the list of hostnames related to the remote server. This tracking is useful for * @param remote the remote domain (previous: hostname)
* reusing the same session for the same remote server even if the server has many names. * @return True if the pair of domains has been authenticated.
* */
* @return the list of hostnames related to the remote server. boolean checkOutgoingDomainPair(String local, String remote);
*/
Collection<String> getHostnames(); /**
* Marks a domain pair as being authenticated.
/** *
* Adds a new hostname to the list of known hostnames of the remote server. This tracking is * @param local the locally hosted domain.
* useful for reusing the same session for the same remote server even if the server has * @param remote the remote domain.
* many names. */
* void addOutgoingDomainPair(String local, String remote);
* @param hostname the new known name of the remote server
*/ /**
void addHostname(String hostname); * Obtains all authenticated domain pairs.
*
/** * Most callers should avoid accessing this and use a simple check as above.
* Authenticates a subdomain of this server with the specified remote server over an exsiting *
* outgoing connection. If the existing session was using server dialback then a new db:result * @return collection of authenticated DomainPairs
* is going to be sent to the remote server. But if the existing session was TLS+SASL based */
* then just assume that the subdomain was authenticated by the remote server. Collection<DomainPair> getOutgoingDomainPairs();
* }
* @param domain the local subdomain to authenticate with the remote server.
* @param hostname the hostname of the remote server.
* @return True if the subdomain was authenticated by the remote server.
*/
boolean authenticateSubdomain(String domain, String hostname);
boolean checkOutgoingDomainPair(String local, String remote);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment