Search in sources :

Example 1 with TGetDelegationTokenResp

use of org.apache.hive.service.rpc.thrift.TGetDelegationTokenResp in project hive by apache.

the class ThriftCLIService method GetDelegationToken.

@Override
public TGetDelegationTokenResp GetDelegationToken(TGetDelegationTokenReq req) throws TException {
    TGetDelegationTokenResp resp = new TGetDelegationTokenResp();
    if (hiveAuthFactory == null || !hiveAuthFactory.isSASLKerberosUser()) {
        resp.setStatus(unsecureTokenErrorStatus());
    } else {
        try {
            String token = cliService.getDelegationToken(new SessionHandle(req.getSessionHandle()), hiveAuthFactory, req.getOwner(), req.getRenewer());
            resp.setDelegationToken(token);
            resp.setStatus(OK_STATUS);
        } catch (HiveSQLException e) {
            LOG.error("Error obtaining delegation token", e);
            TStatus tokenErrorStatus = HiveSQLException.toTStatus(e);
            tokenErrorStatus.setSqlState("42000");
            resp.setStatus(tokenErrorStatus);
        }
    }
    return resp;
}
Also used : HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TStatus(org.apache.hive.service.rpc.thrift.TStatus) TGetDelegationTokenResp(org.apache.hive.service.rpc.thrift.TGetDelegationTokenResp) SessionHandle(org.apache.hive.service.cli.SessionHandle)

Example 2 with TGetDelegationTokenResp

use of org.apache.hive.service.rpc.thrift.TGetDelegationTokenResp in project hive by apache.

the class ThriftCLIServiceClient method getDelegationToken.

@Override
public String getDelegationToken(SessionHandle sessionHandle, HiveAuthFactory authFactory, String owner, String renewer) throws HiveSQLException {
    TGetDelegationTokenReq req = new TGetDelegationTokenReq(sessionHandle.toTSessionHandle(), owner, renewer);
    try {
        TGetDelegationTokenResp tokenResp = cliService.GetDelegationToken(req);
        checkStatus(tokenResp.getStatus());
        return tokenResp.getDelegationToken();
    } catch (Exception e) {
        throw new HiveSQLException(e);
    }
}
Also used : HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TGetDelegationTokenReq(org.apache.hive.service.rpc.thrift.TGetDelegationTokenReq) TGetDelegationTokenResp(org.apache.hive.service.rpc.thrift.TGetDelegationTokenResp) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TException(org.apache.thrift.TException)

Example 3 with TGetDelegationTokenResp

use of org.apache.hive.service.rpc.thrift.TGetDelegationTokenResp in project hive by apache.

the class HiveConnection method getDelegationToken.

public String getDelegationToken(String owner, String renewer) throws SQLException {
    TGetDelegationTokenReq req = new TGetDelegationTokenReq(sessHandle, owner, renewer);
    try {
        TGetDelegationTokenResp tokenResp = client.GetDelegationToken(req);
        Utils.verifySuccess(tokenResp.getStatus());
        return tokenResp.getDelegationToken();
    } catch (TException e) {
        throw new SQLException("Could not retrieve token: " + e.getMessage(), " 08S01", e);
    }
}
Also used : TException(org.apache.thrift.TException) SQLException(java.sql.SQLException) TGetDelegationTokenReq(org.apache.hive.service.rpc.thrift.TGetDelegationTokenReq) TGetDelegationTokenResp(org.apache.hive.service.rpc.thrift.TGetDelegationTokenResp)

Aggregations

TGetDelegationTokenResp (org.apache.hive.service.rpc.thrift.TGetDelegationTokenResp)3 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)2 TGetDelegationTokenReq (org.apache.hive.service.rpc.thrift.TGetDelegationTokenReq)2 TException (org.apache.thrift.TException)2 SQLException (java.sql.SQLException)1 SessionHandle (org.apache.hive.service.cli.SessionHandle)1 TStatus (org.apache.hive.service.rpc.thrift.TStatus)1