Package org.forgerock.openig.jwt
Class JwtCookieSession
- java.lang.Object
-
- org.forgerock.util.MapDecorator<String,Object>
-
- org.forgerock.openig.jwt.JwtCookieSession
-
- All Implemented Interfaces:
Map<String,Object>
,Session
,DirtyListener
public class JwtCookieSession extends MapDecorator<String,Object> implements Session, DirtyListener
Represents an Identity GatewaySession
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 andEncryptionMethod.A128CBC_HS256
method and then signed with theJwsAlgorithm.HS256
algorithm.
-
-
Field Summary
Fields Modifier and Type Field Description static String
OPENIG_JWT_SESSION
Name of the cookie that will store the JWT session.-
Fields inherited from class org.forgerock.util.MapDecorator
map
-
-
Constructor Summary
Constructors Constructor Description JwtCookieSession(Request request, KeyPair pair, CookieBuilder cookieBuilder, Clock clock, Duration sessionTimeout, boolean persistentCookie, Duration skewAllowance, org.forgerock.json.jose.jws.handlers.SigningHandler signingHandler)
Builds a new JwtCookieSession that will manage the given Request's session.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Removes all of the mappings from the map.Set<Map.Entry<String,Object>>
entrySet()
Returns aSet
view of the mappings contained in the map.boolean
isEmpty()
Returnstrue
if the map contains no key-value mappings.Set<String>
keySet()
Returns aSet
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 aCollection
view of the values contained in the map.-
Methods inherited from class org.forgerock.util.MapDecorator
containsKey, containsValue, equals, get, hashCode, size
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, equals, forEach, get, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll, size
-
-
-
-
Field Detail
-
OPENIG_JWT_SESSION
public static final String OPENIG_JWT_SESSION
Name of the cookie that will store the JWT session.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JwtCookieSession
public JwtCookieSession(Request request, KeyPair pair, CookieBuilder cookieBuilder, Clock clock, Duration sessionTimeout, boolean persistentCookie, Duration skewAllowance, org.forgerock.json.jose.jws.handlers.SigningHandler signingHandler)
Builds a new JwtCookieSession that will manage the given Request's session.- Parameters:
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)skewAllowance
- The skew allowance to use for temporal validation on theJwtCookieSession
.signingHandler
- The JWT signing handler.
-
-
Method Detail
-
onElementsRemoved
public void onElementsRemoved()
Description copied from interface:DirtyListener
Called when one or more element from the underlying Map are removed.- Specified by:
onElementsRemoved
in interfaceDirtyListener
-
put
public Object put(String key, Object value)
Description copied from class:MapDecorator
Associates the specified value with the specified key in the map.- Specified by:
put
in interfaceMap<String,Object>
- Overrides:
put
in classMapDecorator<String,Object>
- Parameters:
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.- Returns:
- the previous value associated with key, or
null
if no mapping.
-
putAll
public void putAll(Map<? extends String,?> m)
Description copied from class:MapDecorator
Copies all of the mappings from the specified map to the map.
-
remove
public Object remove(Object key)
Description copied from class:MapDecorator
Removes the mapping for a key from the map if it is present.
-
clear
public void clear()
Description copied from class:MapDecorator
Removes all of the mappings from the map.
-
keySet
public Set<String> keySet()
Description copied from class:MapDecorator
Returns aSet
view of the keys contained in the map.
-
values
public Collection<Object> values()
Description copied from class:MapDecorator
Returns aCollection
view of the values contained in the map.
-
entrySet
public Set<Map.Entry<String,Object>> entrySet()
Description copied from class:MapDecorator
Returns aSet
view of the mappings contained in the map.
-
save
public void save(Response response) throws IOException
Description copied from interface:Session
Save the session state to the response.- Specified by:
save
in interfaceSession
- Parameters:
response
- TheResponse
instance to write the session state to.- Throws:
IOException
- If an I/O error occurs.
-
isEmpty
public boolean isEmpty()
Description copied from class:MapDecorator
Returnstrue
if the map contains no key-value mappings.
-
-