Openfire 3.9.3 Javadoc

org.jivesoftware.openfire.http
Class HttpSession

java.lang.Object
  extended by org.jivesoftware.openfire.session.LocalSession
      extended by org.jivesoftware.openfire.session.LocalClientSession
          extended by org.jivesoftware.openfire.http.HttpSession
All Implemented Interfaces:
ChannelHandler, RoutableChannelHandler, ClientSession, Session

public class HttpSession
extends LocalClientSession

A session represents a series of interactions with an XMPP client sending packets using the HTTP Binding protocol specified in XEP-0124. A session can have several client connections open simultaneously while awaiting packets bound for the client from the server.

Author:
Alexander Wenckus

Nested Class Summary
static class HttpSession.HttpVirtualConnection
          A virtual server connection relates to a http session which its self can relate to many http connections.
 
Field Summary
 
Fields inherited from class org.jivesoftware.openfire.session.LocalClientSession
authToken
 
Fields inherited from class org.jivesoftware.openfire.session.LocalSession
CHARSET, conn, sessionManager, status
 
Fields inherited from interface org.jivesoftware.openfire.session.Session
MAJOR_VERSION, MINOR_VERSION, STATUS_AUTHENTICATED, STATUS_CLOSED, STATUS_CONNECTED
 
Constructor Summary
HttpSession(PacketDeliverer backupDeliverer, String serverName, InetAddress address, StreamID streamID, long rid, HttpConnection connection)
           
 
Method Summary
 void addSessionCloseListener(SessionListener listener)
          Adds a SessionListener to this session.
 void close()
          Closes the session.
protected  String consumeResponse(HttpConnection connection)
          Returns the response for a specific connection instance.
 void deliver(org.xmpp.packet.Packet stanza)
           
 String getAvailableStreamFeatures()
          Returns a text with the available stream features.
 Collection<org.dom4j.Element> getAvailableStreamFeaturesElements()
          Returns the stream features which are available for this session.
 int getHold()
          Specifies the maximum number of requests the connection manager is allowed to keep waiting at any one time during the session.
 int getInactivityTimeout()
          Returns the time, in seconds, after which this session will be considered inactive and terminated.
 String getLanguage()
          Returns the language this session is using.
 long getLastAcknowledged()
          Returns the highest 'rid' attribute the server has received where it has also received all requests with lower 'rid' values.
 long getLastActivity()
          Returns the time in milliseconds since the epoch that this session was last active.
 int getMajorVersion()
          Returns the major version of BOSH which this session utilizes.
 int getMaxPause()
          Returns the maximum length of a temporary session pause (in seconds) that the client MAY request.
 int getMaxPollingInterval()
          Returns the max interval within which a client can send polling requests.
 int getMaxRequests()
          Returns the max number of requests it is permissible for this session to have open at any one time.
 int getMinorVersion()
          Returns the major version of BOSH which this session utilizes.
 X509Certificate[] getPeerCertificates()
          Return the X509Certificates associated with this session.
 int getWait()
          Specifies the longest time (in seconds) that the connection manager is allowed to wait before responding to any request during the session.
 boolean isClosed()
          Returns true if this session has been closed and no longer actively accepting connections.
 boolean isPollingSession()
          Returns true if this session is a polling session.
 boolean isSecure()
          Returns true if all connections on this session should be secured, and false if they should not.
 void pause(int duration)
          Pauses the session for the given amount of time.
 void removeSessionCloseListener(SessionListener listener)
          Removes a SessionListener from this session.
 void resetInactivityTimeout()
          Resets the inactivity timeout of this session to default.
