Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAAS Error

 
Nikhil Jain
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I created a sample JAAS application. When I execute the code I get
Exception in thread "main" java.security.AccessControlException: access denied (javax.security.auth.AuthPermission createLoginContext.chp02) error

I get this error when I call logincontextobject.Login();

Policy File:
grant Principal chp02.UserPrincipal "user"
{
// not granted anything
};
grant Principal chp02.SysAdminPrincipal "sysadmin"
{
permission java.io.FilePermission "conf/chp02.policy", "read";
};

Configuration File

chp02
{
chp02.auth.SimpleLoginModule REQUIRED;
};

Can someone help

Thanks
Shashank
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your post seems to contain the answer to your question already: the user running the application needs to have the "AuthPermission createLoginContext.chp02" permission.
 
Nikhil Jain
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do I give him the permission. I am using JAAS for the first time. I am doing a tutorial, which has not mentioned anything about this permission

javax.security.auth.AuthPermission

thanks

shashank
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably by adding a line like



to the "user" and "sysadmin" entries in the policy file. Once that works, other permissions may also be needed; have a look at the javadocs of the AuthPermission class for more detail.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic