public class StringDigester extends Object implements com.google.common.base.Function<String,String>
MessageDigest algorithm,
and then returns the output in a specified format: Base64-encoded or hexadecimal with with lower or upper
case characters.| Modifier and Type | Class and Description |
|---|---|
static class |
StringDigester.OutputFormat
The output format determining how the the digested byte[] is converted to the output String.
|
| Modifier and Type | Field and Description |
|---|---|
static Charset |
DEFAULT_INPUT_CHARSET
The default input character set.
|
private String |
digestAlgorithm
The message digest algorithm to use.
|
private Charset |
inputCharset
The Charset instance used in converting the input String to a byte[].
|
private org.slf4j.Logger |
log
Logger.
|
private StringDigester.OutputFormat |
outputFormat
The output format instance used to determine how the digested byte[] is converted to the output String.
|
private boolean |
requireSalt
Whether to require a salt to return any output.
|
private String |
salt
Optional salt to add into the digest.
|
| Constructor and Description |
|---|
StringDigester(String algorithm,
StringDigester.OutputFormat format)
Constructor.
|
StringDigester(String algorithm,
StringDigester.OutputFormat format,
Charset charset)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
String |
apply(String input) |
void |
setRequireSalt(boolean flag)
Set whether to return any data if no salt is set.
|
void |
setSalt(String s)
Set a salt to add to the digest input for obfuscation.
|
@Nonnull public static final Charset DEFAULT_INPUT_CHARSET
@Nonnull private final org.slf4j.Logger log
@Nonnull @NotEmpty private String digestAlgorithm
@Nonnull private StringDigester.OutputFormat outputFormat
@Nonnull private Charset inputCharset
private boolean requireSalt
public StringDigester(@Nonnull@NotEmpty@ParameterName(name="algorithm") String algorithm, @Nonnull@ParameterName(name="format") StringDigester.OutputFormat format) throws NoSuchAlgorithmException
The input character set will be UTF-8.
algorithm - the JCA digest algorithm identifierformat - the output format used to convert the digested[] to the output stringNoSuchAlgorithmException - thrown if the digestAlgorithm is not invalid or unsupportedpublic StringDigester(@Nonnull@NotEmpty@ParameterName(name="algorithm") String algorithm, @Nonnull@ParameterName(name="format") StringDigester.OutputFormat format, @Nullable@ParameterName(name="charset") Charset charset) throws NoSuchAlgorithmException
algorithm - the JCA digest algorithm identifierformat - the output format used to convert the digested[] to the output stringcharset - the character set to use in converting the input string to a byte[] prior to digestingNoSuchAlgorithmException - thrown if the digestAlgorithm is not invalid or unsupportedCopyright © 1999–2019 Shibboleth Consortium. All rights reserved.