# HandshakeCompletedEvent

public class **HandshakeCompletedEvent** extends [EventObject](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EventObject.html)  
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.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedListener.html`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSession.html`

### Inherited Field Summary

From class [java.util.EventObject](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EventObject.html)

|---|---|---|
| protected [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [source](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EventObject.html#source) | The object on which the Event initially occurred. |

### Public Constructor Summary

|---|---|
|   | [HandshakeCompletedEvent](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedEvent.html#HandshakeCompletedEvent(javax.net.ssl.SSLSocket,%20javax.net.ssl.SSLSession))([SSLSocket](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html) sock, [SSLSession](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSession.html) s) Constructs a new HandshakeCompletedEvent. |

### Public Method Summary

|---|---|
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [getCipherSuite](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedEvent.html#getCipherSuite())() Returns the cipher suite in use by the session which was produced by the handshake. |
| [Certificate\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/cert/Certificate.html) | [getLocalCertificates](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedEvent.html#getLocalCertificates())() Returns the certificate(s) that were sent to the peer during handshaking. |
| [Principal](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Principal.html) | [getLocalPrincipal](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedEvent.html#getLocalPrincipal())() Returns the principal that was sent to the peer during handshaking. |
| [X509Certificate\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/javax/security/cert/X509Certificate.html) | [getPeerCertificateChain](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedEvent.html#getPeerCertificateChain())() Returns the identity of the peer which was identified as part of defining the session. |
| [Certificate\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/cert/Certificate.html) | [getPeerCertificates](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedEvent.html#getPeerCertificates())() Returns the identity of the peer which was established as part of defining the session. |
| [Principal](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Principal.html) | [getPeerPrincipal](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedEvent.html#getPeerPrincipal())() Returns the identity of the peer which was established as part of defining the session. |
| [SSLSession](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSession.html) | [getSession](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedEvent.html#getSession())() Returns the session that triggered this event. |
| [SSLSocket](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html) | [getSocket](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedEvent.html#getSocket())() Returns the socket which is the source of this event. |

### Inherited Method Summary

From class [java.util.EventObject](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EventObject.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [getSource](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EventObject.html#getSource())() The object on which the Event initially occurred. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/EventObject.html#toString())() Returns a String representation of this EventObject. |

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

## Public Constructors

#### public
**HandshakeCompletedEvent**
([SSLSocket](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html) sock, [SSLSession](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSession.html) s)

Constructs a new HandshakeCompletedEvent.

##### Parameters

| sock | the SSLSocket acting as the source of the event |
| s | the SSLSession this event is associated with |
|---|---|

## Public Methods

#### public [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**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.

#### public [Certificate\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/cert/Certificate.html)
**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

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedEvent.html#getLocalPrincipal()`

#### public [Principal](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Principal.html)
**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.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedEvent.html#getLocalCertificates()`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedEvent.html#getPeerPrincipal()`

#### public [X509Certificate\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/javax/security/cert/X509Certificate.html)
**getPeerCertificateChain**
()

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: this method exists for compatibility with previous
releases. New applications should use
`https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedEvent.html#getPeerCertificates()` instead.*

<br />

##### 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 `https://developers.google.com/j2objc/javadoc/jre/reference/javax/security/cert/X509Certificate.html` format).

##### Throws

| [SSLPeerUnverifiedException](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLPeerUnverifiedException.html) | if the peer is not verified. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedEvent.html#getPeerPrincipal()`

#### public [Certificate\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/cert/Certificate.html)
**getPeerCertificates**
()

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.

##### Returns

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

##### Throws

| [SSLPeerUnverifiedException](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLPeerUnverifiedException.html) | if the peer is not verified. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedEvent.html#getPeerPrincipal()`

#### public [Principal](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Principal.html)
**getPeerPrincipal**
()

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](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLPeerUnverifiedException.html) | if the peer's identity has not been verified |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedEvent.html#getPeerCertificates()`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedEvent.html#getLocalPrincipal()`

#### public [SSLSession](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSession.html)
**getSession**
()

Returns the session that triggered this event.

##### Returns

- the `SSLSession` for this handshake

#### public [SSLSocket](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html)
**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.