T
- The type of the token identifier@InterfaceAudience.Public @InterfaceStability.Evolving public abstract class SecretManager<T extends TokenIdentifier> extends Object
Modifier and Type | Class and Description |
---|---|
static class |
SecretManager.InvalidToken
The token was invalid and the message explains why.
|
Constructor and Description |
---|
SecretManager() |
Modifier and Type | Method and Description |
---|---|
void |
checkAvailableForRead()
No-op if the secret manager is available for reading tokens, throw a
StandbyException otherwise.
|
abstract T |
createIdentifier()
Create an empty token identifier.
|
protected static byte[] |
createPassword(byte[] identifier,
SecretKey key)
Compute HMAC of the identifier using the secret key and return the
output as password
|
protected abstract byte[] |
createPassword(T identifier)
Create the password for the given identifier.
|
protected static SecretKey |
createSecretKey(byte[] key)
Convert the byte[] to a secret key
|
protected SecretKey |
generateSecret()
Generate a new random secret key.
|
byte[] |
retriableRetrievePassword(T identifier)
The same functionality with
retrievePassword(T) , except that this
method can throw a RetriableException or a StandbyException
to indicate that client can retry/failover the same operation because of
temporary issue on the server side. |
abstract byte[] |
retrievePassword(T identifier)
Retrieve the password for the given token identifier.
|
protected abstract byte[] createPassword(T identifier)
identifier
- the identifier to usepublic abstract byte[] retrievePassword(T identifier) throws SecretManager.InvalidToken
identifier
- the identifier to validateSecretManager.InvalidToken
- the token was invalidpublic byte[] retriableRetrievePassword(T identifier) throws SecretManager.InvalidToken, StandbyException, RetriableException, IOException
retrievePassword(T)
, except that this
method can throw a RetriableException
or a StandbyException
to indicate that client can retry/failover the same operation because of
temporary issue on the server side.identifier
- the identifier to validateSecretManager.InvalidToken
- the token was invalidStandbyException
- the server is in standby state, the client can
try other serversRetriableException
- the token was invalid, and the server thinks
this may be a temporary issue and suggests the client to retryIOException
- to allow future exceptions to be added without breaking
compatibilitypublic abstract T createIdentifier()
public void checkAvailableForRead() throws StandbyException
StandbyException
- if the secret manager is not available to read
tokensprotected SecretKey generateSecret()
protected static byte[] createPassword(byte[] identifier, SecretKey key)
identifier
- the bytes of the identifierkey
- the secret keyprotected static SecretKey createSecretKey(byte[] key)
key
- the byte[] to create a secret key fromCopyright © 2017 Apache Software Foundation. All Rights Reserved.