Class RemoteSession
- java.lang.Object
-
- org.jivesoftware.openfire.session.RemoteSession
-
- All Implemented Interfaces:
ChannelHandler<org.xmpp.packet.Packet>
,RoutableChannelHandler
,Session
- Direct Known Subclasses:
RemoteClientSession
,RemoteComponentSession
,RemoteConnectionMultiplexerSession
,RemoteIncomingServerSession
,RemoteOutgoingServerSession
public abstract class RemoteSession extends Object implements Session
Base class for sessions being hosted in other cluster nodes. Almost all messages will be forwarded to the actual session in some remote cluster node. Only some few messages will be local operations like getting the session's address or the session status. And only some operations will be cached locally for a brief period for content that is highly used and not frequently modified.- Author:
- Gaston Dombiak
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jivesoftware.openfire.session.Session
Session.Status
-
-
Field Summary
Fields Modifier and Type Field Description protected org.xmpp.packet.JID
address
protected byte[]
nodeID
protected StreamID
streamID
-
Fields inherited from interface org.jivesoftware.openfire.session.Session
Log, MAJOR_VERSION, MINOR_VERSION, STATUS_AUTHENTICATED, STATUS_CLOSED, STATUS_CONNECTED
-
-
Constructor Summary
Constructors Constructor Description RemoteSession(byte[] nodeID, org.xmpp.packet.JID address)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
close()
Close this session including associated socket connection.void
deliverRawText(String text)
Delivers raw text to this connection.protected void
doClusterTask(ClusterTask task)
Invokes a task on the remote cluster member in an asynchronous fashion.protected Object
doSynchronousClusterTask(ClusterTask<Object> task)
Invokes a task on the remote cluster member synchronously and returns the result of the remote operation.org.xmpp.packet.JID
getAddress()
Obtain the address of the user.String
getCipherSuiteName()
Returns the TLS cipher suite name used by the connection of the session, if any.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.Locale
getLanguage()
Returns the locale that is used for this session (e.g.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.Certificate[]
getPeerCertificates()
Returns the peer certificates associated with this session, if any.String
getServerName()
Obtain the name of the server this session belongs to.Map<String,String>
getSoftwareVersion()
Returns all Software Version data as reported by the peer on this connection, as obtained through XEP-0092.Session.Status
getStatus()
Remote sessions are always authenticated.StreamID
getStreamID()
Obtain the stream ID associated with this session.String
getTLSProtocolName()
Returns the TLS protocol name used by the connection of the session, if any.boolean
isClosed()
Returns true if the connection/session is closed.boolean
isEncrypted()
Returns true if this session uses encrypted connections.boolean
isSecure()
Deprecated.void
process(org.xmpp.packet.Packet packet)
Process an XMPP packet.boolean
validate()
Verifies that the connection is still live.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jivesoftware.openfire.session.Session
isAuthenticated
-
-
-
-
Field Detail
-
nodeID
protected byte[] nodeID
-
address
protected org.xmpp.packet.JID address
-
streamID
protected StreamID streamID
-
-
Method Detail
-
getAddress
public org.xmpp.packet.JID getAddress()
Description copied from interface:Session
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 interfaceRoutableChannelHandler
- Specified by:
getAddress
in interfaceSession
- Returns:
- the address of the packet handler.
-
getStatus
public Session.Status getStatus()
Remote sessions are always authenticated. Otherwise, they won't be visibile to other cluster nodes. When the session is closed it will no longer be visible to other nodes so CLOSED is never returned.
-
getStreamID
public StreamID getStreamID()
Description copied from interface:Session
Obtain the stream ID associated with this session. Stream ID's are generated by the server and should be unique and random.- Specified by:
getStreamID
in interfaceSession
- Returns:
- This session's assigned stream ID
-
getServerName
public String getServerName()
Description copied from interface:Session
Obtain the name of the server this session belongs to.- Specified by:
getServerName
in interfaceSession
- Returns:
- the server name.
-
getCreationDate
public Date getCreationDate()
Description copied from interface:Session
Obtain the date the session was created.- Specified by:
getCreationDate
in interfaceSession
- Returns:
- the session's creation date.
-
getLastActiveDate
public Date getLastActiveDate()
Description copied from interface:Session
Obtain the time the session last had activity.- Specified by:
getLastActiveDate
in interfaceSession
- Returns:
- The last time the session received activity.
-
getNumClientPackets
public long getNumClientPackets()
Description copied from interface:Session
Obtain the number of packets sent from the client to the server.- Specified by:
getNumClientPackets
in interfaceSession
- Returns:
- The number of packets sent from the client to the server.
-
getNumServerPackets
public long getNumServerPackets()
Description copied from interface:Session
Obtain the number of packets sent from the server to the client.- Specified by:
getNumServerPackets
in interfaceSession
- Returns:
- The number of packets sent from the server to the client.
-
getTLSProtocolName
public String getTLSProtocolName()
Description copied from interface:Session
Returns the TLS protocol name used by the connection of the session, if any. Always returns a valid string, though the string may be "NONE"- Specified by:
getTLSProtocolName
in interfaceSession
- Returns:
- a TLS protocol (version) name.
-
getCipherSuiteName
public String getCipherSuiteName()
Description copied from interface:Session
Returns the TLS cipher suite name used by the connection of the session, if any. Always returns a valid string, though the string may be "NONE"- Specified by:
getCipherSuiteName
in interfaceSession
- Returns:
- cipher suite name.
-
getPeerCertificates
public Certificate[] getPeerCertificates()
Description copied from interface:Session
Returns the peer certificates associated with this session, if any.- Specified by:
getPeerCertificates
in interfaceSession
- Returns:
- certificates, possibly empty or null.
-
getSoftwareVersion
public Map<String,String> getSoftwareVersion()
Description copied from interface:Session
Returns all Software Version data as reported by the peer on this connection, as obtained through XEP-0092.- Specified by:
getSoftwareVersion
in interfaceSession
- Returns:
- The Software Version information (never null, possibly empty)
-
process
public void process(org.xmpp.packet.Packet packet)
Description copied from interface:ChannelHandler
Process an XMPP packet.- Specified by:
process
in interfaceChannelHandler<org.xmpp.packet.Packet>
- Specified by:
process
in interfaceSession
- Parameters:
packet
- a packet to process.
-
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.
Session.getStatus()
will be CLOSED.
-
isClosed
public boolean isClosed()
Description copied from interface:Session
Returns true if the connection/session is closed.
-
isSecure
@Deprecated public boolean isSecure()
Deprecated.Description copied from interface:Session
Returns true if this connection is secure.
-
isEncrypted
public boolean isEncrypted()
Description copied from interface:Session
Returns true if this session uses encrypted connections.- Specified by:
isEncrypted
in interfaceSession
- Returns:
- true if the session is encrypted (e.g. TLS)
-
getHostAddress
public String getHostAddress() throws UnknownHostException
Description copied from interface:Session
Returns the IP address string in textual presentation.- Specified by:
getHostAddress
in interfaceSession
- 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 interfaceSession
- 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)
-
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 usingSession.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 interfaceSession
- Parameters:
text
- the XML stanzas represented kept in a String.
-
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?
-
doSynchronousClusterTask
protected Object doSynchronousClusterTask(ClusterTask<Object> task)
Invokes a task on the remote cluster member synchronously and returns the result of the remote operation.- Parameters:
task
- the ClusterTask object to be invoked on a given cluster member.- Returns:
- result of remote operation.
-
doClusterTask
protected void doClusterTask(ClusterTask task)
Invokes a task on the remote cluster member in an asynchronous fashion.- Parameters:
task
- the task to be invoked on the specified cluster member.
-
getLanguage
public final Locale getLanguage()
Description copied from interface:Session
Returns the locale that is used for this session (e.g.Locale.ENGLISH
).- Specified by:
getLanguage
in interfaceSession
- Returns:
- The language for the session.
-
-