Class DelegationTokenSecretManager
java.lang.Object
org.apache.hadoop.security.token.SecretManager<TokenIdent>
org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager<org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier>
org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager
@Private
public class DelegationTokenSecretManager
extends org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager<org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier>
A HDFS specific delegation token secret manager.
The secret manager is responsible for generating and accepting the password
for each token.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager
org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager.DelegationTokenInformationNested classes/interfaces inherited from class org.apache.hadoop.security.token.SecretManager
org.apache.hadoop.security.token.SecretManager.InvalidToken -
Field Summary
Fields inherited from class org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager
allKeys, currentId, currentTokens, delegationTokenSequenceNumber, noInterruptsLock, running, storeTokenTrackingId, tokenOwnerStats -
Constructor Summary
ConstructorsConstructorDescriptionDelegationTokenSecretManager(long delegationKeyUpdateInterval, long delegationTokenMaxLifetime, long delegationTokenRenewInterval, long delegationTokenRemoverScanInterval, boolean storeTokenTrackingId, FSNamesystem namesystem) Create a secret managerDelegationTokenSecretManager(long delegationKeyUpdateInterval, long delegationTokenMaxLifetime, long delegationTokenRenewInterval, long delegationTokenRemoverScanInterval, FSNamesystem namesystem) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPersistedDelegationToken(org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier identifier, long expiryTime) This method is intended to be used only while reading edit logs.static org.apache.hadoop.security.CredentialscreateCredentials(NameNode namenode, org.apache.hadoop.security.UserGroupInformation ugi, String renewer) A utility method for creating credentials.org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifierintReturns the number of delegation keys currently stored.longgetTokenExpiryTime(org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier dtId) Returns expiry time of a token given its identifier.voidloadSecretManagerState(DelegationTokenSecretManager.SecretManagerState state, StartupProgress.Counter counter) voidLoad SecretManager state from fsimage.protected voidlogExpireToken(org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier dtId) protected voidlogUpdateMasterKey(org.apache.hadoop.security.token.delegation.DelegationKey key) Call namesystem to update editlogs for new master key.byte[]retriableRetrievePassword(org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier identifier) byte[]retrievePassword(org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier identifier) voidsaveSecretManagerStateCompat(DataOutputStream out, String sdPath) Store the current state of the SecretManager for persistencevoidupdatePersistedMasterKey(org.apache.hadoop.security.token.delegation.DelegationKey key) Add a MasterKey to the list of keys.voidupdatePersistedTokenCancellation(org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier identifier) Update the token cache with the cancel record in edit logsvoidupdatePersistedTokenRenewal(org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier identifier, long expiryTime) Update the token cache with renewal record in edit logs.Methods inherited from class org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager
addKey, addTokenForOwnerStats, cancelToken, checkToken, createPassword, createSecretKey, decodeTokenIdentifier, getAllKeys, getCandidateTokensForCleanup, getCurrentKeyId, getCurrentTokensSize, getDelegationKey, getDelegationTokenSeqNum, getMetrics, getTokenInfo, getTokenRenewInterval, getTokenTrackingId, getTopTokenRealOwners, getTrackingIdIfEnabled, incrementCurrentKeyId, incrementDelegationTokenSeqNum, isRunning, logExpireTokens, removeExpiredStoredToken, removeStoredMasterKey, removeStoredToken, renewToken, reset, rollMasterKey, setCurrentKeyId, setDelegationTokenSeqNum, startThreads, stopThreads, storeDelegationKey, storeNewMasterKey, storeNewToken, storeToken, syncTokenOwnerStats, updateDelegationKey, updateStoredToken, updateToken, verifyTokenMethods inherited from class org.apache.hadoop.security.token.SecretManager
checkAvailableForRead, createPassword, generateSecret, update, validateSecretKeyLength
-
Constructor Details
-
DelegationTokenSecretManager
public DelegationTokenSecretManager(long delegationKeyUpdateInterval, long delegationTokenMaxLifetime, long delegationTokenRenewInterval, long delegationTokenRemoverScanInterval, FSNamesystem namesystem) -
DelegationTokenSecretManager
public DelegationTokenSecretManager(long delegationKeyUpdateInterval, long delegationTokenMaxLifetime, long delegationTokenRenewInterval, long delegationTokenRemoverScanInterval, boolean storeTokenTrackingId, FSNamesystem namesystem) Create a secret manager- Parameters:
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 millisecondsstoreTokenTrackingId- whether to store the token's tracking id
-
-
Method Details
-
createIdentifier
public org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier createIdentifier()- Specified by:
createIdentifierin classorg.apache.hadoop.security.token.SecretManager<org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier>
-
retrievePassword
public byte[] retrievePassword(org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier identifier) throws org.apache.hadoop.security.token.SecretManager.InvalidToken - Overrides:
retrievePasswordin classorg.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager<org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier>- Throws:
org.apache.hadoop.security.token.SecretManager.InvalidToken
-
retriableRetrievePassword
public byte[] retriableRetrievePassword(org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier identifier) throws org.apache.hadoop.security.token.SecretManager.InvalidToken, org.apache.hadoop.ipc.StandbyException, org.apache.hadoop.ipc.RetriableException, IOException - Overrides:
retriableRetrievePasswordin classorg.apache.hadoop.security.token.SecretManager<org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier>- Throws:
org.apache.hadoop.security.token.SecretManager.InvalidTokenorg.apache.hadoop.ipc.StandbyExceptionorg.apache.hadoop.ipc.RetriableExceptionIOException
-
getTokenExpiryTime
public long getTokenExpiryTime(org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier dtId) throws IOException Returns expiry time of a token given its identifier.- Parameters:
dtId- DelegationTokenIdentifier of a token- Returns:
- Expiry time of the token
- Throws:
IOException
-
loadSecretManagerStateCompat
Load SecretManager state from fsimage.- Parameters:
in- input stream to read fsimage- Throws:
IOException
-
loadSecretManagerState
public void loadSecretManagerState(DelegationTokenSecretManager.SecretManagerState state, StartupProgress.Counter counter) throws IOException - Throws:
IOException
-
saveSecretManagerStateCompat
Store the current state of the SecretManager for persistence- Parameters:
out- Output stream for writing into fsimage.sdPath- String storage directory path- Throws:
IOException
-
saveSecretManagerState
-
addPersistedDelegationToken
public void addPersistedDelegationToken(org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier identifier, long expiryTime) throws IOException This method is intended to be used only while reading edit logs.- Overrides:
addPersistedDelegationTokenin classorg.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager<org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier>- Parameters:
identifier- DelegationTokenIdentifier read from the edit logs or fsimageexpiryTime- token expiry time- Throws:
IOException
-
updatePersistedMasterKey
public void updatePersistedMasterKey(org.apache.hadoop.security.token.delegation.DelegationKey key) throws IOException Add a MasterKey to the list of keys.- Parameters:
key- DelegationKey- Throws:
IOException
-
updatePersistedTokenRenewal
public void updatePersistedTokenRenewal(org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier identifier, long expiryTime) throws IOException Update the token cache with renewal record in edit logs.- Parameters:
identifier- DelegationTokenIdentifier of the renewed tokenexpiryTime- expirty time in milliseconds- Throws:
IOException
-
updatePersistedTokenCancellation
public void updatePersistedTokenCancellation(org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier identifier) throws IOException Update the token cache with the cancel record in edit logs- Parameters:
identifier- DelegationTokenIdentifier of the canceled token- Throws:
IOException
-
getNumberOfKeys
public int getNumberOfKeys()Returns the number of delegation keys currently stored.- Returns:
- number of delegation keys
-
logUpdateMasterKey
protected void logUpdateMasterKey(org.apache.hadoop.security.token.delegation.DelegationKey key) throws IOException Call namesystem to update editlogs for new master key.- Overrides:
logUpdateMasterKeyin classorg.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager<org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier>- Throws:
IOException
-
logExpireToken
protected void logExpireToken(org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier dtId) throws IOException - Overrides:
logExpireTokenin classorg.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager<org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier>- Throws:
IOException
-
createCredentials
public static org.apache.hadoop.security.Credentials createCredentials(NameNode namenode, org.apache.hadoop.security.UserGroupInformation ugi, String renewer) throws IOException A utility method for creating credentials.- Throws:
IOException
-