@Override public DelegationTokenIdentifier createIdentifier() { return new DelegationTokenIdentifier(); }
public String getUserFromToken(String tokenStr) throws IOException { Token<DelegationTokenIdentifier> delegationToken = new Token<DelegationTokenIdentifier>(); delegationToken.decodeFromUrlString(tokenStr); ByteArrayInputStream buf = new ByteArrayInputStream(delegationToken.getIdentifier()); DataInputStream in = new DataInputStream(buf); DelegationTokenIdentifier id = createIdentifier(); id.readFields(in); return id.getUser().getShortUserName(); } }
protected DelegationTokenIdentifier getTokenIdentifier(Token<DelegationTokenIdentifier> token) throws IOException { // turn bytes back into identifier for cache lookup ByteArrayInputStream buf = new ByteArrayInputStream(token.getIdentifier()); DataInputStream in = new DataInputStream(buf); DelegationTokenIdentifier id = createIdentifier(); id.readFields(in); return id; }
/** * Remove expired tokens. Replaces logic in {@link AbstractDelegationTokenSecretManager} * that cannot be reused due to private method access. Logic here can more efficiently * deal with external token store by only loading into memory the minimum data needed. */ protected void removeExpiredTokens() { long now = System.currentTimeMillis(); Iterator<DelegationTokenIdentifier> i = tokenStore.getAllDelegationTokenIdentifiers() .iterator(); while (i.hasNext()) { DelegationTokenIdentifier id = i.next(); if (now > id.getMaxDate()) { this.tokenStore.removeToken(id); // no need to look at token info } else { // get token info to check renew date DelegationTokenInformation tokenInfo = tokenStore.getToken(id); if (tokenInfo != null) { if (now > tokenInfo.getRenewDate()) { this.tokenStore.removeToken(id); } } } } }
@Override public long renewToken(Token<DelegationTokenIdentifier> token, String renewer) throws InvalidToken, IOException { // since renewal is KERBEROS authenticated token may not be cached final DelegationTokenIdentifier id = getTokenIdentifier(token); DelegationTokenInformation tokenInfo = this.tokenStore.getToken(id); if (tokenInfo == null) { throw new InvalidToken("token does not exist: " + id); // no token found } // ensure associated master key is available if (!super.allKeys.containsKey(id.getMasterKeyId())) { LOGGER.info("Unknown master key (id={}), (re)loading keys from token store.", id.getMasterKeyId()); reloadKeys(); } // reuse super renewal logic synchronized (this) { super.currentTokens.put(id, tokenInfo); try { return super.renewToken(token, renewer); } finally { super.currentTokens.remove(id); } } }
protected DelegationTokenIdentifier getTokenIdentifier(Token<DelegationTokenIdentifier> token) throws IOException { // turn bytes back into identifier for cache lookup ByteArrayInputStream buf = new ByteArrayInputStream(token.getIdentifier()); DataInputStream in = new DataInputStream(buf); DelegationTokenIdentifier id = createIdentifier(); id.readFields(in); return id; }
/** * Remove expired tokens. Replaces logic in {@link AbstractDelegationTokenSecretManager} * that cannot be reused due to private method access. Logic here can more efficiently * deal with external token store by only loading into memory the minimum data needed. */ protected void removeExpiredTokens() { long now = System.currentTimeMillis(); Iterator<DelegationTokenIdentifier> i = tokenStore.getAllDelegationTokenIdentifiers() .iterator(); while (i.hasNext()) { DelegationTokenIdentifier id = i.next(); if (now > id.getMaxDate()) { this.tokenStore.removeToken(id); // no need to look at token info } else { // get token info to check renew date DelegationTokenInformation tokenInfo = tokenStore.getToken(id); if (tokenInfo != null) { if (now > tokenInfo.getRenewDate()) { this.tokenStore.removeToken(id); } } } } }
@Override public long renewToken(Token<DelegationTokenIdentifier> token, String renewer) throws InvalidToken, IOException { // since renewal is KERBEROS authenticated token may not be cached final DelegationTokenIdentifier id = getTokenIdentifier(token); DelegationTokenInformation tokenInfo = this.tokenStore.getToken(id); if (tokenInfo == null) { throw new InvalidToken("token does not exist: " + id); // no token found } // ensure associated master key is available if (!super.allKeys.containsKey(id.getMasterKeyId())) { LOGGER.info("Unknown master key (id={}), (re)loading keys from token store.", id.getMasterKeyId()); reloadKeys(); } // reuse super renewal logic synchronized (this) { super.currentTokens.put(id, tokenInfo); try { return super.renewToken(token, renewer); } finally { super.currentTokens.remove(id); } } }
@Override public DelegationTokenIdentifier createIdentifier() { return new DelegationTokenIdentifier(); }
public String getUserFromToken(String tokenStr) throws IOException { Token<DelegationTokenIdentifier> delegationToken = new Token<DelegationTokenIdentifier>(); delegationToken.decodeFromUrlString(tokenStr); ByteArrayInputStream buf = new ByteArrayInputStream(delegationToken.getIdentifier()); DataInputStream in = new DataInputStream(buf); DelegationTokenIdentifier id = createIdentifier(); id.readFields(in); return id.getUser().getShortUserName(); } }
protected DelegationTokenIdentifier getTokenIdentifier(Token<DelegationTokenIdentifier> token) throws IOException { // turn bytes back into identifier for cache lookup ByteArrayInputStream buf = new ByteArrayInputStream(token.getIdentifier()); DataInputStream in = new DataInputStream(buf); DelegationTokenIdentifier id = createIdentifier(); id.readFields(in); return id; }
/** * Remove expired tokens. Replaces logic in {@link AbstractDelegationTokenSecretManager} * that cannot be reused due to private method access. Logic here can more efficiently * deal with external token store by only loading into memory the minimum data needed. */ protected void removeExpiredTokens() { long now = System.currentTimeMillis(); Iterator<DelegationTokenIdentifier> i = tokenStore.getAllDelegationTokenIdentifiers() .iterator(); while (i.hasNext()) { DelegationTokenIdentifier id = i.next(); if (now > id.getMaxDate()) { this.tokenStore.removeToken(id); // no need to look at token info } else { // get token info to check renew date DelegationTokenInformation tokenInfo = tokenStore.getToken(id); if (tokenInfo != null) { if (now > tokenInfo.getRenewDate()) { this.tokenStore.removeToken(id); } } } } }
@Override public long renewToken(Token<DelegationTokenIdentifier> token, String renewer) throws InvalidToken, IOException { // since renewal is KERBEROS authenticated token may not be cached final DelegationTokenIdentifier id = getTokenIdentifier(token); DelegationTokenInformation tokenInfo = this.tokenStore.getToken(id); if (tokenInfo == null) { throw new InvalidToken("token does not exist: " + id); // no token found } // ensure associated master key is available if (!super.allKeys.containsKey(id.getMasterKeyId())) { LOGGER.info("Unknown master key (id={}), (re)loading keys from token store.", id.getMasterKeyId()); reloadKeys(); } // reuse super renewal logic synchronized (this) { super.currentTokens.put(id, tokenInfo); try { return super.renewToken(token, renewer); } finally { super.currentTokens.remove(id); } } }
@Override public DelegationTokenIdentifier createIdentifier() { return new DelegationTokenIdentifier(); }
public String getUserFromToken(String tokenStr) throws IOException { Token<DelegationTokenIdentifier> delegationToken = new Token<DelegationTokenIdentifier>(); delegationToken.decodeFromUrlString(tokenStr); ByteArrayInputStream buf = new ByteArrayInputStream(delegationToken.getIdentifier()); DataInputStream in = new DataInputStream(buf); DelegationTokenIdentifier id = createIdentifier(); id.readFields(in); return id.getUser().getShortUserName(); } }
protected DelegationTokenIdentifier getTokenIdentifier(Token<DelegationTokenIdentifier> token) throws IOException { // turn bytes back into identifier for cache lookup ByteArrayInputStream buf = new ByteArrayInputStream(token.getIdentifier()); DataInputStream in = new DataInputStream(buf); DelegationTokenIdentifier id = createIdentifier(); id.readFields(in); return id; }