Class PasswordWithHash


  • public class PasswordWithHash
    extends Object
    Password holder, with support for hashing.
    • Constructor Detail

      • PasswordWithHash

        public PasswordWithHash​(String passwordWithDigest)
                         throws NoSuchAlgorithmException
        Save password, which can use hashes, for example {MD5}9addb63b65b01292700094b0ef056036 or {SHA-1}2681c738294805939045be2a4af53b687c25bf4d. The hashing algorithms can be any algorithm supported by MessageDigest.
        Parameters:
        passwordWithDigest - Password (could be hashed).
        Throws:
        NoSuchAlgorithmException - If the digest algorithm isn't known to the JVM.
    • Method Detail

      • matches

        public boolean matches​(String password)
        Checks if the given password matches the stored one (or its hash).
        Parameters:
        password - Password to check.
        Returns:
        true if the given password matches the stored one (or its hash), false otherwise.