public final class GenericSecret extends Secret implements AutoCloseable, Destroyable
GenericSecret.destroy()
method called when no longer required.Constructor and Description |
---|
GenericSecret(SecretBuilder builder)
Constructs a generic secret with the given stable identifier and secret data.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Scrubs the secret value from memory on a best-effort basis.
|
void |
destroy() |
boolean |
isDestroyed() |
static GenericSecret |
password(String id,
char[] password,
Clock clock)
A helper utility for constructing a Generic Secret from a password with a default expiry time.
|
<T,E extends Exception> |
reveal(Function<byte[],T,E> function)
Reveals the secret temporarily, allowing it to be used for its intended purpose.
|
<T,E extends Exception> |
revealAndDestroy(Function<byte[],T,E> function)
Reveals the secret temporarily and then scrubs the secret material from memory.
|
<T,E extends Exception> |
revealAsText(Charset charset,
Function<char[],T,E> function)
Reveals the secret temporarily as characters in the given character set.
|
<T,E extends Exception> |
revealAsTextAndDestroy(Charset charset,
Function<char[],T,E> function)
Reveals the secret temporarily as characters in the given character set and then scrubs the secret material
from memory.
|
<T,E extends Exception> |
revealAsUtf8(Function<char[],T,E> function)
Reveals the secret temporarily as characters in UTF-8.
|
<T,E extends Exception> |
revealAsUtf8AndDestroy(Function<char[],T,E> function)
Reveals the secret temporarily as characters in UTF-8 and then scrubs the secret from memory.
|
equals, getExpiryTime, getStableId, hashCode, isExpired, toString
public GenericSecret(SecretBuilder builder) throws NoSuchSecretException
builder
- the secret builder.NoSuchSecretException
- if the secret could not be constructed from the builder.public static GenericSecret password(String id, char[] password, Clock clock)
id
- the stable id of the password.password
- the password.clock
- The clock to use for expiry time.public <T,E extends Exception> T reveal(Function<byte[],T,E> function) throws E extends Exception
GenericSecret.revealAndDestroy(Function)
to also destroy the GenericSecret itself after the
method completes.T
- the type of object returned by the consumer.E
- the type of exceptions thrown by the consumer.function
- the consumer function to reveal the secret to.E
- if the consumer throws.E extends Exception
public <T,E extends Exception> T revealAndDestroy(Function<byte[],T,E> function) throws E extends Exception
GenericSecret.reveal(Function)
.T
- the type of object returned by the consumer.E
- the type of exceptions thrown by the consumer.function
- the consumer function to reveal the secret to.E
- if the consumer throws.E extends Exception
public <T,E extends Exception> T revealAsText(Charset charset, Function<char[],T,E> function) throws E extends Exception
T
- the type of object returned by the consumer.E
- the type of exceptions thrown by the consumer.charset
- the character set to interpret the secret as.function
- the consumer function to reveal the secret to.E
- if the consumer throws.E extends Exception
public <T,E extends Exception> T revealAsTextAndDestroy(Charset charset, Function<char[],T,E> function) throws E extends Exception
GenericSecret.revealAsText(Charset, Function)
.T
- the type of object returned by the consumer.E
- the type of exceptions thrown by the consumer.charset
- the character set to interpret the secret as.function
- the consumer function to reveal the secret to.E
- if the consumer throws.E extends Exception
public <T,E extends Exception> T revealAsUtf8(Function<char[],T,E> function) throws E extends Exception
T
- the type of object returned by the consumer.E
- the type of exceptions thrown by the consumer.function
- the consumer function to reveal the secret to.E
- if the consumer throws.E extends Exception
public <T,E extends Exception> T revealAsUtf8AndDestroy(Function<char[],T,E> function) throws E extends Exception
GenericSecret.revealAsUtf8(Function)
.T
- the type of object returned by the consumer.E
- the type of exceptions thrown by the consumer.function
- the consumer function to reveal the secret to.E
- if the consumer throws.E extends Exception
public void close()
close
in interface AutoCloseable
close
in class Secret
public void destroy()
destroy
in interface Destroyable
public boolean isDestroyed()
isDestroyed
in interface Destroyable
Copyright © 2010-2018, ForgeRock All Rights Reserved.