Top Description Methods
javax.security.enterprise.identitystore

public Interface PasswordHash

Known Direct Subinterfaces
javax.security.enterprise.identitystore.Pbkdf2PasswordHash
Imports
java.util.Map

PasswordHash is an interface for objects that can generate and verify password hashes.

Implementations of PasswordHash are configured for the built-in Database IdentityStore by configuring the type on the DatabaseIdentityStoreDefinition annotation. Parameters for the PasswordHash can also be configured on the annotation, and will be passed to the initialize(Map) method when the IdentityStore is initialized.

See Also
DatabaseIdentityStoreDefinition#hashAlgorithm(), DatabaseIdentityStoreDefinition#hashAlgorithmParameters()

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

The generated password hash value.
generate
(char[]
The password to generate a hash for.
password
)

Generate an encoded password hash value for storage in a user's account.

public default void
initialize(Map<String, String>
A Map of the provided parameters, empty if no parameters were supplied.
parameters
)

Initialize the instance with the parameters it should use to generate and verify password hashes.

public boolean

Returns:

True if the password matched the hashed password, false otherwise.
verify
(char[]
The password to verify.
password
,
String
The hashed password to compare against.
hashedPassword
)

Verify a password against the hashed password value retrieved from a user's account.

Method Detail

generateback to summary
public String generate(char[] password)

Generate an encoded password hash value for storage in a user's account.

This method should not be used to generate a password hash for verification purposes; use verify(char[], String) for that purpose. Use this method only to generate password hashes for new or changed passwords.

The returned hash value should be fully encoded, such that it can be directly stored, as is, with no additional formatting or encoding applied.

Parameters
password:char[]

The password to generate a hash for.

Returns:String

The generated password hash value.

initializeback to summary
public default void initialize(Map<String, String> parameters)

Initialize the instance with the parameters it should use to generate and verify password hashes. The parameters are the name/value pairs specified with the DatabaseIdentityStoreDefinition#hashAlgorithmParameters() attribute.

An implementation is not required to support parameters, and may ignore parameters passed to it. It is also possible that an implementation will use the specified parameters when generating a new password hash, but ignore them in favor of parameters stored with an existing password hash when verifying.

If no parameters were supplied, the argument is an empty Map.

Parameters
parameters:Map<String, String>

A Map of the provided parameters, empty if no parameters were supplied.

verifyback to summary
public boolean verify(char[] password, String hashedPassword)

Verify a password against the hashed password value retrieved from a user's account.

The hashedPassword parameter should be provided exactly as retrieved from the database, with no decoding or formatting applied. The password parameter should be hashed and compared to the hashed password.

Parameters
password:char[]

The password to verify.

hashedPassword:String

The hashed password to compare against.

Returns:boolean

True if the password matched the hashed password, false otherwise.