Package edu.internet2.middleware.grouper
Class GrouperSession
java.lang.Object
edu.internet2.middleware.grouper.GrouperSession
- All Implemented Interfaces:
Serializable
Context for interacting with the Grouper API and Groups Registry.
- Version:
- $Id: GrouperSession.java,v 1.101 2009-11-05 20:06:42 isgwb Exp $
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectcallbackGrouperSession(GrouperSession grouperSession, GrouperSessionHandler grouperSessionHandler) call this to send a callback for the grouper session object. cant use inverse of control for this since it runs it.static voidcallbackGrouperSessionBySubjectId(String subjectId, String sourceId, GrouperSessionHandler grouperSessionHandler) get the subject by root session, then callback in a session for that subjectstatic voidclear the threadlocal grouper sessions (dont really need to call this, just stop the session, but this is here for testing)protected voidfinalize()Get name of class implentingAccessAdapterprivilege interface.Get name of class implentingAccessAdapterprivilege interface.Get theMemberassociated with this API session.Get name of class implentingNamingAdapterprivilege interface.Get this session's id.Get this session's start time.longGet theSubjectassociated with this API session.Get theSubjectassociated with this API session.getUuid()static Objectinternal_callbackRootGrouperSession(boolean runAsRoot, GrouperSessionHandler grouperSessionHandler) call this to send a callback for the root grouper session object.static Objectinternal_callbackRootGrouperSession(GrouperSessionHandler grouperSessionHandler) call this to send a callback for the root grouper session object.static GrouperSessionbooleanif we should take into consideration that we are a wheel member (or act as self if false)voidsetConsiderIfWheelMember(boolean considerIfWheelMember1) if we should take into consideration that we are a wheel member (or act as self if false)voidsetMemberUuid(String memberUUID1) voidsetStartTimeLong(long startTime1) voidsetSubject(Subject subject1) voidstatic GrouperSessionStart a session for interacting with the Grouper API.static GrouperSessionStart a session for interacting with the Grouper API.static GrouperSessionStart a session for interacting with the Grouper API.static GrouperSessionstartBySubjectIdAndSource(String subjectId, String sourceId) start a session based on a sourceId and subjectIdstatic GrouperSessionstartBySubjectIdAndSource(String subjectId, String sourceId, boolean addToThreadLocal) start a session based on a sourceId and subjectIdstatic GrouperSessionstartBySubjectIdentifierAndSource(String subjectIdentifier, String sourceId) start a session based on a sourceId and subjectIdstatic GrouperSessionstartBySubjectIdentifierAndSource(String subjectIdentifier, String sourceId, boolean addToThreadLocal) start a session based on a sourceId and subjectIdstatic GrouperSessionResultstartIfNotStarted(Subject subject) Start a session for interacting with the Grouper API.static GrouperSessionStart a session for interacting with the Grouper API.static GrouperSessionstartRootSession(boolean addToThreadLocal) Start a session for interacting with the Grouper API.static GrouperSessionstartRootSession(boolean addToThreadLocal, boolean addToCurrentSession) Start a session for interacting with the Grouper API.static GrouperSessionResultStart a root session for interacting with the Grouper API.static GrouperSessionget the threadlocal grouper session. access this through inverse of control.static GrouperSessionstaticGrouperSession(boolean exceptionOnNull) get the threadlocal grouper session. access this through inverse of control.voidstop()Stop this API session.static voidstopQuietly(GrouperSession session) stop a session quietlytoString()voidvalidate()static void
-
Constructor Details
-
GrouperSession
public GrouperSession()Default constructor. Dont call this, use the factory: start(Subject)- Since:
- 1.2.0
-
-
Method Details
-
finalize
-
isConsiderIfWheelMember
public boolean isConsiderIfWheelMember()if we should take into consideration that we are a wheel member (or act as self if false)- Returns:
- if considering if wheel member
-
setConsiderIfWheelMember
public void setConsiderIfWheelMember(boolean considerIfWheelMember1) if we should take into consideration that we are a wheel member (or act as self if false)- Parameters:
considerIfWheelMember1-
-
internal_testingGetCurrentSession
-
stopQuietly
stop a session quietly- Parameters:
session-
-
startBySubjectIdAndSource
start a session based on a sourceId and subjectId- Parameters:
sourceId- if null search all sourcessubjectId-- Returns:
- return the GrouperSession
-
startBySubjectIdAndSource
public static GrouperSession startBySubjectIdAndSource(String subjectId, String sourceId, boolean addToThreadLocal) start a session based on a sourceId and subjectId- Parameters:
sourceId- if null search all sourcessubjectId-addToThreadLocal- true if it should be in threadlocal, false if not- Returns:
- return the GrouperSession
-
startBySubjectIdentifierAndSource
public static GrouperSession startBySubjectIdentifierAndSource(String subjectIdentifier, String sourceId) start a session based on a sourceId and subjectId- Parameters:
sourceId- if null search all sourcessubjectIdentifier-- Returns:
- return the GrouperSession
-
startBySubjectIdentifierAndSource
public static GrouperSession startBySubjectIdentifierAndSource(String subjectIdentifier, String sourceId, boolean addToThreadLocal) start a session based on a sourceId and subjectId- Parameters:
subjectIdentifier-sourceId- if null search all sourcesaddToThreadLocal-- Returns:
- return the GrouperSession
-
start
Start a session for interacting with the Grouper API. This adds the session to the threadlocal. This has threadlocal implications, so start and stop these hierarchically, do not alternate. If you need to, use the callback inverse of control.// Start a Grouper API session. GrouperSession s = GrouperSession.subject);
- Parameters:
subject- Start session as thisSubject.- Returns:
- A Grouper API session.
- Throws:
SessionException
-
startIfNotStarted
Start a session for interacting with the Grouper API. This adds the session to the threadlocal. This has threadlocal implications, so start and stop these hierarchically, do not alternate. If you need to, use the callback inverse of control. This will not start a session if it is already started. If it is started as a different user, it will start// Start a Grouper API session. GrouperSession s = GrouperSession.subject);
- Parameters:
subject- Start session as thisSubject.- Returns:
- A Grouper API session.
- Throws:
SessionException
-
startRootSession
Start a session for interacting with the Grouper API. This adds the session to the threadlocal. This has threadlocal implications, so start and stop these hierarchically, do not alternate. If you need to, use the callback inverse of control. This uses// Start a Grouper API session. GrouperSession s = GrouperSession.start(subject);
- Parameters:
addToThreadLocal- true to add this to the grouper session threadlocal which replaces the current one- Returns:
- A Grouper API session.
- Throws:
SessionException
-
startRootSession
public static GrouperSession startRootSession(boolean addToThreadLocal, boolean addToCurrentSession) throws SessionException Start a session for interacting with the Grouper API. This adds the session to the threadlocal. This has threadlocal implications, so start and stop these hierarchically, do not alternate. If you need to, use the callback inverse of control. This uses// Start a Grouper API session. GrouperSession s = GrouperSession.start(subject);
- Parameters:
addToThreadLocal- true to add this to the grouper session threadlocal which replaces the current oneaddToCurrentSession- if the current threadlocal session is set so the session is not garbage collected- Returns:
- A Grouper API session.
- Throws:
SessionException
-
startRootSession
Start a session for interacting with the Grouper API. This adds the session to the threadlocal. This has threadlocal implications, so start and stop these hierarchically, do not alternate. If you need to, use the callback inverse of control. This uses// Start a Grouper API session. GrouperSession s = GrouperSession.start(subject);
- Returns:
- A Grouper API session.
- Throws:
SessionException
-
start
public static GrouperSession start(Subject subject, boolean addToThreadLocal) throws SessionException Start a session for interacting with the Grouper API. This has threadlocal implications, so start and stop these hierarchically, do not alternate. If you need to, use the callback inverse of control.// Start a Grouper API session. GrouperSession s = GrouperSession.start(subject);
- Parameters:
subject- Start session as thisSubject.addToThreadLocal- true to add this to the grouper session threadlocal which replaces the current one. Though if in the context of a callback, the callback has precedence, and you should use an inner callback to preempt it (callbackGrouperSession)- Returns:
- A Grouper API session.
- Throws:
SessionException
-
start
public static GrouperSession start(Subject subject, boolean addToThreadLocal, boolean addToCurrentSession) throws SessionException Start a session for interacting with the Grouper API. This has threadlocal implications, so start and stop these hierarchically, do not alternate. If you need to, use the callback inverse of control.// Start a Grouper API session. GrouperSession s = GrouperSession.start(subject);
- Parameters:
subject- Start session as thisSubject.addToThreadLocal- true to add this to the grouper session threadlocal which replaces the current one. Though if in the context of a callback, the callback has precedence, and you should use an inner callback to preempt it (callbackGrouperSession)addToCurrentSession- if the current threadlocal session is set so the session is not garbage collected- Returns:
- A Grouper API session.
- Throws:
SessionException
-
validate
- Parameters:
s-- Throws:
IllegalStateException- Since:
- 1.2.0
-
getAccessClass
Get name of class implentingAccessAdapterprivilege interface.String klass = s.getAccessClass();
- Returns:
- access class
-
getAttributeDefClass
Get name of class implentingAccessAdapterprivilege interface.String klass = s.getAccessClass();
- Returns:
- access class
-
getAccessResolver
- Returns:
AccessResolverused by this session.- Since:
- 1.2.1
-
getMember
Get theMemberassociated with this API session.Member m = s.getMember();
As of 1.2.0, this method throws an
IllegalStateExceptioninstead of aNullPointerExceptionwhen the member cannot be retrieved.- Returns:
- A
Memberobject. - Throws:
IllegalStateException- ifMembercannot be returned.
-
getNamingClass
Get name of class implentingNamingAdapterprivilege interface.String klass = s.getNamingClass();
- Returns:
- naming class
-
getNamingResolver
- Returns:
NamingResolverused by this session.- Since:
- 1.2.1
-
getSessionId
Get this session's id.String id = s.internal_getSessionId();
- Returns:
- The session id.
-
getStartTime
Get this session's start time.Date startTime = s.getStartTime();
- Returns:
- This session's start time.
-
getSubject
Get theSubjectassociated with this API session.Subject subj = s.getSubject();
- Returns:
- A
Subjectobject. - Throws:
GrouperException
-
getSubjectDb
Get theSubjectassociated with this API session.Subject subj = s.getSubject();
- Returns:
- A
Subjectobject. - Throws:
GrouperException
-
stop
Stop this API session.s.stop();
- Throws:
SessionException
-
toString
-
validate
- Throws:
IllegalStateException- Since:
- 1.2.0
-
internal_getRootSession
- Returns:
- the grouper session
- Throws:
GrouperException
-
getMemberUuid
- Returns:
- member uuid
- Since:
- 1.2.0
-
getStartTimeLong
public long getStartTimeLong()- Returns:
- start time
- Since:
- 1.2.0
-
getUuid
- Returns:
- uuid
- Since:
- 1.2.0
-
setMemberUuid
- Parameters:
memberUUID1-- Since:
- 1.2.0
-
setStartTimeLong
public void setStartTimeLong(long startTime1) - Parameters:
startTime1-- Since:
- 1.2.0
-
setSubject
- Parameters:
subject1-- Since:
- 1.2.0
-
setUuid
- Parameters:
uuid1-- Since:
- 1.2.0
-
toStringDto
- Returns:
- the string
- Since:
- 1.2.0
-
getAttributeDefResolver
- Returns:
AttributeDefResolverused by this session.- Since:
- 1.2.1
-
startRootSessionIfNotStarted
Start a root session for interacting with the Grouper API. This adds the session to the threadlocal. This has threadlocal implications, so start and stop these hierarchically, do not alternate. If you need to, use the callback inverse of control. This will not start a session if it is already started. If it is started as a different user, it will start- Returns:
- A Grouper API session result.
- Throws:
SessionException
-
callbackGrouperSession
public static Object callbackGrouperSession(GrouperSession grouperSession, GrouperSessionHandler grouperSessionHandler) throws GrouperSessionException call this to send a callback for the grouper session object. cant use inverse of control for this since it runs it. Any method in the inverse of control can access the grouper session in a threadlocal- Parameters:
grouperSession- is the session to do an inverse of control ongrouperSessionHandler- will get the callback- Returns:
- the object returned from the callback
- Throws:
GrouperSessionException- if there is a problem, will preserve runtime exceptions so they are thrown to the caller. The GrouperSessionException wraps the underlying exception
-
internal_callbackRootGrouperSession
public static Object internal_callbackRootGrouperSession(GrouperSessionHandler grouperSessionHandler) throws GrouperSessionException call this to send a callback for the root grouper session object. Any method in the inverse of control can access the grouper session in a threadlocal- Parameters:
runAsRoot- true to run as root, false to not run as rootgrouperSessionHandler- will get the callback- Returns:
- the object returned from the callback
- Throws:
GrouperSessionException- if there is a problem, will preserve runtime exceptions so they are thrown to the caller. The GrouperSessionException wraps the underlying exception
-
internal_callbackRootGrouperSession
public static Object internal_callbackRootGrouperSession(boolean runAsRoot, GrouperSessionHandler grouperSessionHandler) throws GrouperSessionException call this to send a callback for the root grouper session object. Any method in the inverse of control can access the grouper session in a threadlocal- Parameters:
grouperSessionHandler- will get the callback- Returns:
- the object returned from the callback
- Throws:
GrouperSessionException- if there is a problem, will preserve runtime exceptions so they are thrown to the caller. The GrouperSessionException wraps the underlying exception
-
staticGrouperSession
get the threadlocal grouper session. access this through inverse of control. this should be called by internal grouper methods which need the grouper session- Returns:
- the grouper session or null if none there
-
clearGrouperSessions
public static void clearGrouperSessions()clear the threadlocal grouper sessions (dont really need to call this, just stop the session, but this is here for testing) -
staticGrouperSession
public static GrouperSession staticGrouperSession(boolean exceptionOnNull) throws IllegalStateException get the threadlocal grouper session. access this through inverse of control. this should be called by internal grouper methods which need the grouper session- Parameters:
exceptionOnNull- true if exception when there is none there- Returns:
- the grouper session or null if none there
- Throws:
IllegalStateException- if no sessions available
-
callbackGrouperSessionBySubjectId
public static void callbackGrouperSessionBySubjectId(String subjectId, String sourceId, GrouperSessionHandler grouperSessionHandler) get the subject by root session, then callback in a session for that subject- Parameters:
sourceId-subjectId-grouperSessionHandler-
-