protected  void sendPendingPackets()
          This methods sends any pending packets in the session.
 void setDefaultInactivityTimeout(int defaultInactivityTimeout)
          Sets the default inactivity timeout of this session.
 void setHold(int hold)
          Specifies the maximum number of requests the connection manager is allowed to keep waiting at any one time during the session.
 void setInactivityTimeout(int inactivityTimeout)
          Sets the time, in seconds, after which this session will be considered inactive and be be terminated.
 void setLanguage(String language)
          Sets the language this session is using.
 void setLastResponseEmpty(boolean lastResponseEmpty)
          lastResponseEmpty true if last response of this session is an empty body element.
 void setMajorVersion(int majorVersion)
          Sets the major version of BOSH which the client implements.
 void setMaxPause(int maxPause)
          Sets the maximum length of a temporary session pause (in seconds) that the client MAY request.
 void setMaxPollingInterval(int maxPollingInterval)
          Sets the max interval within which a client can send polling requests.
 void setMaxRequests(int maxRequests)
          The max number of requests it is permissible for this session to have open at any one time.
 void setMinorVersion(int minorVersion)
          Sets the minor version of BOSH which the client implements.
protected  void setSecure(boolean isSecure)
          Sets whether the initial request on the session was secure.
 void setWait(int wait)
          Specifies the longest time (in seconds) that the connection manager is allowed to wait before responding to any request during the session.
 
Methods inherited from class org.jivesoftware.openfire.session.LocalClientSession
canFloodOfflineMessages, canProcess, createSession, getActiveList, getAllowedAnonymIPs, getAllowedIPs, getAuthToken, getCompressionPolicy, getDefaultList, getPresence, getTLSPolicy, getUsername, incrementConflictCount, isAllowed, isAnonymousUser, isInitialized, isMessageCarbonsEnabled, isOfflineFloodStopped, setActiveList, setAllowedAnonymIPs, setAllowedIPs, setAnonymousAuth, setAuthToken, setAuthToken, setCompressionPolicy, setDefaultList, setInitialized, setMessageCarbonsEnabled, setOfflineFloodStopped, setPresence, setTLSPolicy, toString, wasAvailable
 
Methods inherited from class org.jivesoftware.openfire.session.LocalSession
decodeVersion, deliverRawText, getAddress, getConnection, getCreationDate, getHostAddress, getHostName, getLastActiveDate, getNumClientPackets, getNumServerPackets, getServerName, getSessionData, getStatus, getStreamID, incrementClientPacketCount, incrementServerPacketCount, isUsingSelfSignedCertificate, process, removeSessionData, setAddress, setSessionData, setStatus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jivesoftware.openfire.session.Session
deliverRawText, getAddress, getCreationDate, getHostAddress, getHostName, getLastActiveDate, getNumClientPackets, getNumServerPackets, getServerName, getStatus, getStreamID, process, validate
 

Constructor Detail

HttpSession

public HttpSession(PacketDeliverer backupDeliverer,
                   String serverName,
                   InetAddress address,
                   StreamID streamID,
                   long rid,
                   HttpConnection connection)
Method Detail

getAvailableStreamFeaturesElements

public Collection<org.dom4j.Element> getAvailableStreamFeaturesElements()
Returns the stream features which are available for this session.

Returns:
the stream features which are available for this session.

getAvailableStreamFeatures

public String getAvailableStreamFeatures()
Description copied from class: LocalSession
Returns a text with the available stream features. Each subclass may return different values depending whether the session has been authenticated or not.

Overrides:
getAvailableStreamFeatures in class LocalClientSession
Returns:
a text with the available stream features or null to add nothing.

close

public void close()
Closes the session. After a session has been closed it will no longer accept new connections on the session ID.

Specified by:
close in interface Session
Overrides:
close in class LocalSession

isClosed

public boolean isClosed()
Returns true if this session has been closed and no longer actively accepting connections.

Specified by:
isClosed in interface Session
Overrides:
isClosed in class LocalSession
Returns:
true if this session has been closed and no longer actively accepting connections.

setWait

public void setWait(int wait)
Specifies the longest time (in seconds) that the connection manager is allowed to wait before responding to any request during the session. This enables the client to prevent its TCP connection from expiring due to inactivity, as well as to limit the delay before it discovers any network failure.

Parameters:
wait - the longest time it is permissible to wait for a response.

getWait

public int getWait()
Specifies the longest time (in seconds) that the connection manager is allowed to wait before responding to any request during the session. This enables the client to prevent its TCP connection from expiring due to inactivity, as well as to limit the delay before it discovers any network failure.

Returns:
the longest time it is permissible to wait for a response.

