SK.gnome.dwarf.auth
Class CheckPermissionAction

java.lang.Object
  extended bySK.gnome.dwarf.auth.CheckPermissionAction
All Implemented Interfaces:
java.security.PrivilegedAction

public class CheckPermissionAction
extends java.lang.Object
implements java.security.PrivilegedAction

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

permission

protected final java.security.Permission permission
The checked permission.

Constructor Detail

CheckPermissionAction

public CheckPermissionAction(java.security.Permission permission)
Creates a new CheckPermissionAction.

Parameters:
permission - the permission
Method Detail

run

public java.lang.Object run()
Checks the permission.

The exact action of this method is:

 SecurityManager s = System.getSecurityManager();
 if (s != null)
   s.checkPermission(permission);
 return null;
 

Specified by:
run in interface java.security.PrivilegedAction


Copyright (c) 1999-2005, Gnome Ltd. All rights reserved.