Jive Messenger 2.2.2 Javadoc

org.jivesoftware.messenger
Class ClientSession

java.lang.Object
  extended by org.jivesoftware.messenger.Session
      extended by org.jivesoftware.messenger.ClientSession
All Implemented Interfaces:
ChannelHandler, RoutableChannelHandler

public class ClientSession
extends Session

Represents a session between the server and a client.

Author:
Gaston Dombiak

Field Summary
protected  AuthToken authToken
          The authentication token for this session.
 
Fields inherited from class org.jivesoftware.messenger.Session
CHARSET, conn, sessionManager, status, STATUS_AUTHENTICATED, STATUS_CLOSED, STATUS_CONNECTED, STATUS_STREAMING
 
Constructor Summary
ClientSession(String serverName, Connection connection, StreamID streamID)
          Creates a session with an underlying connection and permission protection.
 
Method Summary
 boolean canFloodOfflineMessages()
          Returns true if the offline messages of the user should be sent to the user when the user becomes online.
static Session createSession(String serverName, org.dom4j.io.XPPPacketReader reader, SocketConnection connection)
          Returns a newly created session between the server and a client.
static Map<String,String> getAllowedIPs()
          Returns the list of IP address that are allowed to connect to the server.
 AuthToken getAuthToken()
          Returns the authentication token associated with this session.
 int getConflictCount()
          Returns the number of conflicts detected on this session.
 Presence getPresence()
          Obtain the presence of this session.
 String getUsername()
          Returns the username associated with this session.
 void incrementConflictCount()
          Increments the conflict by one.
 boolean isInitialized()
          Flag indicating if this session has been initialized once coming online.
 boolean isOfflineFloodStopped()
          Returns true if the user requested to not receive offline messages when sending an available presence.
 void process(Packet packet)
          Process an XMPP packet.
static void setAllowedIPs(Map<String,String> allowed)
          Sets the list of IP address that are allowed to connect to the server.
 void setAnonymousAuth()
          Initialize the session as an anonymous login.
 void setAuthToken(AuthToken auth, UserManager userManager, String resource)
          Initialize the session with a valid authentication token and resource name.
 void setInitialized(boolean isInit)
          Sets the initialization state of the session.
 void setOfflineFloodStopped(boolean offlineFloodStopped)
          Sets if the user requested to not receive offline messages when sending an available presence.
 Presence setPresence(Presence presence)
          Set the presence of this session
 String toString()
           
 
Methods inherited from class org.jivesoftware.messenger.Session
getAddress, getConnection, getCreationDate, getLastActiveDate, getNumClientPackets, getNumServerPackets, getServerName, getStatus, getStreamID, incrementClientPacketCount, incrementServerPacketCount, setAddress, setStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

authToken

protected AuthToken authToken
The authentication token for this session.

Constructor Detail

ClientSession

public ClientSession(String serverName,
                     Connection connection,
                     StreamID streamID)
Creates a session with an underlying connection and permission protection.

Parameters:
connection - The connection we are proxying
Method Detail

createSession

public static Session createSession(String serverName,
                                    org.dom4j.io.XPPPacketReader reader,
                                    SocketConnection connection)
                             throws org.xmlpull.v1.XmlPullParserException,
                                    UnauthorizedException,
                                    IOException
Returns a newly created session between the server and a client. The session will be created and returned only if correct name/prefix (i.e. 'stream' or 'flash') and namespace were provided by the client.

Parameters:
serverName - the name of the server where the session is connecting to.
reader - the reader that is reading the provided XML through the connection.
connection - the connection with the client.
Returns:
a newly created session between the server and a client.
Throws:
org.xmlpull.v1.XmlPullParserException
UnauthorizedException
IOException

getAllowedIPs

public static Map<String,String> getAllowedIPs()
Returns the list of IP address that are allowed to connect to the server. If the list is empty then anyone is allowed to connect to the server.

Returns:
the list of IP address that are allowed to connect to the server.

setAllowedIPs

public static void setAllowedIPs(Map<String,String> allowed)
Sets the list of IP address that are allowed to connect to the server. If the list is empty then anyone is allowed to connect to the server.

