pdi.jwt

Jwt

object Jwt extends JwtCore[String, String]

Default implementation of JwtCore using only Strings. Most of the time, you should use a lib implementing JSON and shouldn't be using this object. But just in case you need pure Scala support, here it is.

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

Warning: since there is no JSON support in Scala, this object doesn't have any way to parse a JSON string as an AST, so it only uses regex with all the limitations it implies. Try not to use keys like exp and nbf in sub-objects of the claim. For example, if you try to use the following claim: {"user":{"exp":1},"exp":1300819380}, it should be correct but it will fail because the regex extracting the expiration will return 1 instead of 1300819380. Sorry about that.

Linear Supertypes
JwtCore[String, String], AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Jwt
  2. JwtCore
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def decode(token: String, key: PublicKey): Try[String]

    An alias of decode if you want to directly pass a string key rather than an Option

    An alias of decode if you want to directly pass a string key rather than an Option

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    key

    the key that will be used to check the token signature

    returns

    if successful, the claim of the token in its correct type

    Definition Classes
    JwtCore
  9. def decode(token: String, key: SecretKey): Try[String]

    An alias of decode if you want to directly pass a string key rather than an Option

    An alias of decode if you want to directly pass a string key rather than an Option

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    key

    the key that will be used to check the token signature

    returns

    if successful, the claim of the token in its correct type

    Definition Classes
    JwtCore
  10. def decode(token: String, key: String): Try[String]

    An alias of decode if you want to directly pass a string key rather than an Option

    An alias of decode if you want to directly pass a string key rather than an Option

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    key

    the key that will be used to check the token signature

    returns

    if successful, the claim of the token in its correct type

    Definition Classes
    JwtCore
  11. def decode(token: String): Try[String]

    Same as decodeAll but only return the claim

    Same as decodeAll but only return the claim

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    returns

    if successful, the claim of the token in its correct type

    Definition Classes
    JwtCore
  12. def decodeAll(token: String, key: PublicKey): Try[(String, String, String)]

    An alias of decodeAll if you want to directly pass a string key rather than an Option

    An alias of decodeAll if you want to directly pass a string key rather than an Option

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    key

    the key that will be used to check the token signature

    returns

    if successful, a tuple representing the header, the claim and eventually the signature

    Definition Classes
    JwtCore
  13. def decodeAll(token: String, key: SecretKey): Try[(String, String, String)]

    An alias of decodeAll if you want to directly pass a string key rather than an Option

    An alias of decodeAll if you want to directly pass a string key rather than an Option

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    key

    the key that will be used to check the token signature

    returns

    if successful, a tuple representing the header, the claim and eventually the signature

    Definition Classes
    JwtCore
  14. def decodeAll(token: String, key: String): Try[(String, String, String)]

    An alias of decodeAll if you want to directly pass a string key rather than an Option

    An alias of decodeAll if you want to directly pass a string key rather than an Option

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    key

    the key that will be used to check the token signature

    returns

    if successful, a tuple representing the header, the claim and eventually the signature

    Definition Classes
    JwtCore
  15. def decodeAll(token: String): Try[(String, String, String)]

    Same as decodeRawAll but return the real header and claim types

    Same as decodeRawAll but return the real header and claim types

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    returns

    if successful, a tuple representing the header, the claim and eventually the signature

    Definition Classes
    JwtCore
  16. def decodeRaw(token: String, key: PublicKey): Try[String]

    Same as decodeRawAll but only return the claim (you only care about the claim most of the time)

    Same as decodeRawAll but only return the claim (you only care about the claim most of the time)

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    key

    the key that will be used to check the token signature

    returns

    if successful, a string representing the JSON version of the claim

    Definition Classes
    JwtCore
  17. def decodeRaw(token: String, key: SecretKey): Try[String]

    Same as decodeRawAll but only return the claim (you only care about the claim most of the time)

    Same as decodeRawAll but only return the claim (you only care about the claim most of the time)

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    key

    the key that will be used to check the token signature

    returns

    if successful, a string representing the JSON version of the claim

    Definition Classes
    JwtCore
  18. def decodeRaw(token: String, key: String): Try[String]

    Same as decodeRawAll but only return the claim (you only care about the claim most of the time)

    Same as decodeRawAll but only return the claim (you only care about the claim most of the time)

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    key

    the key that will be used to check the token signature

    returns

    if successful, a string representing the JSON version of the claim

    Definition Classes
    JwtCore
  19. def decodeRaw(token: String): Try[String]

    Same as decodeRawAll but only return the claim (you only care about the claim most of the time)

    Same as decodeRawAll but only return the claim (you only care about the claim most of the time)

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    returns

    if successful, a string representing the JSON version of the claim

    Definition Classes
    JwtCore
  20. def decodeRawAll(token: String, key: PublicKey): Try[(String, String, String)]

    Will try to decode a JSON Web Token to raw strings

    Will try to decode a JSON Web Token to raw strings

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    key

    the key that will be used to check the token signature

    returns

    if successful, a tuple of 3 strings, the header, the claim and the signature

    Definition Classes
    JwtCore
  21. def decodeRawAll(token: String, key: SecretKey): Try[(String, String, String)]

    Will try to decode a JSON Web Token to raw strings

    Will try to decode a JSON Web Token to raw strings

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    key

    the key that will be used to check the token signature

    returns

    if successful, a tuple of 3 strings, the header, the claim and the signature

    Definition Classes
    JwtCore
  22. def decodeRawAll(token: String, key: String): Try[(String, String, String)]

    Will try to decode a JSON Web Token to raw strings

    Will try to decode a JSON Web Token to raw strings

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    key

    the key that will be used to check the token signature

    returns

    if successful, a tuple of 3 strings, the header, the claim and the signature

    Definition Classes
    JwtCore
  23. def decodeRawAll(token: String): Try[(String, String, String)]

    Will try to decode a JSON Web Token to raw strings

    Will try to decode a JSON Web Token to raw strings

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    returns

    if successful, a tuple of 3 strings, the header, the claim and the signature

    Definition Classes
    JwtCore
  24. def encode(header: JwtHeader, claim: JwtClaim, key: Key): String

    An alias of encode if you only want to pass a string as the key, the algorithm will be deduced from the header.

    An alias of encode if you only want to pass a string as the key, the algorithm will be deduced from the header.

    header

    the header to stringify as a JSON before encoding the token

    claim

    the claim to stringify as a JSON before encoding the token

    key

    the secret key to use to sign the token (note that the algorithm will be deduced from the header)

    returns

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    Definition Classes
    JwtCore
  25. def encode(header: JwtHeader, claim: JwtClaim, key: String): String

    An alias of encode if you only want to pass a string as the key, the algorithm will be deduced from the header.

    An alias of encode if you only want to pass a string as the key, the algorithm will be deduced from the header.

    header

    the header to stringify as a JSON before encoding the token

    claim

    the claim to stringify as a JSON before encoding the token

    key

    the secret key to use to sign the token (note that the algorithm will be deduced from the header)

    returns

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    Definition Classes
    JwtCore
  26. def encode(header: JwtHeader, claim: JwtClaim): String

    An alias to encode if you want to use case classes for the header and the claim rather than strings, they will just be stringified to JSON format.

    An alias to encode if you want to use case classes for the header and the claim rather than strings, they will just be stringified to JSON format.

    header

    the header to stringify as a JSON before encoding the token

    claim

    the claim to stringify as a JSON before encoding the token

    returns

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    Definition Classes
    JwtCore
  27. def encode(claim: JwtClaim, key: PrivateKey, algorithm: JwtAsymetricAlgorithm): String

    An alias to encode which will provide an automatically generated header and use the claim as a case class.

    An alias to encode which will provide an automatically generated header and use the claim as a case class.

    claim

    the claim of the JSON Web Token

    key

    the key that will be used to check the token signature

    algorithm

    the algorithm to sign the token

    returns

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    Definition Classes
    JwtCore
  28. def encode(claim: JwtClaim, key: SecretKey, algorithm: JwtHmacAlgorithm): String

    An alias to encode which will provide an automatically generated header and use the claim as a case class.

    An alias to encode which will provide an automatically generated header and use the claim as a case class.

    claim

    the claim of the JSON Web Token

    key

    the key that will be used to check the token signature

    algorithm

    the algorithm to sign the token

    returns

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    Definition Classes
    JwtCore
  29. def encode(claim: JwtClaim, key: String, algorithm: JwtAlgorithm): String

    An alias to encode which will provide an automatically generated header and use the claim as a case class.

    An alias to encode which will provide an automatically generated header and use the claim as a case class.

    claim

    the claim of the JSON Web Token

    key

    the key that will be used to check the token signature

    algorithm

    the algorithm to sign the token

    returns

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    Definition Classes
    JwtCore
  30. def encode(claim: JwtClaim): String

    An alias to encode which will provide an automatically generated header and setting both key and algorithm to None.

    An alias to encode which will provide an automatically generated header and setting both key and algorithm to None.

    claim

    the claim of the JSON Web Token

    returns

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    Definition Classes
    JwtCore
  31. def encode(claim: String, key: PrivateKey, algorithm: JwtAsymetricAlgorithm): String

    An alias to encode which will provide an automatically generated header and allowing you to get rid of Option for the key and the algorithm.

    An alias to encode which will provide an automatically generated header and allowing you to get rid of Option for the key and the algorithm.

    claim

    a valid stringified JSON representing the claim of the token

    key

    the key that will be used to check the token signature

    algorithm

    the algorithm to sign the token

    returns

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    Definition Classes
    JwtCore
  32. def encode(claim: String, key: SecretKey, algorithm: JwtHmacAlgorithm): String

    An alias to encode which will provide an automatically generated header and allowing you to get rid of Option for the key and the algorithm.

    An alias to encode which will provide an automatically generated header and allowing you to get rid of Option for the key and the algorithm.

    claim

    a valid stringified JSON representing the claim of the token

    key

    the key that will be used to check the token signature

    algorithm

    the algorithm to sign the token

    returns

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    Definition Classes
    JwtCore
  33. def encode(claim: String, key: String, algorithm: JwtAlgorithm): String

    An alias to encode which will provide an automatically generated header and allowing you to get rid of Option for the key and the algorithm.

    An alias to encode which will provide an automatically generated header and allowing you to get rid of Option for the key and the algorithm.

    claim

    a valid stringified JSON representing the claim of the token

    key

    the key that will be used to check the token signature

    algorithm

    the algorithm to sign the token

    returns

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    Definition Classes
    JwtCore
  34. def encode(claim: String): String

    An alias to encode which will provide an automatically generated header.

    An alias to encode which will provide an automatically generated header.

    claim

    a valid stringified JSON representing the claim of the token

    returns

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    Definition Classes
    JwtCore
  35. def encode(header: String, claim: String, key: PrivateKey, algorithm: JwtAsymetricAlgorithm): String

    Definition Classes
    JwtCore
  36. def encode(header: String, claim: String, key: SecretKey, algorithm: JwtHmacAlgorithm): String

    Definition Classes
    JwtCore
  37. def encode(header: String, claim: String, key: String, algorithm: JwtAlgorithm): String

    Encode a JSON Web Token from its different parts.

    Encode a JSON Web Token from its different parts. Both the header and the claim will be encoded to Base64 url-safe, then a signature will be eventually generated from it if you did pass a key and an algorithm, and finally, those three parts will be merged as a single string, using dots as separator.

    header

    a valid stringified JSON representing the header of the token

    claim

    a valid stringified JSON representing the claim of the token

    key

    the key that will be used to check the token signature

    algorithm

    the algorithm to sign the token

    returns

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    Definition Classes
    JwtCore
  38. def encode(header: String, claim: String): String

    Definition Classes
    JwtCore
  39. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  40. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  41. def extractAlgorithm(header: String): Option[JwtAlgorithm]

    Attributes
    protected
    Definition Classes
    JwtJwtCore
  42. def extractExpiration(claim: String): Option[Long]

    Attributes
    protected
    Definition Classes
    JwtJwtCore
  43. def extractNotBefore(claim: String): Option[Long]

    Attributes
    protected
    Definition Classes
    JwtJwtCore
  44. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  45. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  46. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  47. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  48. def isValid(token: String, key: PublicKey): Boolean

    An alias for isValid if you want to directly pass a string as the key

    An alias for isValid if you want to directly pass a string as the key

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    key

    the key that will be used to check the token signature

    returns

    a boolean value indicating if the token is valid or not

    Definition Classes
    JwtCore
  49. def isValid(token: String, key: SecretKey): Boolean

    An alias for isValid if you want to directly pass a string as the key

    An alias for isValid if you want to directly pass a string as the key

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    key

    the key that will be used to check the token signature

    returns

    a boolean value indicating if the token is valid or not

    Definition Classes
    JwtCore
  50. def isValid(token: String, key: String): Boolean

    An alias for isValid if you want to directly pass a string as the key

    An alias for isValid if you want to directly pass a string as the key

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    key

    the key that will be used to check the token signature

    returns

    a boolean value indicating if the token is valid or not

    Definition Classes
    JwtCore
  51. def isValid(token: String): Boolean

    Test if a token is valid.

    Test if a token is valid. Doesn't throw any exception.

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    returns

    a boolean value indicating if the token is valid or not

    Definition Classes
    JwtCore
  52. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  53. final def notify(): Unit

    Definition Classes
    AnyRef
  54. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  55. def parseClaim(claim: String): String

    Attributes
    protected
    Definition Classes
    JwtJwtCore
  56. def parseHeader(header: String): String

    Attributes
    protected
    Definition Classes
    JwtJwtCore
  57. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  58. def toString(): String

    Definition Classes
    AnyRef → Any
  59. def validate(token: String, key: PublicKey): Unit

    An alias of validate in case you want to directly pass a string key.

    An alias of validate in case you want to directly pass a string key.

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    key

    the key that will be used to check the token signature

    Definition Classes
    JwtCore
    Exceptions thrown
    IllegalArgumentException

    couldn't decode the token since it's not a valid base64 string

    JwtExpirationException

    the token isn't valid anymore because its expiration attribute is in the past

    JwtLengthException

    the number of parts separated by dots is wrong

    JwtNotBeforeException

    the token isn't valid yet because its notBefore attribute is in the future

    JwtValidationException

    default validation exeption

  60. def validate(token: String, key: SecretKey): Unit

    An alias of validate in case you want to directly pass a string key.

    An alias of validate in case you want to directly pass a string key.

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    key

    the key that will be used to check the token signature

    Definition Classes
    JwtCore
    Exceptions thrown
    IllegalArgumentException

    couldn't decode the token since it's not a valid base64 string

    JwtExpirationException

    the token isn't valid anymore because its expiration attribute is in the past

    JwtLengthException

    the number of parts separated by dots is wrong

    JwtNotBeforeException

    the token isn't valid yet because its notBefore attribute is in the future

    JwtValidationException

    default validation exeption

  61. def validate(token: String, key: String): Unit

    An alias of validate in case you want to directly pass a string key.

    An alias of validate in case you want to directly pass a string key.

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    key

    the key that will be used to check the token signature

    Definition Classes
    JwtCore
    Exceptions thrown
    IllegalArgumentException

    couldn't decode the token since it's not a valid base64 string

    JwtExpirationException

    the token isn't valid anymore because its expiration attribute is in the past

    JwtLengthException

    the number of parts separated by dots is wrong

    JwtNotBeforeException

    the token isn't valid yet because its notBefore attribute is in the future

    JwtValidationException

    default validation exeption

  62. def validate(token: String): Unit

    Valid a token: doesn't return anything but will thrown exceptions if there are any errors.

    Valid a token: doesn't return anything but will thrown exceptions if there are any errors.

    token

    a JSON Web Token as a Base64 url-safe encoded String which can be used inside an HTTP header

    Definition Classes
    JwtCore
    Exceptions thrown
    IllegalArgumentException

    couldn't decode the token since it's not a valid base64 string

    JwtExpirationException

    the token isn't valid anymore because its expiration attribute is in the past

    JwtLengthException

    the number of parts separated by dots is wrong

    JwtNotBeforeException

    the token isn't valid yet because its notBefore attribute is in the future

    JwtValidationException

    default validation exeption

  63. def validate(header64: String, header: String, claim64: String, claim: String, signature: String, key: PublicKey): Unit

    Attributes
    protected
    Definition Classes
    JwtCore
  64. def validate(header64: String, header: String, claim64: String, claim: String, signature: String, key: SecretKey): Unit

    Attributes
    protected
    Definition Classes
    JwtCore
  65. def validate(header64: String, header: String, claim64: String, claim: String, signature: String, key: String): Unit

    Attributes
    protected
    Definition Classes
    JwtCore
  66. def validate(header64: String, header: String, claim64: String, claim: String, signature: String, verify: (Array[Byte], Array[Byte], JwtAlgorithm) ⇒ Boolean): Unit

    Attributes
    protected
    Definition Classes
    JwtCore
  67. def validate(header: String, claim: String, signature: String): Unit

    Attributes
    protected
    Definition Classes
    JwtCore
  68. def validateTiming(claim: String): Unit

    Attributes
    protected
    Definition Classes
    JwtCore
  69. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  70. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  71. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from JwtCore[String, String]

Inherited from AnyRef

Inherited from Any

Ungrouped