Refine search
private static <T> T doPrivileged(PrivilegedAction<T> action) { if (System.getSecurityManager() != null) { return AccessController.doPrivileged(action); } else { return action.run(); } }
private <P> P run(PrivilegedAction<P> action) { return System.getSecurityManager() != null ? AccessController.doPrivileged( action ) : 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); }
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(); }
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(); } }
/** * 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; } }
static <T> T doPrivileged(final PrivilegedAction<T> action) { return WildFlySecurityManager.isChecking() ? AccessController.doPrivileged(action) : action.run(); }
return System.getSecurityManager() != null ? AccessController.doPrivileged( getCallerClassAction ) : getCallerClassAction.run();
@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(); } } }
private ProxyDefinitionHelpers() { this.groovyGetMetaClassFilter = isSynthetic().and( named( "getMetaClass" ) .and( returns( td -> "groovy.lang.MetaClass".equals( td.getName() ) ) ) ); this.virtualNotFinalizerFilter = isVirtual().and( not( isFinalizer() ) ); this.hibernateGeneratedMethodFilter = nameStartsWith( "$$_hibernate_" ).and( isVirtual() ); PrivilegedAction<MethodDelegation> delegateToInterceptorDispatcherMethodDelegationPrivilegedAction = new PrivilegedAction<MethodDelegation>() { @Override public MethodDelegation run() { return MethodDelegation.to( ProxyConfiguration.InterceptorDispatcher.class ); } }; this.delegateToInterceptorDispatcherMethodDelegation = System.getSecurityManager() != null ? AccessController.doPrivileged( delegateToInterceptorDispatcherMethodDelegationPrivilegedAction ) : delegateToInterceptorDispatcherMethodDelegationPrivilegedAction.run(); PrivilegedAction<FieldAccessor.PropertyConfigurable> interceptorFieldAccessorPrivilegedAction = new PrivilegedAction<FieldAccessor.PropertyConfigurable>() { @Override public FieldAccessor.PropertyConfigurable run() { return FieldAccessor.ofField( ProxyConfiguration.INTERCEPTOR_FIELD_NAME ) .withAssigner( Assigner.DEFAULT, Assigner.Typing.DYNAMIC ); } }; this.interceptorFieldAccessor = System.getSecurityManager() != null ? AccessController.doPrivileged( interceptorFieldAccessorPrivilegedAction ) : interceptorFieldAccessorPrivilegedAction.run(); }
/** * Runs the given privileged action, using a privileged block if required. * <p> * <b>NOTE:</b> This must never be changed into a publicly available method to avoid execution of arbitrary * privileged actions within HV's protection domain. */ private static <T> T run(PrivilegedAction<T> action) { return System.getSecurityManager() != null ? AccessController.doPrivileged( action ) : action.run(); } }
/** * Runs the given privileged action, using a privileged block if required. * <p> * <b>NOTE:</b> This must never be changed into a publicly available method to avoid execution of arbitrary * privileged actions within HV's protection domain. */ private <T> T run(PrivilegedAction<T> action) { return System.getSecurityManager() != null ? AccessController.doPrivileged( action ) : action.run(); }
/** * Runs the given privileged action, using a privileged block if required. * <b>NOTE:</b> This must never be changed into a publicly available method to avoid execution of arbitrary * privileged actions within HV's protection domain. */ private static <V> V run(PrivilegedAction<V> action) { return System.getSecurityManager() != null ? AccessController.doPrivileged( action ) : action.run(); } }
/** * Runs the given privileged action, using a privileged block if required. * <p> * <b>NOTE:</b> This must never be changed into a publicly available method to avoid execution of arbitrary * privileged actions within HV's protection domain. */ private static <T> T run(PrivilegedAction<T> action) { return System.getSecurityManager() != null ? AccessController.doPrivileged( action ) : action.run(); } }
/** * Runs the given privileged action, using a privileged block if required. * * <b>NOTE:</b> This must never be changed into a publicly available method to avoid execution of arbitrary * privileged actions within HV's protection domain. */ private static <T> T run(PrivilegedAction<T> action) { return System.getSecurityManager() != null ? AccessController.doPrivileged( action ) : action.run(); } }
/** * Runs the given privileged action, using a privileged block if required. * <p> * <b>NOTE:</b> This must never be changed into a publicly available method to avoid execution of arbitrary * privileged actions within HV's protection domain. */ private static <T> T run(PrivilegedAction<T> action) { return System.getSecurityManager() != null ? AccessController.doPrivileged( action ) : action.run(); } }
/** * Runs the given privileged action, using a privileged block if required. * <p> * <b>NOTE:</b> This must never be changed into a publicly available method to avoid execution of arbitrary * privileged actions within HV's protection domain. */ private <T> T run(PrivilegedAction<T> action) { return System.getSecurityManager() != null ? AccessController.doPrivileged( action ) : action.run(); }
/** * Runs the given privileged action, using a privileged block if required. * <p> * <b>NOTE:</b> This must never be changed into a publicly available method to avoid execution of arbitrary * privileged actions within HV's protection domain. */ private static <T> T run(PrivilegedAction<T> action) { return System.getSecurityManager() != null ? AccessController.doPrivileged( action ) : action.run(); } }
/** * Runs the given privileged action, using a privileged block if required. * * <b>NOTE:</b> This must never be changed into a publicly available method to avoid execution of arbitrary * privileged actions within HV's protection domain. */ private static <T> T run(PrivilegedAction<T> action) { return System.getSecurityManager() != null ? AccessController.doPrivileged( action ) : action.run(); }
/** * Runs the given privileged action, using a privileged block if required. * <b>NOTE:</b> This must never be changed into a publicly available method to avoid execution of arbitrary * privileged actions within HV's protection domain. */ private static <V> V run(PrivilegedAction<V> action) { return System.getSecurityManager() != null ? AccessController.doPrivileged( action ) : action.run(); } }