info.magnolia.context
Class UserContextImpl

java.lang.Object
  extended by info.magnolia.context.AbstractContext
      extended by info.magnolia.context.UserContextImpl
All Implemented Interfaces:
UserContext, Serializable, Map, org.apache.commons.chain.Context
Direct Known Subclasses:
WebContextImpl

public class UserContextImpl
extends AbstractContext
implements UserContext

User aware context implementation able to release and discard all kept info upon user logout. Also changes the locale from default one to the one preferred by the logged in user. Sets the Subject for the logged in user in session for subsequent requests to pick up. When no user has logged in this class returns the anonymous user.

Version:
$Id$
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
 
Fields inherited from class info.magnolia.context.AbstractContext
locale
 
Fields inherited from interface info.magnolia.context.Context
APPLICATION_SCOPE, ATTRIBUTE_COMMENT, ATTRIBUTE_EXCEPTION, ATTRIBUTE_MESSAGE, ATTRIBUTE_PATH, ATTRIBUTE_POSSIBLE_CSRF, ATTRIBUTE_RECURSIVE, ATTRIBUTE_REPOSITORY, ATTRIBUTE_UUID, ATTRIBUTE_VERSION, ATTRIBUTE_VERSION_MAP, LOCAL_SCOPE, SESSION_SCOPE
 
Constructor Summary
UserContextImpl()
           
 
Method Summary
 Locale getLocale()
          If not yet set try to get the locale of the user.
 Subject getSubject()
           
 User getUser()
          If this is not a UserContext this method will very likely return the system user.
 void login(Subject subject)
           
 void logout()
           
protected  void setLocaleFor(User user)
           
 
Methods inherited from class info.magnolia.context.AbstractContext
clear, containsKey, containsValue, entrySet, get, getAccessManager, getAttribute, getAttribute, getAttributes, getAttributes, getAttributeStrategy, getHierarchyManager, getJCRSession, getMessages, getMessages, getQueryManager, getRepositoryStrategy, isEmpty, keySet, put, putAll, release, remove, removeAttribute, setAttribute, setAttributeStrategy, setLocale, setRepositoryStrategy, size, values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface info.magnolia.context.Context
getAccessManager, getAttribute, getAttribute, getAttributes, getAttributes, getHierarchyManager, getJCRSession, getMessages, getMessages, getQueryManager, release, removeAttribute, setAttribute, setLocale
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Constructor Detail

UserContextImpl

public UserContextImpl()
Method Detail

getLocale

public Locale getLocale()
Description copied from class: AbstractContext
If not yet set try to get the locale of the user. Else use the locale of the system context.

Overrides:
getLocale in class AbstractContext
See Also:
Context.getLocale()

getUser

public User getUser()
Description copied from interface: Context
If this is not a UserContext this method will very likely return the system user.

Overrides:
getUser in class AbstractContext

getSubject

public Subject getSubject()
Overrides:
getSubject in class AbstractContext

login

public void login(Subject subject)
Specified by:
login in interface UserContext

logout

public void logout()
Specified by:
logout in interface UserContext

setLocaleFor

protected void setLocaleFor(User user)


Copyright © 2003–2014 Magnolia International Ltd.. All rights reserved.