Class GenericSaltedPasswordEncoder

  • All Implemented Interfaces:
    PasswordEncoder, java.io.Serializable

    public class GenericSaltedPasswordEncoder
    extends java.lang.Object
    implements PasswordEncoder
    Generic password encoder that can be parametrized with SaltEncodingPolicy and digest algorithm name. Algorithm name must be supported by MessageDigest
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean check​(java.lang.String uid, java.lang.String encoded, java.lang.String password)
      Calculates the hash of 'plain' and compare it with the value of 'encoded'.
      java.lang.String decode​(java.lang.String encoded)
      Decode the given encoded password.
      java.lang.String encode​(java.lang.String uid, java.lang.String password)
      This method add salt to the password and then calculates digest
      java.lang.String getAlgorithm()  
      void setAlgorithm​(java.lang.String algorithm)
      Sets MessageDigest algorithm used by this bean
      void setSaltEncodingPolicy​(SaltEncodingPolicy saltEncodingPolicy)  
      • Methods inherited from class java.lang.Object

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

      • GenericSaltedPasswordEncoder

        public GenericSaltedPasswordEncoder()
    • Method Detail

      • encode

        public java.lang.String encode​(java.lang.String uid,
                                       java.lang.String password)
        This method add salt to the password and then calculates digest
        Specified by:
        encode in interface PasswordEncoder
        Parameters:
        uid - the user id
        password - the user password
        Returns:
        the hashed value of the salted password
        See Also:
        SaltedMD5PasswordEncoder, PlainTextPasswordEncoder
      • check

        public boolean check​(java.lang.String uid,
                             java.lang.String encoded,
                             java.lang.String password)
        Calculates the hash of 'plain' and compare it with the value of 'encoded'.
        Specified by:
        check in interface PasswordEncoder
        Parameters:
        uid - the user id
        encoded - could be 'null'
        password - could be 'null'
        Returns:
        true if hash of 'plain' is equals to 'encoded'
        See Also:
        MD5PasswordEncoder
      • getAlgorithm

        public java.lang.String getAlgorithm()
      • setAlgorithm

        public void setAlgorithm​(java.lang.String algorithm)
        Sets MessageDigest algorithm used by this bean
        Parameters:
        algorithm - message digest algorithm
      • setSaltEncodingPolicy

        public void setSaltEncodingPolicy​(SaltEncodingPolicy saltEncodingPolicy)