public class JwtCookieSession extends MapDecorator<String,Object> implements Session, DirtyListener
Session
that will be stored as an encrypted and signed JSON Web Token in a Cookie.
The generated JWT is encrypted with the JweAlgorithm.RSAES_PKCS1_V1_5
algorithm and EncryptionMethod.A128CBC_HS256
method and then signed with the JwsAlgorithm.HS256
algorithm.Modifier and Type | Field and Description |
---|---|
static String |
OPENIG_JWT_SESSION
Name of the cookie that will store the JWT session.
|
map
Constructor and Description |
---|
JwtCookieSession(Request request,
KeyPair pair,
String cookieName,
String cookieDomain,
TimeService timeService,
Duration sessionTimeout,
boolean persistentCookie,
SigningHandler signingHandler)
Builds a new JwtCookieSession that will manage the given Request's session.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all of the mappings from the map.
|
Set<Map.Entry<String,Object>> |
entrySet()
Returns a
Set view of the mappings contained in the map. |
boolean |
isEmpty()
Returns
true if the map contains no key-value mappings. |
Set<String> |
keySet()
Returns a
Set view of the keys contained in the map. |
void |
onElementsRemoved()
Called when one or more element from the underlying Map are removed.
|
Object |
put(String key,
Object value)
Associates the specified value with the specified key in the map.
|
void |
putAll(Map<? extends String,?> m)
Copies all of the mappings from the specified map to the map.
|
Object |
remove(Object key)
Removes the mapping for a key from the map if it is present.
|
void |
save(Response response)
Save the session state to the response.
|
Collection<Object> |
values()
Returns a
Collection view of the values contained in the map. |
containsKey, containsValue, equals, get, hashCode, size
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
containsKey, containsValue, equals, get, hashCode, size
public static final String OPENIG_JWT_SESSION
public JwtCookieSession(Request request, KeyPair pair, String cookieName, String cookieDomain, TimeService timeService, Duration sessionTimeout, boolean persistentCookie, SigningHandler signingHandler)
request
- Request used to access Cookie and Set-Cookie headers.pair
- Secret key used to sign the JWT payload.cookieName
- Name to be used for the supporting Cookie.cookieDomain
- Domain to be used for the supporting Cookie. If null, the cookie will be treated as a host-based cookie.timeService
- TimeService to use when dealing with JWT sessions' expiration.sessionTimeout
- The duration of the JWT session.persistentCookie
- Issue a persistent cookie (with Expiry attribute) or a session cookie (no Expiry attribute)signingHandler
- The JWT signing handler.public void onElementsRemoved()
DirtyListener
onElementsRemoved
in interface DirtyListener
public Object put(String key, Object value)
MapDecorator
public void putAll(Map<? extends String,?> m)
MapDecorator
public Object remove(Object key)
MapDecorator
public void clear()
MapDecorator
public Set<String> keySet()
MapDecorator
Set
view of the keys contained in the map.public Collection<Object> values()
MapDecorator
Collection
view of the values contained in the map.public Set<Map.Entry<String,Object>> entrySet()
MapDecorator
Set
view of the mappings contained in the map.public void save(Response response) throws IOException
Session
save
in interface Session
response
- The Response
instance to write the session state to.IOException
- If an I/O error occurs.public boolean isEmpty()
MapDecorator
true
if the map contains no key-value mappings.Copyright 2011-2015 ForgeRock AS.