SQLDelegationTokenSecretManager, ZKDelegationTokenSecretManager@Public @Evolving public abstract class AbstractDelegationTokenSecretManager<TokenIdent extends AbstractDelegationTokenIdentifier> extends SecretManager<TokenIdent>
| Modifier and Type | Class | Description |
|---|---|---|
static class |
AbstractDelegationTokenSecretManager.DelegationTokenInformation |
Class to encapsulate a token's renew date and password.
|
SecretManager.InvalidToken| Modifier and Type | Field | Description |
|---|---|---|
protected java.util.Map<java.lang.Integer,DelegationKey> |
allKeys |
Access to allKeys is protected by this object lock
|
protected int |
currentId |
Access to currentId is protected by this object lock.
|
protected java.util.Map<TokenIdent,AbstractDelegationTokenSecretManager.DelegationTokenInformation> |
currentTokens |
Cache of currently valid tokens, mapping from DelegationTokenIdentifier
to DelegationTokenInformation.
|
protected int |
delegationTokenSequenceNumber |
Sequence number to create DelegationTokenIdentifier.
|
protected java.lang.Object |
noInterruptsLock |
If the delegation token update thread holds this lock, it will
not get interrupted.
|
protected boolean |
running |
|
protected boolean |
storeTokenTrackingId |
Whether to store a token's tracking ID in its TokenInformation.
|
protected java.util.Map<java.lang.String,java.lang.Long> |
tokenOwnerStats |
Map of token real owners to its token count.
|
| Constructor | Description |
|---|---|
AbstractDelegationTokenSecretManager(long delegationKeyUpdateInterval,
long delegationTokenMaxLifetime,
long delegationTokenRenewInterval,
long delegationTokenRemoverScanInterval) |
Create a secret manager
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
addKey(DelegationKey key) |
Add a previously used master key to cache (when NN restarts),
should be called before activate().
|
void |
addPersistedDelegationToken(TokenIdent identifier,
long renewDate) |
This method is intended to be used for recovering persisted delegation
tokens.
|
protected void |
addTokenForOwnerStats(TokenIdent id) |
Add token stats to the owner to token count mapping.
|
TokenIdent |
cancelToken(Token<TokenIdent> token,
java.lang.String canceller) |
Cancel a token by removing it from cache.
|
protected AbstractDelegationTokenSecretManager.DelegationTokenInformation |
checkToken(TokenIdent identifier) |
Find the DelegationTokenInformation for the given token id, and verify that
if the token is expired.
|
protected byte[] |
createPassword(TokenIdent identifier) |
Create the password for the given identifier.
|
static javax.crypto.SecretKey |
createSecretKey(byte[] key) |
Convert the byte[] to a secret key
|
TokenIdent |
decodeTokenIdentifier(Token<TokenIdent> token) |
Decode the token identifier.
|
DelegationKey[] |
getAllKeys() |
|
protected java.util.Map<TokenIdent,AbstractDelegationTokenSecretManager.DelegationTokenInformation> |
getCandidateTokensForCleanup() |
|
protected int |
getCurrentKeyId() |
For subclasses externalizing the storage, for example Zookeeper
based implementations.
|
long |
getCurrentTokensSize() |
Total count of active delegation tokens.
|
protected DelegationKey |
getDelegationKey(int keyId) |
For subclasses externalizing the storage, for example Zookeeper
based implementations.
|
protected int |
getDelegationTokenSeqNum() |
For subclasses externalizing the storage, for example Zookeeper
based implementations.
|
protected org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager.DelegationTokenSecretManagerMetrics |
getMetrics() |
|
protected AbstractDelegationTokenSecretManager.DelegationTokenInformation |
getTokenInfo(TokenIdent ident) |
For subclasses externalizing the storage, for example Zookeeper
based implementations
|
protected long |
getTokenRenewInterval() |
Interval for tokens to be renewed.
|
java.lang.String |
getTokenTrackingId(TokenIdent identifier) |
|
java.util.List<Metrics2Util.NameValuePair> |
getTopTokenRealOwners(int n) |
Return top token real owners list as well as the tokens count.
|
protected java.lang.String |
getTrackingIdIfEnabled(TokenIdent ident) |
|
protected int |
incrementCurrentKeyId() |
For subclasses externalizing the storage, for example Zookeeper
based implementations.
|
protected int |
incrementDelegationTokenSeqNum() |
For subclasses externalizing the storage, for example Zookeeper
based implementations.
|
boolean |
isRunning() |
is secretMgr running
|
protected void |
logExpireToken(TokenIdent ident) |
|
protected void |
logExpireTokens(java.util.Collection<TokenIdent> expiredTokens) |
|
protected void |
logUpdateMasterKey(DelegationKey key) |
|
protected void |
removeExpiredStoredToken(TokenIdent ident) |
|
protected void |
removeStoredMasterKey(DelegationKey key) |
|
protected void |
removeStoredToken(TokenIdent ident) |
|
long |
renewToken(Token<TokenIdent> token,
java.lang.String renewer) |
Renew a delegation token.
|
void |
reset() |
Reset all data structures and mutable state.
|
byte[] |
retrievePassword(TokenIdent identifier) |
Retrieve the password for the given token identifier.
|
protected void |
rollMasterKey() |
Update the current master key for generating delegation tokens
It should be called only by tokenRemoverThread.
|
protected void |
setCurrentKeyId(int keyId) |
For subclasses externalizing the storage, for example Zookeeper
based implementations.
|
protected void |
setDelegationTokenSeqNum(int seqNum) |
For subclasses externalizing the storage, for example Zookeeper
based implementations.
|
void |
startThreads() |
should be called before this object is used.
|
void |
stopThreads() |
|
protected void |
storeDelegationKey(DelegationKey key) |
For subclasses externalizing the storage, for example Zookeeper
based implementations.
|
protected void |
storeNewMasterKey(DelegationKey key) |
|
protected void |
storeNewToken(TokenIdent ident,
long renewDate) |
|
protected void |
storeToken(TokenIdent ident,
AbstractDelegationTokenSecretManager.DelegationTokenInformation tokenInfo) |
For subclasses externalizing the storage, for example Zookeeper
based implementations.
|
protected void |
syncTokenOwnerStats() |
This method syncs token information from currentTokens to tokenOwnerStats.
|
protected void |
updateDelegationKey(DelegationKey key) |
For subclasses externalizing the storage, for example Zookeeper
based implementations.
|
protected void |
updateStoredToken(TokenIdent ident,
long renewDate) |
|
protected void |
updateToken(TokenIdent ident,
AbstractDelegationTokenSecretManager.DelegationTokenInformation tokenInfo) |
For subclasses externalizing the storage, for example Zookeeper
based implementations.
|
void |
verifyToken(TokenIdent identifier,
byte[] password) |
Verifies that the given identifier and password are valid and match.
|
checkAvailableForRead, createIdentifier, createPassword, generateSecret, retriableRetrievePasswordprotected java.util.Map<TokenIdent extends AbstractDelegationTokenIdentifier,AbstractDelegationTokenSecretManager.DelegationTokenInformation> currentTokens
protected final java.util.Map<java.lang.String,java.lang.Long> tokenOwnerStats
protected int delegationTokenSequenceNumber
protected final java.util.Map<java.lang.Integer,DelegationKey> allKeys
protected int currentId
protected boolean storeTokenTrackingId
protected volatile boolean running
protected java.lang.Object noInterruptsLock
public AbstractDelegationTokenSecretManager(long delegationKeyUpdateInterval,
long delegationTokenMaxLifetime,
long delegationTokenRenewInterval,
long delegationTokenRemoverScanInterval)
delegationKeyUpdateInterval - the number of milliseconds for rolling
new secret keys.delegationTokenMaxLifetime - the maximum lifetime of the delegation
tokens in millisecondsdelegationTokenRenewInterval - how often the tokens must be renewed
in millisecondsdelegationTokenRemoverScanInterval - how often the tokens are scanned
for expired tokens in millisecondspublic void startThreads()
throws java.io.IOException
java.io.IOException - raised on errors performing I/O.public void reset()
public long getCurrentTokensSize()
protected long getTokenRenewInterval()
public void addKey(DelegationKey key) throws java.io.IOException
key - delegation key.java.io.IOException - raised on errors performing I/O.public DelegationKey[] getAllKeys()
protected void logUpdateMasterKey(DelegationKey key) throws java.io.IOException
java.io.IOExceptionprotected void logExpireToken(TokenIdent ident) throws java.io.IOException
java.io.IOExceptionprotected void storeNewMasterKey(DelegationKey key) throws java.io.IOException
java.io.IOExceptionprotected void removeStoredMasterKey(DelegationKey key)
protected void storeNewToken(TokenIdent ident, long renewDate) throws java.io.IOException
java.io.IOExceptionprotected void removeStoredToken(TokenIdent ident) throws java.io.IOException
java.io.IOExceptionprotected void updateStoredToken(TokenIdent ident, long renewDate) throws java.io.IOException
java.io.IOExceptionprotected int getCurrentKeyId()
protected int incrementCurrentKeyId()
protected void setCurrentKeyId(int keyId)
keyId - keyId.protected int getDelegationTokenSeqNum()
protected int incrementDelegationTokenSeqNum()
protected void setDelegationTokenSeqNum(int seqNum)
seqNum - seqNum.protected DelegationKey getDelegationKey(int keyId)
keyId - keyId.protected void storeDelegationKey(DelegationKey key) throws java.io.IOException
key - DelegationKey.java.io.IOException - raised on errors performing I/O.protected void updateDelegationKey(DelegationKey key) throws java.io.IOException
key - DelegationKey.java.io.IOException - raised on errors performing I/O.protected AbstractDelegationTokenSecretManager.DelegationTokenInformation getTokenInfo(TokenIdent ident)
ident - ident.protected void storeToken(TokenIdent ident, AbstractDelegationTokenSecretManager.DelegationTokenInformation tokenInfo) throws java.io.IOException
ident - ident.tokenInfo - tokenInfo.java.io.IOException - raised on errors performing I/O.protected void updateToken(TokenIdent ident, AbstractDelegationTokenSecretManager.DelegationTokenInformation tokenInfo) throws java.io.IOException
ident - ident.tokenInfo - tokenInfo.java.io.IOException - raised on errors performing I/O.public void addPersistedDelegationToken(TokenIdent identifier, long renewDate) throws java.io.IOException
DelegationKey are
marked as expired and automatically cleaned up.
This method must be called before this secret manager is activated (before
startThreads() is called)identifier - identifier read from persistent storagerenewDate - token renew timejava.io.IOException - raised on errors performing I/O.protected void rollMasterKey()
throws java.io.IOException
java.io.IOException - raised on errors performing I/O.protected byte[] createPassword(TokenIdent identifier)
SecretManagercreatePassword in class SecretManager<TokenIdent extends AbstractDelegationTokenIdentifier>identifier - the identifier to useprotected AbstractDelegationTokenSecretManager.DelegationTokenInformation checkToken(TokenIdent identifier) throws SecretManager.InvalidToken
identifier - identifier.SecretManager.InvalidToken - invalid token exception.public byte[] retrievePassword(TokenIdent identifier) throws SecretManager.InvalidToken
SecretManagerretrievePassword in class SecretManager<TokenIdent extends AbstractDelegationTokenIdentifier>identifier - the identifier to validateSecretManager.InvalidToken - the token was invalidprotected java.lang.String getTrackingIdIfEnabled(TokenIdent ident)
public java.lang.String getTokenTrackingId(TokenIdent identifier)
public void verifyToken(TokenIdent identifier, byte[] password) throws SecretManager.InvalidToken
identifier - Token identifier.password - Password in the token.SecretManager.InvalidToken - InvalidToken.public long renewToken(Token<TokenIdent> token, java.lang.String renewer) throws SecretManager.InvalidToken, java.io.IOException
token - the token to renewrenewer - the full principal name of the user doing the renewalSecretManager.InvalidToken - if the token is invalidAccessControlException - if the user can't renew tokenjava.io.IOExceptionpublic TokenIdent cancelToken(Token<TokenIdent> token, java.lang.String canceller) throws java.io.IOException
token - token.canceller - canceller.SecretManager.InvalidToken - for invalid tokenAccessControlException - if the user isn't allowed to canceljava.io.IOExceptionpublic static javax.crypto.SecretKey createSecretKey(byte[] key)
key - the byte[] to create the secret key fromprotected java.util.Map<TokenIdent,AbstractDelegationTokenSecretManager.DelegationTokenInformation> getCandidateTokensForCleanup()
protected void logExpireTokens(java.util.Collection<TokenIdent> expiredTokens) throws java.io.IOException
java.io.IOExceptionprotected void removeExpiredStoredToken(TokenIdent ident) throws java.io.IOException
java.io.IOExceptionpublic void stopThreads()
public boolean isRunning()
public TokenIdent decodeTokenIdentifier(Token<TokenIdent> token) throws java.io.IOException
token - the token where to extract the identifierjava.io.IOException - raised on errors performing I/O.public java.util.List<Metrics2Util.NameValuePair> getTopTokenRealOwners(int n)
n - top number of usersprotected void addTokenForOwnerStats(TokenIdent id)
id - token id.protected void syncTokenOwnerStats()
protected org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager.DelegationTokenSecretManagerMetrics getMetrics()
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.