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
  • Field Details

    • nodeID

      protected byte[] nodeID
    • address

      protected org.xmpp.packet.JID address
    • streamID

      protected StreamID streamID
  • Constructor Details

    • RemoteSession

      public RemoteSession(byte[] nodeID, org.xmpp.packet.JID address)
  • Method Details

    • getAddress

      @Nonnull 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 interface RoutableChannelHandler
      Specified by:
      getAddress in interface Session
      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.
      Specified by:
      getStatus in interface Session
      Returns:
      the authenticated status.
    • 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 interface Session
      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 interface Session
      Returns:
      the server name.
    • getCreationDate

      public Date getCreationDate()
      Description copied from interface: Session
      Obtain the date the session was created.
      Specified by:
      getCreationDate in interface Session
      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 interface Session
      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 interface Session
      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 interface Session
      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 underlying connection(s) of the session, if any. Always returns a valid string, though the string may be "NONE"
      Specified by:
      getTLSProtocolName in interface Session
      Returns:
      a TLS protocol (version) name.
    • getCipherSuiteName

      public String getCipherSuiteName()
      Description copied from interface: Session
      Returns the TLS cipher suite name used by the underlying connection(s) of the session, if any. Always returns a valid string, though the string may be "NONE"
      Specified by:
      getCipherSuiteName in interface Session
      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 interface Session
      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 remote XMPP entity, as obtained through XEP-0092.
      Specified by:
      getSoftwareVersion in interface Session
      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 interface ChannelHandler<org.xmpp.packet.Packet>
      Specified by:
      process in interface Session
      Parameters:
      packet - a packet to process.
    • close

      public void close()
      Description copied from interface: Session
      Close this session, including associated (socket) connection(s) where appropriate. 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 underlying connection(s) (eg: socket).
      Implementations should ensure that after invocation, the result of Session.getStatus() will be CLOSED.
      Specified by:
      close in interface Session
    • isClosed

      public boolean isClosed()
      Description copied from interface: Session
      Returns true if the link to the remote XMPP entity (the session) is closed.
      Specified by:
      isClosed in interface Session
      Returns:
      true if the session is closed.
    • isDetached

      public boolean isDetached()
      Description copied from interface: Session
      Returns true if the session is detached (that is, if the underlying connection has been closed while the session instance itself has not been closed).
      Specified by:
      isDetached in interface Session
      Returns:
      true if session detached
    • isEncrypted

      public boolean isEncrypted()
      Description copied from interface: Session
      Returns true if this session uses encrypted communication paths when exchanging data with the remote XMPP entity.
      Specified by:
      isEncrypted in interface Session
      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 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:
    • deliverRawText

      public void deliverRawText(String text)
      Description copied from interface: Session
      Delivers raw text to the remote XMPP entity. 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.
    • validate

      public boolean validate()
      Description copied from interface: Session
      Verifies that the session 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.
    • 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 interface Session
      Returns:
      The language for the session.