|
@@ -120,12 +120,12 @@ extends AbstractDelegationTokenIdentifier>
|
|
|
/**
|
|
|
* Access to currentKey is protected by this object lock
|
|
|
*/
|
|
|
- private volatile DelegationKey currentKey;
|
|
|
+ private DelegationKey currentKey;
|
|
|
|
|
|
- private final long keyUpdateInterval;
|
|
|
- private final long tokenMaxLifetime;
|
|
|
- private final long tokenRemoverScanInterval;
|
|
|
- private final long tokenRenewInterval;
|
|
|
+ private long keyUpdateInterval;
|
|
|
+ private long tokenMaxLifetime;
|
|
|
+ private long tokenRemoverScanInterval;
|
|
|
+ private long tokenRenewInterval;
|
|
|
/**
|
|
|
* Whether to store a token's tracking ID in its TokenInformation.
|
|
|
* Can be overridden by a subclass.
|
|
@@ -491,18 +491,17 @@ extends AbstractDelegationTokenIdentifier>
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- protected byte[] createPassword(TokenIdent identifier) {
|
|
|
+ protected synchronized byte[] createPassword(TokenIdent identifier) {
|
|
|
int sequenceNum;
|
|
|
long now = Time.now();
|
|
|
sequenceNum = incrementDelegationTokenSeqNum();
|
|
|
identifier.setIssueDate(now);
|
|
|
identifier.setMaxDate(now + tokenMaxLifetime);
|
|
|
- DelegationKey delegationCurrentKey = currentKey;
|
|
|
- identifier.setMasterKeyId(delegationCurrentKey.getKeyId());
|
|
|
+ identifier.setMasterKeyId(currentKey.getKeyId());
|
|
|
identifier.setSequenceNumber(sequenceNum);
|
|
|
LOG.info("Creating password for identifier: " + formatTokenId(identifier)
|
|
|
- + ", currentKey: " + delegationCurrentKey.getKeyId());
|
|
|
- byte[] password = createPassword(identifier.getBytes(), delegationCurrentKey.getKey());
|
|
|
+ + ", currentKey: " + currentKey.getKeyId());
|
|
|
+ byte[] password = createPassword(identifier.getBytes(), currentKey.getKey());
|
|
|
DelegationTokenInformation tokenInfo = new DelegationTokenInformation(now
|
|
|
+ tokenRenewInterval, password, getTrackingIdIfEnabled(identifier));
|
|
|
try {
|
|
@@ -527,6 +526,7 @@ extends AbstractDelegationTokenIdentifier>
|
|
|
*/
|
|
|
protected DelegationTokenInformation checkToken(TokenIdent identifier)
|
|
|
throws InvalidToken {
|
|
|
+ assert Thread.holdsLock(this);
|
|
|
DelegationTokenInformation info = getTokenInfo(identifier);
|
|
|
String err;
|
|
|
if (info == null) {
|
|
@@ -546,7 +546,7 @@ extends AbstractDelegationTokenIdentifier>
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public byte[] retrievePassword(TokenIdent identifier)
|
|
|
+ public synchronized byte[] retrievePassword(TokenIdent identifier)
|
|
|
throws InvalidToken {
|
|
|
return checkToken(identifier).getPassword();
|
|
|
}
|
|
@@ -558,7 +558,7 @@ extends AbstractDelegationTokenIdentifier>
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public String getTokenTrackingId(TokenIdent identifier) {
|
|
|
+ public synchronized String getTokenTrackingId(TokenIdent identifier) {
|
|
|
DelegationTokenInformation info = getTokenInfo(identifier);
|
|
|
if (info == null) {
|
|
|
return null;
|
|
@@ -572,7 +572,7 @@ extends AbstractDelegationTokenIdentifier>
|
|
|
* @param password Password in the token.
|
|
|
* @throws InvalidToken InvalidToken.
|
|
|
*/
|
|
|
- public void verifyToken(TokenIdent identifier, byte[] password)
|
|
|
+ public synchronized void verifyToken(TokenIdent identifier, byte[] password)
|
|
|
throws InvalidToken {
|
|
|
byte[] storedPassword = retrievePassword(identifier);
|
|
|
if (!MessageDigest.isEqual(password, storedPassword)) {
|
|
@@ -589,7 +589,7 @@ extends AbstractDelegationTokenIdentifier>
|
|
|
* @throws InvalidToken if the token is invalid
|
|
|
* @throws AccessControlException if the user can't renew token
|
|
|
*/
|
|
|
- public long renewToken(Token<TokenIdent> token,
|
|
|
+ public synchronized long renewToken(Token<TokenIdent> token,
|
|
|
String renewer) throws InvalidToken, IOException {
|
|
|
ByteArrayInputStream buf = new ByteArrayInputStream(token.getIdentifier());
|
|
|
DataInputStream in = new DataInputStream(buf);
|
|
@@ -651,7 +651,7 @@ extends AbstractDelegationTokenIdentifier>
|
|
|
* @throws InvalidToken for invalid token
|
|
|
* @throws AccessControlException if the user isn't allowed to cancel
|
|
|
*/
|
|
|
- public TokenIdent cancelToken(Token<TokenIdent> token,
|
|
|
+ public synchronized TokenIdent cancelToken(Token<TokenIdent> token,
|
|
|
String canceller) throws IOException {
|
|
|
ByteArrayInputStream buf = new ByteArrayInputStream(token.getIdentifier());
|
|
|
DataInputStream in = new DataInputStream(buf);
|