# X500PrivateCredential

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/javax/security/auth/x500/X500PrivateCredential#pubctors)\|[Methods](https://developer.android.com/reference/javax/security/auth/x500/X500PrivateCredential#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/javax/security/auth/x500/X500PrivateCredential#inhmethods)  

# X500PrivateCredential

`
public

final

class
X500PrivateCredential
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


implements

`[Destroyable](https://developer.android.com/reference/javax/security/auth/Destroyable)`


`

|---|------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | javax.security.auth.x500.X500PrivateCredential |

<br />

*** ** * ** ***

<br />

This class represents an`X500PrivateCredential`. It associates an X.509 certificate, corresponding private key and the KeyStore alias used to reference that exact key pair in the KeyStore. This enables looking up the private credentials for an X.500 principal in a subject.

## Summary

|                                                                                                                                                                                                                                                                                                 ### Public constructors                                                                                                                                                                                                                                                                                                 ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[X500PrivateCredential](https://developer.android.com/reference/javax/security/auth/x500/X500PrivateCredential#X500PrivateCredential(java.security.cert.X509Certificate,%20java.security.PrivateKey))`(`[X509Certificate](https://developer.android.com/reference/java/security/cert/X509Certificate)` cert, `[PrivateKey](https://developer.android.com/reference/java/security/PrivateKey)` key) ` Creates an X500PrivateCredential that associates an X.509 certificate, a private key and the KeyStore alias.                                                                                                 |
| ` `[X500PrivateCredential](https://developer.android.com/reference/javax/security/auth/x500/X500PrivateCredential#X500PrivateCredential(java.security.cert.X509Certificate,%20java.security.PrivateKey,%20java.lang.String))`(`[X509Certificate](https://developer.android.com/reference/java/security/cert/X509Certificate)` cert, `[PrivateKey](https://developer.android.com/reference/java/security/PrivateKey)` key, `[String](https://developer.android.com/reference/java/lang/String)` alias) ` Creates an X500PrivateCredential that associates an X.509 certificate, a private key and the KeyStore alias. |

|                                                                                                                                                          ### Public methods                                                                                                                                                           ||
|--------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`                                                                                          | ` `[destroy](https://developer.android.com/reference/javax/security/auth/x500/X500PrivateCredential#destroy())`() ` Clears the references to the X.509 certificate, private key and the KeyStore alias in this object.              |
| ` `[String](https://developer.android.com/reference/java/lang/String)                            | ` `[getAlias](https://developer.android.com/reference/javax/security/auth/x500/X500PrivateCredential#getAlias())`() ` Returns the KeyStore alias.                                                                                   |
| ` `[X509Certificate](https://developer.android.com/reference/java/security/cert/X509Certificate) | ` `[getCertificate](https://developer.android.com/reference/javax/security/auth/x500/X500PrivateCredential#getCertificate())`() ` Returns the X.509 certificate.                                                                    |
| ` `[PrivateKey](https://developer.android.com/reference/java/security/PrivateKey)                | ` `[getPrivateKey](https://developer.android.com/reference/javax/security/auth/x500/X500PrivateCredential#getPrivateKey())`() ` Returns the PrivateKey.                                                                             |
| ` boolean`                                                                                       | ` `[isDestroyed](https://developer.android.com/reference/javax/security/auth/x500/X500PrivateCredential#isDestroyed())`() ` Determines if the references to the X.509 certificate and private key in this object have been cleared. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||
| From interface` `[javax.security.auth.Destroyable](https://developer.android.com/reference/javax/security/auth/Destroyable)` ` |--------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------| | ` default void`    | ` `[destroy](https://developer.android.com/reference/javax/security/auth/Destroyable#destroy())`() ` Destroy this`Object`.                                | | ` default boolean` | ` `[isDestroyed](https://developer.android.com/reference/javax/security/auth/Destroyable#isDestroyed())`() ` Determine if this`Object`has been destroyed. | ||

## Public constructors

### X500PrivateCredential

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public X500PrivateCredential (X509Certificate cert, 
                PrivateKey key)
```

Creates an X500PrivateCredential that associates an X.509 certificate, a private key and the KeyStore alias.

<br />

|                         Parameters                          ||
|--------|-----------------------------------------------------|
| `cert` | `X509Certificate`: X509Certificate <br />           |
| `key`  | `PrivateKey`: PrivateKey for the certificate <br /> |

|                                                                Throws                                                                 ||
|--------------------------------------------------------------------------------------------------------|-------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if either`cert`or`key`is null |

### X500PrivateCredential

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public X500PrivateCredential (X509Certificate cert, 
                PrivateKey key, 
                String alias)
```

Creates an X500PrivateCredential that associates an X.509 certificate, a private key and the KeyStore alias.

<br />

|                          Parameters                          ||
|---------|-----------------------------------------------------|
| `cert`  | `X509Certificate`: X509Certificate <br />           |
| `key`   | `PrivateKey`: PrivateKey for the certificate <br /> |
| `alias` | `String`: KeyStore alias <br />                     |

|                                                                    Throws                                                                     ||
|--------------------------------------------------------------------------------------------------------|---------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if either`cert`,`key`or`alias`is null |

## Public methods

### destroy

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void destroy ()
```

Clears the references to the X.509 certificate, private key and the KeyStore alias in this object.

<br />

### getAlias

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String getAlias ()
```

Returns the KeyStore alias.

<br />

|                                            Returns                                            ||
|--------------------------------------------------------------------|---------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | the KeyStore alias <br /> |

### getCertificate

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public X509Certificate getCertificate ()
```

Returns the X.509 certificate.

<br />

|                                                          Returns                                                          ||
|-----------------------------------------------------------------------------------------------|----------------------------|
| [X509Certificate](https://developer.android.com/reference/java/security/cert/X509Certificate) | the X509Certificate <br /> |

### getPrivateKey

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public PrivateKey getPrivateKey ()
```

Returns the PrivateKey.

<br />

|                                                Returns                                                ||
|--------------------------------------------------------------------------------|-----------------------|
| [PrivateKey](https://developer.android.com/reference/java/security/PrivateKey) | the PrivateKey <br /> |

### isDestroyed

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean isDestroyed ()
```

Determines if the references to the X.509 certificate and private key in this object have been cleared.

<br />

|                                Returns                                ||
|-----------|------------------------------------------------------------|
| `boolean` | true if X509Certificate and the PrivateKey are null <br /> |