Class AMPassword
- java.lang.Object
-
- com.sun.identity.security.keystore.AMCallbackHandler
-
- com.sun.identity.security.keystore.AMPassword
-
- All Implemented Interfaces:
Serializable,Cloneable,CallbackHandler
public class AMPassword extends AMCallbackHandler implements Cloneable, Serializable
Stores a password.clearshould be called when the password is no longer needed so that the sensitive information is not left in memory.A
AMPasswordcan be used as a hard-codedAMCallbackHandler.- See Also:
AMCallbackHandler, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AMPassword(char[] pw)Creates a Password from a char array, then wipes the char array.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static byte[]charToByte(char[] charArray)Converts a char array to a null-terminated byte array using a standard encoding, which is currently UTF8.Objectclone()Clones the password.byte[]getByteCopy()Returns a null-terminated byte array that is the byte-encoding of this password.char[]getChars()Returns the char array underlying this password.-
Methods inherited from class com.sun.identity.security.keystore.AMCallbackHandler
clear, finalize, handle, setPassword
-
-
-
-
Method Detail
-
clone
public Object clone()
Clones the password. The resulting clone will be completely independent of the parent, which means it will have to be separately cleared.
-
getChars
public char[] getChars()
Returns the char array underlying this password. It must not be modified in any way.- Returns:
- password in char array
-
getByteCopy
public byte[] getByteCopy()
Returns a null-terminated byte array that is the byte-encoding of this password. The returned array is a copy of the password. The caller is responsible for wiping the returned array, for example usingwipeChars.- Returns:
- the copy of password in byte array
-
charToByte
public static byte[] charToByte(char[] charArray)
Converts a char array to a null-terminated byte array using a standard encoding, which is currently UTF8. The caller is responsible for clearing the copy (withwipeBytes, for example).- Parameters:
charArray- A character array, which should not be null. It will be wiped with zeroes.- Returns:
- A copy of the charArray, converted from Unicode to UTF8. It
is the responsibility of the caller to clear the output byte
array; *
wipeBytesis ideal for this purpose. - See Also:
org.mozilla.jss.util.Password#wipeBytes
-
-