Interface Session
- All Superinterfaces:
ChannelHandler<org.xmpp.packet.Packet>,RoutableChannelHandler
- All Known Subinterfaces:
ClientSession,ComponentSession,ConnectionMultiplexerSession,IncomingServerSession,OutgoingServerSession,ServerSession
- All Known Implementing Classes:
HttpSession,LocalClientSession,LocalComponentSession,LocalConnectionMultiplexerSession,LocalIncomingServerSession,LocalOutgoingServerSession,LocalServerSession,LocalSession,RemoteClientSession,RemoteComponentSession,RemoteConnectionMultiplexerSession,RemoteIncomingServerSession,RemoteOutgoingServerSession,RemoteSession
- Author:
- Gaston Dombiak
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.slf4j.Loggerstatic final intVersion of the XMPP spec supported as MAJOR_VERSION.MINOR_VERSION (e.g.static final int -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close this session, including associated (socket) connection(s) where appropriate.static int[]decodeVersion(String version) voiddeliverRawText(String text) Delivers raw text to the remote XMPP entity.static LocaledetectLanguage(org.xmlpull.v1.XmlPullParser xpp) Parses a locale from the 'lang' attribute of the element that the provided parser is currently on.static int[]detectVersion(org.xmlpull.v1.XmlPullParser xpp) Returns a two-digit version identifier based on the value of the 'version' attribute of the element that the provided parser is currently on.org.xmpp.packet.JIDObtain the address of the user.Returns the TLS cipher suite name used by the underlying connection(s) of the session, if any.Obtain the date the session was created.Returns the IP address string in textual presentation.Gets the host name for this IP address.Returns the locale that is used for this session (e.g.Obtain the time the session last had activity.longObtain the number of packets sent from the client to the server.longObtain the number of packets sent from the server to the client.Returns the peer certificates associated with this session, if any.Obtain the name of the server this session belongs to.Returns all Software Version data as reported by the remote XMPP entity, as obtained through XEP-0092.Obtain the current status of this session.Obtain the stream ID associated with this session.Returns the TLS protocol name used by the underlying connection(s) of the session, if any.default booleanReturns true if this session is authenticated (eg: SASL or Dialback authentication has completed successfully).default booleanisClosed()Returns true if the link to the remote XMPP entity (the session) is closed.booleanReturns true if the session is detached (that is, if the underlying connection has been closed while the session instance itself has not been closed).booleanReturns true if this session uses encrypted communication paths when exchanging data with the remote XMPP entity.voidprocess(org.xmpp.packet.Packet packet) Process an XMPP packet.booleanvalidate()Verifies that the session is still live.
-
Field Details
-
Log
static final org.slf4j.Logger Log -
MAJOR_VERSION
static final int MAJOR_VERSIONVersion of the XMPP spec supported as MAJOR_VERSION.MINOR_VERSION (e.g. 1.0).- See Also:
-
MINOR_VERSION
static final int MINOR_VERSION- See Also:
-
-
Method Details
-
getAddress
@Nonnull org.xmpp.packet.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:
getAddressin interfaceRoutableChannelHandler- Returns:
- the address of the packet handler.
-
getStatus
Session.Status getStatus()Obtain the current status of this session.- Returns:
- The status code for this session
-
getStreamID
StreamID getStreamID()Obtain the stream ID associated with this session. Stream ID's are generated by the server and should be unique and random.- Returns:
- This session's assigned stream ID
-
getServerName
String getServerName()Obtain the name of the server this session belongs to.- Returns:
- the server name.
-
getCreationDate
Date getCreationDate()Obtain the date the session was created.- Returns:
- the session's creation date.
-
getLastActiveDate
Date getLastActiveDate()Obtain the time the session last had activity.- Returns:
- The last time the session received activity.
-
getNumClientPackets
long getNumClientPackets()Obtain the number of packets sent from the client to the server.- Returns:
- The number of packets sent from the client to the server.
-
getNumServerPackets
long getNumServerPackets()Obtain the number of packets sent from the server to the client.- Returns:
- The number of packets sent from the server to the client.
-
close
void close()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).
getStatus()will be CLOSED. -
isClosed
default boolean isClosed()Returns true if the link to the remote XMPP entity (the session) is closed.- Returns:
- true if the session is closed.
-
isDetached
boolean isDetached()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).- Returns:
- true if session detached
-
isEncrypted
boolean isEncrypted()Returns true if this session uses encrypted communication paths when exchanging data with the remote XMPP entity.- Returns:
- true if the session is encrypted (e.g. TLS)
-
isAuthenticated
default boolean isAuthenticated()Returns true if this session is authenticated (eg: SASL or Dialback authentication has completed successfully).- Returns:
- true if the session is authenticated.
-
getPeerCertificates
Certificate[] getPeerCertificates()Returns the peer certificates associated with this session, if any.- Returns:
- certificates, possibly empty or null.
-
getHostAddress
Returns the IP address string in textual presentation.- Returns:
- the raw IP address in a string format.
- Throws:
UnknownHostException- if IP address of host could not be determined.
-
getHostName
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
checkConnectmethod is first called with the hostname and-1as 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.- 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:
-
process
void process(org.xmpp.packet.Packet packet) Description copied from interface:ChannelHandlerProcess an XMPP packet.- Specified by:
processin interfaceChannelHandler<org.xmpp.packet.Packet>- Parameters:
packet- a packet to process.
-
deliverRawText
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 usingprocess(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.
- Parameters:
text- the XML stanzas represented kept in a String.
-
validate
boolean validate()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?- Returns:
- true if the socket remains valid, false otherwise.
-
getTLSProtocolName
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"- Returns:
- a TLS protocol (version) name.
-
getCipherSuiteName
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"- Returns:
- cipher suite name.
-
getLanguage
Locale getLanguage()Returns the locale that is used for this session (e.g.Locale.ENGLISH).- Returns:
- The language for the session.
-
getSoftwareVersion
Returns all Software Version data as reported by the remote XMPP entity, as obtained through XEP-0092.- Returns:
- The Software Version information (never null, possibly empty)
-
detectLanguage
Parses a locale from the 'lang' attribute of the element that the provided parser is currently on. This method returns the English locale when there is no 'lang' attribute found. It will return an undefined Locale if the value of the 'lang' attribute could not be used to identify a language.- Parameters:
xpp- An XML parser- Returns:
- A Locale
-
detectVersion
static int[] detectVersion(org.xmlpull.v1.XmlPullParser xpp) Returns a two-digit version identifier based on the value of the 'version' attribute of the element that the provided parser is currently on. The value of the 'version' attribute is expected to match 'MAJOR.MINOR' where both MAJOR and MINOR are integer values. The version number defaults to 0.0. It is returned as an array of integers, with the first element in the array being the MAJOR version number. If the version that is being reported is larger than the version supported by this implementation, the version number that is supported by this implementation is returned instead of the reported version number.- Parameters:
xpp- An XML parser- Returns:
- an integer array that has a size of two.
-
decodeVersion
-