Search in sources :

Example 1 with TUGIAssumingTransport

use of org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport in project presto by prestodb.

the class KerberosHiveMetastoreAuthentication method authenticateWithToken.

private TTransport authenticateWithToken(TTransport rawTransport, String tokenString) {
    try {
        Token<DelegationTokenIdentifier> token = new Token<>();
        token.decodeFromUrlString(tokenString);
        TTransport saslTransport = new TSaslClientTransport(TOKEN.getMechanismName(), null, null, SASL_DEFAULT_REALM, SASL_PROPERTIES, new SaslClientCallbackHandler(token), rawTransport);
        return new TUGIAssumingTransport(saslTransport, UserGroupInformation.getCurrentUser());
    } catch (IOException ex) {
        throw new UncheckedIOException(ex);
    }
}
Also used : DelegationTokenIdentifier(org.apache.hadoop.hive.metastore.security.DelegationTokenIdentifier) TUGIAssumingTransport(org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport) Token(org.apache.hadoop.security.token.Token) TSaslClientTransport(org.apache.thrift.transport.TSaslClientTransport) UncheckedIOException(java.io.UncheckedIOException) TTransport(org.apache.thrift.transport.TTransport) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

Example 2 with TUGIAssumingTransport

use of org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport in project presto by prestodb.

the class KerberosHiveMetastoreAuthentication method authenticateWithHost.

private TTransport authenticateWithHost(TTransport rawTransport, String hiveMetastoreHost) {
    try {
        String serverPrincipal = getServerPrincipal(hiveMetastoreServicePrincipal, hiveMetastoreHost);
        String[] names = SaslRpcServer.splitKerberosName(serverPrincipal);
        checkState(names.length == 3, "Kerberos principal name does NOT have the expected hostname part: %s", serverPrincipal);
        Map<String, String> saslProps = ImmutableMap.of(QOP, hdfsWireEncryptionEnabled ? "auth-conf" : "auth", SERVER_AUTH, "true");
        TTransport saslTransport = new TSaslClientTransport(KERBEROS.getMechanismName(), null, names[0], names[1], saslProps, null, rawTransport);
        return new TUGIAssumingTransport(saslTransport, authentication.getUserGroupInformation());
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : TUGIAssumingTransport(org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport) TSaslClientTransport(org.apache.thrift.transport.TSaslClientTransport) UncheckedIOException(java.io.UncheckedIOException) TTransport(org.apache.thrift.transport.TTransport) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

Example 3 with TUGIAssumingTransport

use of org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport in project presto by prestodb.

the class KerberosHiveMetastoreAuthentication method authenticate.

@Override
public TTransport authenticate(TTransport rawTransport, String hiveMetastoreHost) throws TTransportException {
    try {
        String serverPrincipal = getServerPrincipal(hiveMetastoreServicePrincipal, hiveMetastoreHost);
        String[] names = SaslRpcServer.splitKerberosName(serverPrincipal);
        checkState(names.length == 3, "Kerberos principal name does NOT have the expected hostname part: %s", serverPrincipal);
        Map<String, String> saslProps = ImmutableMap.of(Sasl.QOP, "auth", Sasl.SERVER_AUTH, "true");
        TTransport saslTransport = new TSaslClientTransport(KERBEROS.getMechanismName(), null, names[0], names[1], saslProps, null, rawTransport);
        return new TUGIAssumingTransport(saslTransport, authentication.getUserGroupInformation());
    } catch (IOException e) {
        throw Throwables.propagate(e);
    }
}
Also used : TUGIAssumingTransport(org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport) TSaslClientTransport(org.apache.thrift.transport.TSaslClientTransport) TTransport(org.apache.thrift.transport.TTransport) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)3 TUGIAssumingTransport (org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport)3 TSaslClientTransport (org.apache.thrift.transport.TSaslClientTransport)3 TTransport (org.apache.thrift.transport.TTransport)3 UncheckedIOException (java.io.UncheckedIOException)2 DelegationTokenIdentifier (org.apache.hadoop.hive.metastore.security.DelegationTokenIdentifier)1 Token (org.apache.hadoop.security.token.Token)1