Class HooksContext
java.lang.Object
edu.internet2.middleware.grouper.hooks.beans.HooksContext
context in which hooks are running
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
hooks internal attribute key for grouper sessionstatic final String
hooks internal attribute key for grouper sessionstatic final String
if application, key in context for requeststatic final String
if application, key in context for responsestatic final String
if application, key in context for session -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionkeep track of grouper session subject if neededboolean
if we started one, we should stop itlook at all threadlocal attributes, and extract the names and values of the threadsafe ones.static void
assignSubjectActAs
(Subject subject) this will be a threadsafe attributestatic void
assignSubjectLoggedIn
(Subject subject) this will be a threadsafe attributekeys of attributes (all put together, global, threadlocal, localstatic void
clear out the threadlocal attributes at a point when everything should be clearif this is an asynchronous hook, the grouper session subject is passed from the other thread to this thread, this is that subject.getAttribute
(String key) get an attributeget the context in which the hooks are running, e.g.keep a unique id to keep the logs straightcurrent acting subject in app (if applicable), or just the current subjectcurrent user in the grouper session or null if none therecurrent user logged in to app (e.g.get the grouper session from the grouper session threadlocalboolean
if this context is asynchronousboolean
isSubjectActAsInGroup
(String groupName) see if the current act as subject is in a certain group.boolean
isSubjectFromGrouperSessionInGroup
(String groupName) see if the current subject in grouper session is in a certain group (e.g.static void
setAttributeThreadLocal
(String key, Object value, boolean okToCopyToNewThread) set a threadlocal attribute
-
Field Details
-
HOOKS_KEY_SUBJECT_LOGGED_IN
hooks internal attribute key for grouper session- See Also:
-
HOOKS_KEY_SUBJECT_ACT_AS
hooks internal attribute key for grouper session- See Also:
-
KEY_HTTP_SERVLET_RESPONSE
if application, key in context for response- See Also:
-
KEY_HTTP_SESSION
if application, key in context for session- See Also:
-
KEY_HTTP_SERVLET_REQUEST
if application, key in context for request- See Also:
-
-
Constructor Details
-
HooksContext
public HooksContext()constructor -
HooksContext
public HooksContext(boolean theAsynchronous, Map<String, Object> threadSafeAttributes, Subject theAsynchronousGrouperSessionSubject, String theAynchronousHookId) constructor- Parameters:
theAsynchronous
- true if this is in a new thread, false if notthreadSafeAttributes
- attributes from another thread if applicabletheAsynchronousGrouperSessionSubject
- if asynchronous, pass in who the grouper subject should betheAynchronousHookId
- if we are asynchronous, pass in what the hook id should be
-
-
Method Details
-
getSubjectLoggedIn
current user logged in to app (e.g. UI or WS)- Returns:
- the subject logged in (or null if not available)
-
getSubjectFromGrouperSession
current user in the grouper session or null if none there- Returns:
- the subject logged in (or null if not available)
-
getSubjectActAs
current acting subject in app (if applicable), or just the current subject- Returns:
- the subject acting as (or null if not available)
-
grouperSession
get the grouper session from the grouper session threadlocal- Returns:
- the grouper session (might be null)
-
getAsynchronousGrouperSessionSubject
if this is an asynchronous hook, the grouper session subject is passed from the other thread to this thread, this is that subject. note, you can call HooksContext.grouperSession() to start a session instead.- Returns:
- the subject
-
assignSubjectLoggedIn
this will be a threadsafe attribute- Parameters:
subject
- or null to clear
-
assignSubjectActAs
this will be a threadsafe attribute- Parameters:
subject
- or null to clear
-
isSubjectActAsInGroup
see if the current act as subject is in a certain group. Note, this group uuid will be stored in a cache. Also the result will be stored in a cache, it is not meant to hold too many items- Parameters:
groupName
-- Returns:
- true if in group, false if not in group, or if the subject is not available
-
isSubjectFromGrouperSessionInGroup
see if the current subject in grouper session is in a certain group (e.g. for authorization)- Parameters:
groupName
- fully qualified group name to check- Returns:
- true if the subject is in group, false if subject is null or not in group
-
_internal_threadSafeAttributes
look at all threadlocal attributes, and extract the names and values of the threadsafe ones. if the values are cloneable, then clone them- Returns:
- the map, never null
-
getGrouperContextType
get the context in which the hooks are running, e.g. UI, GSH, etc- Returns:
- the context
-
setAttributeThreadLocal
set a threadlocal attribute- Parameters:
key
-value
-okToCopyToNewThread
- if this should be set for hooks spawned in new thread
-
clearThreadLocal
public static void clearThreadLocal()clear out the threadlocal attributes at a point when everything should be clear -
attributeKeySet
keys of attributes (all put together, global, threadlocal, local- Returns:
- the key
-
getAttribute
get an attribute- Parameters:
key
-- Returns:
- the object or null if not found
-
isAsynchronous
public boolean isAsynchronous()if this context is asynchronous- Returns:
- the asynchronous
-
_internal_getAsynchronousGrouperSessionSubject
keep track of grouper session subject if needed- Returns:
- the asynchronousGrouperSessionSubject
-
_internal_isAsynchronousGrouperSessionStarted
public boolean _internal_isAsynchronousGrouperSessionStarted()if we started one, we should stop it- Returns:
- the asynchronousGrouperSessionStarted
-
getHookId
keep a unique id to keep the logs straight- Returns:
- the hookId
-