Class UsernamePasswordHashUtil


  • @Deprecated
    public class UsernamePasswordHashUtil
    extends Object
    Deprecated.
    Use PasswordFactory instead.
    A utility class for generating both the {user-name : realm-value : passwd } hash and the hex encoded version of the hash.

    This class makes use of the MessageDigest by single calls to the .digest(byte[]) method, however beyond that there is no synchronisation so this should not be considered thread safe.

    Author:
    Darran Lofthouse
    • Constructor Detail

      • UsernamePasswordHashUtil

        public UsernamePasswordHashUtil()
                                 throws NoSuchAlgorithmException
        Deprecated.
        The default constructor for UsernamePasswordHashUtil, when instantiated using this constructor a local MD5 MessageDigest will be used for the generated hashes.
        Throws:
        NoSuchAlgorithmException - - If the MD5 MessageDigest fails to be created.
      • UsernamePasswordHashUtil

        public UsernamePasswordHashUtil​(MessageDigest digest)
        Deprecated.
        Constructor to allow a pre-instantiated MessageDigest to be supplied.

        The supplied MessageDigest will be used for the hash generation requests,

        Parameters:
        digest - The MessageDigest to use for hash generation requests.
    • Method Detail

      • stringToByte

        private byte[] stringToByte​(String toConvert,
                                    boolean allowUTF8)
        Deprecated.
        An interpretation of the stringToByte_8859_1 method previously from DigestMD5Base.

        Converts the supplied String to a byte array using 8859_1 encoding, however if any of the characters in the String are outside of the range for 8859_1 and if allowUTF8 is true the String will be converted to UTF-8.

        Parameters:
        toConvert - the raw String to convert.
        allowUTF8 - should the conversion use UTF-8 if non 8859_1 chars are found.
        Returns:
        the resulting byte[]
      • stringToByte

        private byte[] stringToByte​(char[] toConvert,
                                    boolean allowUTF8)
        Deprecated.
        A version of stringToByte that takes in a char[]
        Parameters:
        toConvert - the character array to convert.
        allowUTF8 - should the conversion use UTF-8 if non 8859_1 chars are found.
        Returns:
        the resulting byte[]
      • generateHashedURP

        public byte[] generateHashedURP​(String userName,
                                        String realm,
                                        char[] password,
                                        boolean utf8StringConversion)
        Deprecated.
        Takes the supplied username, realm and password and generates the digested { username ':' realm ':' password }
        Parameters:
        userName - The username to use in the generated hash.
        realm - The realm to use in the generated hash.
        password - The password to use in the generated hash.
        utf8StringConversion - Should a conversion to UTF-8 be allowed if non 8859_1 chars are encountered.
        Returns:
        The generated hash.
      • generateHashedURP

        public byte[] generateHashedURP​(String userName,
                                        String realm,
                                        char[] password)
        Deprecated.
      • generateHashedHexURP

        public String generateHashedHexURP​(String userName,
                                           String realm,
                                           char[] password,
                                           boolean utf8StringConversion)
        Deprecated.
      • generateHashedHexURP

        public String generateHashedHexURP​(String userName,
                                           String realm,
                                           char[] password)
        Deprecated.