Class AMPassword

    • Constructor Detail

      • AMPassword

        public AMPassword​(char[] pw)
        Creates a Password from a char array, then wipes the char array.
        Parameters:
        pw - A char[] containing the password. This array will be cleared (set to zeroes) by the constructor.
    • 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.
        Overrides:
        clone in class Object
        Returns:
        the cloned AMPassword
      • 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 using wipeChars.
        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 (with wipeBytes, 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; * wipeBytes is ideal for this purpose.
        See Also:
        org.mozilla.jss.util.Password#wipeBytes