public class QueryAndEncodeDatabaseAuthenticationHandler extends AbstractJdbcUsernamePasswordAuthenticationHandler
This handler uses the hashing method defined by Apache Shiro's
DefaultHashService
. Refer to the Javadocs
to learn more about the behavior. If the hashing behavior and/or configuration
of private and public salts does nto meet your needs, a extension can be developed
to specify alternative methods of encoding and digestion of the encoded password.
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
algorithmName
The Algorithm name.
|
protected java.lang.String |
disabledFieldName
The Expired field name.
|
protected java.lang.String |
expiredFieldName
The Expired field name.
|
protected long |
numberOfIterations
The number of iterations.
|
protected java.lang.String |
numberOfIterationsFieldName
The Number of iterations field name.
|
protected java.lang.String |
passwordFieldName
The Password field name.
|
protected java.lang.String |
saltFieldName
The Salt field name.
|
protected java.lang.String |
sql
The Sql statement to execute.
|
protected java.lang.String |
staticSalt
Static/private salt to be combined with the dynamic salt retrieved
from the database.
|
passwordPolicyHandlingStrategy
credentialSelectionPredicate, principalFactory, servicesManager
SUCCESSFUL_AUTHENTICATION_HANDLERS
Constructor and Description |
---|
QueryAndEncodeDatabaseAuthenticationHandler(java.lang.String name,
ServicesManager servicesManager,
PrincipalFactory principalFactory,
java.lang.Integer order,
javax.sql.DataSource dataSource,
java.lang.String algorithmName,
java.lang.String sql,
java.lang.String passwordFieldName,
java.lang.String saltFieldName,
java.lang.String expiredFieldName,
java.lang.String disabledFieldName,
java.lang.String numberOfIterationsFieldName,
long numberOfIterations,
java.lang.String staticSalt) |
Modifier and Type | Method and Description |
---|---|
protected AuthenticationHandlerExecutionResult |
authenticateUsernamePasswordInternal(UsernamePasswordCredential transformedCredential,
java.lang.String originalPassword)
Authenticates a username/password credential by an arbitrary strategy with extra parameter original credential password before
encoding password.
|
protected java.lang.String |
digestEncodedPassword(java.lang.String encodedPassword,
java.util.Map<java.lang.String,java.lang.Object> values)
Digest encoded password.
|
getDataSource, getJdbcTemplate, getNamedJdbcTemplate
doAuthentication, matches, supports
authenticate, createHandlerResult, createHandlerResult
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
postAuthenticate, preAuthenticate
getName, getOrder
protected java.lang.String algorithmName
protected java.lang.String sql
protected java.lang.String passwordFieldName
protected java.lang.String saltFieldName
protected java.lang.String expiredFieldName
protected java.lang.String disabledFieldName
protected java.lang.String numberOfIterationsFieldName
protected long numberOfIterations
protected java.lang.String staticSalt
If using this implementation as part of a password hashing strategy, it might be desirable to configure a private salt. A hash and the salt used to compute it are often stored together. If an attacker is ever able to access the hash (e.g. during password cracking) and it has the full salt value, the attacker has all of the input necessary to try to brute-force crack the hash (source + complete salt).
However, if part of the salt is not available to the attacker (because it is not stored with the hash), it is much harder to crack the hash value since the attacker does not have the complete inputs necessary. The privateSalt property exists to satisfy this private-and-not-shared part of the salt.
If you configure this attribute, you can obtain this additional very important safety feature.
public QueryAndEncodeDatabaseAuthenticationHandler(java.lang.String name, ServicesManager servicesManager, PrincipalFactory principalFactory, java.lang.Integer order, javax.sql.DataSource dataSource, java.lang.String algorithmName, java.lang.String sql, java.lang.String passwordFieldName, java.lang.String saltFieldName, java.lang.String expiredFieldName, java.lang.String disabledFieldName, java.lang.String numberOfIterationsFieldName, long numberOfIterations, java.lang.String staticSalt)
protected AuthenticationHandlerExecutionResult authenticateUsernamePasswordInternal(UsernamePasswordCredential transformedCredential, java.lang.String originalPassword) throws java.security.GeneralSecurityException, PreventedException
AbstractUsernamePasswordAuthenticationHandler
authenticateUsernamePasswordInternal
in class AbstractUsernamePasswordAuthenticationHandler
transformedCredential
- the credential object bearing the transformed username and password.originalPassword
- original password from credential before password encodingjava.security.GeneralSecurityException
- On authentication failure.PreventedException
- On the indeterminate case when authentication is prevented.protected java.lang.String digestEncodedPassword(java.lang.String encodedPassword, java.util.Map<java.lang.String,java.lang.Object> values)
encodedPassword
- the encoded passwordvalues
- the values retrieved from database