JwtSession

pdi.jwt.JwtSession
See theJwtSession companion object
case class JwtSession(headerData: JsObject, claimData: JsObject, signature: String)(implicit conf: Configuration, clock: Clock)

Similar to the default Play Session but using JsObject instead of Map[String, String]. The data is separated into two attributes: headerData and claimData. There is also a optional signature. Most of the time, you should only care about the claimData which stores the claim of the token containing the custom values you eventually put in it. That's why all methods of JwtSession (such as add and removing values) only modifiy the claimData.

To see a full list of samples, check the online documentation.

'''Warning''' Be aware that if you override the claimData (using withClaim for example), you might override some attributes that were automatically put inside the claim such as the expiration of the token.

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def +(value: JsObject): JwtSession

Merge the value with claimData

Merge the value with claimData

Attributes

def +(key: String, value: JsValueWrapper): JwtSession

Add this (key, value) to claimData (existing key will be overriden)

Add this (key, value) to claimData (existing key will be overriden)

Attributes

def +[T](key: String, value: T)(implicit writer: Writes[T]): JwtSession

Convert value to its JSON counterpart and add it to claimData

Convert value to its JSON counterpart and add it to claimData

Attributes

def ++(fields: (String, JsValueWrapper)*): JwtSession

Add a sequence of (key, value) to claimData

Add a sequence of (key, value) to claimData

Attributes

def -(fieldName: String): JwtSession

Remove one key from claimData

Remove one key from claimData

Attributes

def --(fieldNames: String*): JwtSession

Remove a sequence of keys from claimData

Remove a sequence of keys from claimData

Attributes

def apply(fieldName: String): Option[JsValue]

Alias of get

Alias of get

Attributes

def get(fieldName: String): Option[JsValue]

Retrieve the value corresponding to fieldName from claimData

Retrieve the value corresponding to fieldName from claimData

Attributes

def getAs[T](fieldName: String)(implicit reader: Reads[T]): Option[T]

After retrieving the value, try to read it as T, if no value or fails, returns None.

After retrieving the value, try to read it as T, if no value or fails, returns None.

Attributes

def isEmpty(): Boolean

If your Play app config has a session.maxAge, it will extend the expiration by that amount

If your Play app config has a session.maxAge, it will extend the expiration by that amount

Attributes

Encode the session as a JSON Web Token

Encode the session as a JSON Web Token

Attributes

Overrride the claimData

Overrride the claimData

Attributes

Override the headerData

Override the headerData

Attributes

def withSignature(signature: String): JwtSession

Override the signature (seriously, you should never need this method)

Override the signature (seriously, you should never need this method)

Attributes

Inherited methods

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product