HDFS-14302. Refactor NameNodeWebHdfsMethods#generateDelegationToken() to allow better extensibility. Contributed by CR Hota.

This commit is contained in:
Inigo Goiri 2019-02-20 13:55:13 -08:00
parent 676a9cb888
commit f5b4e0f971

View File

@ -350,12 +350,18 @@ public void cancelDelegationToken(Token<DelegationTokenIdentifier> token)
cp.cancelDelegationToken(token);
}
public Token<? extends TokenIdentifier> generateDelegationToken(
final UserGroupInformation ugi,
public Credentials createCredentials(final UserGroupInformation ugi,
final String renewer) throws IOException {
final NameNode namenode = (NameNode)context.getAttribute("name.node");
final Credentials c = DelegationTokenSecretManager.createCredentials(
namenode, ugi, renewer != null? renewer: ugi.getShortUserName());
return c;
}
public Token<? extends TokenIdentifier> generateDelegationToken(
final UserGroupInformation ugi,
final String renewer) throws IOException {
Credentials c = createCredentials(ugi, renewer);
if (c == null) {
return null;
}