TEST_UTIL.startMiniZKCluster(); SecurityInfo.addInfo(AuthenticationProtos.AuthenticationService.getDescriptor().getName(), new SecurityInfo("hbase.test.kerberos.principal", AuthenticationProtos.TokenIdentifier.Kind.HBASE_AUTH_TOKEN));
public final void callMethod( com.google.protobuf.Descriptors.MethodDescriptor method, com.google.protobuf.RpcController controller, com.google.protobuf.Message request, com.google.protobuf.RpcCallback< com.google.protobuf.Message> done) { if (method.getService() != getDescriptor()) { throw new java.lang.IllegalArgumentException( "Service.callMethod() given method descriptor for wrong " + "service type."); } switch(method.getIndex()) { case 0: this.getAuthenticationToken(controller, (org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.GetAuthenticationTokenRequest)request, com.google.protobuf.RpcUtil.<org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.GetAuthenticationTokenResponse>specializeCallback( done)); return; case 1: this.whoAmI(controller, (org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.WhoAmIRequest)request, com.google.protobuf.RpcUtil.<org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.WhoAmIResponse>specializeCallback( done)); return; default: throw new java.lang.AssertionError("Can't get here."); } }
@Test public void test() throws Exception { try (Connection conn = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration()); Table table = conn.getTable(TableName.META_TABLE_NAME)) { CoprocessorRpcChannel rpcChannel = table.coprocessorService(HConstants.EMPTY_START_ROW); AuthenticationProtos.AuthenticationService.BlockingInterface service = AuthenticationProtos.AuthenticationService.newBlockingStub(rpcChannel); WhoAmIResponse response = service.whoAmI(null, WhoAmIRequest.getDefaultInstance()); assertEquals(USERNAME, response.getUsername()); assertEquals(AuthenticationMethod.TOKEN.name(), response.getAuthMethod()); try { service.getAuthenticationToken(null, GetAuthenticationTokenRequest.getDefaultInstance()); } catch (ServiceException e) { IOException ioe = ProtobufUtil.getRemoteException(e); assertThat(ioe, instanceOf(AccessDeniedException.class)); assertThat(ioe.getMessage(), containsString("Token generation only allowed for Kerberos authenticated clients")); } } } }
AuthenticationProtos.AuthenticationService.newReflectiveBlockingService(this); final org.apache.hbase.thirdparty.com.google.protobuf.BlockingService proxy = new org.apache.hbase.thirdparty.com.google.protobuf.BlockingService() {
TEST_UTIL.startMiniZKCluster(); SecurityInfo.addInfo(AuthenticationProtos.AuthenticationService.getDescriptor().getName(), new SecurityInfo("hbase.test.kerberos.principal", AuthenticationProtos.TokenIdentifier.Kind.HBASE_AUTH_TOKEN));
/** * Obtain and return an authentication token for the current user. * @param conn The HBase cluster connection * @return the authentication token instance */ public static Token<AuthenticationTokenIdentifier> obtainToken( Connection conn) throws IOException { Table meta = null; try { meta = conn.getTable(TableName.META_TABLE_NAME); CoprocessorRpcChannel rpcChannel = meta.coprocessorService(HConstants.EMPTY_START_ROW); AuthenticationProtos.AuthenticationService.BlockingInterface service = AuthenticationProtos.AuthenticationService.newBlockingStub(rpcChannel); AuthenticationProtos.GetAuthenticationTokenResponse response = service.getAuthenticationToken(null, AuthenticationProtos.GetAuthenticationTokenRequest.getDefaultInstance()); return ProtobufUtil.toToken(response.getToken()); } catch (ServiceException se) { ProtobufUtil.toIOException(se); } finally { if (meta != null) { meta.close(); } } // dummy return for ServiceException block return null; }
public final void callMethod( com.facebook.presto.hbase.$internal.com.google.protobuf.Descriptors.MethodDescriptor method, com.facebook.presto.hbase.$internal.com.google.protobuf.RpcController controller, com.facebook.presto.hbase.$internal.com.google.protobuf.Message request, com.facebook.presto.hbase.$internal.com.google.protobuf.RpcCallback< com.facebook.presto.hbase.$internal.com.google.protobuf.Message> done) { if (method.getService() != getDescriptor()) { throw new java.lang.IllegalArgumentException( "Service.callMethod() given method descriptor for wrong " + "service type."); } switch(method.getIndex()) { case 0: this.getAuthenticationToken(controller, (org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.GetAuthenticationTokenRequest)request, com.facebook.presto.hbase.$internal.com.google.protobuf.RpcUtil.<org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.GetAuthenticationTokenResponse>specializeCallback( done)); return; case 1: this.whoAmI(controller, (org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.WhoAmIRequest)request, com.facebook.presto.hbase.$internal.com.google.protobuf.RpcUtil.<org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.WhoAmIResponse>specializeCallback( done)); return; default: throw new java.lang.AssertionError("Can't get here."); } }
public final void callMethod( com.google.protobuf.Descriptors.MethodDescriptor method, com.google.protobuf.RpcController controller, com.google.protobuf.Message request, com.google.protobuf.RpcCallback< com.google.protobuf.Message> done) { if (method.getService() != getDescriptor()) { throw new java.lang.IllegalArgumentException( "Service.callMethod() given method descriptor for wrong " + "service type."); } switch(method.getIndex()) { case 0: this.getAuthenticationToken(controller, (org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.GetAuthenticationTokenRequest)request, com.google.protobuf.RpcUtil.<org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.GetAuthenticationTokenResponse>specializeCallback( done)); return; case 1: this.whoAmI(controller, (org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.WhoAmIRequest)request, com.google.protobuf.RpcUtil.<org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.WhoAmIResponse>specializeCallback( done)); return; default: throw new java.lang.AssertionError("Can't get here."); } }
public final void callMethod( com.google.protobuf.Descriptors.MethodDescriptor method, com.google.protobuf.RpcController controller, com.google.protobuf.Message request, com.google.protobuf.RpcCallback< com.google.protobuf.Message> done) { if (method.getService() != getDescriptor()) { throw new java.lang.IllegalArgumentException( "Service.callMethod() given method descriptor for wrong " + "service type."); } switch(method.getIndex()) { case 0: this.getAuthenticationToken(controller, (org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.GetAuthenticationTokenRequest)request, com.google.protobuf.RpcUtil.<org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.GetAuthenticationTokenResponse>specializeCallback( done)); return; case 1: this.whoAmI(controller, (org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.WhoAmIRequest)request, com.google.protobuf.RpcUtil.<org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.WhoAmIResponse>specializeCallback( done)); return; default: throw new java.lang.AssertionError("Can't get here."); } }
public final com.facebook.presto.hbase.$internal.com.google.protobuf.Message callBlockingMethod( com.facebook.presto.hbase.$internal.com.google.protobuf.Descriptors.MethodDescriptor method, com.facebook.presto.hbase.$internal.com.google.protobuf.RpcController controller, com.facebook.presto.hbase.$internal.com.google.protobuf.Message request) throws com.facebook.presto.hbase.$internal.com.google.protobuf.ServiceException { if (method.getService() != getDescriptor()) { throw new java.lang.IllegalArgumentException( "Service.callBlockingMethod() given method descriptor for " + "wrong service type."); } switch(method.getIndex()) { case 0: return impl.getAuthenticationToken(controller, (org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.GetAuthenticationTokenRequest)request); case 1: return impl.whoAmI(controller, (org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.WhoAmIRequest)request); default: throw new java.lang.AssertionError("Can't get here."); } }
public final com.google.protobuf.Message callBlockingMethod( com.google.protobuf.Descriptors.MethodDescriptor method, com.google.protobuf.RpcController controller, com.google.protobuf.Message request) throws com.google.protobuf.ServiceException { if (method.getService() != getDescriptor()) { throw new java.lang.IllegalArgumentException( "Service.callBlockingMethod() given method descriptor for " + "wrong service type."); } switch(method.getIndex()) { case 0: return impl.getAuthenticationToken(controller, (org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.GetAuthenticationTokenRequest)request); case 1: return impl.whoAmI(controller, (org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.WhoAmIRequest)request); default: throw new java.lang.AssertionError("Can't get here."); } }
@Test public void test() throws Exception { try (Connection conn = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration()); Table table = conn.getTable(TableName.META_TABLE_NAME)) { CoprocessorRpcChannel rpcChannel = table.coprocessorService(HConstants.EMPTY_START_ROW); AuthenticationProtos.AuthenticationService.BlockingInterface service = AuthenticationProtos.AuthenticationService.newBlockingStub(rpcChannel); WhoAmIResponse response = service.whoAmI(null, WhoAmIRequest.getDefaultInstance()); assertEquals(USERNAME, response.getUsername()); assertEquals(AuthenticationMethod.TOKEN.name(), response.getAuthMethod()); try { service.getAuthenticationToken(null, GetAuthenticationTokenRequest.getDefaultInstance()); } catch (ServiceException e) { IOException ioe = ProtobufUtil.getRemoteException(e); assertThat(ioe, instanceOf(AccessDeniedException.class)); assertThat(ioe.getMessage(), containsString("Token generation only allowed for Kerberos authenticated clients")); } } } }
public final com.google.protobuf.Message callBlockingMethod( com.google.protobuf.Descriptors.MethodDescriptor method, com.google.protobuf.RpcController controller, com.google.protobuf.Message request) throws com.google.protobuf.ServiceException { if (method.getService() != getDescriptor()) { throw new java.lang.IllegalArgumentException( "Service.callBlockingMethod() given method descriptor for " + "wrong service type."); } switch(method.getIndex()) { case 0: return impl.getAuthenticationToken(controller, (org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.GetAuthenticationTokenRequest)request); case 1: return impl.whoAmI(controller, (org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.WhoAmIRequest)request); default: throw new java.lang.AssertionError("Can't get here."); } }
public final com.facebook.presto.hbase.$internal.com.google.protobuf.Message getResponsePrototype( com.facebook.presto.hbase.$internal.com.google.protobuf.Descriptors.MethodDescriptor method) { if (method.getService() != getDescriptor()) { throw new java.lang.IllegalArgumentException( "Service.getResponsePrototype() given method " + "descriptor for wrong service type."); } switch(method.getIndex()) { case 0: return org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.GetAuthenticationTokenResponse.getDefaultInstance(); case 1: return org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.WhoAmIResponse.getDefaultInstance(); default: throw new java.lang.AssertionError("Can't get here."); } }
public final com.facebook.presto.hbase.$internal.com.google.protobuf.Message getRequestPrototype( com.facebook.presto.hbase.$internal.com.google.protobuf.Descriptors.MethodDescriptor method) { if (method.getService() != getDescriptor()) { throw new java.lang.IllegalArgumentException( "Service.getRequestPrototype() given method " + "descriptor for wrong service type."); } switch(method.getIndex()) { case 0: return org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.GetAuthenticationTokenRequest.getDefaultInstance(); case 1: return org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.WhoAmIRequest.getDefaultInstance(); default: throw new java.lang.AssertionError("Can't get here."); } }
public final com.facebook.presto.hbase.$internal.com.google.protobuf.Message getRequestPrototype( com.facebook.presto.hbase.$internal.com.google.protobuf.Descriptors.MethodDescriptor method) { if (method.getService() != getDescriptor()) { throw new java.lang.IllegalArgumentException( "Service.getRequestPrototype() given method " + "descriptor for wrong service type."); } switch(method.getIndex()) { case 0: return org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.GetAuthenticationTokenRequest.getDefaultInstance(); case 1: return org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.WhoAmIRequest.getDefaultInstance(); default: throw new java.lang.AssertionError("Can't get here."); } }
public final com.google.protobuf.Message getResponsePrototype( com.google.protobuf.Descriptors.MethodDescriptor method) { if (method.getService() != getDescriptor()) { throw new java.lang.IllegalArgumentException( "Service.getResponsePrototype() given method " + "descriptor for wrong service type."); } switch(method.getIndex()) { case 0: return org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.GetAuthenticationTokenResponse.getDefaultInstance(); case 1: return org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.WhoAmIResponse.getDefaultInstance(); default: throw new java.lang.AssertionError("Can't get here."); } }
public final com.google.protobuf.Message getRequestPrototype( com.google.protobuf.Descriptors.MethodDescriptor method) { if (method.getService() != getDescriptor()) { throw new java.lang.IllegalArgumentException( "Service.getRequestPrototype() given method " + "descriptor for wrong service type."); } switch(method.getIndex()) { case 0: return org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.GetAuthenticationTokenRequest.getDefaultInstance(); case 1: return org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.WhoAmIRequest.getDefaultInstance(); default: throw new java.lang.AssertionError("Can't get here."); } }
public final com.facebook.presto.hbase.$internal.com.google.protobuf.Message getResponsePrototype( com.facebook.presto.hbase.$internal.com.google.protobuf.Descriptors.MethodDescriptor method) { if (method.getService() != getDescriptor()) { throw new java.lang.IllegalArgumentException( "Service.getResponsePrototype() given method " + "descriptor for wrong service type."); } switch(method.getIndex()) { case 0: return org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.GetAuthenticationTokenResponse.getDefaultInstance(); case 1: return org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.WhoAmIResponse.getDefaultInstance(); default: throw new java.lang.AssertionError("Can't get here."); } }
public final com.google.protobuf.Message getResponsePrototype( com.google.protobuf.Descriptors.MethodDescriptor method) { if (method.getService() != getDescriptor()) { throw new java.lang.IllegalArgumentException( "Service.getResponsePrototype() given method " + "descriptor for wrong service type."); } switch(method.getIndex()) { case 0: return org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.GetAuthenticationTokenResponse.getDefaultInstance(); case 1: return org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos.WhoAmIResponse.getDefaultInstance(); default: throw new java.lang.AssertionError("Can't get here."); } }