wood burning stoves 2.0*
The moose likes Security and the fly likes java.security.AccessControlException  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 » Engineering » Security
Bookmark "java.security.AccessControlException  " Watch "java.security.AccessControlException  " New topic


Vaibhav Tomorrow

Joined: Jun 30, 2008
Posts: 6
I am trying to perform authorization and using jaas.policy file.
Can any one suggest what is wrong with the policy file.
it is placed in the same folder where code exists.
jaas.policy file:
grant Principal UserPrincipal "TestUser" {
permission PersonnelPermission "access";
The Client code is :
LoginContext loginContext = new LoginContext("Userpass",new MyCallbackHandler());
Subject.doAsPrivileged(loginContext.getSubject(),new PersonnelAction(),null);

PersonnelAction implements PrivilegedAction.
I am trying to check the access permission but getting the following error:

java.security.AccessControlException: Access denied (test.PersonnelPermission access)
at java.security.AccessController.checkPermission(AccessController.java:104)
at test.PersonnelAction.run(PersonnelAction.java:9)
at java.security.AccessController.doPrivileged(AccessController.java:215)
at javax.security.auth.Subject.doAs(Subject.java:495)
at test.Client.main(Client.java:17)
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41599
How are you specifying the policy file to be used? In won't get used just by virtue of being in the same directory as your code.

Ping & DNS - my free Android networking tools app
It is sorta covered in the JavaRanch Style Guide.
subject: java.security.AccessControlException