Package org.pac4j.core.context.session
Class JEESessionStore
- java.lang.Object
-
- org.pac4j.core.context.session.JEESessionStore
-
- All Implemented Interfaces:
SessionStore
public class JEESessionStore extends java.lang.Object implements SessionStore
Store data in the JEE web session.- Since:
- 1.8.1
- Author:
- Jerome Leleu
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.servlet.http.HttpSession
httpSession
static JEESessionStore
INSTANCE
-
Constructor Summary
Constructors Modifier Constructor Description protected
JEESessionStore()
protected
JEESessionStore(javax.servlet.http.HttpSession httpSession)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<SessionStore>
buildFromTrackableSession(WebContext context, java.lang.Object trackableSession)
Build a new session store from a trackable session.boolean
destroySession(WebContext context)
Destroy the web session.java.util.Optional<java.lang.Object>
get(WebContext context, java.lang.String key)
Get the object from its key in store.protected java.util.Optional<javax.servlet.http.HttpSession>
getNativeSession(WebContext context, boolean createSession)
java.util.Optional<java.lang.String>
getSessionId(WebContext context, boolean createSession)
Get or create the session identifier and initialize the session with it if necessary.java.util.Optional<java.lang.Object>
getTrackableSession(WebContext context)
Get the native session as a trackable object.boolean
renewSession(WebContext context)
Renew the native session by copying all data to a new one.void
set(WebContext context, java.lang.String key, java.lang.Object value)
Save an object in the store by its key.
-
-
-
Field Detail
-
INSTANCE
public static final JEESessionStore INSTANCE
-
httpSession
protected javax.servlet.http.HttpSession httpSession
-
-
Method Detail
-
getNativeSession
protected java.util.Optional<javax.servlet.http.HttpSession> getNativeSession(WebContext context, boolean createSession)
-
getSessionId
public java.util.Optional<java.lang.String> getSessionId(WebContext context, boolean createSession)
Description copied from interface:SessionStore
Get or create the session identifier and initialize the session with it if necessary.- Specified by:
getSessionId
in interfaceSessionStore
- Parameters:
context
- the web context- Returns:
- the optional session identifier
-
get
public java.util.Optional<java.lang.Object> get(WebContext context, java.lang.String key)
Description copied from interface:SessionStore
Get the object from its key in store.- Specified by:
get
in interfaceSessionStore
- Parameters:
context
- the web contextkey
- the key of the object- Returns:
- the optional object in store
-
set
public void set(WebContext context, java.lang.String key, java.lang.Object value)
Description copied from interface:SessionStore
Save an object in the store by its key.- Specified by:
set
in interfaceSessionStore
- Parameters:
context
- the web contextkey
- the key of the objectvalue
- the value to save in store
-
destroySession
public boolean destroySession(WebContext context)
Description copied from interface:SessionStore
Destroy the web session.- Specified by:
destroySession
in interfaceSessionStore
- Parameters:
context
- the web context- Returns:
- whether the session has been destroyed
-
getTrackableSession
public java.util.Optional<java.lang.Object> getTrackableSession(WebContext context)
Description copied from interface:SessionStore
Get the native session as a trackable object.- Specified by:
getTrackableSession
in interfaceSessionStore
- Parameters:
context
- the web context- Returns:
- the optional trackable object
-
buildFromTrackableSession
public java.util.Optional<SessionStore> buildFromTrackableSession(WebContext context, java.lang.Object trackableSession)
Description copied from interface:SessionStore
Build a new session store from a trackable session.- Specified by:
buildFromTrackableSession
in interfaceSessionStore
- Parameters:
context
- the web contexttrackableSession
- the trackable session- Returns:
- the optional new session store
-
renewSession
public boolean renewSession(WebContext context)
Description copied from interface:SessionStore
Renew the native session by copying all data to a new one.- Specified by:
renewSession
in interfaceSessionStore
- Parameters:
context
- the web context- Returns:
- whether the session store has renewed the session
-
-