joshelser commented on a change in pull request #4019:
URL: https://github.com/apache/hbase/pull/4019#discussion_r783341757



##########
File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/security/oauthbearer/internals/OAuthBearerSaslClient.java
##########
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.security.oauthbearer.internals;
+
+import static 
org.apache.hadoop.hbase.security.token.OAuthBearerTokenUtil.OAUTHBEARER_MECHANISM;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Objects;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.sasl.Sasl;
+import javax.security.sasl.SaslClient;
+import javax.security.sasl.SaslClientFactory;
+import javax.security.sasl.SaslException;
+import org.apache.hadoop.hbase.exceptions.IllegalSaslStateException;
+import org.apache.hadoop.hbase.security.auth.AuthenticateCallbackHandler;
+import org.apache.hadoop.hbase.security.oauthbearer.OAuthBearerToken;
+import org.apache.hadoop.hbase.security.oauthbearer.OAuthBearerTokenCallback;
+import org.apache.yetus.audience.InterfaceAudience;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * {@code SaslClient} implementation for SASL/OAUTHBEARER in Kafka. This
+ * implementation requires an instance of {@code AuthenticateCallbackHandler}
+ * that can handle an instance of {@link OAuthBearerTokenCallback} and return
+ * the {@link OAuthBearerToken} generated by the {@code login()} event on the
+ * {@code LoginContext}.
+ *
+ * @see <a href="https://tools.ietf.org/html/rfc6750#section-2.1";>RFC 6750 
Section 2.1</a>
+ *
+ *   This class has been copy-and-pasted from Kafka codebase.
+ */
[email protected]
+public class OAuthBearerSaslClient implements SaslClient {

Review comment:
       >  I need to set "hbase.rpc.protection" to "privacy" which will be 
translated to "auth-conf" QoP in Sasl properties
   
   This has been something I've never fully looked into, but, IIRC, the quality 
of protection (QOP) ultimately defers _back_ to the mechanism in use to give 
that protection. I can't point to any documentation so the easiest thing is to 
try this out.
   
   I had used Wireshark just to listen to the RegionServer traffic on my local 
host when running your standalone tool. 
   
   > I don't think inheriting it would help here.
   
   See the code here.
   
   
https://github.com/apache/hbase/blob/202b17f4fc3229e91d584837776d53ed3e2e8adb/hbase-client/src/main/java/org/apache/hadoop/hbase/security/HBaseSaslRpcClient.java#L192-L295
   
   This is the commons-crypto logic I'm referring to. This wrapping and 
unwrapping will be encrypting the traffic after the SASL handshake is done.
   
   Either way, let me try this out with setting the QOP.
   
   > But where is the negotiation part?
   
   The negotiation is partially happening with the JDK itself and partially 
happening by the Callback implementation's you've written. SASL is just a 
series of challenge/response messages being passed between client and server.




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to