HandshakeCompletedEvent (Java SE 9 & JDK 9 ) (original) (raw)
- java.util.EventObject
- javax.net.ssl.HandshakeCompletedEvent
All Implemented Interfaces:
[Serializable](../../../java/io/Serializable.html "interface in java.io")
public class HandshakeCompletedEvent
extends EventObject
This event indicates that an SSL handshake completed on a given SSL connection. All of 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.
Since:
1.4
See Also:
SSLSocket, HandshakeCompletedListener, SSLSession, Serialized Form
Field Summary
* ### Fields inherited from class java.util.[EventObject](../../../java/util/EventObject.html "class in java.util") `[source](../../../java/util/EventObject.html#source)`
Constructor Summary
Constructors
Constructor Description HandshakeCompletedEvent(SSLSocket sock,SSLSession s) Constructs a new HandshakeCompletedEvent. Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods
Modifier and Type Method Description String getCipherSuite() Returns the cipher suite in use by the session which was produced by the handshake. Certificate[] getLocalCertificates() Returns the certificate(s) that were sent to the peer during handshaking. Principal getLocalPrincipal() Returns the principal that was sent to the peer during handshaking. X509Certificate[] getPeerCertificateChain() Deprecated. Certificate[] getPeerCertificates() Returns the identity of the peer which was established as part of defining the session. Principal getPeerPrincipal() Returns the identity of the peer which was established as part of defining the session. SSLSession getSession() Returns the session that triggered this event. SSLSocket getSocket() Returns the socket which is the source of this event. * ### Methods inherited from class java.util.[EventObject](../../../java/util/EventObject.html "class in java.util") `[getSource](../../../java/util/EventObject.html#getSource--), [toString](../../../java/util/EventObject.html#toString--)` * ### Methods inherited from class java.lang.[Object](../../../java/lang/Object.html "class in java.lang") `[clone](../../../java/lang/Object.html#clone--), [equals](../../../java/lang/Object.html#equals-java.lang.Object-), [finalize](../../../java/lang/Object.html#finalize--), [getClass](../../../java/lang/Object.html#getClass--), [hashCode](../../../java/lang/Object.html#hashCode--), [notify](../../../java/lang/Object.html#notify--), [notifyAll](../../../java/lang/Object.html#notifyAll--), [wait](../../../java/lang/Object.html#wait--), [wait](../../../java/lang/Object.html#wait-long-), [wait](../../../java/lang/Object.html#wait-long-int-)`
Constructor Detail
* #### HandshakeCompletedEvent public HandshakeCompletedEvent([SSLSocket](../../../javax/net/ssl/SSLSocket.html "class in javax.net.ssl") sock, [SSLSession](../../../javax/net/ssl/SSLSession.html "interface in javax.net.ssl") s) Constructs a new HandshakeCompletedEvent. Parameters: `sock` \- the SSLSocket acting as the source of the event `s` \- the SSLSession this event is associated with
Method Detail
* #### getSession public [SSLSession](../../../javax/net/ssl/SSLSession.html "interface in javax.net.ssl") getSession() Returns the session that triggered this event. Returns: the `SSLSession` for this handshake * #### getCipherSuite public [String](../../../java/lang/String.html "class in java.lang") 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: the name of the cipher suite negotiated during this session. * #### getLocalCertificates public [Certificate](../../../java/security/cert/Certificate.html "class in java.security.cert")[] 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: 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()](../../../javax/net/ssl/HandshakeCompletedEvent.html#getLocalPrincipal--) * #### getPeerCertificates public [Certificate](../../../java/security/cert/Certificate.html "class in java.security.cert")[] getPeerCertificates() throws [SSLPeerUnverifiedException](../../../javax/net/ssl/SSLPeerUnverifiedException.html "class in javax.net.ssl") 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: an ordered array of the peer certificates, with the peer's own certificate first followed by any certificate authorities. Throws: `[SSLPeerUnverifiedException](../../../javax/net/ssl/SSLPeerUnverifiedException.html "class in javax.net.ssl")` \- if the peer is not verified. See Also: [getPeerPrincipal()](../../../javax/net/ssl/HandshakeCompletedEvent.html#getPeerPrincipal--) * #### getPeerCertificateChain [@Deprecated](../../../java/lang/Deprecated.html "annotation in java.lang")([since](../../../java/lang/Deprecated.html#since--)="9") public [X509Certificate](../../../javax/security/cert/X509Certificate.html "class in javax.security.cert")[] getPeerCertificateChain() throws [SSLPeerUnverifiedException](../../../javax/net/ssl/SSLPeerUnverifiedException.html "class in javax.net.ssl") Deprecated. 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()](../../../javax/net/ssl/HandshakeCompletedEvent.html#getPeerCertificates--) instead._ 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[X509Certificate](../../../javax/security/cert/X509Certificate.html "class in javax.security.cert") format). Throws: `[SSLPeerUnverifiedException](../../../javax/net/ssl/SSLPeerUnverifiedException.html "class in javax.net.ssl")` \- if the peer is not verified. See Also: [getPeerPrincipal()](../../../javax/net/ssl/HandshakeCompletedEvent.html#getPeerPrincipal--) * #### getPeerPrincipal public [Principal](../../../java/security/Principal.html "interface in java.security") getPeerPrincipal() throws [SSLPeerUnverifiedException](../../../javax/net/ssl/SSLPeerUnverifiedException.html "class in javax.net.ssl") Returns the identity of the peer which was established as part of defining the session. Returns: the peer's principal. Returns an X500Principal of the end-entity certiticate for X509-based cipher suites, and KerberosPrincipal for Kerberos cipher suites. Throws: `[SSLPeerUnverifiedException](../../../javax/net/ssl/SSLPeerUnverifiedException.html "class in javax.net.ssl")` \- if the peer's identity has not been verified Since: 1.5 See Also: [getPeerCertificates()](../../../javax/net/ssl/HandshakeCompletedEvent.html#getPeerCertificates--), [getLocalPrincipal()](../../../javax/net/ssl/HandshakeCompletedEvent.html#getLocalPrincipal--) * #### getLocalPrincipal public [Principal](../../../java/security/Principal.html "interface in java.security") getLocalPrincipal() Returns the principal that was sent to the peer during handshaking. 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. Since: 1.5 See Also: [getLocalCertificates()](../../../javax/net/ssl/HandshakeCompletedEvent.html#getLocalCertificates--), [getPeerPrincipal()](../../../javax/net/ssl/HandshakeCompletedEvent.html#getPeerPrincipal--) * #### getSocket public [SSLSocket](../../../javax/net/ssl/SSLSocket.html "class in javax.net.ssl") 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: the socket on which the connection was made.
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2017, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.