@Embeddable public class Secret extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_EXPIRATION_IN_MINUTES |
| Constructor and Description |
|---|
Secret() |
| Modifier and Type | Method and Description |
|---|---|
java.time.Instant |
getExpiration() |
String |
getHash() |
String |
getSalt() |
static boolean |
isValid(String plainText,
Secret secret)
Returns true if the plaintext "attempt" matches the given hash/salt AND the secret is not expired
|
static Secret |
newSecret(String plainText)
Builds a new hashed secret from the plainText string.
|
static Secret |
newSecret(String plainText,
int expirationInMinutes)
Builds a new hashed secret from the plainText string.
|
void |
setExpiration(java.time.Instant expiration) |
void |
setHash(String hash) |
void |
setSalt(String salt) |
public String getHash()
public void setHash(String hash)
public String getSalt()
public void setSalt(String salt)
public java.time.Instant getExpiration()
public void setExpiration(java.time.Instant expiration)
public static Secret newSecret(String plainText, int expirationInMinutes)
plainText - plaintext of the secretexpirationInMinutes - the number of minutes in which this secret should expirepublic static Secret newSecret(String plainText) throws BadRequestException
plainText - A new plaintext secretBadRequestException - if plainText is blankpublic static boolean isValid(String plainText, Secret secret)
plainText - the plaintext attemptsecret - the known fingerprint of the secretCopyright © 2019. All rights reserved.