This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one 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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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: 41591
    
  55
Does it work if you specify the permissions file explicitly?


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A BIG Problem using java policy files