org.hippoecm.hst.security
Class HstSubject

java.lang.Object
  extended by org.hippoecm.hst.security.HstSubject

public class HstSubject
extends Object

Wrapper for the javax.security.auth.Subject class. Due to a design oversight in JAAS 1.0, the javax.security.auth.Subject.getSubject method does not return the Subject that is associated with the running thread !inside! a java.security.AccessController.doPrivileged code block. As a result, the current subject cannot be determined correctly. This class uses the ThreadLocal mechanism to carry the thread-specific instance of the subject

Version:
$Id$

Method Summary
static void clearSubject()
          Clear subject reference in current thread.
static
<T> T
doAs(Subject subjectInput, PrivilegedAction<T> action)
          Perform work as a particular Subject after setting subject reference in current thread
static
<T> T
doAs(Subject subjectInput, PrivilegedExceptionAction<T> action)
          Perform work as a particular Subject after setting subject reference in current thread.
static
<T> T
doAsPrivileged(Subject subjectInput, PrivilegedAction<T> action, AccessControlContext acc)
          Perform privileged work as a particular Subject after setting subject reference in current thread.
static
<T> T
doAsPrivileged(Subject subjectInput, PrivilegedExceptionAction<T> 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
 

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


doAs

public static <T> T doAs(Subject subjectInput,
                         PrivilegedAction<T> action)
Perform work as a particular Subject after setting subject reference in current thread


doAs

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

Throws:
PrivilegedActionException

doAsPrivileged

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


doAsPrivileged

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

Throws:
PrivilegedActionException

clearSubject

public static void clearSubject()
Clear subject reference in current thread.



Copyright © 2008-2012 Hippo. All Rights Reserved.