Browse Source

[beeswax] Beeswax metastore sasl/kerb. support

Harsh J 12 years ago
parent
commit
74aa11f2cd
1 changed files with 21 additions and 1 deletions
  1. 21 1
      apps/beeswax/java/src/main/java/com/cloudera/beeswax/Server.java

+ 21 - 1
apps/beeswax/java/src/main/java/com/cloudera/beeswax/Server.java

@@ -349,10 +349,30 @@ public class Server {
     Iface handler = new HMSHandler("new db based metaserver");
     FacebookService.Processor processor = new ThriftHiveMetastore.Processor(handler);
 
+    TTransportFactory transFactory;
+
+    if (useKerberos) {
+      final String names[] = SaslRpcServer.splitKerberosName(kerberosName);
+      if (names.length < 2) {
+        throw new IllegalArgumentException(
+            "Kerberos principal should have at least 2 parts: " + kerberosName);
+      }
+
+      TSaslServerTransport.Factory saslFactory =
+          new TSaslServerTransport.Factory(AuthMethod.KERBEROS.getMechanismName(),
+              names[0], names[1] , // two parts of kerberos principal
+              SaslRpcServer.SASL_PROPS,
+              new SaslRpcServer.SaslGssCallbackHandler());
+      transFactory = new KbrSaslTransportFactory(saslFactory, bwUgi);
+    } else {
+      transFactory = new TTransportFactory();
+    }
+
+
     TThreadPoolServer.Args args = new TThreadPoolServer.Args(serverTransport)
         .processor(processor)
         .protocolFactory(new TBinaryProtocol.Factory())
-        .transportFactory(new TTransportFactory());
+        .transportFactory(transFactory);
     TServer server = new TThreadPoolServer(args);
 
     LOG.info("Started new Beeswax Thrift metaserver on port [" + port + "]...");