org.apache.jetspeed.security
Class JSSubject

java.lang.Object
  extended by org.apache.jetspeed.security.JSSubject
All Implemented Interfaces:
Serializable

public class JSSubject
extends Object
implements Serializable

See Also:
Serialized Form

Field Summary
private static long serialVersionUID
           
(package private) static ThreadLocal threadLocal
           
 
Constructor Summary
JSSubject()
           
 
Method Summary
static Object doAs(Subject subject1, PrivilegedAction action)
          Perform work as a particular Subject after setting subject reference in current thread
static Object doAs(Subject subject1, PrivilegedExceptionAction action)
          Perform work as a particular Subject after setting subject reference in current thread.
static Object doAsPrivileged(Subject subject1, PrivilegedAction action, AccessControlContext acc)
          Perform privileged work as a particular Subject after setting subject reference in current thread.
static Object doAsPrivileged(Subject subject, PrivilegedExceptionAction action, AccessControlContext acc)
          Perform privileged work as a particular Subject after setting subject reference in current thread.
static Subject getSubject(AccessControlContext acc)
          Get the Subject associated with the provided AccessControlContext fromn the current Thread or from the standard SUBJECT mechansim
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

threadLocal

static ThreadLocal threadLocal
Constructor Detail

JSSubject

public JSSubject()
Method Detail

getSubject

public static Subject getSubject(AccessControlContext acc)
Get the Subject associated with the provided AccessControlContext fromn the current Thread or from the standard SUBJECT mechansim

Parameters:
acc - the AccessControlContext from which to retrieve the Subject. Only used if current thread doesn't carry subject
Returns:
the Subject associated with the provided AccessControlContext, or null if no Subject is associated with the provided AccessControlContext.
Throws:
SecurityException - if the caller does not have permission to get the Subject.

NullPointerException - if the provided AccessControlContext is null.

doAs

public static Object doAs(Subject subject1,
                          PrivilegedAction action)
Perform work as a particular Subject after setting subject reference in current thread

Parameters:
subject - the Subject that the specified action will run as. This parameter may be null.

action - the code to be run as the specified Subject.

Returns:
the Object returned by the PrivilegedAction's run method.
Throws:
NullPointerException - if the PrivilegedAction is null.

SecurityException - if the caller does not have permission to invoke this method.

doAs

public static Object doAs(Subject subject1,
                          PrivilegedExceptionAction action)
                   throws PrivilegedActionException
Perform work as a particular Subject after setting subject reference in current thread.

Parameters:
subject - the Subject that the specified action will run as. This parameter may be null.

action - the code to be run as the specified Subject.

Returns:
the Object returned by the PrivilegedExceptionAction's run method.
Throws:
PrivilegedActionException - if the PrivilegedExceptionAction.run method throws a checked exception.

NullPointerException - if the specified PrivilegedExceptionAction is null.

SecurityException - if the caller does not have permission to invoke this method.

doAsPrivileged

public static Object doAsPrivileged(Subject subject1,
                                    PrivilegedAction action,
                                    AccessControlContext acc)
Perform privileged work as a particular Subject after setting subject reference in current thread.

Parameters:
subject - the Subject that the specified action will run as. This parameter may be null.

action - the code to be run as the specified Subject.

acc - the AccessControlContext to be tied to the specified subject and action.

Returns:
the Object returned by the PrivilegedAction's run method.
Throws:
NullPointerException - if the PrivilegedAction is null.

SecurityException - if the caller does not have permission to invoke this method.

doAsPrivileged

public static Object doAsPrivileged(Subject subject,
                                    PrivilegedExceptionAction action,
                                    AccessControlContext acc)
                             throws PrivilegedActionException
Perform privileged work as a particular Subject after setting subject reference in current thread.

Parameters:
subject - the Subject that the specified action will run as. This parameter may be null.

action - the code to be run as the specified Subject.

acc - the AccessControlContext to be tied to the specified subject and action.

Returns:
the Object returned by the PrivilegedExceptionAction's run method.
Throws:
PrivilegedActionException - if the PrivilegedExceptionAction.run method throws a checked exception.

NullPointerException - if the specified PrivilegedExceptionAction is null.

SecurityException - if the caller does not have permission to invoke this method.


Copyright © 1999-2007 Apache Software Foundation. All Rights Reserved.