Search in sources :

Example 6 with GetDelegationTokenResponse

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();
}
Also used : GetDelegationTokenRequest(org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenRequest) GetDelegationTokenResponse(org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse)

Example 7 with GetDelegationTokenResponse

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);
    }
}
Also used : GetDelegationTokenResponse(org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse) Text(org.apache.hadoop.io.Text) Token(org.apache.hadoop.security.token.Token) IOException(java.io.IOException) RMDelegationTokenIdentifier(org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Aggregations

GetDelegationTokenResponse (org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse)7 GetDelegationTokenRequest (org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenRequest)6 RMDelegationTokenIdentifier (org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier)5 Test (org.junit.Test)4 IOException (java.io.IOException)3 Text (org.apache.hadoop.io.Text)3 Token (org.apache.hadoop.security.token.Token)3 MemoryRMStateStore (org.apache.hadoop.yarn.server.resourcemanager.recovery.MemoryRMStateStore)3 Configuration (org.apache.hadoop.conf.Configuration)2 Credentials (org.apache.hadoop.security.Credentials)2 DelegationKey (org.apache.hadoop.security.token.delegation.DelegationKey)2 ApplicationAccessType (org.apache.hadoop.yarn.api.records.ApplicationAccessType)2 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)2 RMState (org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.RMState)2 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)2 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 AccessControlException (java.security.AccessControlException)1 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1 ParseException (java.text.ParseException)1 HashSet (java.util.HashSet)1