/** * <p> * Sets the JACC contextID using a privileged action and returns the previousID from the {@code PolicyContext}. * </p> * * @param contextID the JACC contextID to be set. * @return the previous contextID as retrieved from the {@code PolicyContext}. */ protected String setContextID(final String contextID) { if (! WildFlySecurityManager.isChecking()) { final String previousID = PolicyContext.getContextID(); PolicyContext.setContextID(contextID); return previousID; } else { final PrivilegedAction<String> action = new SetContextIDAction(contextID); return AccessController.doPrivileged(action); } }
/** * <p> * Sets the JACC contextID using a privileged action and returns the previousID from the {@code PolicyContext}. * </p> * * @param contextID the JACC contextID to be set. * @return the previous contextID as retrieved from the {@code PolicyContext}. */ protected String setContextID(final String contextID) { if(System.getSecurityManager() == null) { final String previousID = PolicyContext.getContextID(); PolicyContext.setContextID(contextID); return previousID; } else { final PrivilegedAction<String> action = new SetContextIDAction(contextID); return AccessController.doPrivileged(action); } }