use of org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse in project hadoop by apache.
the class YarnClientImpl method getRMDelegationToken.
@Override
public Token getRMDelegationToken(Text renewer) throws YarnException, IOException {
/* get the token from RM */
GetDelegationTokenRequest rmDTRequest = Records.newRecord(GetDelegationTokenRequest.class);
rmDTRequest.setRenewer(renewer.toString());
GetDelegationTokenResponse response = rmClient.getDelegationToken(rmDTRequest);
return response.getRMDelegationToken();
}
use of org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse in project hadoop by apache.
the class ClientRMService method getDelegationToken.
@Override
public GetDelegationTokenResponse getDelegationToken(GetDelegationTokenRequest request) throws YarnException {
try {
// Verify that the connection is kerberos authenticated
if (!isAllowedDelegationTokenOp()) {
throw new IOException("Delegation Token can be issued only with kerberos authentication");
}
GetDelegationTokenResponse response = recordFactory.newRecordInstance(GetDelegationTokenResponse.class);
UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
Text owner = new Text(ugi.getUserName());
Text realUser = null;
if (ugi.getRealUser() != null) {
realUser = new Text(ugi.getRealUser().getUserName());
}
RMDelegationTokenIdentifier tokenIdentifier = new RMDelegationTokenIdentifier(owner, new Text(request.getRenewer()), realUser);
Token<RMDelegationTokenIdentifier> realRMDTtoken = new Token<RMDelegationTokenIdentifier>(tokenIdentifier, this.rmDTSecretManager);
response.setRMDelegationToken(BuilderUtils.newDelegationToken(realRMDTtoken.getIdentifier(), realRMDTtoken.getKind().toString(), realRMDTtoken.getPassword(), realRMDTtoken.getService().toString()));
return response;
} catch (IOException io) {
throw RPCUtil.getRemoteException(io);
}
}
Aggregations