@Override
  public ThreadState bindSubject(final Subject subject) {
    if (subject == null) {
      throw new AuthenticationRequiredException("Failed to find the authenticated user.");
    }

    ThreadState threadState = new SubjectThreadState(subject);
    threadState.bind();
    return threadState;
  }
Binds the passed-in subject to the executing thread. Usage:

<pre>
ThreadState state = null;
try {
  state = securityService.bindSubject(subject);
  // do the rest of the work as this subject
} finally {
  if (state != null) {
    state.clear();
  }
}
</pre>
geode-core/src/main/java/org/apache/geode/internal/security/IntegratedSecurityService.java