Overview | Package | Class | Tree | Deprecated | Index | Help
| Openfire 3.4.4 Javadoc
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jivesoftware.openfire.session
Class LocalSession

    java.lang.Object
      org.jivesoftware.openfire.session.LocalSession

All Implemented Interfaces:
  ChannelHandler, RoutableChannelHandler, Session

Direct Known Subclasses:
  LocalClientSession, LocalComponentSession, LocalConnectionMultiplexerSession, LocalIncomingServerSession, LocalOutgoingServerSession

    public abstract class LocalSession

extends Object
implements Session

The session represents a connection between the server and a client (c2s) or another server (s2s) as well as a connection with a component. Authentication and user accounts are associated with c2s connections while s2s has an optional authentication association but no single user user.

Obtain object managers from the session in order to access server resources.

Author:
  Gaston Dombiak

Field Summary
`protected static String` | `CHARSET` The utf-8 charset for decoding and encoding Jabber packet streams.
`protected Connection` | `conn` The connection that this session represents.
`protected SessionManager` | `sessionManager`
`protected int` | `status` The current session status.

Fields inherited from interface org.jivesoftware.openfire.session.Session
`MAJOR_VERSION, MINOR_VERSION, STATUS_AUTHENTICATED, STATUS_CLOSED, STATUS_CONNECTED`

Constructor Summary
`LocalSession(String serverName, Connection connection, StreamID streamID)` Creates a session with an underlying connection and permission protection.

Method Summary
`void` | `close()` Close this session including associated socket connection.
`protected static int[]` | `decodeVersion(String version)`
`void` | `deliverRawText(String text)` Delivers raw text to this connection.
`JID` | `getAddress()` Obtain the address of the user.
`abstract String` | `getAvailableStreamFeatures()` Returns a text with the available stream features.
`Connection` | `getConnection()` Returns the connection associated with this Session.
`Date` | `getCreationDate()` Obtain the date the session was created.
`String` | `getHostAddress()` Returns the IP address string in textual presentation.
`String` | `getHostName()` Gets the host name for this IP address.
`Date` | `getLastActiveDate()` Obtain the time the session last had activity.
`long` | `getNumClientPackets()` Obtain the number of packets sent from the client to the server.
`long` | `getNumServerPackets()` Obtain the number of packets sent from the server to the client.
`String` | `getServerName()` Obtain the name of the server this session belongs to.
`Object` | `getSessionData(String key)` Retrieves session data.
`int` | `getStatus()` Obtain the current status of this session.
`StreamID` | `getStreamID()` Obtain the stream ID associated with this sesison.
`void` | `incrementClientPacketCount()` Increments the number of packets sent from the client to the server.
`void` | `incrementServerPacketCount()` Increments the number of packets sent from the server to the client.
`boolean` | `isClosed()` Returns true if the connection/session is closed.
`boolean` | `isSecure()` Returns true if this connection is secure.
`void` | `process(Packet packet)` Process an XMPP packet.
`void` | `removeSessionData(String key)` Removes session data.
`void` | `setAddress(JID address)` Sets the new address of this session.
`void` | `setSessionData(String key, Object value)` Saves given session data.
`void` | `setStatus(int status)` Set the new status of this session.
`String` | `toString()`
`boolean` | `validate()` Verifies that the connection is still live.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### CHARSET

    protected static String CHARSET

  The utf-8 charset for decoding and encoding Jabber packet streams.

### status

    protected int status

  The current session status.

### conn

    protected Connection conn

  The connection that this session represents.

### sessionManager

    protected SessionManager sessionManager

Constructor Detail

### LocalSession

    public LocalSession(String serverName,
                        Connection connection,
                        StreamID streamID)

  Creates a session with an underlying connection and permission protection.

  Parameters:
    `serverName` - domain of the XMPP server where the new session belongs.
    `connection` - The connection we are proxying.
    `streamID` - unique identifier for this session.

Method Detail

### getAddress

    public JID getAddress()

  Obtain the address of the user. The address is used by services like the core server packet router to determine if a packet should be sent to the handler. Handlers that are working on behalf of the server should use the generic server hostname address (e.g. server.com).

  Specified by:
    `getAddress` in interface `RoutableChannelHandler`
  Specified by:
    `getAddress` in interface `Session`
  Returns:
    the address of the packet handler.

### setAddress

    public void setAddress(JID address)

  Sets the new address of this session. The address is used by services like the core server packet router to determine if a packet should be sent to the handler. Handlers that are working on behalf of the server should use the generic server hostname address (e.g. server.com).

  Parameters:
    `address` - the new address of this session.

### getConnection

    public Connection getConnection()

  Returns the connection associated with this Session.

  Returns:
    The connection for this session

### getStatus

    public int getStatus()

  Obtain the current status of this session.

  Specified by:
    `getStatus` in interface `Session`
  Returns:
    The status code for this session

### setStatus

    public void setStatus(int status)

  Set the new status of this session. Setting a status may trigger certain events to occur (setting a closed status will close this session).

  Parameters:
    `status` - The new status code for this session

### getStreamID

    public StreamID getStreamID()

  Obtain the stream ID associated with this sesison. Stream ID's are generated by the server and should be unique and random.

  Specified by:
    `getStreamID` in interface `Session`
  Returns:
    This session's assigned stream ID

### getServerName

    public String getServerName()

  Obtain the name of the server this session belongs to.

  Specified by:
    `getServerName` in interface `Session`
  Returns:
    the server name.

