java.lang.Object
de.powerstat.validation.values.Password
All Implemented Interfaces:
IValueObject, Comparable<Password>

public final class Password extends Object implements Comparable<Password>, IValueObject
Password. DSGVO relevant. TODO memory protection TODO encryption algorithm (hashtypes) TODO salt TODO Disallow email address via verifyPassword TODO Disallow user name (case) via verifyPassword TODO Disallow user ID via verifyPassword TODO password age in days TODO Repeated/Reversed history length via verifyPassword TODO validation chain TODO Password generator TODO Verify that password is not in: https://www.datendieter.de/item/Haeufige_Passwoerter https://www.passwortfuchs.de/passwortliste.php https://crackstation.net/crackstation-wordlist-password-cracking-dictionary.htm https://github.com/danielmiessler/SecLists/tree/master/Passwords https://weakpass.com/wordlist https://wiki.skullsecurity.org/Passwords https://thehacktoday.com/password-cracking-dictionarys-download-for-free/
  • Field Details

    • SECRET_PASSWORD

      private static final String SECRET_PASSWORD
      Hidden password.
      See Also:
    • passwd

      private final String passwd
      Password.
    • read

      private final boolean read
      Password could be read via stringValue() if true.
  • Constructor Details

    • Password

      private Password(IPasswordStrategy validationStrategy, String password, boolean noRead)
      Constructor.
      Parameters:
      validationStrategy - Validation strategy
      password - Password
      noRead - true: password could not be read via stringValue(); false: password could be read
      Throws:
      NullPointerException - if password or validationStrategy is null
      IllegalArgumentException - if password contains unsupported characters or is to long or short etc.
  • Method Details

    • of

      public static Password of(IPasswordStrategy validationStrategy, String password, boolean noRead)
      Password factory.
      Parameters:
      validationStrategy - Validation strategy
      password - Password
      noRead - true: password could not be read via stringValue(); false: password could be read
      Returns:
      Password object
    • of

      public static Password of(IPasswordStrategy validationStrategy, String password)
      Password factory.
      Parameters:
      validationStrategy - Validation strategy
      password - Password
      Returns:
      Password object
    • of

      public static Password of(String password, boolean noRead)
      Password factory with PasswordDefaultStrategy.
      Parameters:
      password - Password
      noRead - true: password could not be read via stringValue(); false: password could be read
      Returns:
      Password object
    • of

      public static Password of(String password)
      Password factory with PasswordDefaultStrategy.
      Parameters:
      password - Password
      Returns:
      Password object
    • stringValue

      public String stringValue()
      Returns the value of this Password as a string or ******** if noRead was set during object creation.
      Specified by:
      stringValue in interface IValueObject
      Returns:
      The text value represented by this object after conversion to type string.
    • verifyPassword

      public boolean verifyPassword(String password)
      Verify password.
      Parameters:
      password - Password string to verify against this Password object
      Returns:
      true when password has been successfully verified, false otherwise TODO encryption
    • hashCode

      public int hashCode()
      Calculate hash code.
      Overrides:
      hashCode in class Object
      Returns:
      Hash
      See Also:
    • equals

      public boolean equals(Object obj)
      Is equal with another object.
      Overrides:
      equals in class Object
      Parameters:
      obj - Object
      Returns:
      true when equal, false otherwise
      See Also:
    • toString

      public String toString()
      Returns the string representation of this Password. The exact details of this representation are unspecified and subject to change, but the following may be regarded as typical: "Password[password=********]"
      Overrides:
      toString in class Object
      Returns:
      String representation of this Password
      See Also:
    • compareTo

      public int compareTo(Password obj)
      Compare with another object.
      Specified by:
      compareTo in interface Comparable<Password>
      Parameters:
      obj - Object to compare with
      Returns:
      0: equal; 1: greater; -1: smaller
      See Also: