• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.security.AccessControlException

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
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());
loginContext.login();
Subject.doAsPrivileged(loginContext.getSubject(),new PersonnelAction(),null);
loginContext.logout();

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)
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic