SSLSession

In SSL, sessions are used to describe an ongoing relationship between two entities. Each SSL connection involves one session at a time, but that session may be used on many connections between those entities, simultaneously or sequentially. The session used on a connection may also be replaced by a different session. Sessions are created, or rejoined, as part of the SSL handshaking protocol. Sessions may be invalidated due to policies affecting security or resource usage, or by an application explicitly calling <code>invalidate</code>. Connection management policies are typically used to tune performance.

<P> In addition to the standard session attributes, SSL sessions expose these read-only attributes: <UL>

<LI> <em>Peer Identity.</em> Sessions are between a particular client and a particular server. The identity of the peer may have been established as part of session setup. Peers are generally identified by X.509 certificate chains.

<LI> <em>Cipher Suite Name.</em> Cipher suites describe the kind of cryptographic protection that's used by connections in a particular session.

<LI> <em>Peer Host.</em> All connections in a session are between the same two hosts. The address of the host on the other side of the connection is available.

</UL>

<P> Sessions may be explicitly invalidated. Invalidation may also be done implicitly, when faced with certain kinds of errors.

@author David Brownell

Members

Functions

getApplicationBufferSize
int getApplicationBufferSize()

Gets the current size of the largest application data that is expected when using this session. <P> <code>SSLEngine</code> application data buffers must be large enough to hold the application data from any inbound network application data packet received. Typically, outbound application data buffers can be of any size.

getCipherSuite
string getCipherSuite()

Returns the name of the SSL cipher suite which is used for all connections in the session.

getCreationTime
long getCreationTime()

Returns the time at which this Connection representation was created, in milliseconds since midnight, January 1, 1970 UTC.

getId
byte[] getId()

Returns the identifier assigned to this Connection.

getLastAccessedTime
long getLastAccessedTime()

Returns the last time this Connection representation was accessed by the session level infrastructure, in milliseconds since midnight, January 1, 1970 UTC. <P> Access indicates a new connection being established using session data. Application level operations, such as getting or setting a value associated with the session, are not reflected in this access time.

getPacketBufferSize
int getPacketBufferSize()

Gets the current size of the largest SSL/TLS packet that is expected when using this session. <P> A <code>SSLEngine</code> using this session may generate SSL/TLS packets of any size up to and including the value returned by this method. All <code>SSLEngine</code> network buffers should be sized at least this large to avoid insufficient space problems when performing <code>wrap</code> and <code>unwrap</code> calls.

getPeerHost
string getPeerHost()

Returns the host name of the peer in this session. <P> For the server, this is the client's host; and for the client, it is the server's host. The name may not be a fully qualified host name or even a host name at all as it may represent a string encoding of the peer's network address. If such a name is desired, it might be resolved through a name service based on the value returned by this method. <P> This value is not authenticated and should not be relied upon. It is mainly used as a hint for <code>SSLSession</code> caching strategies.

getPeerPort
int getPeerPort()

Returns the port number of the peer in this session. <P> For the server, this is the client's port number; and for the client, it is the server's port number. <P> This value is not authenticated and should not be relied upon. It is mainly used as a hint for <code>SSLSession</code> caching strategies.

getProtocol
string getProtocol()

Returns the standard name of the protocol used for all connections in the session.

getSessionContext
SSLSessionContext getSessionContext()

Returns the context in which this session is bound. <P> This context may be unavailable in some environments, in which case this method returns null. <P> If the context is available and there is a security manager installed, the caller may require permission to access it or a security exception may be thrown. In a Java environment, the security manager's <code>checkPermission</code> method is called with a <code>SSLPermission("getSSLSessionContext")</code> permission.

getValue
Object getValue(string name)

Returns the object bound to the given name in the session's application layer data. Returns null if there is no such binding. <p> For security reasons, the same named values may not be visible across different access control contexts.

getValueNames
string[] getValueNames()

Returns an array of the names of all the application layer data objects bound into the Connection. <p> For security reasons, the same named values may not be visible across different access control contexts.

invalidate
void invalidate()

Invalidates the session. <P> Future connections will not be able to resume or join this session. However, any existing connection using this session can continue to use the session until the connection is closed.

isValid
bool isValid()

Returns whether this session is valid and available for resuming or joining.

putValue
void putValue(string name, Object value)

Binds the specified <code>value</code> object into the session's application layer data with the given <code>name</code>. <P> Any existing binding using the same <code>name</code> is replaced. If the new (or existing) <code>value</code> implements the <code>SSLSessionBindingListener</code> interface, the object represented by <code>value</code> is notified appropriately. <p> For security reasons, the same named values may not be visible across different access control contexts.

removeValue
void removeValue(string name)

Removes the object bound to the given name in the session's application layer data. Does nothing if there is no object bound to the given name. If the bound existing object implements the <code>SessionBindingListener</code> interface, it is notified appropriately. <p> For security reasons, the same named values may not be visible across different access control contexts.

Meta