code: public static Object doAs(Subject subject, java.security.PrivilegedAction action, boolean setCaller) {
          SecurityManager securitymanager = System.getSecurityManager();
          if (securitymanager != null) {
              securitymanager.checkPermission(DOAS_PERM);
          }
          if (action == null) {
              throw new IllegalArgumentException("null PrivilegedAction provided");
          }
          Subject callerSubject = null;
          SubjectCookie invocationCookie = setInvocationSubject(subject);
          if (setCaller) {
              callerSubject = setCallerSubject(subject);
          }
          try {
              return Subject.doAs(subject, action);
          } catch (Throwable t) {
              if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                  Tr.debug(tc, "WSSubject.doAs(Subject, PrivilegedAction) Exception caught: " + t);
              throw new RuntimeException(t); //$A13
          } finally {
              restoreInvocationSubject(invocationCookie);
              if (setCaller) {
                  restoreCallerSubject(callerSubject);
              }
          }
      }
docs: <p><code>doAs</code> wraps the Subject.doAs to provide the correct
  inter-EJB invocation behavior.
  </p>
  
  <p>
  Please note, if a <code>null</code> Subject is passed in or the Subject does not contain an
  instance of <code>com.ibm.websphere.security.cred.WSCredential</code> then an Unauthenticated
  subject is set as the Invocation subject.
  If setCaller argument is true, the "caller" subject is set with the given subject argument.
  </p>
  
  @return An <code>java.lang.Object</code>.
  @exception SecurityException
  Thrown if there is no doAs and other required permissions.