@VisibleForTesting
  long getUniqueId(Message message, long existingUniqueId) throws Exception {
    byte[] secureBytes = message.getSecureBytes();
    secureBytes = handshake.getEncryptor().decryptBytes(secureBytes);

    // need to decrypt it first then get connectionid
    AuthIds aIds = new AuthIds(secureBytes);

    long connId = aIds.getConnectionId();

    if (connId != connectionId) {
      throw new AuthenticationFailedException("Authentication failed");
    }

    byte[] credBytes = message.getPart(0).getSerializedForm();
    credBytes = handshake.getEncryptor().decryptBytes(credBytes);

    Properties credentials;
    try (ByteArrayDataInput dinp = new ByteArrayDataInput(credBytes)) {
      credentials = DataSerializer.readProperties(dinp);
    }

    // When here, security is enforced on server, if login returns a subject, then it's the newly
    // integrated security, otherwise, do it the old way.
    long uniqueId;
    DistributedSystem system = getDistributedSystem();
    String methodName = system.getProperties().getProperty(SECURITY_CLIENT_AUTHENTICATOR);

    Object principal = Handshake.verifyCredentials(methodName, credentials,
        system.getSecurityProperties(), (InternalLogWriter) system.getLogWriter(),
        (InternalLogWriter) system.getSecurityLogWriter(), proxyId.getDistributedMember(),
        securityService);
    if (principal instanceof Subject) {
      uniqueId = putSubject((Subject) principal, existingUniqueId);
    } else {
      // this sets principal in map as well....
      uniqueId = getUniqueId((Principal) principal);
    }
    return uniqueId;
  }
@return whether this is a connection to a client, regardless of protocol.
geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnection.java