|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.SecurityManager | +--edu.rice.cs.util.PreventExitSecurityManager
A security manager to prevent exiting the VM indiscriminately.
This manager disallows System.exit (unless you call exitVM(int)
).
It also disallows setting a security manager, since this would override
the exit prevention!
If this security manager is enabled and an exit is attempted,
either via System.exit or via exitVM(int)
when exiting is blocked,
a ExitingNotAllowedException
will be thrown.
Field Summary | |
private boolean |
_blockExit
Are we in exit blocking mode? |
private boolean |
_exitAttempted
Has an unauthorized exit been attempted? |
private SecurityManager |
_parent
|
private boolean |
_timeToDeactivate
Is it time to unset this security manager? |
private boolean |
_timeToExit
Is it time to exit, for real? |
private static Permission |
SET_MANAGER_PERM
|
Constructor Summary | |
private |
PreventExitSecurityManager(SecurityManager parent)
Creates a PreventExitSecurityManager, delegating all permission checks except for exiting to the given parent manager. |
Method Summary | |
static PreventExitSecurityManager |
activate()
Creates a new exit-preventing security manager, using the previous security manager to delegate to. |
void |
checkExit(int status)
|
void |
checkPermission(Permission perm)
Disallow setting security manager, but otherwise delegate to parent. |
void |
deactivate()
Removes this security manager. |
boolean |
exitAttempted()
Returns whether a System.exit was attempted since the last time this method was called. |
void |
exitVM(int status)
Exits the VM unless exiting is presently blocked. |
void |
setBlockExit(boolean b)
Sets whether exiting the VM is unconditionally blocked or not. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
Field Detail |
private static final Permission SET_MANAGER_PERM
private final SecurityManager _parent
private boolean _exitAttempted
private boolean _timeToExit
private boolean _blockExit
private boolean _timeToDeactivate
Constructor Detail |
private PreventExitSecurityManager(SecurityManager parent)
parent
- SecurityManager to delegate permission to
This may be null, signifying to allow all.Method Detail |
public static PreventExitSecurityManager activate()
public void deactivate()
public void exitVM(int status)
public void setBlockExit(boolean b)
b
- If true, exiting will never be allowed until set false.public boolean exitAttempted()
public void checkPermission(Permission perm)
checkPermission
in class SecurityManager
public void checkExit(int status)
checkExit
in class SecurityManager
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |