org.silverpeas.authentication.encryption
Class PasswordEncryptionFactory

java.lang.Object
  extended by org.silverpeas.authentication.encryption.PasswordEncryptionFactory

public class PasswordEncryptionFactory
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

Constructor Summary
PasswordEncryptionFactory()
           
 
Method Summary
 PasswordEncryption getDefaultPasswordEncryption()
          Gets the password encryption that is used by default in Silverpeas to encrypt the user passwords and to check them.
static PasswordEncryptionFactory getFactory()
          Gets an instance of the factory of password encryption.
 PasswordEncryption getPasswordEncryption(String digest)
          Gets the encryption that has computed the specified digest.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PasswordEncryptionFactory

public PasswordEncryptionFactory()
Method Detail

getFactory

public static PasswordEncryptionFactory getFactory()
Gets an instance of the factory of password encryption.

Returns:
a instance of the PasswordEncryptionFactory class.

getDefaultPasswordEncryption

public 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 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.


Copyright © 2016 Silverpeas. All Rights Reserved.