java.security.AccessController Class Reference

List of all members.


Detailed Description

This class must be implemented by the vm vendor, or the reference implementation can be used if the documented native is implemented.

Checks access to system resources. Supports marking of code as priveleged. Makes context snapshots to allow checking from other contexts.

Static Public Member Functions

static void checkPermission (Permission perm) throws AccessControlException
 Checks whether the running program is allowed to access the resource being guarded by the given Permission argument.
static AccessControlContext getContext ()
 Answers the access controller context of the current thread, including the inherited ones.
static< T > T doPrivileged (PrivilegedAction< T > action)
 Performs the privileged action specified by action.
static< T > T doPrivileged (PrivilegedAction< T > action, AccessControlContext context)
 Performs the privileged action specified by action.
static< T > T doPrivileged (PrivilegedExceptionAction< T > action) throws PrivilegedActionException
 Performs the privileged action specified by action.
static< T > T doPrivileged (PrivilegedExceptionAction< T > action, AccessControlContext context) throws PrivilegedActionException
 Performs the privileged action specified by action.

Static Package Functions

 [static initializer]

Private Member Functions

 AccessController ()
 Prevents this class from being instantiated.

Static Private Member Functions

static native void initializeInternal ()
static native Object[] getProtectionDomains (int depth)
 This native must be implemented to use the reference implementation of this class.
static void keepalive (AccessControlContext context)
 Used to keep the context live during doPrivileged().
static ProtectionDomain[] toArrayOfProtectionDomains (Object[] domains, AccessControlContext acc)


Constructor & Destructor Documentation

java.security.AccessController.AccessController (  )  [private]

Prevents this class from being instantiated.


Member Function Documentation

static native Object [] java.security.AccessController.getProtectionDomains ( int  depth  )  [static, private]

This native must be implemented to use the reference implementation of this class.

It is used by checkPermission() and getContext(), which call this native with depth = 1.

Returns an array of ProtectionDomain from the classes on the stack, from the specified depth up to the first privileged frame, or the end of the stack if there is not a privileged frame. The array may be larger than required, but must be null terminated. As bootstrap classes have all permissions, bootstrap class frames SHOULD be skipped. Bootstrap class frames MUST be skipped if the ProtectionDomain of bootstrap classes is null. Duplicate ProtectionDomains SHOULD be removed.

The first element of the result is the AccessControlContext, which may be null, either from the privileged frame, or from the current Thread if there is not a privileged frame.

A privileged frame is any frame running one of the following methods:

Parameters:
depth The stack depth at which to start. Depth 0 is the current frame (the caller of this native).
Returns:
an Object[] where the first element is AccessControlContext, and the other elements are ProtectionsDomain.

static void java.security.AccessController.checkPermission ( Permission  perm  )  throws AccessControlException [static]

Checks whether the running program is allowed to access the resource being guarded by the given Permission argument.

Parameters:
perm the permission to check
Exceptions:
AccessControlException if access is not allowed.

static void java.security.AccessController.keepalive ( AccessControlContext  context  )  [static, private]

Used to keep the context live during doPrivileged().

See also:
doPrivileged(PrivilegedAction, AccessControlContext)

static AccessControlContext java.security.AccessController.getContext (  )  [static]

Answers the access controller context of the current thread, including the inherited ones.

It basically retrieves all the protection domains from the calling stack and creates an AccessControlContext with them.

Returns:
the access control context of the current thread
See also:
AccessControlContext

static <T> T java.security.AccessController.doPrivileged ( PrivilegedAction< T >  action  )  [static]

Performs the privileged action specified by action.

When permission checks are made, if the permission has been granted by all frames below and including the one representing the call to this method, then the permission is granted. In otherwords, the check stops here.

Any unchecked exception generated by this method will propagate up the chain.

Parameters:
action the action being performed
<T> the return type for the privileged action
Returns:
the result of evaluating the action
See also:
doPrivileged(PrivilegedAction)

static <T> T java.security.AccessController.doPrivileged ( PrivilegedAction< T >  action,
AccessControlContext  context 
) [static]

Performs the privileged action specified by action.

When permission checks are made, if the permission has been granted by all frames below and including the one representing the call to this method, then the permission is granted iff it is granted by the AccessControlContext context. In otherwords, no more checking of the current stack is performed. Instead, the passed in context is checked.

Any unchecked exception generated by this method will propagate up the chain.

Parameters:
action the action being performed
<T> the return type for the privileged action
context the context being checked for the privileged action
Returns:
the result of evaluating the action
See also:
doPrivileged(PrivilegedAction)

static <T> T java.security.AccessController.doPrivileged ( PrivilegedExceptionAction< T >  action  )  throws PrivilegedActionException [static]

Performs the privileged action specified by action.

When permission checks are made, if the permission has been granted by all frames below and including the one representing the call to this method, then the permission is granted. In otherwords, the check stops here.

Any unchecked exception generated by this method will propagate up the chain. However, checked exceptions will be caught an re-thrown as PrivilegedActionExceptions.

Parameters:
action the action being performed
<T> the return type for the privileged action
Returns:
the result of evaluating the action
Exceptions:
PrivilegedActionException if a checked exception was thrown
See also:
doPrivileged(PrivilegedAction)

static <T> T java.security.AccessController.doPrivileged ( PrivilegedExceptionAction< T >  action,
AccessControlContext  context 
) throws PrivilegedActionException [static]

Performs the privileged action specified by action.

When permission checks are made, if the permission has been granted by all frames below and including the one representing the call to this method, then the permission is granted iff it is granted by the AccessControlContext context. In otherwords, no more checking of the current stack is performed. Instead, the passed in context is checked.

Any unchecked exception generated by this method will propagate up the chain. However, checked exceptions will be caught an re-thrown as PrivilegedActionExceptions

Parameters:
action the action being performed
<T> the return type for the privileged action
context the context being checked for the privileged action
Returns:
the result of evaluating the action
Exceptions:
PrivilegedActionException if a checked exception was thrown
See also:
doPrivileged(PrivilegedAction)


The documentation for this class was generated from the following file:

Genereated on Tue Dec 9 14:09:48 2008 by Doxygen.

(c) Copyright 2005, 2008 The Apache Software Foundation or its licensors, as applicable.