setHold

public void setHold(int hold)
Specifies the maximum number of requests the connection manager is allowed to keep waiting at any one time during the session. (For example, if a constrained client is unable to keep open more than two HTTP connections to the same HTTP server simultaneously, then it SHOULD specify a value of "1".)

Parameters:
hold - the maximum number of simultaneous waiting requests.

getHold

public int getHold()
Specifies the maximum number of requests the connection manager is allowed to keep waiting at any one time during the session. (For example, if a constrained client is unable to keep open more than two HTTP connections to the same HTTP server simultaneously, then it SHOULD specify a value of "1".)

Returns:
the maximum number of simultaneous waiting requests

setLanguage

public void setLanguage(String language)
Sets the language this session is using.

Parameters:
language - the language this session is using.

getLanguage

public String getLanguage()
Returns the language this session is using.

Returns:
the language this session is using.

setMaxPollingInterval

public void setMaxPollingInterval(int maxPollingInterval)
Sets the max interval within which a client can send polling requests. If more than one request occurs in the interval the session will be terminated.

Parameters:
maxPollingInterval - time in seconds a client needs to wait before sending polls to the server, a negative int indicates that there is no limit.

getMaxPollingInterval

public int getMaxPollingInterval()
Returns the max interval within which a client can send polling requests. If more than one request occurs in the interval the session will be terminated.

Returns:
the max interval within which a client can send polling requests. If more than one request occurs in the interval the session will be terminated.

setMaxRequests

public void setMaxRequests(int maxRequests)
The max number of requests it is permissible for this session to have open at any one time.

Parameters:
maxRequests - The max number of requests it is permissible for this session to have open at any one time.

getMaxRequests

public int getMaxRequests()
Returns the max number of requests it is permissible for this session to have open at any one time.

Returns:
the max number of requests it is permissible for this session to have open at any one time.

setMaxPause

public void setMaxPause(int maxPause)
Sets the maximum length of a temporary session pause (in seconds) that the client MAY request.

Parameters:
maxPause - the maximum length of a temporary session pause (in seconds) that the client MAY request.

getMaxPause

public int getMaxPause()
Returns the maximum length of a temporary session pause (in seconds) that the client MAY request.

Returns:
the maximum length of a temporary session pause (in seconds) that the client MAY request.

isSecure

public boolean isSecure()
Returns true if all connections on this session should be secured, and false if they should not.

Specified by:
isSecure in interface Session
Overrides:
isSecure in class LocalSession
Returns:
true if all connections on this session should be secured, and false if they should not.

isPollingSession

public boolean isPollingSession()
Returns true if this session is a polling session. Some clients may be restricted to open only one connection to the server. In this case the client SHOULD inform the server by setting the values of the 'wait' and/or 'hold' attributes in its session creation request to "0", and then "poll" the server at regular intervals throughout the session for stanzas it may have received from the server.

Returns:
true if this session is a polling session.

addSessionCloseListener

public void addSessionCloseListener(SessionListener listener)
Adds a SessionListener to this session. The listener will be notified of changes to the session.

Parameters:
listener - the listener which is being added to the session.

removeSessionCloseListener

public void removeSessionCloseListener(SessionListener listener)
Removes a SessionListener from this session. The listener will no longer be updated when an event occurs on the session.

Parameters:
listener - the session listener that is to be removed.

setDefaultInactivityTimeout

public void setDefaultInactivityTimeout(int defaultInactivityTimeout)
Sets the default inactivity timeout of this session. A session's inactivity timeout can be temporarily changed using session pause requests.

Parameters:
defaultInactivityTimeout - the default inactivity timeout of this session.
See Also:
pause(int)

setInactivityTimeout

public void setInactivityTimeout(int inactivityTimeout)
Sets the time, in seconds, after which this session will be considered inactive and be be terminated.

Parameters:
inactivityTimeout - the time, in seconds, after which this session will be considered inactive and be terminated.

resetInactivityTimeout

public void resetInactivityTimeout()
Resets the inactivity timeout of this session to default. A session's inactivity timeout can be temporarily changed using session pause requests.

See Also:
pause(int)

