On this significance of a ProtectionDomain with a null CodeSource

Good day.

I am putting the finishing touches on a custom security manager that profiles an application's security needs at runtime

http://www.petrovic.org/content/SecMgrTutorial/sm.html

In short, the custom security manager extends java.lang.SecurityManager and overrides the two checkPermission() methods. In those overridden methods, I examine the AccessControlContext for purposes of building a "grant" rule in the generated policy file.

Occasionally I will find in the list of ProtectionDomains therein a ProtectionDomain whose CodeSource is null, a possibility pointed out in the Javadoc for ProtectionDomain.getCodeSource().

As I wrap this work up, my only question is under what conditions would a ProtectionDomain have a null CodeSource? I suspect this case represents a jvm system class of some sort, but that's just a guess. Printing the toString() form of a ProtectionDomain sheds no light on the question, so I'm sort of left guessing.

Can someone comment on this?

Thanks.

[1036 byte] By [msp1960ADa] at [2007-10-3 10:33:09]
# 1
I think classes loaded by the system class loader have no codesource.
ejpa at 2007-7-15 5:56:15 > top of Java-index,Security,Other Security APIs, Tools, and Issues...
# 2

Thank you, ejp (Mr. Pitt?).

I have only seen a ProtectionDomain with a null CodeSource once in my studies: when I start Tomcat with the ProfilingSecurityManager as I outline in my tutorial. I've used the method with other complex platforms (JXTA, Jetty), but I've not seen null CodeSources during those experiences. Which is neither here nor there, but just an observation.

When Tomcat initializes the JMX server during its startup, the java.lang.SecurityManager.checkPermission(Permission, AccessControlContext) method is called, and the codesource of one of the associated ProtectionDomains in the AccessControlContext is null. I can't tell which ProtectionDomain has the null codesource, because, humorously enough, the codesource identifies the very thing I'm looking to discover.

Thanks for the feedback.

msp1960ADa at 2007-7-15 5:56:15 > top of Java-index,Security,Other Security APIs, Tools, and Issues...