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