Class AbstractJAASPasswordEncoder
- java.lang.Object
-
- org.apache.archiva.redback.policy.encoders.AbstractJAASPasswordEncoder
-
- All Implemented Interfaces:
PasswordEncoder
- Direct Known Subclasses:
SHA1PasswordEncoder,SHA256PasswordEncoder
public class AbstractJAASPasswordEncoder extends Object implements PasswordEncoder
Abstract Password Encoder that uses theMessageDigestfrom JAAS.- Author:
- Joakim Erdfelt
-
-
Constructor Summary
Constructors Constructor Description AbstractJAASPasswordEncoder(String algorithm)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringencodePassword(String rawPass)Encodes the specified raw password with an implementation specific algorithm, using the system wide salt.StringencodePassword(String rawPass, Object salt)Encodes the specified raw password with an implementation specific algorithm, using user specific salt.booleanisPasswordValid(String encPass, String rawPass)Validates a specified "raw" password against an encoded password, using the system wide salt.booleanisPasswordValid(String encPass, String rawPass, Object salt)Validates a specified "raw" password against an encoded password, using a user specific salt.voidsetSystemSalt(Object salt)Sets the system wide salt to use in the encoder.
-
-
-
Constructor Detail
-
AbstractJAASPasswordEncoder
public AbstractJAASPasswordEncoder(String algorithm)
-
-
Method Detail
-
setSystemSalt
public void setSystemSalt(Object salt)
Description copied from interface:PasswordEncoderSets the system wide salt to use in the encoder.
The specified salt will potentially be used by the implementation to "salt" the initial value before encoding. A salt is usually a user-specific value which is added to the password before the digest is computed. This means that computation of digests for common dictionary words will be different than those in the backend store, because the dictionary word digests will not reflect the addition of the salt. If a per-user salt is used (rather than a system-wide salt), it also means users with the same password will have different digest encoded passwords in the backend store.
- Specified by:
setSystemSaltin interfacePasswordEncoder- Parameters:
salt- the salt to use as a default for the encoder.
-
encodePassword
public String encodePassword(String rawPass, Object salt)
Description copied from interface:PasswordEncoderEncodes the specified raw password with an implementation specific algorithm, using user specific salt.
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.
The specified salt will potentially be used by the implementation to "salt" the initial value before encoding. A salt is usually a user-specific value which is added to the password before the digest is computed. This means that computation of digests for common dictionary words will be different than those in the backend store, because the dictionary word digests will not reflect the addition of the salt. If a per-user salt is used (rather than a system-wide salt), it also means users with the same password will have different digest encoded passwords in the backend store.
- Specified by:
encodePasswordin interfacePasswordEncoder- Parameters:
rawPass- the password to encodesalt- optionally used by the implementation to "salt" the raw password before encoding. Anullvalue is legal.- Returns:
- encoded password
-
isPasswordValid
public boolean isPasswordValid(String encPass, String rawPass, Object salt)
Description copied from interface:PasswordEncoderValidates a specified "raw" password against an encoded password, using a user specific salt.
The encoded password should have previously been generated by
PasswordEncoder.encodePassword(String, Object). This method will encode therawPass(using the optionalsalt), and then compared it with the presentedencPass.For a discussion of salts, please refer to
PasswordEncoder.encodePassword(String, Object).- Specified by:
isPasswordValidin interfacePasswordEncoder- Parameters:
encPass- a pre-encoded passwordrawPass- a raw password to encode and compare against the pre-encoded passwordsalt- optionally used by the implementation to "salt" the raw password before encoding. Anullvalue is legal.- Returns:
- true if the password is valid , false otherwise
-
encodePassword
public String encodePassword(String rawPass)
Description copied from interface:PasswordEncoderEncodes the specified raw password with an implementation specific algorithm, using the system wide salt.
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.
- Specified by:
encodePasswordin interfacePasswordEncoder- Parameters:
rawPass- the password to encode- Returns:
- encoded password
-
isPasswordValid
public boolean isPasswordValid(String encPass, String rawPass)
Description copied from interface:PasswordEncoderValidates a specified "raw" password against an encoded password, using the system wide salt.
The encoded password should have previously been generated by
PasswordEncoder.encodePassword(String). This method will encode therawPass(using the system widesalt), and then compared it with the presentedencPass.For an explanation of salts, please refer to
PasswordEncoder.setSystemSalt(Object).- Specified by:
isPasswordValidin interfacePasswordEncoder- Parameters:
encPass- a pre-encoded passwordrawPass- a raw password to encode and compare against the pre-encoded password- Returns:
- true if the password is valid , false otherwise
-
-