DefaultPasswordService

Default implementation of the {@link PasswordService} interface that relies on an internal {@link HashService}, {@link HashFormat}, and {@link HashFormatFactory} to function: <h2>Hashing Passwords</h2>

<h2>Comparing Passwords</h2> All hashing operations are performed by the internal {@link #getHashService() hashService}. After the hash is computed, it is formatted into a string value via the internal {@link #getHashFormat() hashFormat}.

Constructors

this
this()
Undocumented in source.

Members

Functions

buildHashRequest
HashRequest buildHashRequest(ByteSource plaintext, Hash saved)
Undocumented in source. Be warned that the author may not have intended to support it.
checkHashFormatDurability
void checkHashFormatDurability()
Undocumented in source. Be warned that the author may not have intended to support it.
createByteSource
ByteSource createByteSource(Object o)
Undocumented in source. Be warned that the author may not have intended to support it.
createHashRequest
HashRequest createHashRequest(ByteSource plaintext)
Undocumented in source. Be warned that the author may not have intended to support it.
encryptPassword
string encryptPassword(Object plaintext)
Undocumented in source. Be warned that the author may not have intended to support it.
getHashFormat
HashFormat getHashFormat()
Undocumented in source. Be warned that the author may not have intended to support it.
getHashFormatFactory
HashFormatFactory getHashFormatFactory()
Undocumented in source. Be warned that the author may not have intended to support it.
getHashService
HashService getHashService()
Undocumented in source. Be warned that the author may not have intended to support it.
hashPassword
Hash hashPassword(Object plaintext)
Undocumented in source. Be warned that the author may not have intended to support it.
passwordsMatch
bool passwordsMatch(Object plaintext, Hash saved)
Undocumented in source. Be warned that the author may not have intended to support it.
passwordsMatch
bool passwordsMatch(Object submittedPlaintext, string saved)
Undocumented in source. Be warned that the author may not have intended to support it.
setHashFormat
void setHashFormat(HashFormat hashFormat)
Undocumented in source. Be warned that the author may not have intended to support it.
setHashFormatFactory
void setHashFormatFactory(HashFormatFactory hashFormatFactory)
Undocumented in source. Be warned that the author may not have intended to support it.
setHashService
void setHashService(HashService hashService)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

DEFAULT_HASH_ALGORITHM
enum string DEFAULT_HASH_ALGORITHM;
Undocumented in source.
DEFAULT_HASH_ITERATIONS
enum int DEFAULT_HASH_ITERATIONS;
Undocumented in source.

Inherited Members

From HashingPasswordService

hashPassword
Hash hashPassword(Object plaintext)

Hashes the specified plaintext password using internal hashing configuration settings pertinent to password hashing. <p/> Note that this method is only likely to be used in more complex environments that wish to format and/or save the returned {@code Hash} object in a custom manner. Most applications will find the {@link #encryptPassword(Object) encryptPassword} method suitable enough for safety and ease-of-use. <h3>Usage</h3> The input argument type can be any 'byte backed' {@code Object} - almost always either a string or character array representing passwords (character arrays are often a safer way to represent passwords as they can be cleared/nulled-out after use. Any argument type supported by {@link ByteSourceUtil#isCompatible(Object)} is valid. <p/> Regardless of your choice of using Strings or character arrays to represent submitted passwords, you can wrap either as a {@code ByteSource} by using {@link ByteSourceUtil}, for example, when the passwords are captured as Strings: <pre> ByteSource passwordBytes = ByteSourceUtil.bytes(submittedPasswordString); Hash hashedPassword = hashingPasswordService.hashPassword(passwordBytes); </pre> or, identically, when captured as a character array: <pre> ByteSource passwordBytes = ByteSourceUtil.bytes(submittedPasswordCharacterArray); Hash hashedPassword = hashingPasswordService.hashPassword(passwordBytes); </pre>

passwordsMatch
bool passwordsMatch(Object plaintext, Hash savedPasswordHash)

Returns {@code true} if the {@code submittedPlaintext} password matches the existing {@code savedPasswordHash}, {@code false} otherwise. Note that this method is only likely to be used in more complex environments that save hashes in a custom manner. Most applications will find the {@link #passwordsMatch(Object, string) passwordsMatch(plaintext,string)} method sufficient if {@link #encryptPassword(Object) encrypting passwords as Strings}. <h3>Usage</h3> The {@code submittedPlaintext} argument type can be any 'byte backed' {@code Object} - almost always either a string or character array representing passwords (character arrays are often a safer way to represent passwords as they can be cleared/nulled-out after use. Any argument type supported by {@link ByteSourceUtil#isCompatible(Object)} is valid.

Meta