@Immutable
public class SecretManager
extends java.lang.Object
SecretEntry
s from a SecretRegistry
.
A SecretManager
will store SecretEntry
s in a SecretRegistry
. It will
also return HmacValidator
s corresponding to the SecretEntry
s for validating
hashes (signatures) .
Constructor and Description |
---|
SecretManager(SecretRegistry registry)
Constructs a
SecretManager with the specified SecretRegistry . |
SecretManager(SecretRegistry registry,
com.google.common.cache.Cache<SecretEntry.Key,com.scalar.dl.ledger.crypto.HmacValidator> cacheForKey,
com.google.common.cache.Cache<java.lang.String,com.scalar.dl.ledger.crypto.HmacValidator> cacheForSecret) |
Modifier and Type | Method and Description |
---|---|
com.scalar.dl.ledger.crypto.HmacValidator |
getValidator(SecretEntry.Key key)
Returns a
HmacValidator for the given SecretEntry.Key . |
com.scalar.dl.ledger.crypto.HmacValidator |
getValidator(java.lang.String secretKey)
Returns a
HmacValidator for the given secret. |
void |
register(SecretEntry entry)
Stores the specified
SecretEntry in a SecretRegistry . |
@Inject public SecretManager(SecretRegistry registry)
SecretManager
with the specified SecretRegistry
.registry
- a SecretRegistry
public SecretManager(SecretRegistry registry, com.google.common.cache.Cache<SecretEntry.Key,com.scalar.dl.ledger.crypto.HmacValidator> cacheForKey, com.google.common.cache.Cache<java.lang.String,com.scalar.dl.ledger.crypto.HmacValidator> cacheForSecret)
public void register(SecretEntry entry)
SecretEntry
in a SecretRegistry
. Will throw a DatabaseException
if the secret has already been registered.entry
- a SecretEntry
public com.scalar.dl.ledger.crypto.HmacValidator getValidator(SecretEntry.Key key)
HmacValidator
for the given SecretEntry.Key
.key
- SecretEntry.Key
HmacValidator
public com.scalar.dl.ledger.crypto.HmacValidator getValidator(java.lang.String secretKey)
HmacValidator
for the given secret.secretKey
- secret keyHmacValidator