# KeyStore.PrivateKeyEntry

public static final class **KeyStore.PrivateKeyEntry** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
implements [KeyStore.Entry](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.Entry.html) A `KeyStore` entry that holds a `PrivateKey`
and corresponding certificate chain.

### Public Constructor Summary

|---|---|
|   | [PrivateKeyEntry](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.PrivateKeyEntry.html#PrivateKeyEntry(java.security.PrivateKey,%20java.security.cert.Certificate[]))([PrivateKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivateKey.html) privateKey, [Certificate\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/cert/Certificate.html) chain) Constructs a `PrivateKeyEntry` with a `PrivateKey` and corresponding certificate chain. |
|   | [PrivateKeyEntry](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.PrivateKeyEntry.html#PrivateKeyEntry(java.security.PrivateKey,%20java.security.cert.Certificate[],%20java.util.Set<java.security.KeyStore.Entry.Attribute>))([PrivateKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivateKey.html) privateKey, [Certificate\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/cert/Certificate.html) chain, [Set](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html)\<[KeyStore.Entry.Attribute](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.Entry.Attribute.html)\> attributes) Constructs a `PrivateKeyEntry` with a `PrivateKey` and corresponding certificate chain and associated entry attributes. |

### Public Method Summary

|---|---|
| [Set](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html)\<[KeyStore.Entry.Attribute](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.Entry.Attribute.html)\> | [getAttributes](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.PrivateKeyEntry.html#getAttributes())() Retrieves the attributes associated with an entry. |
| [Certificate](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/cert/Certificate.html) | [getCertificate](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.PrivateKeyEntry.html#getCertificate())() Gets the end entity `Certificate` from the certificate chain in this entry. |
| [Certificate\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/cert/Certificate.html) | [getCertificateChain](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.PrivateKeyEntry.html#getCertificateChain())() Gets the `Certificate` chain from this entry. |
| [PrivateKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivateKey.html) | [getPrivateKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.PrivateKeyEntry.html#getPrivateKey())() Gets the `PrivateKey` from this entry. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.PrivateKeyEntry.html#toString())() Returns a string representation of this PrivateKeyEntry. |

### Inherited Method Summary

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. |

From interface [java.security.KeyStore.Entry](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.Entry.html)

|---|---|
| [Set](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html)\<[KeyStore.Entry.Attribute](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.Entry.Attribute.html)\> | [getAttributes](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.Entry.html#getAttributes())() Retrieves the attributes associated with an entry. |

## Public Constructors

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

Constructs a `PrivateKeyEntry` with a
`PrivateKey` and corresponding certificate chain.

The specified `chain` is cloned before it is stored
in the new `PrivateKeyEntry` object.

##### Parameters

| privateKey | the `PrivateKey` |
| chain | an array of `Certificate`s representing the certificate chain. The chain must be ordered and contain a `Certificate` at index 0 corresponding to the private key. |
|---|---|

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if `privateKey` or `chain` is `null` |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if the specified chain has a length of 0, if the specified chain does not contain `Certificate`s of the same type, or if the `PrivateKey` algorithm does not match the algorithm of the `PublicKey` in the end entity `Certificate` (at index 0) |
|---|---|

#### public
**PrivateKeyEntry**
([PrivateKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivateKey.html) privateKey, [Certificate\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/cert/Certificate.html) chain, [Set](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html)\<[KeyStore.Entry.Attribute](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.Entry.Attribute.html)\> attributes)

Constructs a `PrivateKeyEntry` with a `PrivateKey` and
corresponding certificate chain and associated entry attributes.

The specified `chain` and `attributes` are cloned
before they are stored in the new `PrivateKeyEntry` object.

##### Parameters

| privateKey | the `PrivateKey` |
| chain | an array of `Certificate`s representing the certificate chain. The chain must be ordered and contain a `Certificate` at index 0 corresponding to the private key. |
| attributes | the attributes |
|---|---|

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if `privateKey`, `chain` or `attributes` is `null` |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if the specified chain has a length of 0, if the specified chain does not contain `Certificate`s of the same type, or if the `PrivateKey` algorithm does not match the algorithm of the `PublicKey` in the end entity `Certificate` (at index 0) |
|---|---|

## Public Methods

#### public [Set](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html)\<[KeyStore.Entry.Attribute](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.Entry.Attribute.html)\>
**getAttributes**
()

Retrieves the attributes associated with an entry.

<br />

##### Returns

- an unmodifiable `Set` of attributes, possibly empty

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

Gets the end entity `Certificate`
from the certificate chain in this entry.

##### Returns

- the end entity `Certificate` (at index 0) from the certificate chain in this entry. If the certificate is of type X.509, the runtime type of the returned certificate is `X509Certificate`.

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

Gets the `Certificate` chain from this entry.

The stored chain is cloned before being returned.

##### Returns

- an array of `Certificate`s corresponding to the certificate chain for the public key. If the certificates are of type X.509, the runtime type of the returned array is `X509Certificate[]`.

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

Gets the `PrivateKey` from this entry.

##### Returns

- the `PrivateKey` from this entry

#### public [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**toString**
()

Returns a string representation of this PrivateKeyEntry.

##### Returns

- a string representation of this PrivateKeyEntry.