/** * Perform an action with permission checking disabled. If permission checking is already disabled, the action is * simply run. The caller must have the {@code doUnchecked} runtime permission. * * @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 * @throws PrivilegedActionException if the action threw an exception */ public static <T> T doUnchecked(PrivilegedExceptionAction<T> action, AccessControlContext context) throws PrivilegedActionException { final Context ctx = CTX.get(); if (! ctx.checking) { return AccessController.doPrivileged(action, context); } ctx.checking = false; try { final SecurityManager sm = getSecurityManager(); if (sm != null) { checkPDPermission(getCallerClass(2), doUncheckedPermission); } return AccessController.doPrivileged(action, context); } finally { ctx.checking = true; } }
/** * 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 context the access control context to use * @param <T> the action return type * @return the return value of the action */ public static <T> T doUnchecked(PrivilegedAction<T> action, AccessControlContext context) { final Context ctx = CTX.get(); if (! ctx.checking) { return AccessController.doPrivileged(action, context); } ctx.checking = false; try { final SecurityManager sm = getSecurityManager(); if (sm != null) { checkPDPermission(getCallerClass(2), doUncheckedPermission); } return AccessController.doPrivileged(action, context); } finally { ctx.checking = true; } }
/** * Get the current thread's context class loader, doing a faster permission check that skips having to execute a * privileged action frame. * * @return the context class loader */ public static ClassLoader getCurrentContextClassLoaderPrivileged() { final SecurityManager sm = System.getSecurityManager(); if (sm == null) { return currentThread().getContextClassLoader(); } if (sm instanceof WildFlySecurityManager) { final Context ctx = CTX.get(); if (! ctx.checking) { return currentThread().getContextClassLoader(); } ctx.checking = false; try { checkPDPermission(getCallerClass(2), GET_CLASS_LOADER_PERMISSION); return currentThread().getContextClassLoader(); } finally { ctx.checking = true; } } else { checkPDPermission(getCallerClass(2), GET_CLASS_LOADER_PERMISSION); return doPrivileged(GetContextClassLoaderAction.getInstance()); } }
/** * Get the system environment map, doing a faster permission check that skips having to execute a privileged action * frame. * * @return the system environment map */ public static Map<String, String> getSystemEnvironmentPrivileged() { final SecurityManager sm = System.getSecurityManager(); if (sm == null) { return getenv(); } if (sm instanceof WildFlySecurityManager) { final Context ctx = CTX.get(); if (! ctx.checking) { return getenv(); } ctx.checking = false; try { checkPDPermission(getCallerClass(2), ENVIRONMENT_PERMISSION); return getenv(); } finally { ctx.checking = true; } } else { checkPDPermission(getCallerClass(2), ENVIRONMENT_PERMISSION); return doPrivileged(GetEnvironmentAction.getInstance()); } }
checkPDPermission(caller, SET_CLASS_LOADER_PERMISSION); checkPDPermission(caller, GET_CLASS_LOADER_PERMISSION); try { return thread.getContextClassLoader(); checkPDPermission(caller, SET_CLASS_LOADER_PERMISSION); checkPDPermission(caller, GET_CLASS_LOADER_PERMISSION); return doPrivileged(new SetContextClassLoaderAction(clazz.getClassLoader()));
/** * Get the class loader for a class, doing a faster permission check that skips having to execute a privileged action * frame. * * @param clazz the class to check * @return the class loader */ public static ClassLoader getClassLoaderPrivileged(Class<?> clazz) { final SecurityManager sm = System.getSecurityManager(); if (sm == null) { return clazz.getClassLoader(); } if (sm instanceof WildFlySecurityManager) { final Context ctx = CTX.get(); if (! ctx.checking) { return clazz.getClassLoader(); } ctx.checking = false; try { checkPDPermission(getCallerClass(2), GET_CLASS_LOADER_PERMISSION); return clazz.getClassLoader(); } finally { ctx.checking = true; } } else { checkPDPermission(getCallerClass(2), GET_CLASS_LOADER_PERMISSION); return doPrivileged(new GetClassLoaderAction(clazz)); } }
/** * Get the system properties map, doing a faster permission check that skips having to execute a privileged action * frame. * * @return the system property map */ public static Properties getSystemPropertiesPrivileged() { final SecurityManager sm = System.getSecurityManager(); if (sm == null) { return getProperties(); } if (sm instanceof WildFlySecurityManager) { final Context ctx = CTX.get(); if (! ctx.checking) { return getProperties(); } ctx.checking = false; try { checkPDPermission(getCallerClass(2), PROPERTIES_PERMISSION); return getProperties(); } finally { ctx.checking = true; } } else { checkPDPermission(getCallerClass(2), PROPERTIES_PERMISSION); return doPrivileged(GetSystemPropertiesAction.getInstance()); } }
checkPDPermission(getCallerClass(2), SET_CLASS_LOADER_PERMISSION); try { return thread.getContextClassLoader(); checkPDPermission(getCallerClass(2), SET_CLASS_LOADER_PERMISSION); return doPrivileged(new SetContextClassLoaderAction(newClassLoader));
/** * 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; } }
/** * 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 parameter the parameter to pass to the action * @param action the action to perform * @param <T> the action return type * @param <P> the action parameter type * @return the return value of the action */ public static <T, P> T doUnchecked(P parameter, ParametricPrivilegedAction<T, P> action) { final Context ctx = CTX.get(); if (! ctx.checking) { return action.run(parameter); } ctx.checking = false; try { final SecurityManager sm = getSecurityManager(); if (sm != null) { checkPDPermission(getCallerClass(2), doUncheckedPermission); } return action.run(parameter); } finally { ctx.checking = true; } }
/** * 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 parameter the parameter to pass to the action * @param action the action to perform * @param context the access control context to use * @param <T> the action return type * @param <P> the action parameter type * @return the return value of the action */ public static <T, P> T doUnchecked(P parameter, ParametricPrivilegedAction<T, P> action, AccessControlContext context) { final Context ctx = CTX.get(); if (! ctx.checking) { return doPrivilegedWithParameter(parameter, action, context); } ctx.checking = false; try { final SecurityManager sm = getSecurityManager(); if (sm != null) { checkPDPermission(getCallerClass(2), doUncheckedPermission); } return doPrivilegedWithParameter(parameter, action, context); } finally { ctx.checking = true; } }
/** * Perform an action with permission checking disabled. If permission checking is already disabled, the action is * simply run. The caller must have the {@code doUnchecked} runtime permission. * * @param parameter the parameter to pass to the action * @param action the action to perform * @param context the access control context to use * @param <T> the action return type * @param <P> the action parameter type * @return the return value of the action * @throws PrivilegedActionException if the action threw an exception */ public static <T, P> T doUnchecked(P parameter, ParametricPrivilegedExceptionAction<T, P> action, AccessControlContext context) throws PrivilegedActionException { final Context ctx = CTX.get(); if (! ctx.checking) { return doPrivilegedWithParameter(parameter, action, context); } ctx.checking = false; try { final SecurityManager sm = getSecurityManager(); if (sm != null) { checkPDPermission(getCallerClass(2), doUncheckedPermission); } return doPrivilegedWithParameter(parameter, action, context); } finally { ctx.checking = true; } }
final SecurityManager sm = getSecurityManager(); if (sm != null) { checkPDPermission(getCallerClass(2), doUncheckedPermission);
final SecurityManager sm = getSecurityManager(); if (sm != null) { checkPDPermission(getCallerClass(2), doUncheckedPermission);
/** * 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 context the access control context to use * @param <T> the action return type * @return the return value of the action */ public static <T> T doUnchecked(PrivilegedAction<T> action, AccessControlContext context) { final Context ctx = CTX.get(); if (! ctx.checking) { return AccessController.doPrivileged(action, context); } ctx.checking = false; try { final SecurityManager sm = getSecurityManager(); if (sm != null) { checkPDPermission(getCallerClass(2), doUncheckedPermission); } return AccessController.doPrivileged(action, context); } finally { ctx.checking = true; } }
/** * 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 context the access control context to use * @param <T> the action return type * @return the return value of the action */ public static <T> T doUnchecked(PrivilegedAction<T> action, AccessControlContext context) { final Context ctx = CTX.get(); if (! ctx.checking) { return AccessController.doPrivileged(action, context); } ctx.checking = false; try { final SecurityManager sm = getSecurityManager(); if (sm != null) { checkPDPermission(getCallerClass(2), DO_UNCHECKED_PERMISSION); } return AccessController.doPrivileged(action, context); } finally { ctx.checking = true; } }
/** * Perform an action with permission checking disabled. If permission checking is already disabled, the action is * simply run. The caller must have the {@code doUnchecked} runtime permission. * * @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 * @throws PrivilegedActionException if the action threw an exception */ public static <T> T doUnchecked(PrivilegedExceptionAction<T> action, AccessControlContext context) throws PrivilegedActionException { final Context ctx = CTX.get(); if (! ctx.checking) { return AccessController.doPrivileged(action, context); } ctx.checking = false; try { final SecurityManager sm = getSecurityManager(); if (sm != null) { checkPDPermission(getCallerClass(2), doUncheckedPermission); } return AccessController.doPrivileged(action, context); } finally { ctx.checking = true; } }
/** * 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; } }
/** * 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; } }
/** * 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), DO_UNCHECKED_PERMISSION); } return action.run(); } finally { ctx.checking = true; } }