getInactivityTimeout

public int getInactivityTimeout()
Returns the time, in seconds, after which this session will be considered inactive and terminated.

Returns:
the time, in seconds, after which this session will be considered inactive and terminated.

pause

public void pause(int duration)
Pauses the session for the given amount of time. If a client encounters an exceptional temporary situation during which it will be unable to send requests to the connection manager for a period of time greater than the maximum inactivity period, then the client MAY request a temporary increase to the maximum inactivity period by including a 'pause' attribute in a request.

Parameters:
duration - the time, in seconds, after which this session will be considered inactive and terminated.

getLastActivity

public long getLastActivity()
Returns the time in milliseconds since the epoch that this session was last active. Activity is a request was either made or responded to. If the session is currently active, meaning there are connections awaiting a response, the current time is returned.

Returns:
the time in milliseconds since the epoch that this session was last active.

getLastAcknowledged

public long getLastAcknowledged()
Returns the highest 'rid' attribute the server has received where it has also received all requests with lower 'rid' values. When responding to a request that it has been holding, if the server finds it has already received another request with a higher 'rid' attribute (typically while it was holding the first request), then it MAY acknowledge the reception to the client.

Returns:
the highest 'rid' attribute the server has received where it has also received all requests with lower 'rid' values.

setMajorVersion

public void setMajorVersion(int majorVersion)
Sets the major version of BOSH which the client implements. Currently, the only versions supported by Openfire are 1.5 and 1.6.

Parameters:
majorVersion - the major version of BOSH which the client implements.

getMajorVersion

public int getMajorVersion()
Returns the major version of BOSH which this session utilizes. The version refers to the version of the XEP which the connecting client implements. If the client did not specify a version 1 is returned as 1.5 is the last version of the XEP that the client was not required to pass along its version information when creating a session.

Returns:
the major version of the BOSH XEP which the client is utilizing.

setMinorVersion

public void setMinorVersion(int minorVersion)
Sets the minor version of BOSH which the client implements. Currently, the only versions supported by Openfire are 1.5 and 1.6. Any versions less than or equal to 5 will be interpreted as 5 and any values greater than or equal to 6 will be interpreted as 6.

Parameters:
minorVersion - the minor version of BOSH which the client implements.

getMinorVersion

public int getMinorVersion()
Returns the major version of BOSH which this session utilizes. The version refers to the version of the XEP which the connecting client implements. If the client did not specify a version 5 is returned as 1.5 is the last version of the XEP that the client was not required to pass along its version information when creating a session.

Returns:
the minor version of the BOSH XEP which the client is utilizing.

setLastResponseEmpty

public void setLastResponseEmpty(boolean lastResponseEmpty)
lastResponseEmpty true if last response of this session is an empty body element. This is used in overactivity checking.

Parameters:
lastResponseEmpty - true if last response of this session is an empty body element.

consumeResponse

protected String consumeResponse(HttpConnection connection)
                          throws HttpBindException
Returns the response for a specific connection instance. It is possible for there to be multiple connections in the queue for the same rid so we need to be careful that we are accessing the correct connection.

Note that this method also removes the connection from the internal connection queue.

Parameters:
connection - the connection for which to get the response.
Returns:
the response from the connection
Throws:
HttpBindException

setSecure

protected void setSecure(boolean isSecure)
Sets whether the initial request on the session was secure.

Parameters:
isSecure - true if the initial request was secure and false if it wasn't.

sendPendingPackets

protected void sendPendingPackets()
This methods sends any pending packets in the session. If no packets are pending, this method simply returns. The method is internally synchronized to avoid simultaneous sending operations on this Session. If two threads try to run this method simultaneously, the first one will trigger the pending packets to be sent, while the second one will simply return (as there are no packets left to send).


getPeerCertificates

public X509Certificate[] getPeerCertificates()
Return the X509Certificates associated with this session.

Returns:
the X509Certificate associated with this session.

deliver

public void deliver(org.xmpp.packet.Packet stanza)
Overrides:
deliver in class LocalClientSession

Openfire 3.9.3 Javadoc

Copyright © 2003-2008 Jive Software.