File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Setting codebase and permissions in java.policy file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Setting codebase and permissions in java.policy file" Watch "Setting codebase and permissions in java.policy file" New topic
Author

Setting codebase and permissions in java.policy file

Geraldine Premkumar
Greenhorn

Joined: May 01, 2006
Posts: 5
Hi,

I am new to javaranch and am not sure if this is the right place to post question on java2 policy files. If not please route it to the right forum.

I have restricted access to a pacakge in the ${java.home}/jre/lib/security/java.security file through
package.access = test.mypackage;

Now I want to grant access to the above package only to web.myfiles.jar which I did through the following entry in ${java.home}/jre/lib/security/java.policy

grant codeBase "file:///web/myfiles.jar" {
permission java.lang.RuntimePermission "accessClassInPackage.test.mypackage";
};

I run the following command

java -DenableJava2Security=true -Djava.security.manager Trialcode

where Trialcode is a class file in web/myfiles.jar.

TrialCode just calls a class in test.mypackage. I expect TrialCode to have the permission to do that but I get the
java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.test.mypackage).

What am I missing out here?

Thanks
Geraldine
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35220
    
    7
Welcome to JavaRanch.

Is "/web" really a top-level directory on your machine? That needs to be an absolute path in the grant statement.


Android appsImageJ pluginsJava web charts
Geraldine Premkumar
Greenhorn

Joined: May 01, 2006
Posts: 5
Hi

Thank you for your reply. web isnt the top level directory but I have included the absolute path from the top level as

"file:///home/user/web/myfiles.jar" in the grant statement and it still doesnt work.

Thanks
Geraldine
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Setting codebase and permissions in java.policy file
 
Similar Threads
Problems with security policies for Axis2 in Tomcat
createLoginContext.Userpass : access denied
Java 2 Security Problems
Denying system.exit in java code
Java2 Security Permissions