Interface PasswordEncoder

All Known Implementing Classes:
Md5PasswordEncoder

public interface PasswordEncoder
Interface for performing one-way encryption and authenticity validation on a password.
Since:
7.0.1
Author:
Moran Avigdor
  • Method Summary

    Modifier and Type
    Method
    Description
    Encodes the specified raw password with an implementation specific algorithm.
    boolean
    isPasswordValid(String encPass, String rawPass)
    Validates a specified "raw" password against an encoded password.
  • Method Details

    • encodePassword

      String encodePassword(String rawPass) throws EncodingException
      Encodes the specified raw password with an implementation specific algorithm.

      This will generally be a one-way message digest such as MD5 or SHA, but may also be a plaintext variant which does no encoding at all, but rather returns the same password it was fed. The latter is useful to plug in when the original password must be stored as-is.

      Parameters:
      rawPass - the password to encode
      Returns:
      encoded password
      Throws:
      EncodingException - if couldn't encode the raw password
    • isPasswordValid

      boolean isPasswordValid(String encPass, String rawPass) throws EncodingException
      Validates a specified "raw" password against an encoded password.

      The encoded password should have previously been generated by encodePassword(String) . This method will encode the rawPass, and then compare it with the presented encPass.

      Parameters:
      encPass - a pre-encoded password
      rawPass - a raw password to encode and compare against the pre-encoded password
      Returns:
      true if the password is valid, false otherwise
      Throws:
      EncodingException - if couldn't encode the raw password (see encodePassword(String))