com.sun.jini.tool
Class ProfilingSecurityManager

java.lang.Object
  extended by java.lang.SecurityManager
      extended by com.sun.jini.tool.ProfilingSecurityManager

public class ProfilingSecurityManager
extends SecurityManager

ProfilingSecurityManager is a Java security manager that profiles what resources an application accesses, and in what manner --- e.g., read, write, etc. It does not enforce a security policy, but rather produces a starting point for crafting one.

It extends java.lang.SecurityManager and overrides the two forms of the checkPermission() method. For each call to checkPermission(), ProfilingSecurityManager first guards against the condition that it itself induced the call to checkPermission(), which would result in unterminated recursion. If a call to checkPermission() resulted from a call outside ProfilingSecurityManager, the current context is examined and each class found therein is profiled as needing access to the java.security.Permission in question. Profiling is manifested as a writing to System.out a "grant" rule for each java.security.Permission requested on a per CodeBase basis. The implementation here does some very simple rule caching. If a rule has been seen previously, it is not output to System.out. The caching cannot prevent a security check, but it can reduce I/O during profiling.

Author:
Mark S. Petrovic

Field Summary
private  ArrayList<String> cacheList
           
private  String psmMsg
           
private  String thisClassName
           
private  String thisCodeSourceURLString
           
 
Fields inherited from class java.lang.SecurityManager
inCheck
 
Constructor Summary
ProfilingSecurityManager()
           
 
Method Summary
private  void buildRules(Permission permission, AccessControlContext ctx)
           
 void checkPermission(Permission permission)
           
 void checkPermission(Permission permission, Object context)
           
private  String formatRule(Permission permission, ProtectionDomain pd)
           
private  ProtectionDomain[] getProtectionDomains(AccessControlContext context)
           
private  boolean isCached(String candidate)
           
private  boolean isRecur(StackTraceElement[] st)
           
 String toString()
           
 
Methods inherited from class java.lang.SecurityManager
checkAccept, checkAccess, checkAccess, checkAwtEventQueueAccess, checkConnect, checkConnect, checkCreateClassLoader, checkDelete, checkExec, checkExit, checkLink, checkListen, checkMemberAccess, checkMulticast, checkMulticast, checkPackageAccess, checkPackageDefinition, 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, wait, wait, wait
 

Field Detail

thisClassName

private final String thisClassName

thisCodeSourceURLString

private final String thisCodeSourceURLString

psmMsg

private final String psmMsg
See Also:
Constant Field Values

cacheList

private final ArrayList<String> cacheList
Constructor Detail

ProfilingSecurityManager

public ProfilingSecurityManager()
Method Detail

checkPermission

public void checkPermission(Permission permission)
Overrides:
checkPermission in class SecurityManager

checkPermission

public void checkPermission(Permission permission,
                            Object context)
Overrides:
checkPermission in class SecurityManager

buildRules

private void buildRules(Permission permission,
                        AccessControlContext ctx)

isRecur

private boolean isRecur(StackTraceElement[] st)

getProtectionDomains

private ProtectionDomain[] getProtectionDomains(AccessControlContext context)
                                         throws IllegalStateException
Throws:
IllegalStateException

formatRule

private String formatRule(Permission permission,
                          ProtectionDomain pd)

isCached

private boolean isCached(String candidate)

toString

public String toString()
Overrides:
toString in class Object


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.