### getCreationDate

    public Date getCreationDate()

  Obtain the date the session was created.

  Specified by:
    `getCreationDate` in interface `Session`
  Returns:
    the session's creation date.

### getLastActiveDate

    public Date getLastActiveDate()

  Obtain the time the session last had activity.

  Specified by:
    `getLastActiveDate` in interface `Session`
  Returns:
    The last time the session received activity.

### incrementClientPacketCount

    public void incrementClientPacketCount()

  Increments the number of packets sent from the client to the server.

### incrementServerPacketCount

    public void incrementServerPacketCount()

  Increments the number of packets sent from the server to the client.

### getNumClientPackets

    public long getNumClientPackets()

  Obtain the number of packets sent from the client to the server.

  Specified by:
    `getNumClientPackets` in interface `Session`
  Returns:
    The number of packets sent from the client to the server.

### getNumServerPackets

    public long getNumServerPackets()

  Obtain the number of packets sent from the server to the client.

  Specified by:
    `getNumServerPackets` in interface `Session`
  Returns:
    The number of packets sent from the server to the client.

### setSessionData

    public void setSessionData(String key,
                               Object value)

  Saves given session data. Data are saved to temporary storage only and are accessible during this session life only and only from this session instance.

  Parameters:
    `key` - a `String` value of stored data key ID.
    `value` - a `Object` value of data stored in session.
  See Also:
    `getSessionData(String)`

### getSessionData

    public Object getSessionData(String key)

  Retrieves session data. This method gives access to temporary session data only. You can retrieve earlier saved data giving key ID to receive needed value. Please see `setSessionData(String, Object)` description for more details.

  Parameters:
    `key` - a `String` value of stored data ID.
  Returns:
    a `Object` value of data for given key.
  See Also:
    `setSessionData(String, Object)`

### removeSessionData

    public void removeSessionData(String key)

  Removes session data. Please see `setSessionData(String, Object)` description for more details.

  Parameters:
    `key` - a `String` value of stored data ID.
  See Also:
    `setSessionData(String, Object)`

### process

    public void process(Packet packet)

  Description copied from interface: `ChannelHandler`
  Process an XMPP packet.

  Specified by:
    `process` in interface `ChannelHandler`
  Specified by:
    `process` in interface `Session`
  Parameters:
    `packet` - a packet to process.

### deliverRawText

    public void deliverRawText(String text)

  Description copied from interface: `Session`
  Delivers raw text to this connection. This is a very low level way for sending XML stanzas to the client. This method should not be used unless you have very good reasons for not using `Session.process(Packet)`.

  This method avoids having to get the writer of this connection and mess directly with the writer. Therefore, this method ensures a correct delivery of the stanza even if other threads were sending data concurrently.

  Specified by:
    `deliverRawText` in interface `Session`
  Parameters:
    `text` - the XML stanzas represented kept in a String.

### getAvailableStreamFeatures

    public abstract String getAvailableStreamFeatures()

  Returns a text with the available stream features. Each subclass may return different values depending whether the session has been authenticated or not.

  Returns:
    a text with the available stream features or `null` to add nothing.

### close

    public void close()

  Description copied from interface: `Session`
  Close this session including associated socket connection. The order of events for closing the session is:
  - Set closing flag to prevent redundant shutdowns.
  - Call notifyEvent all listeners that the channel is shutting down.
  - Close the socket.

  Specified by:
    `close` in interface `Session`

### validate

    public boolean validate()

  Description copied from interface: `Session`
  Verifies that the connection is still live. Typically this is done by sending a whitespace character between packets. // TODO No one is sending this message now. Delete it?

  Specified by:
    `validate` in interface `Session`
  Returns:
    true if the socket remains valid, false otherwise.

### isSecure

    public boolean isSecure()

  Description copied from interface: `Session`
  Returns true if this connection is secure.

  Specified by:
    `isSecure` in interface `Session`
  Returns:
    true if the connection is secure (e.g. SSL/TLS)

### isClosed

    public boolean isClosed()

  Description copied from interface: `Session`
  Returns true if the connection/session is closed.

  Specified by:
    `isClosed` in interface `Session`
  Returns:
    true if the connection is closed.

### getHostAddress

    public String getHostAddress()
                          throws UnknownHostException

  Description copied from interface: `Session`
  Returns the IP address string in textual presentation.

  Specified by:
    `getHostAddress` in interface `Session`
  Returns:
    the raw IP address in a string format.
  Throws:
    `UnknownHostException` - if IP address of host could not be determined.

### getHostName

    public String getHostName()
                       throws UnknownHostException

  Description copied from interface: `Session`
  Gets the host name for this IP address.

  If this InetAddress was created with a host name, this host name will be remembered and returned; otherwise, a reverse name lookup will be performed and the result will be returned based on the system configured name lookup service. If a lookup of the name service is required, call `getCanonicalHostName`.

  If there is a security manager, its `checkConnect` method is first called with the hostname and `-1` as its arguments to see if the operation is allowed. If the operation is not allowed, it will return the textual representation of the IP address.

  Specified by:
    `getHostName` in interface `Session`
  Returns:
    the host name for this IP address, or if the operation is not allowed by the security check, the textual representation of the IP address.
  Throws:
    `UnknownHostException` - if IP address of host could not be determined.
  See Also:
    `InetAddress.getCanonicalHostName()`, `SecurityManager.checkConnect(java.lang.String, int)`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### decodeVersion

    protected static int[] decodeVersion(String version)

Overview | Package | Class | Tree | Deprecated | Index | Help
| Openfire 3.4.4 Javadoc
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2007 Jive Software.