public class SecureSM extends SecurityManager
There are a few major problems that require custom SecurityManager
logic to fix:
exitVM
permission is implicitly granted to all code by the default
Policy implementation. For a server app, this is not wanted. modifyThread/modifyThreadGroup
. Applications
are encouraged to override the logic here to implement a stricter policy.
modifyThread
is abused by its shutdown
checks. This means
a thread must have modifyThread
to even terminate its own pool, leaving
system threads unprotected.
exitVM
calls, and provides a testing mode
where calls from test runners are allowed.
Additionally it enforces threadgroup security with the following rules:
modifyThread
and modifyThreadGroup
are required for any thread access
checks: with these permissions, access is granted as long as the thread group is
the same or an ancestor (sourceGroup.parentOf(targetGroup) == true
).
ThreadPermission
can violate
threadgroup security rules.
If java security debugging (java.security.debug
) is enabled, and this SecurityManager
is installed, it will emit additional debugging information when threadgroup access checks fail.
inCheck
Constructor and Description |
---|
SecureSM()
Create a new SecurityManager.
|
SecureSM(boolean allowTestExit)
Expert: for testing only.
|
Modifier and Type | Method and Description |
---|---|
void |
checkAccess(Thread t) |
void |
checkAccess(ThreadGroup g) |
void |
checkExit(int status) |
protected void |
checkTestExit(int status)
The "Uwe Schindler" algorithm.
|
protected void |
checkThreadAccess(Thread t) |
protected void |
checkThreadGroupAccess(ThreadGroup g) |
checkAccept, checkAwtEventQueueAccess, checkConnect, checkConnect, checkCreateClassLoader, checkDelete, checkExec, checkLink, checkListen, checkMemberAccess, checkMulticast, checkMulticast, checkPackageAccess, checkPackageDefinition, checkPermission, checkPermission, checkPrintJobAccess, checkPropertiesAccess, checkPropertyAccess, checkRead, checkRead, checkRead, checkSecurityAccess, checkSetFactory, checkSystemClipboardAccess, checkTopLevelWindow, checkWrite, checkWrite, classDepth, classLoaderDepth, currentClassLoader, currentLoadedClass, getClassContext, getInCheck, getSecurityContext, getThreadGroup, inClass, inClassLoader
public SecureSM()
public SecureSM(boolean allowTestExit)
allowTestExit
- true
if test-runners should be allowed to exit the VM.public void checkAccess(Thread t)
checkAccess
in class SecurityManager
public void checkAccess(ThreadGroup g)
checkAccess
in class SecurityManager
protected void checkThreadAccess(Thread t)
protected void checkThreadGroupAccess(ThreadGroup g)
public void checkExit(int status)
checkExit
in class SecurityManager
protected void checkTestExit(int status)
Copyright © 2015-2016. All Rights Reserved.