|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.SecurityManager sysModel.MBSSecurityManager
public class MBSSecurityManager
Special security manager that does not permit fish to call System.exit() or System.setSecurityManager().
Field Summary | |
---|---|
private MBSClassLoader |
_classLoader
Class loader. |
private java.lang.String |
_classPath
Class path. |
private java.lang.String[] |
_classPathDirs
Class path directories. |
private boolean |
_drJava
True if DrJava is present. |
private java.lang.ThreadGroup |
_fishThreadGroup
Fish thread group. |
private boolean |
_isProtected
Flag if actions are protected. |
private java.lang.String |
_pathSep
Path separator. |
private java.util.Stack<java.lang.Boolean> |
_protectionFlagStack
Stack of protection flags. |
private java.lang.SecurityManager |
_sm
SecurityManager to delegate to. |
Fields inherited from class java.lang.SecurityManager |
---|
inCheck |
Constructor Summary | |
---|---|
MBSSecurityManager(boolean drJava)
Constructor. |
Method Summary | |
---|---|
void |
checkAccess(java.lang.Thread t)
Throws a SecurityException if the calling thread is not allowed to modify the thread argument. |
void |
checkAccess(java.lang.ThreadGroup g)
Throws a SecurityException if the calling thread is not allowed to modify the thread group
argument. |
void |
checkExit(int status)
Throws a SecurityException if the calling thread is not allowed to cause the Java Virtual Machine to
halt with the specified status code. |
void |
checkPermission(java.security.Permission perm)
Throws a SecurityException if the requested access, specified by the given permission, is not
permitted based on the security policy currently in effect. |
java.lang.ClassLoader |
getClassLoader()
Return the class loader. |
java.lang.ThreadGroup |
getFishThreadGroup()
Get the thread group the fish are run in. |
protected boolean |
isFishCaller()
Returns true if a fish is somewhere on the call stack. |
protected boolean |
isOnClassPath(java.lang.String filename)
Returns true if the filename is on the class path. |
boolean |
isProtected()
Get the protection flag. |
void |
popProtected()
Pops the top protection flag from the stack and sets it as new value. |
void |
pushProtected(boolean isProtected)
Push the current protection flag onto the stack and set a new value. |
void |
setProtected(boolean isProtected)
Set the protection flag. |
Methods inherited from class java.lang.SecurityManager |
---|
checkAccept, checkAwtEventQueueAccess, checkConnect, checkConnect, checkCreateClassLoader, checkDelete, checkExec, checkLink, checkListen, checkMemberAccess, checkMulticast, checkMulticast, checkPackageAccess, checkPackageDefinition, checkPermission, checkPrintJobAccess, checkPropertiesAccess, checkPropertyAccess, checkRead, checkRead, checkRead, checkSecurityAccess, checkSetFactory, checkSystemClipboardAccess, checkTopLevelWindow, checkWrite, checkWrite, classDepth, classLoaderDepth, currentClassLoader, currentLoadedClass, getClassContext, getInCheck, getSecurityContext, getThreadGroup, inClass, inClassLoader |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private boolean _drJava
private boolean _isProtected
private java.lang.SecurityManager _sm
private java.lang.String _classPath
private java.lang.String _pathSep
private java.lang.String[] _classPathDirs
private java.lang.ThreadGroup _fishThreadGroup
private MBSClassLoader _classLoader
private java.util.Stack<java.lang.Boolean> _protectionFlagStack
Constructor Detail |
---|
public MBSSecurityManager(boolean drJava)
drJava
- true if DrJava is runningMethod Detail |
---|
public void setProtected(boolean isProtected)
isProtected
- true if actions are to be protectedpublic boolean isProtected()
public void pushProtected(boolean isProtected)
isProtected
- true if actions are to be protectedpublic void popProtected()
protected boolean isOnClassPath(java.lang.String filename)
filename
- filename to test
protected boolean isFishCaller()
public void checkPermission(java.security.Permission perm)
SecurityException
if the requested access, specified by the given permission, is not
permitted based on the security policy currently in effect.
This method calls AccessController.checkPermission
with the given permission.
checkPermission
in class java.lang.SecurityManager
perm
- the requested permission.
java.lang.SecurityException
- if access is not permitted based on the current security policy.
java.lang.NullPointerException
- if the permission argument is null
.public void checkAccess(java.lang.Thread t)
SecurityException
if the calling thread is not allowed to modify the thread argument.
This method is invoked for the current security manager by the stop
, suspend
,
resume
, setPriority
, setName
, and setDaemon
methods of class
Thread
.
If the thread argument is a system thread (belongs to the thread group with a null
parent) then this
method calls checkPermission
with the RuntimePermission("modifyThread")
permission. If
the thread argument is not a system thread, this method just returns silently.
Applications that want a stricter policy should override this method. If this method is overridden, the method
that overrides it should additionally check to see if the calling thread has the
RuntimePermission("modifyThread")
permission, and if so, return silently. This is to ensure that
code granted that permission (such as the SDK itself) is allowed to manipulate any thread.
If this method is overridden, then super.checkAccess
should be called by the first statement in the
overridden method, or the equivalent security check should be placed in the overridden method.
checkAccess
in class java.lang.SecurityManager
t
- the thread to be checked.
java.lang.SecurityException
- if the calling thread does not have permission to modify the thread.
java.lang.NullPointerException
- if the thread argument is null
.resume
,
setDaemon
,
setName
,
setPriority
,
stop
,
suspend
,
checkPermission
public void checkAccess(java.lang.ThreadGroup g)
SecurityException
if the calling thread is not allowed to modify the thread group
argument.
This method is invoked for the current security manager when a new child thread or child thread group is created,
and by the setDaemon
, setMaxPriority
, stop
, suspend
,
resume
, and destroy
methods of class ThreadGroup
.
If the thread group argument is the system thread group ( has a null
parent) then this method calls
checkPermission
with the RuntimePermission("modifyThreadGroup")
permission. If the
thread group argument is not the system thread group, this method just returns silently.
Applications that want a stricter policy should override this method. If this method is overridden, the method
that overrides it should additionally check to see if the calling thread has the
RuntimePermission("modifyThreadGroup")
permission, and if so, return silently. This is to ensure
that code granted that permission (such as the SDK itself) is allowed to manipulate any thread.
If this method is overridden, then super.checkAccess
should be called by the first statement in the
overridden method, or the equivalent security check should be placed in the overridden method.
checkAccess
in class java.lang.SecurityManager
g
- the thread group to be checked.
java.lang.SecurityException
- if the calling thread does not have permission to modify the thread group.
java.lang.NullPointerException
- if the thread group argument is null
.destroy
,
resume
,
setDaemon
,
setMaxPriority
,
stop
,
suspend
,
checkPermission
public void checkExit(int status)
SecurityException
if the calling thread is not allowed to cause the Java Virtual Machine to
halt with the specified status code.
This method is invoked for the current security manager by the exit
method of class
Runtime
. A status of 0
indicates success; other values indicate various errors.
This method calls checkPermission
with the RuntimePermission("exitVM")
permission.
If you override this method, then you should make a call to super.checkExit
at the point the
overridden method would normally throw an exception.
checkExit
in class java.lang.SecurityManager
status
- the exit status.
java.lang.SecurityException
- if the calling thread does not have permission to halt the Java Virtual Machine with
the specified status.exit
,
checkPermission
public java.lang.ThreadGroup getFishThreadGroup()
public java.lang.ClassLoader getClassLoader()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |