Package akka.javasdk

Interface JwtClaims


public interface JwtClaims
Representation of JWT claims that have been validated and extracted from the bearer token of a request.
  • Method Details

    • allClaimNames

      Iterable<String> allClaimNames()
      Returns the names of all the claims in this request.
      Returns:
      The names of all the claims in this request.
    • asMap

      Map<String,String> asMap()
      Returns all the claims as a map of strings to strings.

      If the claim is a String claim, the value will be the raw String. For all other types, it will be the value of the claim encoded to JSON.

      Returns:
      All the claims represented as a map of string claim names to string values.
    • hasClaims

      boolean hasClaims()
      Does this request have any claims that have been validated?
      Returns:
      true if there are claims.
    • issuer

      Optional<String> issuer()
      Get the issuer, that is, the iss claim, as described in RFC 7519 section 4.1.1.
      Returns:
      the issuer, if present.
      See Also:
    • subject

      Optional<String> subject()
      Get the subject, that is, the sub claim, as described in RFC 7519 section 4.1.2.
      Returns:
      the subject, if present.
      See Also:
    • audience

      Optional<String> audience()
      Get the audience, that is, the aud claim, as described in RFC 7519 section 4.1.3.
      Returns:
      the audience, if present.
      See Also:
    • expirationTime

      Optional<Instant> expirationTime()
      Get the expiration time, that is, the exp claim, as described in RFC 7519 section 4.1.4.
      Returns:
      the expiration time, if present. Returns empty if the value is not a numeric date.
      See Also:
    • notBefore

      Optional<Instant> notBefore()
      Get the not before, that is, the nbf claim, as described in RFC 7519 section 4.1.5.
      Returns:
      the not before, if present. Returns empty if the value is not a numeric date.
      See Also:
    • issuedAt

      Optional<Instant> issuedAt()
      Get the issued at, that is, the iat claim, as described in RFC 7519 section 4.1.6.
      Returns:
      the issued at, if present. Returns empty if the value is not a numeric date.
      See Also:
    • jwtId

      Optional<String> jwtId()
      Get the JWT ID, that is, the jti claim, as described in RFC 7519 section 4.1.7.
      Returns:
      the JWT ID, if present.
      See Also:
    • getString

      Optional<String> getString(String name)
      Get the string claim with the given name.

      Note that if the claim with the given name is not a string claim, this will return the JSON encoding of it.

      Parameters:
      name - The name of the claim.
      Returns:
      The string claim, if present.
    • getInteger

      Optional<Integer> getInteger(String name)
      Get the integer claim with the given name.
      Parameters:
      name - The name of the claim.
      Returns:
      The integer claim, if present. Returns empty if the claim is not an integer or can't be parsed as an integer.
    • getLong

      Optional<Long> getLong(String name)
      Get the long claim with the given name.
      Parameters:
      name - The name of the claim.
      Returns:
      The long claim, if present. Returns empty if the claim is not a long or can't be parsed as an long.
    • getDouble

      Optional<Double> getDouble(String name)
      Get the double claim with the given name.
      Parameters:
      name - The name of the claim.
      Returns:
      The double claim, if present. Returns empty if the claim is not a double or can't be parsed as an double.
    • getBoolean

      Optional<Boolean> getBoolean(String name)
      Get the boolean claim with the given name.
      Parameters:
      name - The name of the claim.
      Returns:
      The boolean claim, if present. Returns empty if the claim is not a boolean or can't be parsed as a boolean.
    • getNumericDate

      Optional<Instant> getNumericDate(String name)
      Get the numeric data claim with the given name.

      Numeric dates are expressed as a number of seconds since epoch, as described in RFC 7519 section 2.

      Parameters:
      name - The name of the claim.
      Returns:
      The numeric date claim, if present. Returns empty if the claim is not a numeric date or can't be parsed as a numeric date.
      See Also:
    • getObject

      Optional<com.fasterxml.jackson.databind.JsonNode> getObject(String name)
      Get the object claim with the given name.

      This returns the claim as a Jackson JsonNode AST.

      Parameters:
      name - The name of the claim.
      Returns:
      The object claim, if present. Returns empty if the claim is not an object or can't be parsed as an object.
    • getStringList

      Optional<List<String>> getStringList(String name)
      Get the string list claim with the given name.
      Parameters:
      name - The name of the claim.
      Returns:
      The string list claim, if present. Returns empty if the claim is not a JSON array of strings or cannot be parsed as a JSON array of strings.
    • getIntegerList

      Optional<List<Integer>> getIntegerList(String name)
      Get the integer list claim with the given name.
      Parameters:
      name - The name of the claim.
      Returns:
      The integer list claim, if present. Returns empty if the claim is not a JSON array of integers or cannot be parsed as a JSON array of integers.
    • getLongList

      Optional<List<Long>> getLongList(String name)
      Get the long list claim with the given name.
      Parameters:
      name - The name of the claim.
      Returns:
      The long list claim, if present. Returns empty if the claim is not a JSON array of longs or cannot be parsed as a JSON array of longs.
    • getDoubleList

      Optional<List<Double>> getDoubleList(String name)
      Get the double list claim with the given name.
      Parameters:
      name - The name of the claim.
      Returns:
      The double list claim, if present. Returns empty if the claim is not a JSON array of doubles or cannot be parsed as a JSON array of doubles.
    • getBooleanList

      Optional<List<Boolean>> getBooleanList(String name)
      Get the boolean list claim with the given name.
      Parameters:
      name - The name of the claim.
      Returns:
      The boolean list claim, if present. Returns empty if the claim is not a JSON array of booleans or cannot be parsed as a JSON array of booleans.
    • getNumericDateList

      Optional<List<Instant>> getNumericDateList(String name)
      Get the numeric date list claim with the given name.
      Parameters:
      name - The name of the claim.
      Returns:
      The numeric date list claim, if present. Returns empty if the claim is not a JSON array of numeric dates or cannot be parsed as a JSON array of numeric dates.
    • getObjectList

      Optional<List<com.fasterxml.jackson.databind.JsonNode>> getObjectList(String name)
      Get the object list claim with the given name.
      Parameters:
      name - The name of the claim.
      Returns:
      The object list claim, if present. Returns empty if the claim is not a JSON array of objects or cannot be parsed as a JSON array of objects.