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,
CookieBuilder cookieBuilder,
Clock clock,
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
compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, equals, forEach, get, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll, size
public static final String OPENIG_JWT_SESSION
public JwtCookieSession(Request request, KeyPair pair, CookieBuilder cookieBuilder, Clock clock, 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.cookieBuilder
- The CookieBuilder for building the session cookie.clock
- Clock 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
put
in interface Map<String,Object>
put
in class MapDecorator<String,Object>
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.null
if no
mapping.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-2017 ForgeRock AS.