Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A BIG Problem using java policy files

 
Parth Mehta
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone, I have some trouble using policy files, which I hope someone might help me with. Here is all the information you need:-

1) I am trying to build a small program to test JMX security(probably not important, but mentioned anyway )

2) I have a policy file "server.policy" in the SAME directory as my Server.class file which has the "main" method".

3) I have this entry in the policy file:
grant codeBase "file:C:/xyz/*" {
permission javax.management.MBeanServerPermission "createMBeanServer";
};
The whole directory is C:\xyz\Server.class (Windows XP machine)

4) I have made entry into java.security for the path of this file so that i dont have to explicitly point to it during running of my program everytime.
using policy.url.3=file:C:/xyz/server.policy"

5) When I run the java program with security manaber enabled, and that too in debug mode, My java program is NOT given the permission, even though it is shown that server.policy is actually used by the security manager successfully. One of the messages I get is this :-
-------------------------------------------------
policy: evaluate codesources:
Policy CodeSource: (file:/C:/xyz/* <no signer certificates>
-------------------------------------------------
The after many others, it throws me the following stack trace:

java.security.AccessControlException: access denied (javax.management.MBeanServerPermission createMBeanServer)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
at java.security.AccessController.checkPermission(AccessController.java:427)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at javax.management.MBeanServerFactory.checkPermission(MBeanServerFactory.java:412)
at javax.management.MBeanServerFactory.createMBeanServer(MBeanServerFactory.java:217)
at javax.management.MBeanServerFactory.createMBeanServer(MBeanServerFactory.java:180)
at server.Server.main(Server.java:37)

I really dont know what I am doing wrong.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does it work if you specify the permissions file explicitly?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic