code: public static <T> T doAs(final boolean inflowed, final SecurityIdentity securityIdentity, final InetAddress remoteAddress, final PrivilegedAction<T> action) {
          final AccessAuditContext previous = contextThreadLocal.get();
          try {
              contextThreadLocal.set(new AccessAuditContext(inflowed, securityIdentity, remoteAddress, previous));
              return securityIdentity != null ? securityIdentity.runAs(action) : action.run();
          } finally {
              contextThreadLocal.set(previous);
          }
      }
docs: Perform work with a new {@code AccessAuditContext} as a particular {@code SecurityIdentity}
  @param inflowed was the identity inflowed from a remote process?
  @param securityIdentity the {@code SecurityIdentity} that the specified {@code action} will run as. May be {@code null}
  @param remoteAddress the remote address of the caller.
  @param action the work to perform. Cannot be {@code null}
  @param <T> the type of teh return value
  @return the value returned by the PrivilegedAction's <code>run</code> method
  
  @exception NullPointerException if the specified
  <code>PrivilegedExceptionAction</code> is
  <code>null</code>.
  
  @exception SecurityException if the caller does not have permission
  to invoke this method.