Package org.wildfly.security.manager
Class WildFlySecurityManager
- java.lang.Object
-
- java.lang.SecurityManager
-
- org.wildfly.security.manager.WildFlySecurityManager
-
- All Implemented Interfaces:
PermissionVerifier
@MetaInfServices(java.lang.SecurityManager.class) public final class WildFlySecurityManager extends SecurityManager implements PermissionVerifier
The security manager. This security manager implementation can be switched on and off on a per-thread basis, and additionally logs access violations in a way that should be substantially clearer than most JDK implementations.- Author:
- David M. Lloyd
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classWildFlySecurityManager.Context
-
Field Summary
Fields Modifier and Type Field Description private static ClassValue<AccessControlContext>ACC_CACHEprivate static PermissionACCESS_DECLARED_MEMBERS_PERMISSIONprivate static Class<?>[]ATOMIC_FIELD_UPDATER_TYPESprivate static ThreadLocal<WildFlySecurityManager.Context>CTXprivate static PermissionENVIRONMENT_PERMISSIONprivate static PermissionGET_CLASS_LOADER_PERMISSIONprivate static booleanhasGetCallerClassprivate static WildFlySecurityManagerINSTANCEprivate static booleanLOG_ONLYprivate static PrivilegedAction<Object>PA_TRAMPOLINE1private static PrivilegedExceptionAction<Object>PA_TRAMPOLINE2private static longpdStackOffsetprivate static PermissionPROPERTIES_PERMISSIONprivate static PermissionSECURITY_MANAGER_PERMISSIONprivate static PermissionSET_CLASS_LOADER_PERMISSIONprivate static sun.misc.Unsafeunsafeprivate static booleanusingStackWalker-
Fields inherited from interface org.wildfly.security.permission.PermissionVerifier
ALL, NONE
-
-
Constructor Summary
Constructors Constructor Description WildFlySecurityManager()Construct a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidcheckAccept(String host, int port)voidcheckAccess(Thread t)voidcheckAccess(ThreadGroup g)voidcheckConnect(String host, int port)voidcheckConnect(String host, int port, Object context)voidcheckCreateClassLoader()voidcheckDelete(String file)private static voidcheckEnvPropertyReadPermission(Class<?> clazz, String propertyName)voidcheckExec(String cmd)voidcheckExit(int status)voidcheckLink(String lib)voidcheckListen(int port)voidcheckMemberAccess(Class<?> clazz, int which)Deprecated.voidcheckMulticast(InetAddress maddr)voidcheckMulticast(InetAddress maddr, byte ttl)Deprecated.voidcheckPackageAccess(String pkg)voidcheckPackageDefinition(String pkg)private static voidcheckPDPermission(Class<?> clazz, Permission permission)voidcheckPermission(Permission perm)Perform a permission check.voidcheckPermission(Permission perm, Object context)Perform a permission check.voidcheckPermission(Permission perm, AccessControlContext context)Perform a permission check.voidcheckPrintJobAccess()voidcheckPropertiesAccess()voidcheckPropertyAccess(String key)private static voidcheckPropertyReadPermission(Class<?> clazz, String propertyName)private static voidcheckPropertyWritePermission(Class<?> clazz, String propertyName)voidcheckRead(FileDescriptor fd)voidcheckRead(String file)voidcheckRead(String file, Object context)voidcheckSecurityAccess(String target)voidcheckSetFactory()voidcheckWrite(FileDescriptor fd)voidcheckWrite(String file)static StringclearPropertyPrivileged(String name)Clear a property, doing a faster permission check that skips having to execute a privileged action frame.private static <T> Tdef(T test, T def)private static booleandoCheck()private static booleandoCheck(WildFlySecurityManager.Context ctx)static <T> TdoChecked(PrivilegedAction<T> action)Perform an action with permission checking enabled.static <T> TdoChecked(PrivilegedAction<T> action, AccessControlContext context)Perform an action with permission checking enabled.static <T> TdoChecked(PrivilegedExceptionAction<T> action)Perform an action with permission checking enabled.static <T> TdoChecked(PrivilegedExceptionAction<T> action, AccessControlContext context)Perform an action with permission checking enabled.static <T,P>
TdoChecked(P parameter, ParametricPrivilegedAction<T,P> action)Perform an action with permission checking enabled.static <T,P>
TdoChecked(P parameter, ParametricPrivilegedAction<T,P> action, AccessControlContext context)Perform an action with permission checking enabled.static <T,P>
TdoChecked(P parameter, ParametricPrivilegedExceptionAction<T,P> action)Perform an action with permission checking enabled.static <T,P>
TdoChecked(P parameter, ParametricPrivilegedExceptionAction<T,P> action, AccessControlContext context)Perform an action with permission checking enabled.static <T,P>
TdoPrivilegedWithParameter(P parameter, ParametricPrivilegedAction<T,P> action)Execute a parametric privileged action with the given parameter in a privileged context.static <T,P>
TdoPrivilegedWithParameter(P parameter, ParametricPrivilegedAction<T,P> action, AccessControlContext accessControlContext)Execute a parametric privileged action with the given parameter with the given context.static <T,P>
TdoPrivilegedWithParameter(P parameter, ParametricPrivilegedExceptionAction<T,P> action)Execute a parametric privileged action with the given parameter in a privileged context.static <T,P>
TdoPrivilegedWithParameter(P parameter, ParametricPrivilegedExceptionAction<T,P> action, AccessControlContext accessControlContext)Execute a parametric privileged action with the given parameter with the given context.static <T> TdoUnchecked(PrivilegedAction<T> action)Perform an action with permission checking disabled.static <T> TdoUnchecked(PrivilegedAction<T> action, AccessControlContext context)Perform an action with permission checking disabled.static <T> TdoUnchecked(PrivilegedExceptionAction<T> action)Perform an action with permission checking disabled.static <T> TdoUnchecked(PrivilegedExceptionAction<T> action, AccessControlContext context)Perform an action with permission checking disabled.static <T,P>
TdoUnchecked(P parameter, ParametricPrivilegedAction<T,P> action)Perform an action with permission checking disabled.static <T,P>
TdoUnchecked(P parameter, ParametricPrivilegedAction<T,P> action, AccessControlContext context)Perform an action with permission checking disabled.static <T,P>
TdoUnchecked(P parameter, ParametricPrivilegedExceptionAction<T,P> action)Perform an action with permission checking disabled.static <T,P>
TdoUnchecked(P parameter, ParametricPrivilegedExceptionAction<T,P> action, AccessControlContext context)Perform an action with permission checking disabled.static ProtectionDomainfindAccessDenial(Permission permission, ProtectionDomain... domains)Find the protection domain in the given list which denies a permission, ornullif the permission check would pass.private static AccessControlContextgetCallerAccessControlContext()(package private) static Class<?>getCallerClass(int n)(package private) static Class<?>[]getCallStack()static ClassLoadergetClassLoaderPrivileged(Class<?> clazz)Get the class loader for a class, doing a faster permission check that skips having to execute a privileged action frame.static ClassLoadergetCurrentContextClassLoaderPrivileged()Get the current thread's context class loader, doing a faster permission check that skips having to execute a privileged action frame.static StringgetEnvPropertyPrivileged(String name, String def)Get an environmental property, doing a faster permission check that skips having to execute a privileged action frame.static StringgetPropertyPrivileged(String name, String def)Get a property, doing a faster permission check that skips having to execute a privileged action frame.private static ProtectionDomain[]getProtectionDomainStack(AccessControlContext context)static Map<String,String>getSystemEnvironmentPrivileged()Get the system environment map, doing a faster permission check that skips having to execute a privileged action frame.static PropertiesgetSystemPropertiesPrivileged()Get the system properties map, doing a faster permission check that skips having to execute a privileged action frame.booleanimplies(Permission permission)Determine if the permission is verified by this object.static voidinstall()Deprecated.private static booleanisAssignableToOneOf(Class<?> test, Class<?>... expect)static booleanisChecking()Determine whether the security manager is currently checking permissions.static ClassLoadersetCurrentContextClassLoaderPrivileged(Class<?> clazz)Set the current thread's context class loader, doing a faster permission check that skips having to execute a privileged action frame.static ClassLoadersetCurrentContextClassLoaderPrivileged(ClassLoader newClassLoader)Set the current thread's context class loader, doing a faster permission check that skips having to execute a privileged action frame.static StringsetPropertyPrivileged(String name, String value)Set a property, doing a faster permission check that skips having to execute a privileged action frame.static booleantryCheckPermission(Permission permission, ProtectionDomain... domains)Try a permission check.-
Methods inherited from class java.lang.SecurityManager
getClassContext, getSecurityContext, getThreadGroup
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.wildfly.security.permission.PermissionVerifier
and, not, or, toPermissionCollection, unless, xor
-
-
-
-
Field Detail
-
SECURITY_MANAGER_PERMISSION
private static final Permission SECURITY_MANAGER_PERMISSION
-
PROPERTIES_PERMISSION
private static final Permission PROPERTIES_PERMISSION
-
ENVIRONMENT_PERMISSION
private static final Permission ENVIRONMENT_PERMISSION
-
GET_CLASS_LOADER_PERMISSION
private static final Permission GET_CLASS_LOADER_PERMISSION
-
SET_CLASS_LOADER_PERMISSION
private static final Permission SET_CLASS_LOADER_PERMISSION
-
ACCESS_DECLARED_MEMBERS_PERMISSION
private static final Permission ACCESS_DECLARED_MEMBERS_PERMISSION
-
LOG_ONLY
private static final boolean LOG_ONLY
-
CTX
private static final ThreadLocal<WildFlySecurityManager.Context> CTX
-
unsafe
private static final sun.misc.Unsafe unsafe
-
pdStackOffset
private static final long pdStackOffset
-
INSTANCE
private static final WildFlySecurityManager INSTANCE
-
hasGetCallerClass
private static final boolean hasGetCallerClass
-
usingStackWalker
private static final boolean usingStackWalker
-
ATOMIC_FIELD_UPDATER_TYPES
private static final Class<?>[] ATOMIC_FIELD_UPDATER_TYPES
-
ACC_CACHE
private static final ClassValue<AccessControlContext> ACC_CACHE
-
PA_TRAMPOLINE1
private static final PrivilegedAction<Object> PA_TRAMPOLINE1
-
PA_TRAMPOLINE2
private static final PrivilegedExceptionAction<Object> PA_TRAMPOLINE2
-
-
Constructor Detail
-
WildFlySecurityManager
public WildFlySecurityManager() throws SecurityExceptionConstruct a new instance. If the caller does not have permission to do so, this method will throw an exception.- Throws:
SecurityException- if the caller does not have permission to create a security manager instance
-
-
Method Detail
-
install
@Deprecated public static void install() throws SecurityException
Deprecated.- Throws:
SecurityException
-
getCallerClass
static Class<?> getCallerClass(int n)
-
getCallStack
static Class<?>[] getCallStack()
-
isChecking
public static boolean isChecking()
Determine whether the security manager is currently checking permissions.- Returns:
trueif the security manager is currently checking permissions
-
checkPermission
public void checkPermission(Permission perm) throws SecurityException
Perform a permission check.- Specified by:
checkPermissionin interfacePermissionVerifier- Overrides:
checkPermissionin classSecurityManager- Parameters:
perm- the permission to check- Throws:
SecurityException- if the check fails
-
checkPermission
public void checkPermission(Permission perm, Object context) throws SecurityException
Perform a permission check.- Overrides:
checkPermissionin classSecurityManager- Parameters:
perm- the permission to checkcontext- the security context to use for the check (must be anAccessControlContextinstance)- Throws:
SecurityException- if the check fails
-
findAccessDenial
public static ProtectionDomain findAccessDenial(Permission permission, ProtectionDomain... domains)
Find the protection domain in the given list which denies a permission, ornullif the permission check would pass.- Parameters:
permission- the permission to testdomains- the protection domains to try- Returns:
- the first denying protection domain, or
nullif there is none
-
tryCheckPermission
public static boolean tryCheckPermission(Permission permission, ProtectionDomain... domains)
Try a permission check. Any violations will be logged to theorg.wildfly.security.accesscategory at aDEBUGlevel.- Parameters:
permission- the permission to checkdomains- the protection domains to try- Returns:
trueif the access check succeeded,falseotherwise
-
implies
public boolean implies(Permission permission)
Description copied from interface:PermissionVerifierDetermine if the permission is verified by this object.- Specified by:
impliesin interfacePermissionVerifier- Parameters:
permission- the permission to verify (must not benull)- Returns:
trueif the permission is implied by this verifier,falseotherwise
-
checkPermission
public void checkPermission(Permission perm, AccessControlContext context) throws SecurityException
Perform a permission check.- Parameters:
perm- the permission to checkcontext- the security context to use for the check- Throws:
SecurityException- if the check fails
-
getProtectionDomainStack
private static ProtectionDomain[] getProtectionDomainStack(AccessControlContext context)
-
doCheck
private static boolean doCheck()
-
doCheck
private static boolean doCheck(WildFlySecurityManager.Context ctx)
-
checkCreateClassLoader
public void checkCreateClassLoader()
- Overrides:
checkCreateClassLoaderin classSecurityManager
-
checkAccess
public void checkAccess(Thread t)
- Overrides:
checkAccessin classSecurityManager
-
checkAccess
public void checkAccess(ThreadGroup g)
- Overrides:
checkAccessin classSecurityManager
-
checkExit
public void checkExit(int status)
- Overrides:
checkExitin classSecurityManager
-
checkExec
public void checkExec(String cmd)
- Overrides:
checkExecin classSecurityManager
-
checkLink
public void checkLink(String lib)
- Overrides:
checkLinkin classSecurityManager
-
checkRead
public void checkRead(FileDescriptor fd)
- Overrides:
checkReadin classSecurityManager
-
checkRead
public void checkRead(String file)
- Overrides:
checkReadin classSecurityManager
-
checkRead
public void checkRead(String file, Object context)
- Overrides:
checkReadin classSecurityManager
-
checkWrite
public void checkWrite(FileDescriptor fd)
- Overrides:
checkWritein classSecurityManager
-
checkWrite
public void checkWrite(String file)
- Overrides:
checkWritein classSecurityManager
-
checkDelete
public void checkDelete(String file)
- Overrides:
checkDeletein classSecurityManager
-
checkConnect
public void checkConnect(String host, int port)
- Overrides:
checkConnectin classSecurityManager
-
checkConnect
public void checkConnect(String host, int port, Object context)
- Overrides:
checkConnectin classSecurityManager
-
checkListen
public void checkListen(int port)
- Overrides:
checkListenin classSecurityManager
-
checkAccept
public void checkAccept(String host, int port)
- Overrides:
checkAcceptin classSecurityManager
-
checkMulticast
public void checkMulticast(InetAddress maddr)
- Overrides:
checkMulticastin classSecurityManager
-
checkMulticast
@Deprecated public void checkMulticast(InetAddress maddr, byte ttl)
Deprecated.- Overrides:
checkMulticastin classSecurityManager
-
checkPropertiesAccess
public void checkPropertiesAccess()
- Overrides:
checkPropertiesAccessin classSecurityManager
-
checkPropertyAccess
public void checkPropertyAccess(String key)
- Overrides:
checkPropertyAccessin classSecurityManager
-
checkPrintJobAccess
public void checkPrintJobAccess()
- Overrides:
checkPrintJobAccessin classSecurityManager
-
checkPackageAccess
public void checkPackageAccess(String pkg)
- Overrides:
checkPackageAccessin classSecurityManager
-
checkPackageDefinition
public void checkPackageDefinition(String pkg)
- Overrides:
checkPackageDefinitionin classSecurityManager
-
checkSetFactory
public void checkSetFactory()
- Overrides:
checkSetFactoryin classSecurityManager
-
checkMemberAccess
@Deprecated public void checkMemberAccess(Class<?> clazz, int which)
Deprecated.
-
checkSecurityAccess
public void checkSecurityAccess(String target)
- Overrides:
checkSecurityAccessin classSecurityManager
-
doChecked
public static <T> T doChecked(PrivilegedAction<T> action)
Perform an action with permission checking enabled. If permission checking is already enabled, the action is simply run.- Type Parameters:
T- the action return type- Parameters:
action- the action to perform- Returns:
- the return value of the action
-
doChecked
public static <T> T doChecked(PrivilegedExceptionAction<T> action) throws PrivilegedActionException
Perform an action with permission checking enabled. If permission checking is already enabled, the action is simply run.- Type Parameters:
T- the action return type- Parameters:
action- the action to perform- Returns:
- the return value of the action
- Throws:
PrivilegedActionException- if the action threw an exception
-
doChecked
public static <T> T doChecked(PrivilegedAction<T> action, AccessControlContext context)
Perform an action with permission checking enabled. If permission checking is already enabled, the action is simply run.- Type Parameters:
T- the action return type- Parameters:
action- the action to performcontext- the access control context to use- Returns:
- the return value of the action
-
doChecked
public static <T> T doChecked(PrivilegedExceptionAction<T> action, AccessControlContext context) throws PrivilegedActionException
Perform an action with permission checking enabled. If permission checking is already enabled, the action is simply run.- Type Parameters:
T- the action return type- Parameters:
action- the action to performcontext- the access control context to use- Returns:
- the return value of the action
- Throws:
PrivilegedActionException- if the action threw an exception
-
doChecked
public static <T,P> T doChecked(P parameter, ParametricPrivilegedAction<T,P> action)Perform an action with permission checking enabled. If permission checking is already enabled, the action is simply run.- Type Parameters:
T- the action return typeP- the action parameter type- Parameters:
parameter- the parameter to pass to the actionaction- the action to perform- Returns:
- the return value of the action
-
doChecked
public static <T,P> T doChecked(P parameter, ParametricPrivilegedExceptionAction<T,P> action) throws PrivilegedActionExceptionPerform an action with permission checking enabled. If permission checking is already enabled, the action is simply run.- Type Parameters:
T- the action return typeP- the action parameter type- Parameters:
parameter- the parameter to pass to the actionaction- the action to perform- Returns:
- the return value of the action
- Throws:
PrivilegedActionException- if the action threw an exception
-
doChecked
public static <T,P> T doChecked(P parameter, ParametricPrivilegedAction<T,P> action, AccessControlContext context)Perform an action with permission checking enabled. If permission checking is already enabled, the action is simply run.- Type Parameters:
T- the action return typeP- the action parameter type- Parameters:
parameter- the parameter to pass to the actionaction- the action to performcontext- the access control context to use- Returns:
- the return value of the action
-
doChecked
public static <T,P> T doChecked(P parameter, ParametricPrivilegedExceptionAction<T,P> action, AccessControlContext context) throws PrivilegedActionExceptionPerform an action with permission checking enabled. If permission checking is already enabled, the action is simply run.- Type Parameters:
T- the action return typeP- the action parameter type- Parameters:
parameter- the parameter to pass to the actionaction- the action to performcontext- the access control context to use- Returns:
- the return value of the action
- Throws:
PrivilegedActionException- if the action threw an exception
-
doUnchecked
public static <T> T doUnchecked(PrivilegedAction<T> action)
Perform an action with permission checking disabled. If permission checking is already disabled, the action is simply run. The immediate caller must have thedoUncheckedruntime permission.- Type Parameters:
T- the action return type- Parameters:
action- the action to perform- Returns:
- the return value of the action
-
doUnchecked
public static <T> T doUnchecked(PrivilegedExceptionAction<T> action) throws PrivilegedActionException
Perform an action with permission checking disabled. If permission checking is already disabled, the action is simply run. The caller must have thedoUncheckedruntime permission.- Type Parameters:
T- the action return type- Parameters:
action- the action to perform- Returns:
- the return value of the action
- Throws:
PrivilegedActionException- if the action threw an exception
-
doUnchecked
public static <T> T doUnchecked(PrivilegedAction<T> action, AccessControlContext context)
Perform an action with permission checking disabled. If permission checking is already disabled, the action is simply run. The immediate caller must have thedoUncheckedruntime permission.- Type Parameters:
T- the action return type- Parameters:
action- the action to performcontext- the access control context to use- Returns:
- the return value of the action
-
doUnchecked
public static <T> T doUnchecked(PrivilegedExceptionAction<T> action, AccessControlContext context) throws PrivilegedActionException
Perform an action with permission checking disabled. If permission checking is already disabled, the action is simply run. The caller must have thedoUncheckedruntime permission.- Type Parameters:
T- the action return type- Parameters:
action- the action to performcontext- the access control context to use- Returns:
- the return value of the action
- Throws:
PrivilegedActionException- if the action threw an exception
-
doUnchecked
public static <T,P> T doUnchecked(P parameter, ParametricPrivilegedAction<T,P> action)Perform an action with permission checking disabled. If permission checking is already disabled, the action is simply run. The immediate caller must have thedoUncheckedruntime permission.- Type Parameters:
T- the action return typeP- the action parameter type- Parameters:
parameter- the parameter to pass to the actionaction- the action to perform- Returns:
- the return value of the action
-
doUnchecked
public static <T,P> T doUnchecked(P parameter, ParametricPrivilegedExceptionAction<T,P> action) throws PrivilegedActionExceptionPerform an action with permission checking disabled. If permission checking is already disabled, the action is simply run. The caller must have thedoUncheckedruntime permission.- Type Parameters:
T- the action return typeP- the action parameter type- Parameters:
parameter- the parameter to pass to the actionaction- the action to perform- Returns:
- the return value of the action
- Throws:
PrivilegedActionException- if the action threw an exception
-
doUnchecked
public static <T,P> T doUnchecked(P parameter, ParametricPrivilegedAction<T,P> action, AccessControlContext context)Perform an action with permission checking disabled. If permission checking is already disabled, the action is simply run. The immediate caller must have thedoUncheckedruntime permission.- Type Parameters:
T- the action return typeP- the action parameter type- Parameters:
parameter- the parameter to pass to the actionaction- the action to performcontext- the access control context to use- Returns:
- the return value of the action
-
doUnchecked
public static <T,P> T doUnchecked(P parameter, ParametricPrivilegedExceptionAction<T,P> action, AccessControlContext context) throws PrivilegedActionExceptionPerform an action with permission checking disabled. If permission checking is already disabled, the action is simply run. The caller must have thedoUncheckedruntime permission.- Type Parameters:
T- the action return typeP- the action parameter type- Parameters:
parameter- the parameter to pass to the actionaction- the action to performcontext- the access control context to use- Returns:
- the return value of the action
- Throws:
PrivilegedActionException- if the action threw an exception
-
checkPropertyReadPermission
private static void checkPropertyReadPermission(Class<?> clazz, String propertyName)
-
checkEnvPropertyReadPermission
private static void checkEnvPropertyReadPermission(Class<?> clazz, String propertyName)
-
checkPropertyWritePermission
private static void checkPropertyWritePermission(Class<?> clazz, String propertyName)
-
checkPDPermission
private static void checkPDPermission(Class<?> clazz, Permission permission)
-
getPropertyPrivileged
public static String getPropertyPrivileged(String name, String def)
Get a property, doing a faster permission check that skips having to execute a privileged action frame.- Parameters:
name- the property namedef- the default value if the property is not found- Returns:
- the property value, or the default value
-
def
private static <T> T def(T test, T def)
-
getEnvPropertyPrivileged
public static String getEnvPropertyPrivileged(String name, String def)
Get an environmental property, doing a faster permission check that skips having to execute a privileged action frame.- Parameters:
name- the property namedef- the default value if the property is not found- Returns:
- the property value, or the default value
-
setPropertyPrivileged
public static String setPropertyPrivileged(String name, String value)
Set a property, doing a faster permission check that skips having to execute a privileged action frame.- Parameters:
name- the property namevalue- the value ot set- Returns:
- the previous property value, or
nullif there was none
-
clearPropertyPrivileged
public static String clearPropertyPrivileged(String name)
Clear a property, doing a faster permission check that skips having to execute a privileged action frame.- Parameters:
name- the property name- Returns:
- the previous property value, or
nullif there was none
-
getCurrentContextClassLoaderPrivileged
public static ClassLoader getCurrentContextClassLoaderPrivileged()
Get the current thread's context class loader, doing a faster permission check that skips having to execute a privileged action frame.- Returns:
- the context class loader
-
setCurrentContextClassLoaderPrivileged
public static ClassLoader setCurrentContextClassLoaderPrivileged(ClassLoader newClassLoader)
Set the current thread's context class loader, doing a faster permission check that skips having to execute a privileged action frame.- Parameters:
newClassLoader- the new class loader to set- Returns:
- the previously set context class loader
-
setCurrentContextClassLoaderPrivileged
public static ClassLoader setCurrentContextClassLoaderPrivileged(Class<?> clazz)
Set the current thread's context class loader, doing a faster permission check that skips having to execute a privileged action frame.- Parameters:
clazz- the class whose class loader is the new class loader to set- Returns:
- the previously set context class loader
-
getSystemPropertiesPrivileged
public static Properties getSystemPropertiesPrivileged()
Get the system properties map, doing a faster permission check that skips having to execute a privileged action frame.- Returns:
- the system property map
-
getSystemEnvironmentPrivileged
public static Map<String,String> getSystemEnvironmentPrivileged()
Get the system environment map, doing a faster permission check that skips having to execute a privileged action frame.- Returns:
- the system environment map
-
getClassLoaderPrivileged
public static ClassLoader getClassLoaderPrivileged(Class<?> clazz)
Get the class loader for a class, doing a faster permission check that skips having to execute a privileged action frame.- Parameters:
clazz- the class to check- Returns:
- the class loader
-
doPrivilegedWithParameter
public static <T,P> T doPrivilegedWithParameter(P parameter, ParametricPrivilegedAction<T,P> action)Execute a parametric privileged action with the given parameter in a privileged context.- Type Parameters:
T- the action result typeP- the parameter type- Parameters:
parameter- the parameter to send in to the actionaction- the action to execute- Returns:
- the action result
-
doPrivilegedWithParameter
public static <T,P> T doPrivilegedWithParameter(P parameter, ParametricPrivilegedExceptionAction<T,P> action) throws PrivilegedActionExceptionExecute a parametric privileged action with the given parameter in a privileged context.- Type Parameters:
T- the action result typeP- the parameter type- Parameters:
parameter- the parameter to send in to the actionaction- the action to execute- Returns:
- the action result
- Throws:
PrivilegedActionException
-
doPrivilegedWithParameter
public static <T,P> T doPrivilegedWithParameter(P parameter, ParametricPrivilegedAction<T,P> action, AccessControlContext accessControlContext)Execute a parametric privileged action with the given parameter with the given context.- Type Parameters:
T- the action result typeP- the parameter type- Parameters:
parameter- the parameter to send in to the actionaction- the action to executeaccessControlContext- the context to use- Returns:
- the action result
-
doPrivilegedWithParameter
public static <T,P> T doPrivilegedWithParameter(P parameter, ParametricPrivilegedExceptionAction<T,P> action, AccessControlContext accessControlContext) throws PrivilegedActionExceptionExecute a parametric privileged action with the given parameter with the given context.- Type Parameters:
T- the action result typeP- the parameter type- Parameters:
parameter- the parameter to send in to the actionaction- the action to executeaccessControlContext- the context to use- Returns:
- the action result
- Throws:
PrivilegedActionException
-
getCallerAccessControlContext
private static AccessControlContext getCallerAccessControlContext()
-
-