Example doAs()
. . .
// Authenticate user & build a Subject wUser . . . // Switch to the authenticated user Subject.doAs(wUser, new PrivilegedAction() { public Object Run(){ // Work to be done as wUser requiring // the addition of the user's privileges return processUserRequest(); } } // end of PrivilegedAction ); |