Interface PasswordEncoderService

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String decode​(UserModel user)
      Tries to decodes from the given user the encoded password based on the encoding set to the user.
      java.lang.String encode​(UserModel user, java.lang.String plainTextPassword, java.lang.String passwordEncoding)
      Encodes the given plainTextPassword with the corresponding PasswordEncoder (based on the passwordEncoding) and returns it.
      java.util.Collection<java.lang.String> getSupportedEncodings()  
      boolean isSupportedEncoding​(java.lang.String encoding)
      Checks if the given password encoding is supported.
      boolean isValid​(UserModel user, java.lang.String plainPassword)
      Checks if the encoded password (stored in the user) matches the given plain text password.
    • Method Detail

      • encode

        java.lang.String encode​(UserModel user,
                                java.lang.String plainTextPassword,
                                java.lang.String passwordEncoding)
                         throws PasswordEncoderNotFoundException
        Encodes the given plainTextPassword with the corresponding PasswordEncoder (based on the passwordEncoding) and returns it. The user can be used as 'salt' in the implementation of the PasswordEncoders
        Parameters:
        user - can be used as 'salt'. See MD5PasswordEncoder
        plainTextPassword - the plain password
        passwordEncoding - based on this encoding the correct PasswordEncoder is used
        Returns:
        the encoded password
        Throws:
        PasswordEncoderNotFoundException - if for the given passwordEncoding no PasswordEncoder is known
      • isSupportedEncoding

        boolean isSupportedEncoding​(java.lang.String encoding)
        Checks if the given password encoding is supported.
        Parameters:
        encoding - the password encoding
        Returns:
        true if the given encoding is supported, false otherwise.
        See Also:
        PasswordEncoderConstants.DEFAULT_ENCODING
      • getSupportedEncodings

        java.util.Collection<java.lang.String> getSupportedEncodings()
        Returns:
        a collection with the supported encodings of this system.
      • isValid

        boolean isValid​(UserModel user,
                        java.lang.String plainPassword)
        Checks if the encoded password (stored in the user) matches the given plain text password. For this the plain password will be encoded and compared with the user's encoded password.
        Parameters:
        user - the user contains the encoded password and the (password) encoding
        plainPassword - the plain text password
        Returns:
        true if the encoded passwords matches, false otherwise