atg.security
Class ThreadSecurityManager

java.lang.Object
  extended by atg.security.ThreadSecurityManager

public class ThreadSecurityManager
extends java.lang.Object

Class used to manage the User object that is associated with the current thread.

See Also:
User

Field Summary
static java.lang.String CLASS_VERSION
           
 
Constructor Summary
ThreadSecurityManager()
           
 
Method Summary
static void clearThreadUser()
          Unbinds any existing User object from the current thread.
static User currentUser()
          Returns the User object associated with the current thread.
static java.lang.Object doAs(User pUser, Action pAction)
          Calls the run() method in a Runnable object, associating the given User object with the current thread.
static void setThreadUser(User user)
          Binds a new User object to the current thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Constructor Detail

ThreadSecurityManager

public ThreadSecurityManager()
Method Detail

doAs

public static java.lang.Object doAs(User pUser,
                                    Action pAction)
                             throws java.lang.Exception
Calls the run() method in a Runnable object, associating the given User object with the current thread.

Throws:
java.lang.Exception

currentUser

public static User currentUser()
Returns the User object associated with the current thread. If none has been specified, null is returned.


clearThreadUser

public static void clearThreadUser()
Unbinds any existing User object from the current thread. This is typically used in a "finally" block following a call to setThreadUser().

See Also:
setThreadUser(atg.security.User)

setThreadUser

public static void setThreadUser(User user)
Binds a new User object to the current thread. This will replace any existing binding. This is best used when ownership of the thread is intended to be permanent, however it may also be used within a "try" block with the corresponding "finally" block contains a call to clearThreadUser().

If you would like to temporarily assign an ID to a thread it may be better to use doAs() instead.

This call should be used sparingly, as it is possible to accidentally leave a user bound to the thread, perhaps leading to inadvertent use of the user's identity.

See Also:
doAs(atg.security.User, atg.security.Action), clearThreadUser()