Top Description Fields Constructors Methods
org.apache.derby.iapi.sql.dictionary

public Class PasswordHasher

extends Object
Class Inheritance
Imports
java.io.UnsupportedEncodingException, java.security.MessageDigest, .NoSuchAlgorithmException, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.util.ArrayUtil, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.util.StringUtil, org.apache.derby.shared.common.reference.SQLState

This machine performs the hashing of Derby passwords.

Field Summary

Modifier and TypeField and Description
private int
private String
private byte[]
private static final String
ENCODING

The encoding to use when converting the credentials to a byte array that can be passed to the hash function in the configurable hash scheme.

public static final String
ID_PATTERN_CONFIGURABLE_HASH_SCHEME

Pattern that is prefixed to the stored password in the configurable hash authentication scheme.

public static final String
ID_PATTERN_CONFIGURABLE_STRETCHED_SCHEME

Pattern that is prefixed to the stored password in the configurable hash authentication scheme if key stretching has been applied.

public static final String
ID_PATTERN_SHA1_SCHEME

Pattern that is prefixed to the stored password in the SHA-1 authentication scheme.

private static final char
SEPARATOR_CHAR

Character that separates the hash value from the name of the hash algorithm in the stored password generated by the configurable hash authentication scheme.

Constructor Summary

AccessConstructor and Description
public
PasswordHasher(String messageDigestAlgorithm, byte[] salt, int iterations)

Construct from pieces.

public
PasswordHasher(String hashingScheme)

Construct from a hashed BUILTIN password stored in the PropertyConglomerate or from a SYSUSERS.HASHINGSCHEME column.

Method Summary

Modifier and TypeMethod and Description
private StandardException
public String
encodeHashingScheme()

Encodes the hashing algorithm in a string suitable for storing in SYSUSERS.HASHINGSCHEME.

private MessageDigest
public String
hashAndEncode(String userName, String password)

Hash a username/password pair and return an encoded representation suitable for storing as a BUILTIN password value in the PropertyConglomerate.

private String
hashAndEncode(String stringDigest)

public String
hashPasswordIntoString(String userName, String password)

Produce a hashed password using a plaintext username and password.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_iterationsback to summary
private int _iterations
_messageDigestAlgorithmback to summary
private String _messageDigestAlgorithm
_saltback to summary
private byte[] _salt
ENCODINGback to summary
private static final String ENCODING

The encoding to use when converting the credentials to a byte array that can be passed to the hash function in the configurable hash scheme.

ID_PATTERN_CONFIGURABLE_HASH_SCHEMEback to summary
public static final String ID_PATTERN_CONFIGURABLE_HASH_SCHEME

Pattern that is prefixed to the stored password in the configurable hash authentication scheme.

ID_PATTERN_CONFIGURABLE_STRETCHED_SCHEMEback to summary
public static final String ID_PATTERN_CONFIGURABLE_STRETCHED_SCHEME

Pattern that is prefixed to the stored password in the configurable hash authentication scheme if key stretching has been applied. This scheme extends the configurable hash scheme by adding a random salt and applying the hash function multiple times when generating the hashed token.

ID_PATTERN_SHA1_SCHEMEback to summary
public static final String ID_PATTERN_SHA1_SCHEME

Pattern that is prefixed to the stored password in the SHA-1 authentication scheme.

SEPARATOR_CHARback to summary
private static final char SEPARATOR_CHAR

Character that separates the hash value from the name of the hash algorithm in the stored password generated by the configurable hash authentication scheme.

Constructor Detail

PasswordHasherback to summary
public PasswordHasher(String messageDigestAlgorithm, byte[] salt, int iterations)

Construct from pieces. Used for databases at rev level 10.6 or later.

PasswordHasherback to summary
public PasswordHasher(String hashingScheme)

Construct from a hashed BUILTIN password stored in the PropertyConglomerate or from a SYSUSERS.HASHINGSCHEME column.

Method Detail

badMessageDigestback to summary
private StandardException badMessageDigest(Throwable t)
encodeHashingSchemeback to summary
public String encodeHashingScheme()

Encodes the hashing algorithm in a string suitable for storing in SYSUSERS.HASHINGSCHEME.

getEmptyMessageDigestback to summary
private MessageDigest getEmptyMessageDigest() throws StandardException
hashAndEncodeback to summary
public String hashAndEncode(String userName, String password) throws StandardException

Hash a username/password pair and return an encoded representation suitable for storing as a BUILTIN password value in the PropertyConglomerate.

hashAndEncodeback to summary
private String hashAndEncode(String stringDigest)
hashPasswordIntoStringback to summary
public String hashPasswordIntoString(String userName, String password) throws StandardException

Produce a hashed password using a plaintext username and password. Turn it into a printable string.