Class UnprotectedPassword

java.lang.Object
com.aoapps.security.Password
com.aoapps.security.UnprotectedPassword
All Implemented Interfaces:
AutoCloseable, Cloneable, Destroyable

public final class UnprotectedPassword extends Password
Unlike Password, which goes out of its way to protect the password, an unprotected password provides access to the password value. This is intended for when the password needs to be accessible to the application, such as providing a generated password to the user.
Author:
AO Industries, Inc.
  • Constructor Details

    • UnprotectedPassword

      public UnprotectedPassword(char[] password) throws IllegalArgumentException
      Parameters:
      password - Is zeroed before this method returns. If the original password is needed, pass a copy to this method.
      Throws:
      IllegalArgumentException - when password == null || password.length == 0 or when password is already destroyed (contains all zeroes).
    • UnprotectedPassword

      public UnprotectedPassword(SupplierE<? extends char[],Ex> generator) throws Ex
      Generates a new password using the provided password generator.

      The password will never be all-zeroes, since this would conflict with the representation of already destroyed. In the unlikely event the generator creates an all-zero password, the password will be discarded and another will be generated. We do recognize that disallowing certain values from the password space may provide an advantage to attackers (i.e. Enigma), losing the all-zero password is probably a good choice anyway.

      Type Parameters:
      Ex - An arbitrary exception type that may be thrown
      Throws:
      Ex
    • UnprotectedPassword

      @Deprecated public UnprotectedPassword(Random random)
      Deprecated.
      Please use SecureRandom. This method will stay, but will remain deprecated since it should only be used after careful consideration.
      Generates a new password using the default password generator and the provided Random source.
    • UnprotectedPassword

      public UnprotectedPassword(SecureRandom secureRandom)
      Generates a new password using the default password generator and the provided SecureRandom source.
    • UnprotectedPassword

      public UnprotectedPassword()
      Generates a new password using the default password generator and a default SecureRandom instance, which is not a strong instance to avoid blocking.
  • Method Details