wood burning stoves 2.0*
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
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: 41109
    
  45
Does it work if you specify the permissions file explicitly?


Ping & DNS - my free Android networking tools app
 
Don't get me started about those stupid light bulbs.
 
subject: A BIG Problem using java policy files
 
Similar Threads
Under Java Security Manager, accessing a file inside a jar
java.security. AccessControlException : access denied
Security Settings
Exception while adding folder to JBOSS_CLASSPATH
Problem with Sun's Bootstraping Example