Module java.base
Package javax.net.ssl

Interface SSLSession

All Known Implementing Classes:
ExtendedSSLSession

public interface 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 invalidate. Session management policies are typically used to tune performance.

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

  • Peer Identity. 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.
  • Cipher Suite Name. Cipher suites describe the kind of cryptographic protection that's used by connections in a particular session.
  • Peer Host. 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.

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

Since:
1.4
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the current size of the largest application data that is expected when using this session.
    Returns the name of the SSL cipher suite which is used for all connections in the session.
    long
    Returns the time at which this Session representation was created, in milliseconds since midnight, January 1, 1970 UTC.
    byte[]
    Returns the identifier assigned to this Session.
    long
    Returns the last time this Session representation was accessed by the session level infrastructure, in milliseconds since midnight, January 1, 1970 UTC.
    Returns the certificate(s) that were sent to the peer during handshaking.
    Returns the principal that was sent to the peer during handshaking.
    int
    Gets the current size of the largest SSL/TLS/DTLS packet that is expected when using this session.
    default X509Certificate[]
    Deprecated, for removal: This API element is subject to removal in a future version.
    The getPeerCertificates() method that returns an array of java.security.cert.Certificate should be used instead.
    Returns the identity of the peer which was established as part of defining the session.
    Returns the host name of the peer in this session.
    int
    Returns the port number of the peer in this session.
    Returns the identity of the peer which was established as part of defining the session.
    Returns the standard name of the protocol used for all connections in the session.
    Returns the context in which this session is bound.
    getValue​(String name)
    Returns the object bound to the given name in the session's application layer data.
    Returns an array of the names of all the application layer data objects bound into the Session.
    void
    Invalidates the session.
    boolean
    Returns whether this session is valid and available for resuming or joining.
    void
    putValue​(String name, Object value)
    Binds the specified value object into the session's application layer data with the given name.
    void
    Removes the object bound to the given name in the session's application layer data.
  • Method Details

    • getId

      byte[] getId()
      Returns the identifier assigned to this Session.
      Returns:
      the Session identifier
    • getSessionContext