Package org.apache.catalina.security
Class SecurityUtil
- java.lang.Object
-
- org.apache.catalina.security.SecurityUtil
-
public final class SecurityUtil extends java.lang.Object
This utility class associates aSubject
to the currentAccessControlContext
. When aSecurityManager
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
Constructors Constructor Description SecurityUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
doAsPrivilege(java.lang.String methodName, Filter targetObject)
Perform work as a particularSubject
.static void
doAsPrivilege(java.lang.String methodName, Filter targetObject, java.lang.Class<?>[] targetType, java.lang.Object[] targetArguments)
Perform work as a particularSubject
.static void
doAsPrivilege(java.lang.String methodName, Filter targetObject, java.lang.Class<?>[] targetParameterTypes, java.lang.Object[] targetParameterValues, java.security.Principal principal)
Perform work as a particularSubject
.static void
doAsPrivilege(java.lang.String methodName, Servlet targetObject)
Perform work as a particularSubject
.static void
doAsPrivilege(java.lang.String methodName, Servlet targetObject, java.lang.Class<?>[] targetType, java.lang.Object[] targetArguments)
Perform work as a particularSubject
.static void
doAsPrivilege(java.lang.String methodName, Servlet targetObject, java.lang.Class<?>[] targetParameterTypes, java.lang.Object[] targetArguments, java.security.Principal principal)
Perform work as a particularSubject
.static boolean
isPackageProtectionEnabled()
Return theSecurityManager
only if Security is enabled AND package protection mechanism is enabled.static void
remove(java.lang.Object cachedObject)
Remove the object from the cache.
-
-
-
Method Detail
-
doAsPrivilege
public static void doAsPrivilege(java.lang.String methodName, Servlet targetObject) throws java.lang.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.- Throws:
java.lang.Exception
- an execution error occurred
-
doAsPrivilege
public static void doAsPrivilege(java.lang.String methodName, Servlet targetObject, java.lang.Class<?>[] targetType, java.lang.Object[] targetArguments) throws java.lang.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:
java.lang.Exception
- an execution error occurred
-
doAsPrivilege
public static void doAsPrivilege(java.lang.String methodName, Servlet targetObject, java.lang.Class<?>[] targetParameterTypes, java.lang.Object[] targetArguments, java.security.Principal principal) throws java.lang.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:
java.lang.Exception
- an execution error occurred
-
doAsPrivilege
public static void doAsPrivilege(java.lang.String methodName, Filter targetObject) throws java.lang.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.- Throws:
java.lang.Exception
- an execution error occurred
-
doAsPrivilege
public static void doAsPrivilege(java.lang.String methodName, Filter targetObject, java.lang.Class<?>[] targetType, java.lang.Object[] targetArguments) throws java.lang.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:
java.lang.Exception
- an execution error occurred
-
doAsPrivilege
public static void doAsPrivilege(java.lang.String methodName, Filter targetObject, java.lang.Class<?>[] targetParameterTypes, java.lang.Object[] targetParameterValues, java.security.Principal principal) throws java.lang.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:
java.lang.Exception
- an execution error occurred
-
remove
public static void remove(java.lang.Object cachedObject)
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
-
-