public abstract class AbstractConfigurablePasswordEncoder extends Object implements ConfigurablePasswordEncoder
ConfigurablePasswordEncoder containing configuration parsing methods.| Modifier and Type | Field and Description |
|---|---|
static String |
KEY_PREFIX
Property key for a prefix to used to prefix encoded values to aid in identifying the type of hash.
|
static String |
KEY_RANDOM
Property key for the SecureRandom class name to use for generating salt.
|
| Constructor and Description |
|---|
AbstractConfigurablePasswordEncoder() |
| Modifier and Type | Method and Description |
|---|---|
void |
configure(Properties parameters,
String prefix)
Configures and initializes the encoder using the given
Properties. |
protected byte[] |
decodeBytes(String encoded)
Decodes the given text using the default text encoder.
|
abstract void |
doConfigure(Properties parameters,
String prefix)
Configures and initializes the encoder using the given Properties.
|
abstract String |
doEncode(CharSequence rawPassword)
Encode the raw password.
|
String |
encode(CharSequence rawPassword)
Encode the raw password.
|
protected String |
encodeBytes(byte[] bytes)
Encodes the given data using the default text encoder.
|
protected Charset |
getCharset() |
protected String |
getPropertyName(String prefix,
String baseName)
Returns the property name for the given prefix and key baseName.
|
protected SecureRandom |
getRandom(Properties parameters,
String prefix)
Returns a static
SecureRandom matching the name configured in the given Properties. |
protected TextEncoder |
getTextEncoder() |
abstract boolean |
isMatch(CharSequence rawPassword,
String encodedPassword)
Verify the encoded password obtained from storage matches the submitted raw password after it too is encoded.
|
boolean |
matches(CharSequence rawPassword,
String encodedPassword)
Verify the encoded password obtained from storage matches the submitted raw
password after it too is encoded.
|
protected boolean |
parseBoolean(Properties parameters,
String prefix,
String key,
boolean defaultValue)
Parses the property value as a boolean from the given parameters.
|
protected <T> T |
parseInstance(String value)
Parses the string as a class name and returns a new instance of that class.
|
protected int |
parseInt(Properties parameters,
String prefix,
String key,
int defaultValue)
Parses the property value as an int from the given parameters.
|
protected Integer |
parseInt(String value)
Parses the given string as an integer.
|
protected String |
parseString(Properties parameters,
String prefix,
String key,
String defaultValue)
Parses the property value from the given parameters.
|
protected byte[] |
toBytes(CharSequence text)
Converts the given
CharSequence to bytes using the default charset. |
public static final String KEY_RANDOM
public static final String KEY_PREFIX
protected SecureRandom getRandom(Properties parameters, String prefix)
SecureRandom matching the name configured in the given Properties.parameters - the configuration parametersprefix - the prefix for the Properties keysSecureRandom matching the name configured in the given Propertiesprotected int parseInt(Properties parameters, String prefix, String key, int defaultValue)
parameters - the Propertiesprefix - the property prefixkey - the property keydefaultValue - the default value if no value is configuredprotected Integer parseInt(String value)
value - the input stringprotected <T> T parseInstance(String value)
T - the returne type of the instancevalue - the name of the classprotected boolean parseBoolean(Properties parameters, String prefix, String key, boolean defaultValue)
parameters - the Propertiesprefix - the property prefixkey - the property keydefaultValue - the default value if no value is configuredprotected String parseString(Properties parameters, String prefix, String key, String defaultValue)
parameters - the Propertiesprefix - the property prefixkey - the property keydefaultValue - the default value if no value is configuredprotected String getPropertyName(String prefix, String baseName)
prefix - the property key prefixbaseName - the property key base name (may be null)protected byte[] toBytes(CharSequence text)
CharSequence to bytes using the default charset.text - the textprotected String encodeBytes(byte[] bytes)
bytes - the dataprotected byte[] decodeBytes(String encoded)
encoded - the encoded textprotected TextEncoder getTextEncoder()
TextEncoder (Base64)public final void configure(Properties parameters, String prefix)
Properties.configure in interface ConfigurablePasswordEncoderparameters - the parametersprefix - the property prefixpublic abstract void doConfigure(Properties parameters, String prefix)
parameters - the parametersprefix - the prefixpublic final String encode(CharSequence rawPassword)
encode in interface PasswordEncoderrawPassword - the raw password to encodepublic final boolean matches(CharSequence rawPassword, String encodedPassword)
matches in interface PasswordEncoderrawPassword - the raw password to encode and matchencodedPassword - the encoded password from storage to compare withpublic abstract String doEncode(CharSequence rawPassword)
rawPassword - the raw password to encodepublic abstract boolean isMatch(CharSequence rawPassword, String encodedPassword)
rawPassword - the raw password to encode and matchencodedPassword - the encoded password from storage to compare with