public static class

KeyStore.PasswordProtection

extends Object
implements KeyStore.ProtectionParameter Destroyable
java.lang.Object
   ↳ java.security.KeyStore.PasswordProtection

Class Overview

A password-based implementation of ProtectionParameter.

Summary

Public Constructors
KeyStore.PasswordProtection(char[] password)
Creates a password parameter.
Public Methods
synchronized void destroy()
Clears the password.
synchronized char[] getPassword()
Gets the password.
synchronized boolean isDestroyed()
Determines if password has been cleared.
[Expand]
Inherited Methods
From class java.lang.Object
From interface javax.security.auth.Destroyable

Public Constructors

public KeyStore.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 Methods

public synchronized void destroy ()

Clears the password.

Throws
if this method was unable to clear the password
DestroyFailedException

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 if the password has been cleared (destroyed)
See Also

public synchronized boolean isDestroyed ()

Determines if password has been cleared.

Returns
  • true if the password has been cleared, false otherwise