Results 1 to 1 of 1
Thread: Java authorization problem
- 11-30-2010, 08:06 PM #1
Member
- Join Date
- Nov 2010
- Posts
- 1
- Rep Power
- 0
Java authorization problem
Greetings! I have a problem setting an authorization permission in an application
I tweaked a bit the files from the Java Authorization tutorial, found here:
JAAS Authorization Tutorial
What I want is to implement a permission rule on the SampleAzn class, I want a
particular user, namely admin, to be able to run the doAsPrivileged instruction within the SampleAzn code
SampleAzn code:
Subject mySubject = lc.getSubject();
// let's see what Principals we have
Iterator principalIterator = mySubject.getPrincipals().iterator();
System.out.println("Authenticated user has the following Principals:");
PrivilegedAction action = new usePrintServer( current_principal );
Subject.doAsPrivileged(mySubject, action, null);
the user admin, has been authenticated, and the next method to be executed is doAsPrivileged. admin is added as a principal in the Subject
Below, is the policy file I use, concerning the SampleAzn class
grant codebase "file:./SampleAzn.jar" {
permission javax.security.auth.AuthPermission "createLoginContext.Sample";
// permission javax.security.auth.AuthPermission "doAsPrivileged";
};
grant codebase "file:./SampleAzn.jar",
Principal sample.principal.SamplePrincipal "admin" {
permission javax.security.auth.AuthPermission "getSubject";
permission javax.security.auth.AuthPermission "createLoginContext.Sample";
permission javax.security.auth.AuthPermission "doAsPrivileged";
};
What I want, is to make admin the only principal who is able to execute the doAsPrivileged instruction. If I remove the // characters, the code runs file, since no authorization is applied on SampleAzn. But with the comments, the output is the following exception:
Authenticated user has the following Principals:
SamplePrincipal: admin
User has 0 Public Credential(s)
Exception in thread "main" java.security.AccessControlException: access denied (javax.security.auth.AuthPermission doAsPrivileged)
at java.security.AccessControlContext.checkPermission (AccessControlContext.java:323)
at java.security.AccessController.checkPermission(Acc essController.java:546)
at java.lang.SecurityManager.checkPermission(Security Manager.java:532)
at javax.security.auth.Subject.doAsPrivileged(Subject .java:439)
at sample.SampleAzn.main(SampleAzn.java:154)
What could be wrong? Is there a way to fix this, while the principal admin has exclusive execution rights??
Thanx for your time
Similar Threads
-
Java GUI problem
By theBurgh22 in forum AWT / SwingReplies: 5Last Post: 03-13-2012, 03:27 PM -
user authorization problem
By adammyth in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 03-17-2010, 09:56 PM -
Java problem help!
By wexgal in forum New To JavaReplies: 3Last Post: 10-26-2009, 12:52 PM -
urgent help -java mail authorization failed exception
By ravinder.kadiyan in forum Advanced JavaReplies: 2Last Post: 04-30-2008, 11:27 AM -
Problem in java
By saytri in forum New To JavaReplies: 6Last Post: 01-09-2008, 04:13 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks