ProtectionDomain in java

In Java.lang.Class there is a method called getProtectionDomain() . Where can we usethis method? give me one example ofProtectionDomain in java
[164 byte] By [Pandiana] at [2007-10-3 6:54:36]
# 1

The relevance of the ProtectionDomain is in conjunction with an active SecurityManager. Basically classes loaded by the same classloader from the same code source (e.g. jar file) have the same ProtectionDomain and are controlled by the same set of permissions, usually from the policy file.

Usually, even with a SecurityManager, it all happens automatically and you don't need to access the ProtectionDomain.

One, occasionally useful feature is that getProtectionDomain().getCodeSource().getLocation() will give you the URL of the source from which a particular class was loaded. For example I use it to get the jar file of my program so as to record the jar's modified date and, hence, identify the version on logging.

malcolmmca at 2007-7-15 1:46:11 > top of Java-index,Java Essentials,Java Programming...