HDFS-14302. Refactor NameNodeWebHdfsMethods#generateDelegationToken() to allow better extensibility. Contributed by CR Hota.
This commit is contained in:
parent
676a9cb888
commit
f5b4e0f971
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue