org.kuali.rice.krad
Class UserSession

java.lang.Object
  extended by org.kuali.rice.krad.UserSession
All Implemented Interfaces:
Serializable

public class UserSession
extends Object
implements Serializable

Holds info about the User Session

Author:
Kuali Rice Team (rice.collab@kuali.org)
See Also:
Serialized Form

Constructor Summary
UserSession(String principalName)
          Creates a user session for the principal specified in the parameter.
 
Method Summary
 void addObject(String key, Object object)
          allows adding an arbitrary object to the session with static a string key that can be used to later access this object from the session using the retrieveObject method in this class
 String addObjectWithGeneratedKey(Object object)
          allows adding an arbitrary object to the session and returns a string key that can be used to later access this object from the session using the retrieveObject method in this class.
 String addObjectWithGeneratedKey(Serializable object, String keyPrefix)
          allows adding an arbitrary object to the session and returns a string key that can be used to later access this object from the session using the retrieveObject method in this class.
 void clearBackdoorUser()
          clear the backdoor user
 void clearObjectMap()
          clear the objectMap
 Person getActualPerson()
          Returns the actual current user even if the backdoor is in use.
 List<SessionTicket> getAllSessionTickets()
          Retrieves all SessionTicket instances currently in the UserSession#objectMap
 List<SessionTicket> getAllSessionTicketsByType(String ticketTypeName)
          Retrieves all SessionTicket instances currently in the UserSession#objectMap that are of a given ticket type
 String getKualiSessionId()
          Returns the session id.
 String getLoggedInUserPrincipalName()
          Returns who is logged in.
 Map<String,Object> getObjectMap()
          retrieves an unmodifiable view of the objectMap.
 Person getPerson()
          Returns a Person object for the current user.
 String getPrincipalId()
          Returns the id of the current user.
 String getPrincipalName()
          Returns the name of the current user.
 boolean hasMatchingSessionTicket(String ticketTypeName, Map<String,String> matchContext)
          Determines if the UserSession contains a ticket of the given type that matches the given context.
protected  void initPerson(String principalName)
          Loads the Person object from KIM.
 boolean isBackdoorInUse()
           
 String putSessionTicket(SessionTicket ticket)
          Adds the given SessionTicket to the objectMap and returns the associated key
 void removeObject(String objectKey)
          allows for removal of an object from session that has been put into the userSession based on the key that would have been assigned
 void removeObjectsByPrefix(String objectKeyPrefix)
          allows for removal of an object from session that has been put into the userSession based on a key that starts with the given prefix
 Object retrieveObject(String objectKey)
          allows for fetching an object that has been put into the userSession based on the key that would have been returned when adding the object
 void setBackdoorUser(String principalName)
          override the current user in the system by setting the backdoor networkId, which is useful when dealing with routing or other reasons why you would need to assume an identity in the system
 void setKualiSessionId(String kualiSessionId)
          Sets the session id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserSession

public UserSession(String principalName)
Creates a user session for the principal specified in the parameter. Take in a netid, and construct the user from that.

Parameters:
principalName -
Method Detail

getKualiSessionId

public String getKualiSessionId()
Returns the session id. The session id is a unique identifier for the session.

Returns:
the kualiSessionId

setKualiSessionId

public void setKualiSessionId(String kualiSessionId)
Sets the session id.

Parameters:
kualiSessionId - the kualiSessionId to set

initPerson

protected void initPerson(String principalName)
Loads the Person object from KIM. Factored out for testability.

Parameters:
principalName - the principalName

getPrincipalId

public String getPrincipalId()
Returns the id of the current user.

Returns:
the principalId of the current user in the system, backdoor principalId if backdoor is set

getPrincipalName

public String getPrincipalName()
Returns the name of the current user.

Returns:
the principalName of the current user in the system, backdoor principalName if backdoor is set

getLoggedInUserPrincipalName

public String getLoggedInUserPrincipalName()
Returns who is logged in. If the backdoor is in use, this will return the network id of the person that is standing in as the backdoor user.

Returns:
String

getPerson

public Person getPerson()
Returns a Person object for the current user.

Returns:
the KualiUser which is the current user in the system, backdoor if backdoor is set

getActualPerson

public Person getActualPerson()
Returns the actual current user even if the backdoor is in use.

Returns:
the KualiUser which is the current user in the system

setBackdoorUser

public void setBackdoorUser(String principalName)
override the current user in the system by setting the backdoor networkId, which is useful when dealing with routing or other reasons why you would need to assume an identity in the system

Parameters:
principalName -

clearBackdoorUser

public void clearBackdoorUser()
clear the backdoor user


addObjectWithGeneratedKey

public String addObjectWithGeneratedKey(Serializable object,
                                        String keyPrefix)
allows adding an arbitrary object to the session and returns a string key that can be used to later access this object from the session using the retrieveObject method in this class. This allows for a prefix to be placed in front of the incremented key. So if the prefix is "searchResults" and the nextObjectKey (local int that holds the key value) is 2 then the new key will be "searchResults3". "searchResults3" will be returned from the method.

Parameters:
object -

addObjectWithGeneratedKey

public String addObjectWithGeneratedKey(Object object)
allows adding an arbitrary object to the session and returns a string key that can be used to later access this object from the session using the retrieveObject method in this class. The key is generated from an integer and incremented for every object added. So the first object added with have a key of "1". This key will be returned from the method.

Parameters:
object -

addObject

public void addObject(String key,
                      Object object)
allows adding an arbitrary object to the session with static a string key that can be used to later access this object from the session using the retrieveObject method in this class

Parameters:
object -

retrieveObject

public Object retrieveObject(String objectKey)
allows for fetching an object that has been put into the userSession based on the key that would have been returned when adding the object

Parameters:
objectKey -

removeObject

public void removeObject(String objectKey)
allows for removal of an object from session that has been put into the userSession based on the key that would have been assigned

Parameters:
objectKey -

removeObjectsByPrefix

public void removeObjectsByPrefix(String objectKeyPrefix)
allows for removal of an object from session that has been put into the userSession based on a key that starts with the given prefix


isBackdoorInUse

public boolean isBackdoorInUse()
Returns:
boolean indicating if the backdoor is in use

putSessionTicket

public String putSessionTicket(SessionTicket ticket)
Adds the given SessionTicket to the objectMap and returns the associated key

Parameters:
ticket - - SessionTicket to add
Returns:
the objectMap key for the ticket as a String

getAllSessionTickets

public List<SessionTicket> getAllSessionTickets()
Retrieves all SessionTicket instances currently in the UserSession#objectMap

Returns:
List contained in user session

getAllSessionTicketsByType

public List<SessionTicket> getAllSessionTicketsByType(String ticketTypeName)
Retrieves all SessionTicket instances currently in the UserSession#objectMap that are of a given ticket type

Returns:
List contained in user session

hasMatchingSessionTicket

public boolean hasMatchingSessionTicket(String ticketTypeName,
                                        Map<String,String> matchContext)
Determines if the UserSession contains a ticket of the given type that matches the given context. To match context the ticket must contain all the same keys at the given context and the values must be equal with the exception of case

Parameters:
ticketTypeName - - Name of the ticket type to match
matchContext - - Map on context parameters to match on
Returns:
true if a ticket was found in the UserSession that matches the request, false if one was not found

getObjectMap

public Map<String,Object> getObjectMap()
retrieves an unmodifiable view of the objectMap.


clearObjectMap

public void clearObjectMap()
clear the objectMap



Copyright © 2005-2013 The Kuali Foundation. All Rights Reserved.