Class PasswordClass

    • Constructor Detail

      • PasswordClass

        public PasswordClass()
    • Method Detail

      • getStorageType

        public String getStorageType()
        Returns:
        One of 'Clear', 'Hash' or 'Encrypt'.
      • setStorageType

        public void setStorageType​(String storageType)
        Parameters:
        storageType - One of 'Clear', 'Hash' or 'Encrypt'
        Since:
        10.7RC1
      • getHashAlgorithm

        public String getHashAlgorithm()
        Returns:
        The hash algorithm configured for this XProperty.
      • getCryptAlgorithm

        public String getCryptAlgorithm()
        Returns:
        The encryption algorithm configured for this XProperty.
      • getAlgorithmFromPassword

        public String getAlgorithmFromPassword​(String password)
        Parameters:
        password -
        Returns:
        The algorithm used for the given password.
      • getSaltFromPassword

        public String getSaltFromPassword​(String password)
        Parameters:
        password -
        Returns:
        The salt used for the given password. If this is an unsalted password, let it be known by returning "".
      • getEquivalentPassword

        public String getEquivalentPassword​(String storedPassword,
                                            String plainPassword)
        Transforms a plain text password so that it has the same encryption as a password stored in the database. The current configuration for this password XProperty cannot be used, as the user might have a different encryption mechanism (for example, if the user was imported, or the password was not yet upgraded).
        Parameters:
        storedPassword - The stored password, which gives the storage type and algorithm.
        plainPassword - The plain text password to be encrypted.
        Returns:
        The input password, encrypted with the same mechanism as the stored password.
      • getProcessedPassword

        public String getProcessedPassword​(String password)
      • getPasswordCrypt

        public String getPasswordCrypt​(String password)
      • getPasswordCrypt

        public String getPasswordCrypt​(String password,
                                       String algorithmName)
      • getPasswordHash

        public String getPasswordHash​(String password)
        Parameters:
        password - the password to hash.
        Returns:
        a string of the form hash:<algorithmName>:<salt>:<hexStrignHash>, where <algorithmName> is the default hashing algorithm (see DEFAULT_HASH_ALGORITHM), <salt> is a random 64 character salt and <hexStrignHash> is the salted hash of the given password, using the given hashing algorithm.
      • getPasswordHash

        public String getPasswordHash​(String password,
                                      String algorithmName)
        Parameters:
        password - the password to hash.
        algorithmName - the name of the hashing algorithm to use. See MessageDigest.getInstance(String).
        Returns:
        a string of the form hash:<algorithmName>:<salt>:<hexStrignHash>, where <salt> is a random 64 character salt and <hexStrignHash> is the salted hash of the given password, using the given hashing algorithm.
      • getPasswordHash

        public String getPasswordHash​(String password,
                                      String algorithmName,
                                      String salt)
        Parameters:
        password - the password to hash.
        algorithmName - the name of the hashing algorithm to use. See MessageDigest.getInstance(String).
        salt - the string to pad the password with before hashing. If null, a random 64 character salt will be used. To disable salting, use an empty ("") salt string.
        Returns:
        a string of the form hash:<algorithmName>:<salt>:<hexStrignHash>, where <hexStrignHash> is the salted hash of the given password, using the given hashing algorithm.
        Since:
        6.3M2
      • randomSalt

        public static String randomSalt()