• Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting codebase and permissions in java.policy file  RSS feed

 
Geraldine Premkumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Is "/web" really a top-level directory on your machine? That needs to be an absolute path in the grant statement.
 
Geraldine Premkumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!