Package net.shibboleth.shared.codec
Class StringDigester
java.lang.Object
net.shibboleth.shared.codec.StringDigester
- Direct Known Subclasses:
StringDigester
A function which accepts a String input, digests it according to a specified
MessageDigest algorithm,
and then returns the output in a specified format: Base32/64-encoded or hexadecimal with with lower or upper
case characters.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe output format determining how the the digested byte[] is converted to the output String. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CharsetThe default input character set.private StringThe message digest algorithm to use.private CharsetThe Charset instance used in converting the input String to a byte[].private final org.slf4j.LoggerLogger.private StringDigester.OutputFormatThe output format instance used to determine how the digested byte[] is converted to the output String.private booleanWhether to require a salt to return any output.private StringOptional salt to add into the digest. -
Constructor Summary
ConstructorsConstructorDescriptionStringDigester(String algorithm, StringDigester.OutputFormat format) Constructor.StringDigester(String algorithm, StringDigester.OutputFormat format, Charset charset) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate StringencodeOutput(byte[] digestedBytes) Apply the output encoding.voidsetRequireSalt(boolean flag) Set whether to return any data if no salt is set.voidSet a salt to add to the digest input for obfuscation.
-
Field Details
-
DEFAULT_INPUT_CHARSET
The default input character set. -
log
@Nonnull private final org.slf4j.Logger logLogger. -
digestAlgorithm
The message digest algorithm to use. -
outputFormat
The output format instance used to determine how the digested byte[] is converted to the output String. -
inputCharset
The Charset instance used in converting the input String to a byte[]. -
salt
Optional salt to add into the digest. -
requireSalt
private boolean requireSaltWhether to require a salt to return any output.
-
-
Constructor Details
-
Method Details
-
setSalt
Set a salt to add to the digest input for obfuscation.- Parameters:
s- salt value
-
setRequireSalt
public void setRequireSalt(boolean flag) Set whether to return any data if no salt is set.- Parameters:
flag- flag to set
-
apply
-
encodeOutput
Apply the output encoding.- Parameters:
digestedBytes- input to encoding- Returns:
- encoded string or null if the format is unknown
-