de.tu_darmstadt.sp.ssl
Class SSLeaySession

java.lang.Object
  |
  +--de.tu_darmstadt.sp.ssl.SSLeaySession

public class SSLeaySession
extends java.lang.Object
implements SSLSession

Class SSLeaySession is a stateless, lightweight object which interracts with a SSL_SESSION Structure inside SSLeay. Most of the methods here are native methods, exporting the state of the SSL_SESSION Structure as Java objects.

SSLeaySession -- uses reference to a Java Hashtable which represents the application data of this Session. However this hashtable is referenced from the SSL_SESSION Structure and not from SSLeaySession.

At the time being, it is not entirely clear to me if SSLeay exchanges the application data of a client-session and its corresponging server-session (and vice-versa) or if the application data is just meant for exchanging application information among several connections on the same host.

Version:
$Revision: 1.8 $
Author:
Andrei Popovici

Field Summary
protected  SSLeaySessionContext context
           
protected  int session
           
 
Constructor Summary
protected SSLeaySession(int session, SSLeaySessionContext context)
          Create a new SSLeaySession which is a facade of the SSL_SESSION structure identified by the session opaque pointer.
 
Method Summary
protected  java.util.Dictionary applicationData()
          Return the Dictionary we use to store application data in this session.
protected  void doInvalidate()
          Removes the corresponding SSL_SESSION structure form the respective SSL_CTX
 java.lang.String getCipherSuite()
          Returns the name of the SSL cipher suite which is used for all connections in the session.
 long getCreationTime()
          Returns the time at which this Session representation was created, in milliseconds since midnight, January 1, 1970 UTC.
 byte[] getId()
          Returns the identifier assigned to this Session.
 long getLastAccessedTime()
          Returns the last time this Session representation was accessed by the session level infrastructure, in milliseconds since midnight, January 1, 1970 UTC.
 X509Certificate[] getPeerCertificateChain()
          Return the certificate chain of the peer.
protected  java.lang.String[] getPeerCertificateChainString()
          Return a list of Strings, each string containing the textual form of a X509Certificate.
 java.lang.String getPeerHost()
          Returns the host name of the peer in this session.
 SSLSessionContext getSessionContext()
          Returns the context in which this session is bound.
 java.lang.Object getValue(java.lang.String name)
          Return the object previously bound to name.
 java.lang.String[] getValueNames()
          Return the list of names in the application data
 void invalidate()
          Invalidates the session.
 void putValue(java.lang.String name, java.lang.Object value)
          Bind a object to the application data of this session.
 void removeValue(java.lang.String name)
          Removes the object bound to the given name in the session's application layer data.
 java.lang.String toString()
          Return all information available about this session in string forma
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

session

protected int session

context

protected SSLeaySessionContext context
Constructor Detail

SSLeaySession

protected SSLeaySession(int session,
                        SSLeaySessionContext context)
Create a new SSLeaySession which is a facade of the SSL_SESSION structure identified by the session opaque pointer. Use the context java object to return information about the context. The specified context object should correspond to the context used internally by the underlying SSL_SESSION.
Parameters:
session - opaque pointer of the SSL_SESSION ssleay structure
context - context object to use
Method Detail

applicationData

protected java.util.Dictionary applicationData()
Return the Dictionary we use to store application data in this session. Since SSLeaySession is only a facade, the dictionary object is referenced directly from the SSL_SESSION, to prevent garbage collection of application data.

putValue

public void putValue(java.lang.String name,
                     java.lang.Object value)
Bind a object to the application data of this session. If the object implements the interfaced, it will be notified via its valueBound method. The application data of a session is common to all and thus SSL sockets on one side of a connection (either in the client or in the server). The current implementation of this interface to SSLeay does not interchange application data of corresponding
Specified by:
putValue in interface SSLSession
Parameters:
name - the name to which value should be bound
value - the object to be bound
Throws:
java.lang.IllegalArgumentException - (RuntimeException) if either name or value are NULL

getValue

public java.lang.Object getValue(java.lang.String name)
Return the object previously bound to name. If no object was bound to name, return null
Specified by:
getValue in interface SSLSession
Parameters:
name - the name of the binding to find
Returns:
the object bound to name

getValueNames

public java.lang.String[] getValueNames()
Return the list of names in the application data
Specified by:
getValueNames in interface SSLSession
Returns:
a String array containing the keys

removeValue

public void removeValue(java.lang.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 value implements the SessionBindingListener interface, it is notified appropriately.
Specified by:
removeValue in interface SSLSession
Parameters:
name - the name to remove the binding with
Throws:
java.lang.IllegalArgumentException - (RuntimeException) if name is NULL

getSessionContext

public SSLSessionContext getSessionContext()
Returns the context in which this session is bound.
Specified by:
getSessionContext in interface SSLSession

getPeerCertificateChain

public X509Certificate[] getPeerCertificateChain()
                                          throws SSLPeerUnverifiedException
Return the certificate chain of the peer. The first certificate is the certificate of the peer itself.
Specified by:
getPeerCertificateChain in interface SSLSession
Returns:
array of X509Certificate, peer identity first

getPeerCertificateChainString

protected java.lang.String[] getPeerCertificateChainString()
                                                    throws SSLPeerUnverifiedException
Return a list of Strings, each string containing the textual form of a X509Certificate. Note: the current implementation does not throw the Exception

getPeerHost

public java.lang.String getPeerHost()
Returns the host name of the peer in this session. That is, for the server, this is the client's host, and for the client it is the server's host NOTE:Not yet implemented
Specified by:
getPeerHost in interface SSLSession

getId

public byte[] getId()
Returns the identifier assigned to this Session.
Specified by:
getId in interface SSLSession

getCreationTime

public long getCreationTime()
Returns the time at which this Session representation was created, in milliseconds since midnight, January 1, 1970 UTC.
Specified by:
getCreationTime in interface SSLSession

getLastAccessedTime

public long getLastAccessedTime()
Returns the last time this Session representation was accessed by the session level infrastructure, in milliseconds since midnight, January 1, 1970 UTC. 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.

This information is particularly useful in session management policies. For example, a session manager thread could leave all sessions in a given context which haven't been used in a long time; or, the sessions might be sorted according to age to optimize some task.

NOTE:not implemented yet

Specified by:
getLastAccessedTime in interface SSLSession

invalidate

public void invalidate()
Invalidates the session. Future connections will not be able to resume or join this session. Removes this session object from the Session Context.
Specified by:
invalidate in interface SSLSession

doInvalidate

protected void doInvalidate()
Removes the corresponding SSL_SESSION structure form the respective SSL_CTX

getCipherSuite

public java.lang.String getCipherSuite()
Returns the name of the SSL cipher suite which is used for all connections in the session. This defines the level of protection provided to the data sent on the connection, including the kind of encryption used and most aspects of how authentication is done..
Specified by:
getCipherSuite in interface SSLSession
Returns:
a string representing the cipher suite used for all connections of this session

toString

public java.lang.String toString()
Return all information available about this session in string forma
Overrides:
toString in class java.lang.Object