Package org.apache.catalina.security
Class SecurityUtil
java.lang.Object
org.apache.catalina.security.SecurityUtil
This utility class associates a
Subject
to the current AccessControlContext
. When a
SecurityManager
is used, the container will always associate the called thread with an
AccessControlContext containing only the principal of the requested Servlet/Filter. This class uses reflection to
invoke the methods.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
doAsPrivilege
(String methodName, Filter targetObject) Perform work as a particularSubject
.static void
doAsPrivilege
(String methodName, Filter targetObject, Class<?>[] targetType, Object[] targetArguments) Perform work as a particularSubject
.static void
doAsPrivilege
(String methodName, Filter targetObject, Class<?>[] targetParameterTypes, Object[] targetParameterValues, Principal principal) Perform work as a particularSubject
.static void
doAsPrivilege
(String methodName, Servlet targetObject) Perform work as a particularSubject
.static void
doAsPrivilege
(String methodName, Servlet targetObject, Class<?>[] targetType, Object[] targetArguments) Perform work as a particularSubject
.static void
doAsPrivilege
(String methodName, Servlet targetObject, Class<?>[] targetParameterTypes, Object[] targetArguments, Principal principal) Perform work as a particularSubject
.static boolean
Return theSecurityManager
only if Security is enabled AND package protection mechanism is enabled.static void
Remove the object from the cache.
-
Constructor Details
-
SecurityUtil
public SecurityUtil()
-
-
Method Details
-
doAsPrivilege
Perform work as a particularSubject
. Here the work will be granted to anull
subject.- Parameters:
methodName
- the method to apply the security restrictiontargetObject
- theServlet
on which the method will be called.- Throws:
Exception
- an execution error occurred
-
doAsPrivilege
public static void doAsPrivilege(String methodName, Servlet targetObject, Class<?>[] targetType, Object[] targetArguments) throws Exception Perform work as a particularSubject
. Here the work will be granted to anull
subject.- Parameters:
methodName
- the method to apply the security restrictiontargetObject
- theServlet
on which the method will be called.targetType
-Class
array used to instantiate aMethod
object.targetArguments
-Object
array contains the runtime parameters instance.- Throws:
Exception
- an execution error occurred
-
doAsPrivilege
public static void doAsPrivilege(String methodName, Servlet targetObject, Class<?>[] targetParameterTypes, Object[] targetArguments, Principal principal) throws Exception Perform work as a particularSubject
. Here the work will be granted to anull
subject.- Parameters:
methodName
- the method to apply the security restrictiontargetObject
- theServlet
on which the method will be called.targetParameterTypes
-Class
array used to instantiate aMethod
object.targetArguments
-Object
array contains the runtime parameters instance.principal
- thePrincipal
to which the security privilege applies- Throws:
Exception
- an execution error occurred
-
doAsPrivilege
Perform work as a particularSubject
. Here the work will be granted to anull
subject.- Parameters:
methodName
- the method to apply the security restrictiontargetObject
- theFilter
on which the method will be called.- Throws:
Exception
- an execution error occurred
-
doAsPrivilege
public static void doAsPrivilege(String methodName, Filter targetObject, Class<?>[] targetType, Object[] targetArguments) throws Exception Perform work as a particularSubject
. Here the work will be granted to anull
subject.- Parameters:
methodName
- the method to apply the security restrictiontargetObject
- theFilter
on which the method will be called.targetType
-Class
array used to instantiate aMethod
object.targetArguments
-Object
array contains the runtime parameters instance.- Throws:
Exception
- an execution error occurred
-
doAsPrivilege
public static void doAsPrivilege(String methodName, Filter targetObject, Class<?>[] targetParameterTypes, Object[] targetParameterValues, Principal principal) throws Exception Perform work as a particularSubject
. Here the work will be granted to anull
subject.- Parameters:
methodName
- the method to apply the security restrictiontargetObject
- theFilter
on which the method will be called.targetParameterTypes
-Class
array used to instantiate aMethod
object.targetParameterValues
-Object
array contains the runtime parameters instance.principal
- thePrincipal
to which the security privilege applies- Throws:
Exception
- an execution error occurred
-
remove
Remove the object from the cache.- Parameters:
cachedObject
- The object to remove
-
isPackageProtectionEnabled
public static boolean isPackageProtectionEnabled()Return theSecurityManager
only if Security is enabled AND package protection mechanism is enabled.- Returns:
true
if package level protection is enabled
-