Class PasswordKeyMapper
- java.lang.Object
-
- org.wildfly.security.auth.realm.jdbc.mapper.PasswordKeyMapper
-
- All Implemented Interfaces:
ColumnMapper,KeyMapper
public class PasswordKeyMapper extends Object implements KeyMapper
A
KeyMapperthat knows how to map columns from a SQL query to attributes of specificPasswordtype as defined by the algorithm.- Author:
- Pedro Igor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPasswordKeyMapper.BuilderA builder forPasswordKeyMapperinstances.
-
Field Summary
Fields Modifier and Type Field Description private intalgorithmColumnprivate StringdefaultAlgorithmprivate intdefaultIterationCountprivate inthashColumnprivate EncodinghashEncodingprivate intiterationCountColumnprivate intsaltColumnprivate EncodingsaltEncoding
-
Constructor Summary
Constructors Constructor Description PasswordKeyMapper(PasswordKeyMapper.Builder builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PasswordKeyMapper.Builderbuilder()Construct a builder for password key mappers.private static byte[]decodeColumn(String string, Encoding encoding)intgetAlgorithmColumn()Get the column index of the algorithm name column.private static byte[]getBinaryColumn(ResultSetMetaData metaData, ResultSet resultSet, int column, Encoding encoding)SupportLevelgetCredentialAcquireSupport(Class<? extends Credential> credentialType, String algorithmName, AlgorithmParameterSpec parameterSpec)Determine whether a credential of the given type and algorithm is definitely obtainable, possibly obtainable (for] some identities), or definitely not obtainable.StringgetDefaultAlgorithm()Returns the name of the algorithm being used.intgetDefaultIterationCount()Get the default iteration count.SupportLevelgetEvidenceVerifySupport(Class<? extends Evidence> evidenceType, String algorithmName)Determine whether a given type of evidence is definitely verifiable, possibly verifiable (for some identities), or definitely not verifiable.intgetHashColumn()Returns an integer representing the column index from where the password in its clear, hash or encoded form is obtained.intgetIterationCountColumn()Returns an integer representing the column index from where the iteration count (if supported) is obtained.intgetSaltColumn()Returns an integer representing the column index from where the salt (if supported) is obtained.private static StringgetStringColumn(ResultSetMetaData metaData, ResultSet resultSet, int column)Credentialmap(ResultSet resultSet, Supplier<Provider[]> providers)Maps the givenResultSetto some internal representation.
-
-
-
Field Detail
-
hashColumn
private final int hashColumn
-
saltColumn
private final int saltColumn
-
iterationCountColumn
private final int iterationCountColumn
-
defaultIterationCount
private final int defaultIterationCount
-
algorithmColumn
private final int algorithmColumn
-
defaultAlgorithm
private final String defaultAlgorithm
-
hashEncoding
private final Encoding hashEncoding
-
saltEncoding
private final Encoding saltEncoding
-
-
Constructor Detail
-
PasswordKeyMapper
PasswordKeyMapper(PasswordKeyMapper.Builder builder)
-
-
Method Detail
-
getCredentialAcquireSupport
public SupportLevel getCredentialAcquireSupport(Class<? extends Credential> credentialType, String algorithmName, AlgorithmParameterSpec parameterSpec)
Description copied from interface:KeyMapperDetermine whether a credential of the given type and algorithm is definitely obtainable, possibly obtainable (for] some identities), or definitely not obtainable.- Specified by:
getCredentialAcquireSupportin interfaceKeyMapper- Parameters:
credentialType- the exact credential type (must not benull)algorithmName- the algorithm name, ornullif any algorithm is acceptable or the credential type does not support algorithm namesparameterSpec- the algorithm parameters to match, ornullif any parameters are acceptable or the credential type does not support algorithm parameters- Returns:
- the level of support for this credential
-
getEvidenceVerifySupport
public SupportLevel getEvidenceVerifySupport(Class<? extends Evidence> evidenceType, String algorithmName)
Description copied from interface:KeyMapperDetermine whether a given type of evidence is definitely verifiable, possibly verifiable (for some identities), or definitely not verifiable.- Specified by:
getEvidenceVerifySupportin interfaceKeyMapper- Parameters:
evidenceType- the type of evidence to be verified (must not benull)algorithmName- the algorithm name, ornullif any algorithm is acceptable or the evidence type does not support algorithm names- Returns:
- the level of support for this evidence type
-
getDefaultAlgorithm
public String getDefaultAlgorithm()
Returns the name of the algorithm being used.- Returns:
- the algorithm
-
getHashColumn
public int getHashColumn()
Returns an integer representing the column index from where the password in its clear, hash or encoded form is obtained.- Returns:
- the column index
-
getSaltColumn
public int getSaltColumn()
Returns an integer representing the column index from where the salt (if supported) is obtained.- Returns:
- the column index
-
getIterationCountColumn
public int getIterationCountColumn()
Returns an integer representing the column index from where the iteration count (if supported) is obtained.- Returns:
- the column index
-
getDefaultIterationCount
public int getDefaultIterationCount()
Get the default iteration count. This count is used if there is no iteration count column but the password algorithm uses an iteration count.- Returns:
- the default iteration count
-
getAlgorithmColumn
public int getAlgorithmColumn()
Get the column index of the algorithm name column.- Returns:
- the column index of the algorithm name column, or -1 if there is no algorithm column defined
-
getBinaryColumn
private static byte[] getBinaryColumn(ResultSetMetaData metaData, ResultSet resultSet, int column, Encoding encoding) throws SQLException
- Throws:
SQLException
-
getStringColumn
private static String getStringColumn(ResultSetMetaData metaData, ResultSet resultSet, int column) throws SQLException
- Throws:
SQLException
-
map
public Credential map(ResultSet resultSet, Supplier<Provider[]> providers) throws SQLException
Description copied from interface:ColumnMapperMaps the givenResultSetto some internal representation.- Specified by:
mapin interfaceColumnMapper- Specified by:
mapin interfaceKeyMapper- Parameters:
resultSet- the result set previously created based on a queryproviders- the providers to use if required- Returns:
- the resulting object mapped from the given
ResultSet - Throws:
SQLException- if any error occurs when manipulating the givenResultSet
-
builder
public static PasswordKeyMapper.Builder builder()
Construct a builder for password key mappers.- Returns:
- the new builder (not
null)
-
-