ThreadState bindSubject(Command command) {
    if (!securityService.isIntegratedSecurity()) {
      return null;
    }

    if (communicationMode.isWAN()) {
      return null;
    }

    if (command instanceof PutUserCredentials) {
      return null;
    }

    if (isInternalMessage(requestMessage, allowInternalMessagesWithoutCredentials)) {
      return null;
    }

    long uniqueId = getUniqueId();
    String messageType = requestMessage.getMessageType().toString();
    if (uniqueId == 0 || uniqueId == -1) {
      logger.debug("No unique ID yet. {}, {}", messageType, getName());
      return null;
    }

    Subject subject = clientUserAuths.getSubject(uniqueId);
    if (subject == null) {
      secureLogger.warn(
          "Failed to bind the subject of uniqueId {} for message {} with {} : Possible re-authentication required",
          uniqueId, messageType, getName());
      throw new AuthenticationRequiredException("Failed to find the authenticated user.");
    }

    ThreadState threadState = securityService.bindSubject(subject);
    secureLogger.debug("Bound {} with uniqueId {} for message {} with {}", subject.getPrincipal(),
        uniqueId, messageType, getName());

    return threadState;
  }
@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