File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Security and the fly likes Loading different policy files in runtime for Java SecurityManager Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Security
Bookmark "Loading different policy files in runtime for Java SecurityManager" Watch "Loading different policy files in runtime for Java SecurityManager" New topic
Author

Loading different policy files in runtime for Java SecurityManager

chaam Mangaleswaran
Greenhorn

Joined: Sep 14, 2012
Posts: 1
Hi,
I am trying to load different policy file during run time. I am trying to have different policy files for different users in my system. Hence I'm checking their ID and with the ID Key I'm trying to set a policy file ( something like policy.url.ID) I am trying to set the policy URLs using the method System.setProperty("java.security.policy",url). But I don't have the privilege to do so(I'm getting java.security.AccessControlException )
When I set the policy URLs are set I was trying to set the policy file using Policy.setPolicy(Policy p ) I want to know where I went wrong and what will be the best way to set java policy files in run time ?
Richard Tookey
Ranch Hand

Joined: Aug 27, 2012
Posts: 963
    
  10

Consider the security implications if a Java program could define which policy file should be used. If the new policy file is tighter than the original then nothing would change; the program could still do anything that the original policy file allowed. If the new policy file is more relaxed that the original then it would allow the Java program to do things that it the system manager did not want to allow. This would make nonsense of having a policy file in the first place..
Rishi Shah
Ranch Hand

Joined: Sep 05, 2012
Posts: 43

Implement a custom SecurityManager based on your needs. Even if this were possible with policy files (which it's not), that method would be more inflexible and be more of a hassle.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Loading different policy files in runtime for Java SecurityManager
 
Similar Threads
java.security file policy setting not working...
classpath/ Assertions
Class file not being made
policy file
singed applets (are policy files needed)