Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

java.security
Class AccessController  view AccessController download AccessController.java

java.lang.Object
  extended byjava.security.AccessController

public final class AccessController
extends java.lang.Object

Access control context and permission checker. Can check permissions in the access control context of the current thread through the checkPermission() method. Manipulates the access control context for code that needs to be executed the protection domain of the calling class (by explicitly ignoring the context of the calling code) in the doPrivileged() methods. And provides a getContext() method which gives the access control context of the current thread that can be used for checking permissions at a later time and/or in another thread.

Since:
1.2

Constructor Summary
private AccessController()
          This class only has static methods so there is no public contructor.
 
Method Summary
static void checkPermission(Permission perm)
          Checks wether the access control context of the current thread allows the given Permission.
static java.lang.Object doPrivileged(PrivilegedAction action)
          Calls the run() method of the given action with as (initial) access control context only the protection domain of the calling class.
static java.lang.Object doPrivileged(PrivilegedAction action, AccessControlContext context)
          Calls the run() method of the given action with as (initial) access control context the given context combined with the protection domain of the calling class.
static java.lang.Object doPrivileged(PrivilegedExceptionAction action)
          Calls the run() method of the given action with as (initial) access control context only the protection domain of the calling class.
static java.lang.Object doPrivileged(PrivilegedExceptionAction action, AccessControlContext context)
          Calls the run() method of the given action with as (initial) access control context the given context combined with the protection domain of the calling class.
static AccessControlContext getContext()
          Returns the complete access control context of the current thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccessController

private AccessController()
This class only has static methods so there is no public contructor.

Method Detail

checkPermission

public static void checkPermission(Permission perm)
                            throws AccessControlException
Checks wether the access control context of the current thread allows the given Permission. Throws an AccessControlException when the permission is not allowed in the current context. Otherwise returns silently without throwing an exception.


doPrivileged

public static java.lang.Object doPrivileged(PrivilegedAction action)
Calls the run() method of the given action with as (initial) access control context only the protection domain of the calling class. Calls to checkPermission() in the run() method ignore all earlier protection domains of classes in the call chain. Note that the protection domains of classes called by the code in the run() method are not ignored.


doPrivileged

public static java.lang.Object doPrivileged(PrivilegedAction action,
                                            AccessControlContext context)
Calls the run() method of the given action with as (initial) access control context the given context combined with the protection domain of the calling class. Calls to checkPermission() in the run() method ignore all earlier protection domains of classes in the call chain, but add checks for the protection domains given in the supplied context.


doPrivileged

public static java.lang.Object doPrivileged(PrivilegedExceptionAction action)
                                     throws PrivilegedActionException
Calls the run() method of the given action with as (initial) access control context only the protection domain of the calling class. Calls to checkPermission() in the run() method ignore all earlier protection domains of classes in the call chain. Note that the protection domains of classes called by the code in the run() method are not ignored. If the run() method throws an exception then this method will wrap that exception in an PrivilegedActionException.


doPrivileged

public static java.lang.Object doPrivileged(PrivilegedExceptionAction action,
                                            AccessControlContext context)
                                     throws PrivilegedActionException
Calls the run() method of the given action with as (initial) access control context the given context combined with the protection domain of the calling class. Calls to checkPermission() in the run() method ignore all earlier protection domains of classes in the call chain, but add checks for the protection domains given in the supplied context. If the run() method throws an exception then this method will wrap that exception in an PrivilegedActionException.


getContext

public static AccessControlContext getContext()
Returns the complete access control context of the current thread. The returned object encompasses all ProtectionDomain objects for all classes in the current call stack, or the set of protection domains until the last call to doPrivileged(java.security.PrivilegedAction) 55 .

Additionally, if a call was made to doPrivileged(java.security.PrivilegedAction,java.security.AccessControlContext) 55 that supplied an AccessControlContext, then that context will be intersected with the calculated one.