Parameters:
allowed - the list of IP address that are allowed to connect to the server.

getUsername

public String getUsername()
                   throws UserNotFoundException
Returns the username associated with this session. Use this information with the user manager to obtain the user based on username.

Returns:
the username associated with this session
Throws:
UserNotFoundException - if a user is not associated with a session (the session has not authenticated yet)

setAuthToken

public void setAuthToken(AuthToken auth,
                         UserManager userManager,
                         String resource)
                  throws UserNotFoundException
Initialize the session with a valid authentication token and resource name. This automatically upgrades the session's status to authenticated and enables many features that are not available until authenticated (obtaining managers for example).

Parameters:
auth - the authentication token obtained from the AuthFactory.
resource - the resource this session authenticated under.
userManager - the user manager this authentication occured under.
Throws:
UserNotFoundException

setAnonymousAuth

public void setAnonymousAuth()

Initialize the session as an anonymous login.

This automatically upgrades the session's status to authenticated and enables many features that are not available until authenticated (obtaining managers for example).


getAuthToken

public AuthToken getAuthToken()
Returns the authentication token associated with this session.

Returns:
the authentication token associated with this session (can be null).

isInitialized

public boolean isInitialized()
Flag indicating if this session has been initialized once coming online. Session initialization occurs after the session receives the first "available" presence update from the client. Initialization actions include pushing offline messages, presence subscription requests, and presence statuses to the client. Initialization occurs only once following the first available presence transition.

Returns:
True if the session has already been initializsed

setInitialized

public void setInitialized(boolean isInit)
Sets the initialization state of the session.

Parameters:
isInit - True if the session has been initialized
See Also:
isInitialized()

canFloodOfflineMessages

public boolean canFloodOfflineMessages()
Returns true if the offline messages of the user should be sent to the user when the user becomes online. If the user sent a disco request with node "http://jabber.org/protocol/offline" before the available presence then do not flood the user with the offline messages. If the user is connected from many resources then if one of the sessions stopped the flooding then no session should flood the user.

Returns:
true if the offline messages of the user should be sent to the user when the user becomes online.

isOfflineFloodStopped

public boolean isOfflineFloodStopped()
Returns true if the user requested to not receive offline messages when sending an available presence. The user may send a disco request with node "http://jabber.org/protocol/offline" so that no offline messages are sent to the user when he becomes online. If the user is connected from many resources then if one of the sessions stopped the flooding then no session should flood the user.

Returns:
true if the user requested to not receive offline messages when sending an available presence.

setOfflineFloodStopped

public void setOfflineFloodStopped(boolean offlineFloodStopped)
Sets if the user requested to not receive offline messages when sending an available presence. The user may send a disco request with node "http://jabber.org/protocol/offline" so that no offline messages are sent to the user when he becomes online. If the user is connected from many resources then if one of the sessions stopped the flooding then no session should flood the user.

Parameters:
offlineFloodStopped - if the user requested to not receive offline messages when sending an available presence.

getPresence

public Presence getPresence()
Obtain the presence of this session.

Returns:
The presence of this session or null if not authenticated

setPresence

public Presence setPresence(Presence presence)
Set the presence of this session

Parameters:
presence - The presence for the session
Returns:
The old priority of the session or null if not authenticated

getConflictCount

public int getConflictCount()
Returns the number of conflicts detected on this session. Conflicts typically occur when another session authenticates properly to the user account and requests to use a resource matching the one in use by this session. Administrators may configure the server to automatically kick off existing sessions when their conflict count exceeds some limit including 0 (old sessions are kicked off immediately to accommodate new sessions). Conflicts typically signify the existing (old) session is broken/hung.

Returns:
The number of conflicts detected for this session

incrementConflictCount

public void incrementConflictCount()
Increments the conflict by one.


process

public void process(Packet packet)
Description copied from interface: ChannelHandler
Process an XMPP packet.

Parameters:
packet - a packet to process.

toString

public String toString()
Overrides:
toString in class Session

Jive Messenger 2.2.2 Javadoc

Copyright © 1999-2004 Jive Software.