|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object SK.gnome.dwarf.auth.CheckPermissionAction
Defines an action for checking the subject-based permissions.
Use this class to check the subject-based permissions:
// instantiate the permission Permission permission = new ServicePermissions("setLogger"); // instantiate the subject Subject subject = new Subject(); // let the subject represent any user running a service "MyService" subject.getPrincipals().add(EveryonePrincipal.INSTANCE); subject.getPrincipals().add(new ServicePrincipal("MyService")); // check whether the ServicePermission "setLogger" has been granted to everyone try { Subject.doAs(subject, new CheckPermissionAction(permission)); log(LOG_INFO, "Permission granted"); } catch (AccessControlException e) { log(LOG_INFO, "Permission not granted"); }
Field Summary | |
protected java.security.Permission |
permission
The checked permission. |
Constructor Summary | |
CheckPermissionAction(java.security.Permission permission)
Creates a new CheckPermissionAction. |
Method Summary | |
java.lang.Object |
run()
Checks the permission. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final java.security.Permission permission
Constructor Detail |
public CheckPermissionAction(java.security.Permission permission)
permission
- the permissionMethod Detail |
public java.lang.Object run()
The exact action of this method is:
SecurityManager s = System.getSecurityManager(); if (s != null) s.checkPermission(permission); return null;
run
in interface java.security.PrivilegedAction
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |