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