joshelser commented on a change in pull request #884: HBASE-23347 Allowable 
custom authentication methods for RPCs
URL: https://github.com/apache/hbase/pull/884#discussion_r359014642
 
 

 ##########
 File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcConnection.java
 ##########
 @@ -81,115 +81,51 @@
   // the last time we were picked up from connection pool.
   protected long lastTouched;
 
+  protected SaslClientAuthenticationProvider provider;
+
   protected RpcConnection(Configuration conf, HashedWheelTimer timeoutTimer, 
ConnectionId remoteId,
       String clusterId, boolean isSecurityEnabled, Codec codec, 
CompressionCodec compressor)
       throws IOException {
     if (remoteId.getAddress().isUnresolved()) {
       throw new UnknownHostException("unknown host: " + 
remoteId.getAddress().getHostName());
     }
+    this.serverAddress = remoteId.getAddress().getAddress();
     this.timeoutTimer = timeoutTimer;
     this.codec = codec;
     this.compressor = compressor;
     this.conf = conf;
 
     UserGroupInformation ticket = remoteId.getTicket().getUGI();
-    SecurityInfo securityInfo = 
SecurityInfo.getInfo(remoteId.getServiceName());
+    this.securityInfo = SecurityInfo.getInfo(remoteId.getServiceName());
     this.useSasl = isSecurityEnabled;
-    Token<? extends TokenIdentifier> token = null;
-    String serverPrincipal = null;
+
+    // Choose the correct Token and AuthenticationProvider for this client to 
use
+    SaslClientAuthenticationProviders providers =
+        SaslClientAuthenticationProviders.getInstance(conf);
+    Pair<SaslClientAuthenticationProvider, Token<? extends TokenIdentifier>> 
pair;
     if (useSasl && securityInfo != null) {
-      AuthenticationProtos.TokenIdentifier.Kind tokenKind = 
securityInfo.getTokenKind();
-      if (tokenKind != null) {
-        TokenSelector<? extends TokenIdentifier> tokenSelector = 
AbstractRpcClient.TOKEN_HANDLERS
-            .get(tokenKind);
-        if (tokenSelector != null) {
-          token = tokenSelector.selectToken(new Text(clusterId), 
ticket.getTokens());
-        } else if (LOG.isDebugEnabled()) {
-          LOG.debug("No token selector found for type " + tokenKind);
-        }
-      }
-      String serverKey = securityInfo.getServerPrincipal();
-      if (serverKey == null) {
-        throw new IOException("Can't obtain server Kerberos config key from 
SecurityInfo");
+      pair = providers.selectProvider(new Text(clusterId), ticket);
+      if (pair == null) {
+        LOG.error("Found no valid authentication method from {} with 
tokens={}",
+            providers.toString(), ticket.getTokens());
+        throw new RuntimeException("Found no valid authentication method from 
options");
 
 Review comment:
   Moved this to trace for the added debug-ability.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to