Class PasswordEncryptionProvider


  • public class PasswordEncryptionProvider
    extends Object
    Factory of password encryption objects implementing a given algorithm. It wraps the concrete implementation of the PasswordEncryption interface used for encrypting a password according to a chosen algorithm.

    This factory provides all of the available password encryption supported by Silverpeas, nevertheless it returns only the main encryption used by default in Silverpeas (the one that is considered as the more robust and secure) with the getDefaultPasswordEncryption() method. Getting others encryption can be done in order to work with passwords encrypted with old (and then deprecated) algorithms with the getPasswordEncryption(digest) method.

    Author:
    mmoquillon
    • Method Detail

      • getDefaultPasswordEncryption

        public static PasswordEncryption getDefaultPasswordEncryption()
        Gets the password encryption that is used by default in Silverpeas to encrypt the user passwords and to check them.
        Returns:
        the current default password encryption.
      • getPasswordEncryption

        public static PasswordEncryption getPasswordEncryption​(String digest)
                                                        throws IllegalArgumentException
        Gets the encryption that has computed the specified digest.

        As digests in password encryption are usually made up of an encryption algorithm identifier, the factory can then find the algorithm that matches the specified digest. If the digest doesn't contain any algorithm identifier, then the UnixDES is returned (yet it is the only one supported by Silverpeas that doesn't generate an algorithm identifier in the digest). In the case the identifier in the digest isn't known, then a exception is thrown.

        Parameters:
        digest - the digest from which the password encryption has be found.
        Returns:
        the password encryption that has computed the specified digest.
        Throws:
        IllegalArgumentException - if the digest was not computed by any of the password encryption supported in Silverpeas.