# KeyStore.PasswordProtection

public static class **KeyStore.PasswordProtection** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
implements [KeyStore.ProtectionParameter](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.ProtectionParameter.html) [Destroyable](https://developers.google.com/j2objc/javadoc/jre/reference/javax/security/auth/Destroyable.html) A password-based implementation of `ProtectionParameter`.

### Public Constructor Summary

|---|---|
|   | [PasswordProtection](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.PasswordProtection.html#PasswordProtection(char[]))(char\[\] password) Creates a password parameter. |
|   | [PasswordProtection](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.PasswordProtection.html#PasswordProtection(char[],%20java.lang.String,%20java.security.spec.AlgorithmParameterSpec))(char\[\] password, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) protectionAlgorithm, [AlgorithmParameterSpec](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/spec/AlgorithmParameterSpec.html) protectionParameters) Creates a password parameter and specifies the protection algorithm and associated parameters to use when encrypting a keystore entry. |

### Public Method Summary

|---|---|
| synchronized void | [destroy](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.PasswordProtection.html#destroy())() Clears the password. |
| synchronized char\[\] | [getPassword](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.PasswordProtection.html#getPassword())() Gets the password. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [getProtectionAlgorithm](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.PasswordProtection.html#getProtectionAlgorithm())() Gets the name of the protection algorithm. |
| [AlgorithmParameterSpec](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/spec/AlgorithmParameterSpec.html) | [getProtectionParameters](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.PasswordProtection.html#getProtectionParameters())() Gets the parameters supplied for the protection algorithm. |
| synchronized boolean | [isDestroyed](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.PasswordProtection.html#isDestroyed())() Determines if password has been cleared. |

### 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 [javax.security.auth.Destroyable](https://developers.google.com/j2objc/javadoc/jre/reference/javax/security/auth/Destroyable.html)

|---|---|
| void | [destroy](https://developers.google.com/j2objc/javadoc/jre/reference/javax/security/auth/Destroyable.html#destroy())() Destroy this `Object`. |
| boolean | [isDestroyed](https://developers.google.com/j2objc/javadoc/jre/reference/javax/security/auth/Destroyable.html#isDestroyed())() Determine if this `Object` has been destroyed. |

## Public Constructors

#### public
**PasswordProtection**
(char\[\] password)

Creates a password parameter.

The specified `password` is cloned before it is stored
in the new `PasswordProtection` object.

##### Parameters

| password | the password, which may be `null` |
|---|---|

#### public
**PasswordProtection**
(char\[\] password, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) protectionAlgorithm, [AlgorithmParameterSpec](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/spec/AlgorithmParameterSpec.html) protectionParameters)

Creates a password parameter and specifies the protection algorithm
and associated parameters to use when encrypting a keystore entry.


The specified `password` is cloned before it is stored in the
new `PasswordProtection` object.

##### Parameters

| password | the password, which may be `null` |
| protectionAlgorithm | the encryption algorithm name, for example, `PBEWithHmacSHA256AndAES_256`. See the Cipher section in the [Java Cryptography Architecture Standard Algorithm Name Documentation](https://developers.google.com/j2objc/javadoc/jre/technotes/guides/security/StandardNames.html#Cipher) for information about standard encryption algorithm names. |
| protectionParameters | the encryption algorithm parameter specification, which may be `null` |
|---|---|

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if `protectionAlgorithm` is `null` |
|---|---|

## Public Methods

#### public synchronized void
**destroy**
()

Clears the password.

##### Throws

| [DestroyFailedException](https://developers.google.com/j2objc/javadoc/jre/reference/javax/security/auth/DestroyFailedException.html) | if this method was unable to clear the password |
|---|---|

#### public synchronized char\[\]
**getPassword**
()

Gets the password.

Note that this method returns a reference to the password.
If a clone of the array is created it is the caller's
responsibility to zero out the password information
after it is no longer needed.

##### Returns

- the password, which may be `null`

##### Throws

| [IllegalStateException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalStateException.html) | if the password has been cleared (destroyed) |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.PasswordProtection.html#destroy()`

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

Gets the name of the protection algorithm.
If none was set then the keystore provider will use its default
protection algorithm. The name of the default protection algorithm
for a given keystore type is set using the
`'keystore.<type>.keyProtectionAlgorithm'` security property.
For example, the
`keystore.PKCS12.keyProtectionAlgorithm` property stores the
name of the default key protection algorithm used for PKCS12
keystores. If the security property is not set, an
implementation-specific algorithm will be used.

##### Returns

- the algorithm name, or `null` if none was set

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

Gets the parameters supplied for the protection algorithm.

##### Returns

- the algorithm parameter specification, or `null`, if none was set

#### public synchronized boolean
**isDestroyed**
()

Determines if password has been cleared.

##### Returns

- true if the password has been cleared, false otherwise