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
1 changed files with 8 additions and 2 deletions

View File

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