Class JwtClaimsImpl

  • All Implemented Interfaces:
    JwtClaims, JwtClaims, java.io.Serializable, scala.Equals, scala.Product

    public final class JwtClaimsImpl
    extends java.lang.Object
    implements JwtClaims, JwtClaims, scala.Product, java.io.Serializable
    INTERNAL API

    JwtClaims provides utilities to easily assert and extract claims from the JWT token

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      JwtClaimsImpl​(spray.json.JsObject claims)  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract static R apply​(T1 v1)  
      scala.Option<java.lang.Object> booleanClaim​(java.lang.String name)
      Extracts a boolean claim from the list of claims.
      spray.json.JsObject claims()  
      scala.Option<java.lang.Object> doubleClaim​(java.lang.String name)
      Extracts a double claim from the list of claims.
      java.util.Optional<java.lang.Object> getBooleanClaim​(java.lang.String name)
      Extracts a boolean claim from the list of claims.
      java.util.Optional<java.lang.Object> getDoubleClaim​(java.lang.String name)
      Extracts a double claim from the list of claims.
      java.util.Optional<java.lang.Object> getIntClaim​(java.lang.String name)
      Extracts an integer claim from the list of claims.
      java.util.Optional<java.lang.Object> getLongClaim​(java.lang.String name)
      Extracts a long claim from the list of claims.
      java.util.Optional<java.lang.String> getRawClaim​(java.lang.String name)
      Extracts a raw claim from the list of claims.
      java.util.Optional<java.lang.String> getStringClaim​(java.lang.String name)
      Extracts a string claim from the list of claims.
      java.util.List<java.lang.String> getStringClaims​(java.lang.String name)
      Extracts a list of string claims from the list of claims.
      boolean hasClaim​(java.lang.String name)
      Checks if a claim with the given name exists in the list of claims.
      scala.Option<java.lang.Object> intClaim​(java.lang.String name)
      Extracts an integer claim from the list of claims.
      scala.Option<java.lang.Object> longClaim​(java.lang.String name)
      Extracts a long claim from the list of claims.
      scala.Option<spray.json.JsValue> rawClaim​(java.lang.String name)
      Extracts a raw claim from the list of claims.
      scala.Option<java.lang.String> stringClaim​(java.lang.String name)
      Extracts a string claim from the list of claims.
      scala.collection.immutable.List<java.lang.String> stringClaims​(java.lang.String name)
      Extracts a list of string claims from the list of claims.
      static java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface scala.Equals

        canEqual, equals
      • Methods inherited from interface scala.Product

        productArity, productElement, productElementName, productElementNames, productIterator, productPrefix
    • Constructor Detail

      • JwtClaimsImpl

        public JwtClaimsImpl​(spray.json.JsObject claims)
    • Method Detail

      • apply

        public abstract static R apply​(T1 v1)
      • toString

        public static java.lang.String toString()
      • claims

        public spray.json.JsObject claims()
      • hasClaim

        public boolean hasClaim​(java.lang.String name)
        Description copied from interface: JwtClaims
        Checks if a claim with the given name exists in the list of claims.

        Specified by:
        hasClaim in interface JwtClaims
        Specified by:
        hasClaim in interface JwtClaims
        Parameters:
        name - the name of the claim.
        Returns:
        true if the claim exists, false otherwise.
      • intClaim

        public scala.Option<java.lang.Object> intClaim​(java.lang.String name)
        Description copied from interface: JwtClaims
        Extracts an integer claim from the list of claims.

        Specified by:
        intClaim in interface JwtClaims
        Parameters:
        name - the name of the claim.
        Returns:
        an Option containing the integer value of the claim if it exists and is an integer, None otherwise.
      • longClaim

        public scala.Option<java.lang.Object> longClaim​(java.lang.String name)
        Description copied from interface: JwtClaims
        Extracts a long claim from the list of claims.

        Specified by:
        longClaim in interface JwtClaims
        Parameters:
        name - the name of the claim.
        Returns:
        an Option containing the long value of the claim if it exists and is a long, None otherwise.
      • doubleClaim

        public scala.Option<java.lang.Object> doubleClaim​(java.lang.String name)
        Description copied from interface: JwtClaims
        Extracts a double claim from the list of claims.

        Specified by:
        doubleClaim in interface JwtClaims
        Parameters:
        name - the name of the claim.
        Returns:
        an Option containing the double value of the claim if it exists and is a double, None otherwise.
      • stringClaim

        public scala.Option<java.lang.String> stringClaim​(java.lang.String name)
        Description copied from interface: JwtClaims
        Extracts a string claim from the list of claims.

        Specified by:
        stringClaim in interface JwtClaims
        Parameters:
        name - the name of the claim.
        Returns:
        an Option containing the string value of the claim if it exists and is a string, None otherwise.
      • stringClaims

        public scala.collection.immutable.List<java.lang.String> stringClaims​(java.lang.String name)
        Description copied from interface: JwtClaims
        Extracts a list of string claims from the list of claims.

        Specified by:
        stringClaims in interface JwtClaims
        Parameters:
        name - the name of the claim.
        Returns:
        a List containing the string values of the claim if it exists and is a list of strings, empty list otherwise.
      • booleanClaim

        public scala.Option<java.lang.Object> booleanClaim​(java.lang.String name)
        Description copied from interface: JwtClaims
        Extracts a boolean claim from the list of claims.

        Specified by:
        booleanClaim in interface JwtClaims
        Parameters:
        name - the name of the claim.
        Returns:
        an Option containing the boolean value of the claim if it exists and is a boolean, None otherwise.
      • rawClaim

        public scala.Option<spray.json.JsValue> rawClaim​(java.lang.String name)
        Description copied from interface: JwtClaims
        Extracts a raw claim from the list of claims. This can be useful if you need to extract a claim that is not a primitive type but a complex one.

        Specified by:
        rawClaim in interface JwtClaims
        Parameters:
        name - the name of the claim.
        Returns:
        an Option containing the raw JsValue of the claim if it exists, None otherwise.
      • getIntClaim

        public java.util.Optional<java.lang.Object> getIntClaim​(java.lang.String name)
        Description copied from interface: JwtClaims
        Extracts an integer claim from the list of claims.

        Specified by:
        getIntClaim in interface JwtClaims
        Parameters:
        name - the name of the claim.
        Returns:
        an Optional containing the integer value of the claim if it exists and is an integer, Optional.empty otherwise.
      • getLongClaim

        public java.util.Optional<java.lang.Object> getLongClaim​(java.lang.String name)
        Description copied from interface: JwtClaims
        Extracts a long claim from the list of claims.

        Specified by:
        getLongClaim in interface JwtClaims
        Parameters:
        name - the name of the claim.
        Returns:
        an Optional containing the long value of the claim if it exists and is a long, Optional.empty otherwise.
      • getDoubleClaim

        public java.util.Optional<java.lang.Object> getDoubleClaim​(java.lang.String name)
        Description copied from interface: JwtClaims
        Extracts a double claim from the list of claims.

        Specified by:
        getDoubleClaim in interface JwtClaims
        Parameters:
        name - the name of the claim.
        Returns:
        an Optional containing the double value of the claim if it exists and is a double, Optional.empty otherwise.
      • getStringClaim

        public java.util.Optional<java.lang.String> getStringClaim​(java.lang.String name)
        Description copied from interface: JwtClaims
        Extracts a string claim from the list of claims.

        Specified by:
        getStringClaim in interface JwtClaims
        Parameters:
        name - the name of the claim.
        Returns:
        an Optional containing the string value of the claim if it exists and is a string, Optional.empty otherwise.
      • getStringClaims

        public java.util.List<java.lang.String> getStringClaims​(java.lang.String name)
        Description copied from interface: JwtClaims
        Extracts a list of string claims from the list of claims.

        Specified by:
        getStringClaims in interface JwtClaims
        Parameters:
        name - the name of the claim.
        Returns:
        a List containing the string values of the claim if it exists and is a list of strings, empty list otherwise.
      • getBooleanClaim

        public java.util.Optional<java.lang.Object> getBooleanClaim​(java.lang.String name)
        Description copied from interface: JwtClaims
        Extracts a boolean claim from the list of claims.

        Specified by:
        getBooleanClaim in interface JwtClaims
        Parameters:
        name - the name of the claim.
        Returns:
        an Optional containing the boolean value of the claim if it exists and is a boolean, Optional.empty otherwise.
      • getRawClaim

        public java.util.Optional<java.lang.String> getRawClaim​(java.lang.String name)
        Description copied from interface: JwtClaims
        Extracts a raw claim from the list of claims. This can be useful if you need to extract a claim that is not a primitive type but a complex one.

        Specified by:
        getRawClaim in interface JwtClaims
        Parameters:
        name - the name of the claim.
        Returns:
        an Optional containing the raw JSON String value of the claim if it exists, Optional.empty otherwise.