org.benow.security.user
Class SubjectThread

java.lang.Object
  extended by org.benow.java.run.RestartableRunner
      extended by org.benow.security.user.SubjectThread
All Implemented Interfaces:
java.lang.Runnable

Deprecated. use securethread

@Deprecated
public class SubjectThread
extends org.benow.java.run.RestartableRunner

A SubjectThread is a BaseThread which executes PrivilegedActions via calls to doAs(Principal, PriviligedAction). The actions may then call Subject.assertPermission(Permission) (which calls SubjectThread.assertPermission(Permission)) to verify that the Pricipal which is associated with the current executing action has a specified permission.

This may seem to be a bit backwards, but the separation of SubjectThread and Subject is required for pooling purposes. The performance overhead due to user->action association is lessened due to this pooling, at the expense of memory usage.

Note: This thread is synchronized and can only handle one doAs() at a time. Pending doAs() calls will be blocked.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.benow.java.run.RestartableRunner
org.benow.java.run.RestartableRunner.LoopWatcher
 
Field Summary
 
Fields inherited from class org.benow.java.run.RestartableRunner
loopWatcher, running
 
Constructor Summary
SubjectThread()
          Deprecated.  
SubjectThread(User user, org.benow.java.run.MessyRunnable action)
          Deprecated.  
 
Method Summary
static void assertPermission(Permission perm)
          Deprecated. Asserts the given permission on the current associated user.
protected  java.lang.Thread createThread()
          Deprecated. Override default thread with thread which has reference to this SubjectThread (which is actually not a thread, but a runnable...).
static SubjectThread currentThread()
          Deprecated.  
 void doAs(User user, org.benow.java.run.MessyRunnable action)
          Deprecated. Performs the given action as the given principal (Subject, User, Principal, etc).
 java.lang.Object doAs(User user, org.benow.java.run.MessyRunnable action, SubjectThreadListener listener)
          Deprecated.  
 java.lang.Object exec()
          Deprecated.  
static User getCurrentUser()
          Deprecated.  
 User getUser()
          Deprecated.  
static boolean hasPermission(Permission perm)
          Deprecated.  
 boolean runBody()
          Deprecated.  
 
Methods inherited from class org.benow.java.run.RestartableRunner
die, disableRestartProtection, enableRestartProtect, getName, getThread, onRestartAbort, restart, restartBody, run, runInit, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubjectThread

public SubjectThread(User user,
                     org.benow.java.run.MessyRunnable action)
Deprecated. 

SubjectThread

public SubjectThread()
Deprecated. 
Method Detail

doAs

public void doAs(User user,
                 org.benow.java.run.MessyRunnable action)
          throws java.lang.Throwable
Deprecated. 
Performs the given action as the given principal (Subject, User, Principal, etc).

Parameters:
user -
action -
Throws:
java.lang.Exception
java.lang.Throwable

getUser

public User getUser()
Deprecated. 
Returns:
user this thread is active as

exec

public java.lang.Object exec()
                      throws java.lang.Throwable
Deprecated. 
Throws:
java.lang.Throwable

doAs

public java.lang.Object doAs(User user,
                             org.benow.java.run.MessyRunnable action,
                             SubjectThreadListener listener)
                      throws java.lang.Throwable
Deprecated. 
Throws:
java.lang.Throwable

currentThread

public static SubjectThread currentThread()
Deprecated. 

assertPermission

public static void assertPermission(Permission perm)
Deprecated. 
Asserts the given permission on the current associated user. In order to associate a user with the invocation, wrap the protected code in a PrivilegedAction and execute via the doAs(User, PrivilegedAction) method. If the code is not running in a privileged action (ie there is no user associated with execution) a warning is issued and the user is assumed to be the Adminitrator user. Otherwise, the given permission is asserted on the user as whom the code is executing.

In other words, it is safe to call this method even when a runtime user has not been specified.

Parameters:
perm - permission to assert

createThread

protected java.lang.Thread createThread()
Deprecated. 
Override default thread with thread which has reference to this SubjectThread (which is actually not a thread, but a runnable...).

Overrides:
createThread in class org.benow.java.run.RestartableRunner
Returns:
new subject thread

runBody

public final boolean runBody()
Deprecated. 
Specified by:
runBody in class org.benow.java.run.RestartableRunner

getCurrentUser

public static User getCurrentUser()
Deprecated. 

hasPermission

public static boolean hasPermission(Permission perm)
Deprecated.