org.jdesktop.wonderland.client.login
Class ServerSessionManager

java.lang.Object
  extended by org.jdesktop.wonderland.client.login.ServerSessionManager

public class ServerSessionManager
extends java.lang.Object

Manager for all the sessions for a particular server

Author:
jkaplan

Nested Class Summary
static class ServerSessionManager.DefaultSessionCreator
           
 class ServerSessionManager.EitherLoginControl
          A wrapper that works with either a NoAuthLoginControl or a WebServiceLoginControl, depending on which method the UI uses.
 class ServerSessionManager.LoginControl
           
 class ServerSessionManager.NoAuthLoginControl
           
 class ServerSessionManager.UserPasswordLoginControl
           
 class ServerSessionManager.WebServiceLoginControl
           
 
Method Summary
 void addLifecycleListener(SessionLifecycleListener listener)
          Add a lifecycle listener.
 void addServerStatusListener(ServerStatusListener listener)
          Add a session status listener.
protected  void checkTimeStamp(ServerDetails details)
          Check the server timestamp, and disconnect if it is newer than the timestamp we have.
protected  ServerSessionManager.LoginControl createLoginControl(AuthenticationInfo info)
          Create a new LoginControl of the appropriate type
 WonderlandSession createSession()
          Create a new WonderlandSession using the default session creator
<T extends WonderlandSession>
T
createSession(SessionCreator<T> creator)
          Create a new WonderlandSession using a custom session creator
 void disconnect()
          Disconnect this session.
<T extends WonderlandSession>
java.util.Collection<T>
getAllSession(java.lang.Class<T> clazz)
          Get all sessions that implement the given type
 java.util.Collection<WonderlandSession> getAllSessions()
          Get all sessions
 ScannedClassLoader getClassloader()
          Get the classloader this session uses to load plugins.
 CredentialManager getCredentialManager()
          Get the credential manager for making secure connections back to this server.
 ServerDetails getDetails()
          Get the details for this server
 WonderlandSession getPrimarySession()
          Get the primary session
 java.lang.String getServerNameAndPort()
          Get the server URL as a string: <server name>:<port>
 java.lang.String getServerURL()
          Get the server URL this server session manager represents.
 java.lang.String getUsername()
          Get the username this session is connected as.
 boolean isConnected()
          Determine if this session manager is connected to the server.
protected  ServerDetails loadDetails(java.lang.String serverURL)
          Load the server details for the server
 void removeLifecycleListener(SessionLifecycleListener listener)
          Remove a lifecycle listener.
 void removeServerStatusListener(ServerStatusListener listener)
          Remove a session status listener.
protected  void requestLogin(ServerSessionManager.LoginControl control)
          Request login from the given login control object
 void setPrimarySession(WonderlandSession primarySession)
          Set the primary session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getServerURL

public java.lang.String getServerURL()
Get the server URL this server session manager represents. This is the canonical URL returned by the server that was originally requested, not necessarily the original URL that was passed in

Returns:
the canonical server URL

getServerNameAndPort

public java.lang.String getServerNameAndPort()
Get the server URL as a string: <server name>:<port>

Returns:
<server name>:<port>

getDetails

public ServerDetails getDetails()
Get the details for this server

Returns:
the details for this server

isConnected

public boolean isConnected()
Determine if this session manager is connected to the server. This method will return true after the first call to create session, once login has completed and all plugins have been initialized.

Returns:
true if this session manager is connected to the server, or false if not

disconnect

public void disconnect()
Disconnect this session. All sessions will be disconnected, and all plugins will be cleaned up.


getUsername

public java.lang.String getUsername()
Get the username this session is connected as. Only valid after login has been requested.

Returns:
the username this session is logged in as, or null if this session is not connected

getCredentialManager

public CredentialManager getCredentialManager()
Get the credential manager for making secure connections back to this server. Only valid after login has completed.

Returns:
the credential manager, or null if this session manager is not yet connected.

createSession

public WonderlandSession createSession()
                                throws LoginFailureException
Create a new WonderlandSession using the default session creator

Returns:
the newly created session
Throws:
LoginFailureException - if there is a problem creating the session with the login credentials from this manager

createSession

public <T extends WonderlandSession> T createSession(SessionCreator<T> creator)
                                          throws LoginFailureException
Create a new WonderlandSession using a custom session creator

Parameters:
creator - the SessionCreator to use when creating the session
Returns:
the newly created session
Throws:
LoginFailureException - if there is a problem creating the session with the login credentials from this manager

getAllSessions

public java.util.Collection<WonderlandSession> getAllSessions()
Get all sessions

Returns:
a list of all sessions

getAllSession

public <T extends WonderlandSession> java.util.Collection<T> getAllSession(java.lang.Class<T> clazz)
Get all sessions that implement the given type

Parameters:
clazz - the class of session to get

getPrimarySession

public WonderlandSession getPrimarySession()
Get the primary session

Returns:
the primary session

setPrimarySession

public void setPrimarySession(WonderlandSession primarySession)
Set the primary session. The primary session must be in the connected state. It will be removed automatically if it disconnects.

Parameters:
primary - the primary session

addLifecycleListener

public void addLifecycleListener(SessionLifecycleListener listener)
Add a lifecycle listener. This will receive messages for all clients that are created or change status

Parameters:
listener - the listener to add

removeLifecycleListener

public void removeLifecycleListener(SessionLifecycleListener listener)
Remove a lifecycle listener.

Parameters:
listener - the listener to remove

addServerStatusListener

public void addServerStatusListener(ServerStatusListener listener)
Add a session status listener. This will be notified when this session connects or disconnects.

Parameters:
listener - the listener to add

removeServerStatusListener

public void removeServerStatusListener(ServerStatusListener listener)
Remove a session status listener.

Parameters:
listener - the listener to remove

getClassloader

public ScannedClassLoader getClassloader()
Get the classloader this session uses to load plugins. Only valid after login has been requested.

Returns:
the classloader this session uses, or null if this session is not connected

loadDetails

protected ServerDetails loadDetails(java.lang.String serverURL)
                             throws java.io.IOException
Load the server details for the server

Parameters:
serverURL - the URL of the server to load details for
Throws:
java.io.IOException - if there is an error loading or decoding the details

checkTimeStamp

protected void checkTimeStamp(ServerDetails details)
                       throws LoginFailureException
Check the server timestamp, and disconnect if it is newer than the timestamp we have.

Throws:
LoginFailureException - if there is an error checking the timestamp

createLoginControl

protected ServerSessionManager.LoginControl createLoginControl(AuthenticationInfo info)
Create a new LoginControl of the appropriate type

Parameters:
authInfo - the authentication info
Returns:
a new LoginControl for the given type

requestLogin

protected void requestLogin(ServerSessionManager.LoginControl control)
                     throws LoginFailureException
Request login from the given login control object

Parameters:
loginControl - the login control object to get login info from throws LoginFailureException if the login fails or is cancelled
Throws:
LoginFailureException


Open Wonderland - http://openwonderland.org