I am designing a JAAS authentication and authorisation application.In the authentication part,the username and password entered by the user is matched against the values retrieved from the database.There are three principals for each user(username,password,position).Upon successful authentication the principals are added to the subject.This part is working fine.
The problem lies in the authorisation part(when I set the SecurityManager),where depending upon the position (either manager or employee) permissions are granted.
The policy file is
grant codebase "/home/esamsar/NetBeansProjects/JAAS/*"
{
permission javax.security.auth.AuthPermission "createLoginContext.Sample";
permission javax.security.auth.AuthPermission "doAsPrivileged";
}
grant Principal PositionPrincipal "manager"
{
permission java.util.PropertyPermission "java.home", "read";
permission java.util.PropertyPermission "user.home", "read,write";
permission java.io.FilePermission "topsecurity.txt", "read";
};
grant Principal PositionPrincipal "employee"
{
permission java.util.PropertyPermission "java.home", "read";
permission java.util.PropertyPermission "user.home", "read,write";
};
Upon adding the following lines of code I encounter "Cannot create LoginContext. access denied ("java.util.PropertyPermission" "java.security.auth.login.config" "write")"
System.setSecurityManager(new SecurityManager());
System.setProperty("java.security.auth.login.config", configFile);
System.setProperty( "java.security.policy", policyFile );
configFile and policyFile are the jaas configuration file and policy file respectively. What could I add to my policy file to resolve the problem.Thank in advance.