dschneider-pivotal commented on a change in pull request #6835:
URL: https://github.com/apache/geode/pull/6835#discussion_r707799598



##########
File path: 
geode-core/src/main/java/org/apache/geode/cache/client/internal/AuthenticateUserOp.java
##########
@@ -123,39 +119,61 @@ private AuthenticateUserOp() {
       super(MessageType.USER_CREDENTIAL_MESSAGE, 1);
       securityProperties = securityProps;
       needsServerLocation = needsServer;
-
       getMessage().setMessageHasSecurePartFlag();
     }
 
     @Override
     protected void sendMessage(Connection cnx) throws Exception {
-      HeapDataOutputStream hdos = new 
HeapDataOutputStream(KnownVersion.CURRENT);
-      byte[] secureBytes;
-      hdos.writeLong(cnx.getConnectionID());
-      if (securityProperties != null) {
-        DistributedMember server = new 
InternalDistributedMember(cnx.getSocket().getInetAddress(),
-            cnx.getSocket().getPort(), false);
-        DistributedSystem sys = 
InternalDistributedSystem.getConnectedInstance();
-        String authInitMethod = 
sys.getProperties().getProperty(SECURITY_CLIENT_AUTH_INIT);
-
-        Properties credentials = Handshake.getCredentials(authInitMethod, 
securityProperties,
-            server, false, sys.getLogWriter(), sys.getSecurityLogWriter());
-        byte[] credentialBytes;
-        try (HeapDataOutputStream heapdos = new 
HeapDataOutputStream(KnownVersion.CURRENT)) {
-          DataSerializer.writeProperties(credentials, heapdos);
-          credentialBytes = ((ConnectionImpl) 
cnx).encryptBytes(heapdos.toByteArray());
-        }
-        getMessage().addBytesPart(credentialBytes);
+      if (securityProperties == null) {
+        securityProperties = getConnectedSystem().getSecurityProperties();
       }
-      try {
-        secureBytes = ((ConnectionImpl) cnx).encryptBytes(hdos.toByteArray());
-      } finally {
-        hdos.close();
+      byte[] credentialBytes = getCredentialBytes(cnx, securityProperties);
+      getMessage().addBytesPart(credentialBytes);
+
+      long userId = getUserId(cnx);
+      try (HeapDataOutputStream hdos = new 
HeapDataOutputStream(KnownVersion.CURRENT)) {
+        hdos.writeLong(cnx.getConnectionID());
+        hdos.writeLong(userId);

Review comment:
       You declare "long userId" right before the try block that uses it. You 
could narrow the scope of this variable by declaring and initializing it inside 
the try block. I was not suggesting you get rid of the getUserId method
   but you could in this code just have "hdos.writeLong(getUserId(connection));"




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