Nuxeo Enterprise Platform 5.4

org.nuxeo.ecm.webengine.session
Class UserSession

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<java.lang.String,java.lang.Object>
          extended by org.nuxeo.ecm.webengine.session.UserSession
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,java.lang.Object>
Direct Known Subclasses:
StatefulUserSession, StatelessUserSession

public abstract class UserSession
extends java.util.HashMap<java.lang.String,java.lang.Object>

Used to store user session. This object is cached in a the HTTP session Principal, subject and credentials are immutable per user session

Author:
Bogdan Stefanescu
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Field Summary
static java.lang.String CLEANUP_HANDLERS
           
 
Method Summary
static void addRequestCleanupHandler(javax.servlet.http.HttpServletRequest request, RequestCleanupHandler handler)
          Register a cleanup handler that will be invoked when HTTP request terminate.
<T extends Component>
T
findComponent(java.lang.Class<T> type, java.lang.String name)
          Finds an existing component.
<T extends Component>
T
getComponent(java.lang.Class<T> type)
           
<T extends Component>
T
getComponent(java.lang.Class<T> type, java.lang.String name)
          Gets a component given its class and an optional name.
<T extends Component>
T
getComponent(java.lang.String id)
          Gets component by ID.
<T extends Component>
T
getComponent(java.lang.String typeName, java.lang.String name)
           
 CoreSession getCoreSession()
          Gets a core session.
 CoreSession getCoreSession(java.lang.String repoName)
          Gets a core session.
 java.lang.Object getCredentials()
           
static UserSession getCurrentSession(javax.servlet.http.HttpServletRequest request)
           
 java.lang.String getDefaultRepository()
          Return the name of the default repository in the context of this request.
 java.security.Principal getPrincipal()
           
 javax.security.auth.Subject getSubject()
           
abstract  boolean isStateful()
           
static CoreSession openSession(java.lang.String repoName)
           
static UserSession register(javax.servlet.http.HttpServletRequest request, boolean stateful)
           
 void terminateRequest(javax.servlet.http.HttpServletRequest request)
           
static UserSession tryGetCurrentSession(javax.servlet.http.HttpServletRequest request)
           
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

CLEANUP_HANDLERS

public static final java.lang.String CLEANUP_HANDLERS
See Also:
Constant Field Values
Method Detail

tryGetCurrentSession

public static UserSession tryGetCurrentSession(javax.servlet.http.HttpServletRequest request)

getCurrentSession

public static UserSession getCurrentSession(javax.servlet.http.HttpServletRequest request)

register

public static UserSession register(javax.servlet.http.HttpServletRequest request,
                                   boolean stateful)

isStateful

public abstract boolean isStateful()

getDefaultRepository

public java.lang.String getDefaultRepository()
Return the name of the default repository in the context of this request. Return null if the default registered repository should be used

Returns:

getCoreSession

public CoreSession getCoreSession(java.lang.String repoName)
Gets a core session.

If it does not already exist, it will be opened against the given repository.

Parameters:
repoName -
Returns:
the core session

getCoreSession

public CoreSession getCoreSession()
Gets a core session.

If not already opened, opens a new core session against the default repository.


getPrincipal

public java.security.Principal getPrincipal()

getCredentials

public java.lang.Object getCredentials()

getSubject

public javax.security.auth.Subject getSubject()

openSession

public static CoreSession openSession(java.lang.String repoName)
                               throws java.lang.Exception
Throws:
java.lang.Exception

findComponent

public <T extends Component> T findComponent(java.lang.Class<T> type,
                                             java.lang.String name)
Finds an existing component.

The component state will not be modified before being returned as in getComponent(Class, String).

If the component was not found in that session, returns null.


getComponent

public <T extends Component> T getComponent(java.lang.Class<T> type,
                                            java.lang.String name)
                                 throws SessionException
Gets a component given its class and an optional name.

If the component was not yet created in this session, it will be created and registered against the session.

Throws:
SessionException

getComponent

public <T extends Component> T getComponent(java.lang.Class<T> type)
                                 throws SessionException
Throws:
SessionException

getComponent

public <T extends Component> T getComponent(java.lang.String typeName,
                                            java.lang.String name)
                                 throws SessionException
Throws:
SessionException

getComponent

public <T extends Component> T getComponent(java.lang.String id)
                                 throws SessionException
Gets component by ID.

The ID is of the form type#name for non-null names and type for null names.

Throws:
SessionException

terminateRequest

public void terminateRequest(javax.servlet.http.HttpServletRequest request)

addRequestCleanupHandler

public static void addRequestCleanupHandler(javax.servlet.http.HttpServletRequest request,
                                            RequestCleanupHandler handler)
Register a cleanup handler that will be invoked when HTTP request terminate. This method is not thread safe.


Nuxeo Enterprise Platform 5.4

Copyright © 2010 Nuxeo SAS. All Rights Reserved.