Refine search
private static <T> T doPrivileged(PrivilegedAction<T> action) { if (System.getSecurityManager() != null) { return AccessController.doPrivileged(action); } else { return action.run(); } }
public static Charset defaultCharset() { synchronized (Charset.class) { if (defaultCharset == null) { java.security.PrivilegedAction pa = new GetPropertyAction("file.encoding"); String csn = (String)AccessController.doPrivileged(pa); Charset cs = lookup(csn); if (cs != null) return cs; return forName("UTF-8"); } return defaultCharset; } }
/** * Calls {@code action.run()}. */ public static <T> T doPrivileged(PrivilegedAction<T> action, AccessControlContext context) { return action.run(); }
/** * Calls {@code action.run()}. */ public static <T> T doPrivileged(PrivilegedAction<T> action) { return action.run(); }
private <P> P run(PrivilegedAction<P> action) { return System.getSecurityManager() != null ? AccessController.doPrivileged( action ) : action.run(); } }
public static Charset defaultCharset() { if (defaultCharset == null) { synchronized (Charset.class) { java.security.PrivilegedAction pa = new GetPropertyAction("file.encoding"); String csn = (String)AccessController.doPrivileged(pa); Charset cs = lookup(csn); if (cs != null) defaultCharset = cs; else defaultCharset = forName("UTF-8"); } } return defaultCharset; }
/** * Calls {@code action.run()}. */ public static <T> T doPrivilegedWithCombiner(PrivilegedAction<T> action) { return action.run(); }
/** * Gets the current Thread ClassLoader. Returns the system ClassLoader if the TCCL is {@code null}. If the system * ClassLoader is {@code null} as well, then the ClassLoader for this class is returned. If running with a * {@link SecurityManager} that does not allow access to the Thread ClassLoader or system ClassLoader, then the * ClassLoader for this class is returned. * * @return the current ThreadContextClassLoader. */ public static ClassLoader getThreadContextClassLoader() { if (GET_CLASS_LOADER_DISABLED) { // we can at least get this class's ClassLoader regardless of security context // however, if this is null, there's really no option left at this point return LoaderUtil.class.getClassLoader(); } return SECURITY_MANAGER == null ? TCCL_GETTER.run() : AccessController.doPrivileged(TCCL_GETTER); }
@Override public <T> T execute(PrivilegedAction<T> action) { return action.run(); }
private static Method doPrivilegedAction(PrivilegedAction<Method> privilegedAction) { Class<?> callerClass = getCallerClass(); if ( !authorizedClasses.contains( callerClass.getName() ) ) { throw new SecurityException( "Unauthorized call by class " + callerClass ); } return System.getSecurityManager() != null ? AccessController.doPrivileged( privilegedAction ) : privilegedAction.run(); }
public static <T> T doPrivileged(PrivilegedAction<T> action) { final Boolean original = privileged.get(); privileged.set(Boolean.TRUE); try { return action.run(); } finally { privileged.set(original); } }
private AttributeAccess buildAttributeAccess(final String attributeName) { final PrivilegedAction<AttributeAccess> action = new PrivilegedAction<AttributeAccess>() { @Override public AttributeAccess run() { for ( Class clazz : classHierarchy ) { try { final Field field = clazz.getDeclaredField( attributeName ); if ( field != null ) { return new FieldAttributeAccess( field ); } } catch ( NoSuchFieldException e ) { final Method method = getMethod( clazz, attributeName ); if ( method != null ) { return new MethodAttributeAccess( attributeName, method ); } } } //we could not find any match return new NoSuchAttributeAccess( specifiedClass, attributeName ); } }; return System.getSecurityManager() != null ? AccessController.doPrivileged( action ) : action.run(); } }
public Object call() { return action.run(); }}; }
/** * Perform an action with permission checking enabled. If permission checking is already enabled, the action is * simply run. * * @param action the action to perform * @param context the access control context to use * @param <T> the action return type * @return the return value of the action */ public static <T> T doChecked(PrivilegedAction<T> action, AccessControlContext context) { final Context ctx = CTX.get(); if (ctx.checking) { return action.run(); } ctx.checking = true; try { return AccessController.doPrivileged(action, context); } finally { ctx.checking = false; } }
/** * Perform an action with permission checking enabled. If permission checking is already enabled, the action is * simply run. * * @param action the action to perform * @param <T> the action return type * @return the return value of the action */ public static <T> T doChecked(PrivilegedAction<T> action) { final Context ctx = CTX.get(); if (ctx.checking) { return action.run(); } ctx.checking = true; try { return action.run(); } finally { ctx.checking = false; } }
static <T> T doPrivileged(final PrivilegedAction<T> action) { return WildFlySecurityManager.isChecking() ? AccessController.doPrivileged(action) : action.run(); }
/** * Perform an action with permission checking disabled. If permission checking is already disabled, the action is * simply run. The immediate caller must have the {@code doUnchecked} runtime permission. * * @param action the action to perform * @param <T> the action return type * @return the return value of the action */ public static <T> T doUnchecked(PrivilegedAction<T> action) { final Context ctx = CTX.get(); if (! ctx.checking) { return action.run(); } ctx.checking = false; try { final SecurityManager sm = getSecurityManager(); if (sm != null) { checkPDPermission(getCallerClass(2), doUncheckedPermission); } return action.run(); } finally { ctx.checking = true; } }
return System.getSecurityManager() != null ? AccessController.doPrivileged( getCallerClassAction ) : getCallerClassAction.run();
void doAsSubject(final java.security.PrivilegedAction<Void> action) { if (getSubject() == null) { action.run(); } else { Subject.doAs(getSubject(), action); } }
@Override public Object processInvocation(final InterceptorContext context) throws Exception { // TODO - special cases need to be handled where SecurityContext not established or minimal unauthenticated principal context instead. String previousContextID = this.setContextID(this.policyContextID); if (WildFlySecurityManager.isChecking()) { doPrivileged(pushAction); } else { pushAction.run(); } try { return context.proceed(); } finally { this.setContextID(previousContextID); if (WildFlySecurityManager.isChecking()) { doPrivileged(popAction); } else { popAction.run(); } } }