eolivelli commented on a change in pull request #3677: PIP-30: interface and 
mutual change authentication
URL: https://github.com/apache/pulsar/pull/3677#discussion_r261581603
 
 

 ##########
 File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
 ##########
 @@ -446,52 +454,128 @@ private String getOriginalPrincipal(String 
originalAuthData, String originalAuth
         return originalPrincipal;
     }
 
+    // complete the connect and sent newConnected command
+    private void completeConnect(int clientProtoVersion, String clientVersion) 
{
+        ctx.writeAndFlush(Commands.newConnected(clientProtoVersion));
+        state = State.Connected;
+        remoteEndpointProtocolVersion = clientProtoVersion;
+        if (isNotBlank(clientVersion) && !clientVersion.contains(" ") /* 
ignore default version: pulsar client */) {
+            this.clientVersion = clientVersion.intern();
+        }
+    }
+
+    // According to auth result, send newConnected or newAuthResponse command.
+    private void doingAuthentication(AuthData clientData,
+                                     int clientProtocolVersion,
+                                     String clientVersion) throws Exception {
+        AuthData brokerData = authState.authenticate(clientData);
+        // authentication has completed, will send newConnected command.
+        if (authState.isComplete()) {
+            authRole = authState.getAuthRole();
+            if (log.isDebugEnabled()) {
+                log.debug("[{}] Client successfully authenticated with {} role 
{} and originalPrincipal {}",
+                    remoteAddress, authMethod, authRole, originalPrincipal);
+            }
+            completeConnect(clientProtocolVersion, clientVersion);
+            return;
+        }
+
+        // auth not complete, continue auth with client side.
+        ctx.writeAndFlush(Commands.newAuthResponse(authMethod, brokerData, 
clientProtocolVersion));
+        if (log.isDebugEnabled()) {
+            log.debug("[{}] Client authenticated with {}  continue auth with 
client.",
+                remoteAddress, authMethod);
+        }
 
 Review comment:
   Is this Connecting or AuthenticationInProgress ?
   I mean, should we choose a better name?

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


With regards,
Apache Git Services

Reply via email to