2222
2323import java .net .InetAddress ;
2424import java .util .ArrayList ;
25- import java .util .Arrays ;
2625import java .util .Collection ;
2726import java .util .Collections ;
28- import java .util .Date ;
29- import java .util .Deque ;
3027import java .util .HashSet ;
3128import java .util .Iterator ;
3229import java .util .List ;
3330import java .util .Locale ;
3431import java .util .Map ;
35- import java .util .Map .Entry ;
3632import java .util .Set ;
3733import java .util .concurrent .atomic .AtomicInteger ;
3834import java .util .concurrent .locks .Lock ;
3935
40- import org .dom4j .Element ;
4136import org .jivesoftware .openfire .audit .AuditStreamIDFactory ;
4237import org .jivesoftware .openfire .auth .AuthToken ;
4338import org .jivesoftware .openfire .auth .UnauthorizedException ;
4439import org .jivesoftware .openfire .cluster .ClusterEventListener ;
4540import org .jivesoftware .openfire .cluster .ClusterManager ;
4641import org .jivesoftware .openfire .component .InternalComponentManager ;
4742import org .jivesoftware .openfire .container .BasicModule ;
48- import org .jivesoftware .openfire .disco .DiscoInfoProvider ;
49- import org .jivesoftware .openfire .disco .DiscoItem ;
50- import org .jivesoftware .openfire .disco .DiscoItemsProvider ;
51- import org .jivesoftware .openfire .disco .DiscoServerItem ;
52- import org .jivesoftware .openfire .disco .ServerItemsProvider ;
5343import org .jivesoftware .openfire .event .SessionEventDispatcher ;
5444import org .jivesoftware .openfire .http .HttpConnection ;
5545import org .jivesoftware .openfire .http .HttpSession ;
7060import org .jivesoftware .openfire .session .RemoteSessionLocator ;
7161import org .jivesoftware .openfire .session .Session ;
7262import org .jivesoftware .openfire .spi .BasicStreamIDFactory ;
73- import org .jivesoftware .openfire .streammanagement .StreamManager ;
7463import org .jivesoftware .openfire .user .UserManager ;
75- import org .jivesoftware .openfire .user .UserNotFoundException ;
7664import org .jivesoftware .util .JiveGlobals ;
7765import org .jivesoftware .util .LocaleUtils ;
78- import org .jivesoftware .util .Log ;
79- import org .jivesoftware .util .XMPPDateTimeFormat ;
8066import org .jivesoftware .util .cache .Cache ;
8167import org .jivesoftware .util .cache .CacheFactory ;
8268import org .slf4j .Logger ;
8369import org .slf4j .LoggerFactory ;
84- import org .xmpp .forms .DataForm ;
8570import org .xmpp .packet .JID ;
8671import org .xmpp .packet .Message ;
8772import org .xmpp .packet .Packet ;
@@ -145,15 +130,15 @@ public class SessionManager extends BasicModule implements ClusterEventListener/
145130 * Cache (unlimited, never expire) that holds incoming sessions of remote servers.
146131 * Key: stream ID that identifies the socket/session, Value: nodeID
147132 */
148- private Cache <String , byte []> incomingServerSessionsCache ;
133+ private Cache <StreamID , byte []> incomingServerSessionsCache ;
149134 /**
150135 * Cache (unlimited, never expire) that holds list of incoming sessions
151136 * originated from the same remote server (domain/subdomain). For instance, jabber.org
152137 * may have 2 connections to the server running in jivesoftware.com (one socket to
153138 * jivesoftware.com and the other socket to conference.jivesoftware.com).
154139 * Key: remote hostname (domain/subdomain), Value: list of stream IDs that identify each socket.
155140 */
156- private Cache <String , List <String >> hostnameSessionsCache ;
141+ private Cache <String , List <StreamID >> hostnameSessionsCache ;
157142
158143 /**
159144 * Cache (unlimited, never expire) that holds domains, subdomains and virtual
@@ -167,7 +152,7 @@ public class SessionManager extends BasicModule implements ClusterEventListener/
167152 * will have access to this clustered cache even in the case of this node going
168153 * down.
169154 */
170- private Cache <String , Set <String >> validatedDomainsCache ;
155+ private Cache <StreamID , Set <String >> validatedDomainsCache ;
171156
172157 private ClientSessionListener clientSessionListener = new ClientSessionListener ();
173158 private ComponentSessionListener componentSessionListener = new ComponentSessionListener ();
@@ -465,15 +450,15 @@ public void outgoingServerSessionCreated(LocalOutgoingServerSession session) {
465450 */
466451 public void registerIncomingServerSession (String hostname , LocalIncomingServerSession session ) {
467452 // Keep local track of the incoming server session connected to this JVM
468- String streamID = session .getStreamID (). getID ();
453+ StreamID streamID = session .getStreamID ();
469454 localSessionManager .addIncomingServerSessions (streamID , session );
470455 // Keep track of the nodeID hosting the incoming server session
471456 incomingServerSessionsCache .put (streamID , server .getNodeID ().toByteArray ());
472457 // Update list of sockets/sessions coming from the same remote hostname
473458 Lock lock = CacheFactory .getLock (hostname , hostnameSessionsCache );
474459 try {
475460 lock .lock ();
476- List <String > streamIDs = hostnameSessionsCache .get (hostname );
461+ List <StreamID > streamIDs = hostnameSessionsCache .get (hostname );
477462 if (streamIDs == null ) {
478463 streamIDs = new ArrayList <>();
479464 }
@@ -508,7 +493,7 @@ public void registerIncomingServerSession(String hostname, LocalIncomingServerSe
508493 */
509494 public void unregisterIncomingServerSession (String hostname , IncomingServerSession session ) {
510495 // Remove local track of the incoming server session connected to this JVM
511- String streamID = session .getStreamID (). getID ();
496+ StreamID streamID = session .getStreamID ();
512497 localSessionManager .removeIncomingServerSessions (streamID );
513498 // Remove track of the nodeID hosting the incoming server session
514499 incomingServerSessionsCache .remove (streamID );
@@ -517,7 +502,7 @@ public void unregisterIncomingServerSession(String hostname, IncomingServerSessi
517502 Lock lock = CacheFactory .getLock (hostname , hostnameSessionsCache );
518503 try {
519504 lock .lock ();
520- List <String > streamIDs = hostnameSessionsCache .get (hostname );
505+ List <StreamID > streamIDs = hostnameSessionsCache .get (hostname );
521506 if (streamIDs != null ) {
522507 streamIDs .remove (streamID );
523508 if (streamIDs .isEmpty ()) {
@@ -563,7 +548,7 @@ public void unregisterIncomingServerSession(String hostname, IncomingServerSessi
563548 * @param streamID id that uniquely identifies the session.
564549 * @return domains, subdomains and virtual hosts that where validated.
565550 */
566- public Collection <String > getValidatedDomains (String streamID ) {
551+ public Collection <String > getValidatedDomains (StreamID streamID ) {
567552 Lock lock = CacheFactory .getLock (streamID , validatedDomainsCache );
568553 try {
569554 lock .lock ();
@@ -850,7 +835,7 @@ public Collection<ClientSession> getSessions(SessionResultFilter filter) {
850835 * @param streamID the stream ID that identifies the incoming server session hosted by this JVM.
851836 * @return the incoming server session hosted by this JVM or null if none was found.
852837 */
853- public LocalIncomingServerSession getIncomingServerSession (String streamID ) {
838+ public LocalIncomingServerSession getIncomingServerSession (StreamID streamID ) {
854839 return localSessionManager .getIncomingServerSession (streamID );
855840 }
856841
@@ -863,7 +848,7 @@ public LocalIncomingServerSession getIncomingServerSession(String streamID) {
863848 * @return the sessions that were originated by a remote server.
864849 */
865850 public List <IncomingServerSession > getIncomingServerSessions (String hostname ) {
866- List <String > streamIDs ;
851+ List <StreamID > streamIDs ;
867852 // Get list of sockets/sessions coming from the remote hostname
868853 Lock lock = CacheFactory .getLock (hostname , hostnameSessionsCache );
869854 try {
@@ -880,7 +865,7 @@ public List<IncomingServerSession> getIncomingServerSessions(String hostname) {
880865 else {
881866 // Collect the sessions associated to the found stream IDs
882867 List <IncomingServerSession > sessions = new ArrayList <>();
883- for (String streamID : streamIDs ) {
868+ for (StreamID streamID : streamIDs ) {
884869 // Search in local hosted sessions
885870 IncomingServerSession session = localSessionManager .getIncomingServerSession (streamID );
886871 RemoteSessionLocator locator = server .getRemoteSessionLocator ();
@@ -1608,14 +1593,14 @@ private void restoreCacheContent() {
16081593
16091594 // Add incoming server sessions hosted locally to the cache (using new nodeID)
16101595 for (LocalIncomingServerSession session : localSessionManager .getIncomingServerSessions ()) {
1611- String streamID = session .getStreamID (). getID ();
1596+ StreamID streamID = session .getStreamID ();
16121597 incomingServerSessionsCache .put (streamID , server .getNodeID ().toByteArray ());
16131598 for (String hostname : session .getValidatedDomains ()) {
16141599 // Update list of sockets/sessions coming from the same remote hostname
16151600 Lock lock = CacheFactory .getLock (hostname , hostnameSessionsCache );
16161601 try {
16171602 lock .lock ();
1618- List <String > streamIDs = hostnameSessionsCache .get (hostname );
1603+ List <StreamID > streamIDs = hostnameSessionsCache .get (hostname );
16191604 if (streamIDs == null ) {
16201605 streamIDs = new ArrayList <>();
16211606 }
0 commit comments