code: private Object setJ2CThreadIdentity(final Subject subj) throws ResourceException {
  
          Object retObject = null;
  
          try {
              if (System.getSecurityManager() != null) {
                  retObject = AccessController.doPrivileged(
                                                            new PrivilegedExceptionAction() {
                                                                @Override
                                                                public Object run() throws Exception {
                                                                    return ThreadIdentityManager.setJ2CThreadIdentity(subj);
                                                                }
                                                            });
              } else {
                  retObject = ThreadIdentityManager.setJ2CThreadIdentity(subj);
              }
          } catch (PrivilegedActionException pae) {
              FFDCFilter.processException(pae, "com.ibm.ejs.j2c.ThreadIdentitySecurityHelper.beforeGettingConnection", "11", this);
              Tr.error(tc, "FAILED_DOPRIVILEGED_J2CA0060", pae);
              Exception e = pae.getException();
              ResourceException re = new ResourceException("ThreadIdentitySecurityHelper.beforeGettingConnection() failed attempting to push the current user identity to the OS Thread");
              re.initCause(e);
              throw re;
          } catch (IllegalStateException ise) {
              FFDCFilter.processException(ise, "com.ibm.ejs.j2c.ThreadIdentitySecurityHelper.beforeGettingConnection", "20", this);
              Object[] parms = new Object[] { "ThreadIdentitySecurityHelper.beforeGettingConnection()", ise };
              Tr.error(tc, "ILLEGAL_STATE_EXCEPTION_J2CA0079", parms);
              ResourceException re = new ResourceException("ThreadIdentitySecurityHelper.beforeGettingConnection() failed attempting to push the current user identity to the OS Thread");
              re.initCause(ise);
              throw re;
          } catch (ThreadIdentityException tie) {
              FFDCFilter.processException(tie, "com.ibm.ejs.j2c.ThreadIdentitySecurityHelper.beforeGettingConnection", "21", this);
              ResourceException re = new ResourceException("ThreadIdentitySecurityHelper.beforeGettingConnection() failed attempting to push the current user identity to the OS Thread");
              re.initCause(tie);
              throw re;
          }
  
          return retObject;
      }
docs: Apply the given subject's identity to the thread.
  
  @return The identity token that must be supplied on the subsequent call to reset
  the thread identity.