net.drijf.javaone
Class StrictSecurityManager

java.lang.Object
  |
  +--java.lang.SecurityManager
        |
        +--net.drijf.javaone.StrictSecurityManager

public class StrictSecurityManager
extends java.lang.SecurityManager

This class implements a more strict Security manager than the standard SecurityManager. In particular, it:

The last two checks even fail if the protection domain implies AllPermissions. While this is not according to specification of Sun, it gives some hints on how a policy could be defined that allows for subtractive permissions.

Author:
Otto Moerbeek

Fields inherited from class java.lang.SecurityManager
inCheck
 
Constructor Summary
StrictSecurityManager()
           
 
Method Summary
 void checkAccess(java.lang.ThreadGroup g)
          Check access to the ThreadGroup.
 void checkExit(int code)
          Prevent access to System.exit(), even if AllPermission has been granted.
 void checkPermission(java.security.Permission perm)
          Check if setting the security manager is allowed.
protected  void checkTrusted(java.lang.String className)
          Check is we trust the class with the given name.
 
Methods inherited from class java.lang.SecurityManager
checkAccept, checkAccess, 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
 

Constructor Detail

StrictSecurityManager

public StrictSecurityManager()
Method Detail

checkAccess

public void checkAccess(java.lang.ThreadGroup g)
Check access to the ThreadGroup. The standard security manager allows creation of threads outside the system thread group. This method disallows thread creation in any group unless modifyThreadGroup permission has been granted.
Overrides:
checkAccess in class java.lang.SecurityManager
Parameters:
g - the thread group to check access to.

checkExit

public void checkExit(int code)
Prevent access to System.exit(), even if AllPermission has been granted. The only case that is allowed shutdown: all code on the stack is found to be OK by checkTrusted
Overrides:
checkExit in class java.lang.SecurityManager
See Also:
checkTrusted(java.lang.String)

checkTrusted

protected void checkTrusted(java.lang.String className)
Check is we trust the class with the given name.
Parameters:
className - the name of the class to check.

checkPermission

public void checkPermission(java.security.Permission perm)
Check if setting the security manager is allowed. The check is implemented by this general method, because there is no separate method for checking "setSecurityManagerPermission".
Overrides:
checkPermission in class java.lang.SecurityManager