Class RFC2307SHAPasswordEncryptor

  • All Implemented Interfaces:
    PasswordEncryptor

    public final class RFC2307SHAPasswordEncryptor
    extends java.lang.Object
    implements PasswordEncryptor

    Utility class for easily performing password digesting and checking according to {SHA}, a password encryption scheme defined in RFC2307 and commonly found in LDAP systems.

    This class internally holds a StandardStringDigester configured this way:

    • Algorithm: SHA-1.
    • Salt size: 0 bytes (no salt).
    • Iterations: 1 (no hash iteration).
    • Prefix: {SHA}.

    This class is thread-safe

    Since:
    1.7
    • Constructor Summary

      Constructors 
      Constructor Description
      RFC2307SHAPasswordEncryptor()
      Creates a new instance of RFC2307SHAPasswordEncryptor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean checkPassword​(java.lang.String plainPassword, java.lang.String encryptedPassword)
      Checks an unencrypted (plain) password against an encrypted one (a digest) to see if they match.
      java.lang.String encryptPassword​(java.lang.String password)
      Encrypts (digests) a password.
      void setStringOutputType​(java.lang.String stringOutputType)
      Sets the the form in which String output will be encoded.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RFC2307SHAPasswordEncryptor

        public RFC2307SHAPasswordEncryptor()
        Creates a new instance of RFC2307SHAPasswordEncryptor
    • Method Detail

      • setStringOutputType

        public void setStringOutputType​(java.lang.String stringOutputType)

        Sets the the form in which String output will be encoded. Available encoding types are:

        • base64 (default)
        • hexadecimal
        Parameters:
        stringOutputType - the string output type.
      • checkPassword

        public boolean checkPassword​(java.lang.String plainPassword,
                                     java.lang.String encryptedPassword)
        Checks an unencrypted (plain) password against an encrypted one (a digest) to see if they match.
        Specified by:
        checkPassword in interface PasswordEncryptor
        Parameters:
        plainPassword - the plain password to check.
        encryptedPassword - the digest against which to check the password.
        Returns:
        true if passwords match, false if not.
        See Also:
        StandardStringDigester.matches(String, String)