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
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
callbackGrouperSession
(GrouperSession grouperSession, GrouperSessionHandler grouperSessionHandler) call this to send a callback for the grouper session object.static void
callbackGrouperSessionBySubjectId
(String subjectId, String sourceId, GrouperSessionHandler grouperSessionHandler) get the subject by root session, then callback in a session for that subjectstatic void
clear the threadlocal grouper sessions (dont really need to call this, just stop the session, but this is here for testing)protected void
finalize()
Get name of class implentingAccessAdapter
privilege interface.Get name of class implentingAccessAdapter
privilege interface.Get theMember
associated with this API session.Get name of class implentingNamingAdapter
privilege interface.Get this session's id.Get this session's start time.long
Get theSubject
associated with this API session.Get theSubject
associated with this API session.getUuid()
static Object
internal_callbackRootGrouperSession
(boolean runAsRoot, GrouperSessionHandler grouperSessionHandler) call this to send a callback for the root grouper session object.static Object
internal_callbackRootGrouperSession
(GrouperSessionHandler grouperSessionHandler) call this to send a callback for the root grouper session object.static GrouperSession
boolean
if we should take into consideration that we are a wheel member (or act as self if false)void
setConsiderIfWheelMember
(boolean considerIfWheelMember1) if we should take into consideration that we are a wheel member (or act as self if false)void
setMemberUuid
(String memberUUID1) void
setStartTimeLong
(long startTime1) void
setSubject
(Subject subject1) void
static GrouperSession
Start a session for interacting with the Grouper API.static GrouperSession
Start a session for interacting with the Grouper API.static GrouperSession
Start a session for interacting with the Grouper API.static GrouperSession
startBySubjectIdAndSource
(String subjectId, String sourceId) start a session based on a sourceId and subjectIdstatic GrouperSession
startBySubjectIdAndSource
(String subjectId, String sourceId, boolean addToThreadLocal) start a session based on a sourceId and subjectIdstatic GrouperSession
startBySubjectIdentifierAndSource
(String subjectIdentifier, String sourceId) start a session based on a sourceId and subjectIdstatic GrouperSession
startBySubjectIdentifierAndSource
(String subjectIdentifier, String sourceId, boolean addToThreadLocal) start a session based on a sourceId and subjectIdstatic GrouperSessionResult
startIfNotStarted
(Subject subject) Start a session for interacting with the Grouper API.static GrouperSession
Start a session for interacting with the Grouper API.static GrouperSession
startRootSession
(boolean addToThreadLocal) Start a session for interacting with the Grouper API.static GrouperSession
startRootSession
(boolean addToThreadLocal, boolean addToCurrentSession) Start a session for interacting with the Grouper API.static GrouperSessionResult
Start a root session for interacting with the Grouper API.static GrouperSession
get the threadlocal grouper session.static GrouperSession
staticGrouperSession
(boolean exceptionOnNull) get the threadlocal grouper session.void
stop()
Stop this API session.static void
stopQuietly
(GrouperSession session) stop a session quietlytoString()
void
validate()
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 implentingAccessAdapter
privilege interface.String klass = s.getAccessClass();
- Returns:
- access class
-
getAttributeDefClass
Get name of class implentingAccessAdapter
privilege interface.String klass = s.getAccessClass();
- Returns:
- access class
-
getAccessResolver
- Returns:
AccessResolver
used by this session.- Since:
- 1.2.1
-
getMember
Get theMember
associated with this API session.Member m = s.getMember();
As of 1.2.0, this method throws an
IllegalStateException
instead of aNullPointerException
when the member cannot be retrieved.- Returns:
- A
Member
object. - Throws:
IllegalStateException
- ifMember
cannot be returned.
-
getNamingClass
Get name of class implentingNamingAdapter
privilege interface.String klass = s.getNamingClass();
- Returns:
- naming class
-
getNamingResolver
- Returns:
NamingResolver
used 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 theSubject
associated with this API session.Subject subj = s.getSubject();
- Returns:
- A
Subject
object. - Throws:
GrouperException
-
getSubjectDb
Get theSubject
associated with this API session.Subject subj = s.getSubject();
- Returns:
- A
Subject
object. - 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:
AttributeDefResolver
used 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
-
-