public abstract class LocalSession extends Object implements Session
Obtain object managers from the session in order to access server resources.
Modifier and Type | Field and Description |
---|---|
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.
|
MAJOR_VERSION, MINOR_VERSION, STATUS_AUTHENTICATED, STATUS_CLOSED, STATUS_CONNECTED
Constructor and Description |
---|
LocalSession(String serverName,
Connection connection,
StreamID streamID)
Creates a session with an underlying connection and permission protection.
|
Modifier and Type | Method and Description |
---|---|
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.
|
org.xmpp.packet.JID |
getAddress()
Obtain the address of the user.
|
abstract String |
getAvailableStreamFeatures()
Returns a text with the available stream features.
|
String |
getCipherSuiteName()
Returns a String representing the Cipher Suite Name, or "NONE".
|
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.
|
boolean |
isUsingSelfSignedCertificate()
Returns true if the other peer of this session presented a self-signed certificate.
|
void |
process(org.xmpp.packet.Packet packet)
Process an XMPP packet.
|
void |
removeSessionData(String key)
Removes session data.
|
void |
setAddress(org.xmpp.packet.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.
|
protected static String CHARSET
protected int status
protected final Connection conn
protected SessionManager sessionManager
public LocalSession(String serverName, Connection connection, StreamID streamID)
serverName
- domain of the XMPP server where the new session belongs.connection
- The connection we are proxying.streamID
- unique identifier for this session.public org.xmpp.packet.JID getAddress()
getAddress
in interface RoutableChannelHandler
getAddress
in interface Session
public void setAddress(org.xmpp.packet.JID address)
address
- the new address of this session.public Connection getConnection()
public int getStatus()
public void setStatus(int status)
status
- The new status code for this sessionpublic StreamID getStreamID()
getStreamID
in interface Session
public String getServerName()
getServerName
in interface Session
public Date getCreationDate()
getCreationDate
in interface Session
public Date getLastActiveDate()
getLastActiveDate
in interface Session
public void incrementClientPacketCount()
public void incrementServerPacketCount()
public long getNumClientPackets()
getNumClientPackets
in interface Session
public long getNumServerPackets()
getNumServerPackets
in interface Session
public void setSessionData(String key, Object value)
key
- a String
value of stored data key ID.value
- a Object
value of data stored in session.getSessionData(String)
public Object getSessionData(String key)
setSessionData(String, Object)
description for more details.key
- a String
value of stored data ID.Object
value of data for given key.setSessionData(String, Object)
public void removeSessionData(String key)
setSessionData(String, Object)
description
for more details.key
- a String
value of stored data ID.setSessionData(String, Object)
public void process(org.xmpp.packet.Packet packet)
ChannelHandler
process
in interface ChannelHandler
process
in interface Session
packet
- a packet to process.public void deliverRawText(String text)
Session
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.
deliverRawText
in interface Session
text
- the XML stanzas represented kept in a String.public abstract String getAvailableStreamFeatures()
public void close()
Session
public boolean validate()
Session
public boolean isSecure()
Session
public boolean isClosed()
Session
public String getHostAddress() throws UnknownHostException
Session
getHostAddress
in interface Session
UnknownHostException
- if IP address of host could not be determined.public String getHostName() throws UnknownHostException
Session
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.
getHostName
in interface Session
UnknownHostException
- if IP address of host could not be determined.InetAddress.getCanonicalHostName()
,
SecurityManager.checkConnect(java.lang.String, int)
protected static int[] decodeVersion(String version)
public boolean isUsingSelfSignedCertificate()
public String getCipherSuiteName()
getCipherSuiteName
in interface Session
Copyright © 2003-2008 Jive Software.