This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Java in General and the fly likes A BIG Problem using java policy files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "A BIG Problem using java policy files" Watch "A BIG Problem using java policy files" New topic
Author

A BIG Problem using java policy files

Parth Mehta
Greenhorn

Joined: Mar 02, 2007
Posts: 7
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
Marshal

Joined: Mar 22, 2005
Posts: 41630
    
  55
Does it work if you specify the permissions file explicitly?


Ping & DNS - my free Android networking tools app
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: A BIG Problem using java policy files