APIdia Launch Partner
Top Description Fields Constructors Methods
javax.net.ssl

public Class HandshakeCompletedEvent

extends EventObject
Class Inheritance
Imports
java.util.EventObject, java.security.cert.Certificate, .X509Certificate, java.security.Principal

This event indicates that an SSL handshake completed on a given SSL connection. All the core information about that handshake's result is captured through an "SSLSession" object. As a convenience, this event class provides direct access to some important session attributes.

The source of this event is the SSLSocket on which handshaking just completed.

Author
David Brownell
Since
1.4
See Also
SSLSocket, HandshakeCompletedListener, SSLSession

Field Summary

Modifier and TypeField and Description
private static final long
private final transient SSLSession
Inherited from java.util.EventObject:
source

Constructor Summary

AccessConstructor and Description
public
HandshakeCompletedEvent(SSLSocket
the SSLSocket acting as the source of the event
sock
,
SSLSession
the SSLSession this event is associated with
s
)

Constructs a new HandshakeCompletedEvent.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the name of the cipher suite negotiated during this session.
getCipherSuite
()

Returns the cipher suite in use by the session which was produced by the handshake.

public Certificate[]

Returns:

an ordered array of certificates, with the local certificate first followed by any certificate authorities. If no certificates were sent, then null is returned.
getLocalCertificates
()

Returns the certificate(s) that were sent to the peer during handshaking.

public Principal

Returns:

the principal sent to the peer. Returns an X500Principal of the end-entity certificate for X509-based cipher suites, and KerberosPrincipal for Kerberos cipher suites. If no principal was sent, then null is returned.
getLocalPrincipal
()

Returns the principal that was sent to the peer during handshaking.

public X509Certificate[]

Returns:

an ordered array of peer X.509 certificates, with the peer's own certificate first followed by any certificate authorities. (The certificates are in the original JSSE javax.security.cert.X509Certificate format).
getPeerCertificateChain
()
Deprecated for removal since 9. The getPeerCertificates() method that returns an array of java.security.cert.Certificate should be used instead.

Returns the identity of the peer which was identified as part of defining the session.

public Certificate[]

Returns:

an ordered array of the peer certificates, with the peer's own certificate first followed by any certificate authorities.
getPeerCertificates
()

Returns the identity of the peer which was established as part of defining the session.

public Principal

Returns:

the peer's principal. Returns an X500Principal of the end-entity certificate for X509-based cipher suites, and KerberosPrincipal for Kerberos cipher suites.
getPeerPrincipal
()

Returns the identity of the peer which was established as part of defining the session.

public SSLSession

Returns:

the SSLSession for this handshake
getSession
()

Returns the session that triggered this event.

public SSLSocket

Returns:

the socket on which the connection was made.
getSocket
()

Returns the socket which is the source of this event.

Inherited from java.util.EventObject:
getSourcetoString

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.EventObject.serialVersionUID.

Annotations
@Serial
sessionback to summary
private final transient SSLSession session

Constructor Detail

HandshakeCompletedEventback to summary
public HandshakeCompletedEvent(SSLSocket sock, SSLSession s)

Constructs a new HandshakeCompletedEvent.

Parameters
sock:SSLSocket

the SSLSocket acting as the source of the event

s:SSLSession

the SSLSession this event is associated with

Method Detail

getCipherSuiteback to summary
public String getCipherSuite()

Returns the cipher suite in use by the session which was produced by the handshake. (This is a convenience method for getting the ciphersuite from the SSLsession.)

Returns:String

the name of the cipher suite negotiated during this session.

getLocalCertificatesback to summary
public Certificate[] getLocalCertificates()

Returns the certificate(s) that were sent to the peer during handshaking.

Note

This method is useful only when using certificate-based cipher suites. When multiple certificates are available for use in a handshake, the implementation chooses what it considers the "best" certificate chain available, and transmits that to the other side. This method allows the caller to know which certificate chain was actually used.

Returns:Certificate[]

an ordered array of certificates, with the local certificate first followed by any certificate authorities. If no certificates were sent, then null is returned.

See Also
getLocalPrincipal()
getLocalPrincipalback to summary
public Principal getLocalPrincipal()

Returns the principal that was sent to the peer during handshaking.

Returns:Principal

the principal sent to the peer. Returns an X500Principal of the end-entity certificate for X509-based cipher suites, and KerberosPrincipal for Kerberos cipher suites. If no principal was sent, then null is returned.

Since
1.5
See Also
getLocalCertificates(), getPeerPrincipal()
getPeerCertificateChainback to summary
public X509Certificate[] getPeerCertificateChain() throws SSLPeerUnverifiedException

Deprecated

for removal since 9.

The getPeerCertificates() method that returns an array of java.security.cert.Certificate should be used instead.

Returns the identity of the peer which was identified as part of defining the session.

Note

This method can be used only when using certificate-based cipher suites; using it with non-certificate-based cipher suites, such as Kerberos, will throw an SSLPeerUnverifiedException.

Note

The returned value may not be a valid certificate chain and should not be relied on for trust decisions.

Note

this method exists for compatibility with previous releases. New applications should use getPeerCertificates instead.

Returns:X509Certificate[]

an ordered array of peer X.509 certificates, with the peer's own certificate first followed by any certificate authorities. (The certificates are in the original JSSE javax.security.cert.X509Certificate format).

Annotations
@SuppressWarnings:removal
@Deprecated
since:9
forRemoval:true
Exceptions
SSLPeerUnverifiedException:
if the peer is not verified.
UnsupportedOperationException:
if the underlying provider does not implement the SSLSession#getPeerCertificateChain operation.
See Also
getPeerPrincipal()
getPeerCertificatesback to summary
public Certificate[] getPeerCertificates() throws SSLPeerUnverifiedException

Returns the identity of the peer which was established as part of defining the session.

Note

This method can be used only when using certificate-based cipher suites; using it with non-certificate-based cipher suites, such as Kerberos, will throw an SSLPeerUnverifiedException.

Note

The returned value may not be a valid certificate chain and should not be relied on for trust decisions.

Returns:Certificate[]

an ordered array of the peer certificates, with the peer's own certificate first followed by any certificate authorities.

Exceptions
SSLPeerUnverifiedException:
if the peer is not verified.
See Also
getPeerPrincipal()
getPeerPrincipalback to summary
public Principal getPeerPrincipal() throws SSLPeerUnverifiedException

Returns the identity of the peer which was established as part of defining the session.

Returns:Principal

the peer's principal. Returns an X500Principal of the end-entity certificate for X509-based cipher suites, and KerberosPrincipal for Kerberos cipher suites.

Exceptions
SSLPeerUnverifiedException:
if the peer's identity has not been verified
Since
1.5
See Also
getPeerCertificates(), getLocalPrincipal()
getSessionback to summary
public SSLSession getSession()

Returns the session that triggered this event.

Returns:SSLSession

the SSLSession for this handshake

getSocketback to summary
public SSLSocket getSocket()

Returns the socket which is the source of this event. (This is a convenience function, to let applications write code without type casts.)

Returns:SSLSocket

the socket on which the connection was made.