Skip to content

Most visited

Recently visited

navigation

KeyStore.PasswordProtection

public static class KeyStore.PasswordProtection
extends Object implements KeyStore.ProtectionParameter, Destroyable

java.lang.Object
   ↳ java.security.KeyStore.PasswordProtection


A password-based implementation of ProtectionParameter.

Summary

Public constructors

KeyStore.PasswordProtection(char[] password)

Creates a password parameter.

KeyStore.PasswordProtection(char[] password, String protectionAlgorithm, AlgorithmParameterSpec protectionParameters)

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

Public methods

void destroy()

Clears the password.

char[] getPassword()

Gets the password.

String getProtectionAlgorithm()

Gets the name of the protection algorithm.

AlgorithmParameterSpec getProtectionParameters()

Gets the parameters supplied for the protection algorithm.

boolean isDestroyed()

Determines if password has been cleared.

Inherited methods

From class java.lang.Object
From interface javax.security.auth.Destroyable

Public constructors

KeyStore.PasswordProtection

added in API level 1
KeyStore.PasswordProtection (char[] password)

Creates a password parameter.

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

Parameters
password char: the password, which may be null

KeyStore.PasswordProtection

KeyStore.PasswordProtection (char[] password, 
                String protectionAlgorithm, 
                AlgorithmParameterSpec 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 char: the password, which may be null
protectionAlgorithm String: the encryption algorithm name, for example, PBEWithHmacSHA256AndAES_256. See the Cipher section in the Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard encryption algorithm names.
protectionParameters AlgorithmParameterSpec: the encryption algorithm parameter specification, which may be null
Throws
NullPointerException if protectionAlgorithm is null

Public methods

destroy

added in API level 1
void destroy ()

Clears the password.

Throws
DestroyFailedException if this method was unable to clear the password

getPassword

added in API level 1
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
char[] the password, which may be null
Throws
IllegalStateException if the password has been cleared (destroyed)

See also:

getProtectionAlgorithm

String 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
String the algorithm name, or null if none was set

getProtectionParameters

AlgorithmParameterSpec getProtectionParameters ()

Gets the parameters supplied for the protection algorithm.

Returns
AlgorithmParameterSpec the algorithm parameter specification, or null, if none was set

isDestroyed

added in API level 1
boolean isDestroyed ()

Determines if password has been cleared.

Returns
boolean true if the password has been cleared, false otherwise
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.