Class JsonNodeClaim

java.lang.Object
com.auth0.jwt.impl.JsonNodeClaim
All Implemented Interfaces:
Claim

class JsonNodeClaim extends Object implements Claim
The JsonNodeClaim retrieves a claim value from a JsonNode object.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final com.fasterxml.jackson.databind.JsonNode
     
    private final com.fasterxml.jackson.databind.ObjectReader
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    JsonNodeClaim(com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.ObjectReader objectReader)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    as(Class<T> tClazz)
    Get this Claim as a custom type T.
    <T> T[]
    asArray(Class<T> tClazz)
    Get this Claim as an Array of type T.
    Get this Claim as a Boolean.
    Get this Claim as a Date.
    Get this Claim as a Double.
    Get this Claim as an Integer.
    <T> List<T>
    asList(Class<T> tClazz)
    Get this Claim as a List of type T.
    Get this Claim as an Long.
    Get this Claim as a generic Map of values.
    Get this Claim as a String.
    (package private) static Claim
    claimFromNode(com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.ObjectReader objectReader)
    Helper method to create a Claim representation from the given JsonNode.
    (package private) static Claim
    extractClaim(String claimName, Map<String,com.fasterxml.jackson.databind.JsonNode> tree, com.fasterxml.jackson.databind.ObjectReader objectReader)
    Helper method to extract a Claim from the given JsonNode tree.
    boolean
    Whether this Claim has a null value or not.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • objectReader

      private final com.fasterxml.jackson.databind.ObjectReader objectReader
    • data

      private final com.fasterxml.jackson.databind.JsonNode data
  • Constructor Details

    • JsonNodeClaim

      private JsonNodeClaim(com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.ObjectReader objectReader)
  • Method Details

    • asBoolean

      public Boolean asBoolean()
      Description copied from interface: Claim
      Get this Claim as a Boolean. If the value isn't of type Boolean or it can't be converted to a Boolean, null will be returned.
      Specified by:
      asBoolean in interface Claim
      Returns:
      the value as a Boolean or null.
    • asInt

      public Integer asInt()
      Description copied from interface: Claim
      Get this Claim as an Integer. If the value isn't of type Integer or it can't be converted to an Integer, null will be returned.
      Specified by:
      asInt in interface Claim
      Returns:
      the value as an Integer or null.
    • asLong

      public Long asLong()
      Description copied from interface: Claim
      Get this Claim as an Long. If the value isn't of type Long or it can't be converted to an Long, null will be returned.
      Specified by:
      asLong in interface Claim
      Returns:
      the value as an Long or null.
    • asDouble

      public Double asDouble()
      Description copied from interface: Claim
      Get this Claim as a Double. If the value isn't of type Double or it can't be converted to a Double, null will be returned.
      Specified by:
      asDouble in interface Claim
      Returns:
      the value as a Double or null.
    • asString

      public String asString()
      Description copied from interface: Claim
      Get this Claim as a String. If the value isn't of type String or it can't be converted to a String, null will be returned.
      Specified by:
      asString in interface Claim
      Returns:
      the value as a String or null.
    • asDate

      public Date asDate()
      Description copied from interface: Claim
      Get this Claim as a Date. If the value can't be converted to a Date, null will be returned.
      Specified by:
      asDate in interface Claim
      Returns:
      the value as a Date or null.
    • asArray

      public <T> T[] asArray(Class<T> tClazz) throws JWTDecodeException
      Description copied from interface: Claim
      Get this Claim as an Array of type T. If the value isn't an Array, null will be returned.
      Specified by:
      asArray in interface Claim
      Type Parameters:
      T - type
      Parameters:
      tClazz - the type class
      Returns:
      the value as an Array or null.
      Throws:
      JWTDecodeException - if the values inside the Array can't be converted to a class T.
    • asList

      public <T> List<T> asList(Class<T> tClazz) throws JWTDecodeException
      Description copied from interface: Claim
      Get this Claim as a List of type T. If the value isn't an Array, null will be returned.
      Specified by:
      asList in interface Claim
      Type Parameters:
      T - type
      Parameters:
      tClazz - the type class
      Returns:
      the value as a List or null.
      Throws:
      JWTDecodeException - if the values inside the List can't be converted to a class T.
    • asMap

      public Map<String,Object> asMap() throws JWTDecodeException
      Description copied from interface: Claim
      Get this Claim as a generic Map of values.
      Specified by:
      asMap in interface Claim
      Returns:
      the value as instance of Map.
      Throws:
      JWTDecodeException - if the value can't be converted to a Map.
    • as

      public <T> T as(Class<T> tClazz) throws JWTDecodeException
      Description copied from interface: Claim
      Get this Claim as a custom type T.
      Specified by:
      as in interface Claim
      Type Parameters:
      T - type
      Parameters:
      tClazz - the type class
      Returns:
      the value as instance of T.
      Throws:
      JWTDecodeException - if the value can't be converted to a class T.
    • isNull

      public boolean isNull()
      Description copied from interface: Claim
      Whether this Claim has a null value or not.
      Specified by:
      isNull in interface Claim
      Returns:
      whether this Claim has a null value or not.
    • extractClaim

      static Claim extractClaim(String claimName, Map<String,com.fasterxml.jackson.databind.JsonNode> tree, com.fasterxml.jackson.databind.ObjectReader objectReader)
      Helper method to extract a Claim from the given JsonNode tree.
      Parameters:
      claimName - the Claim to search for.
      tree - the JsonNode tree to search the Claim in.
      Returns:
      a valid non-null Claim.
    • claimFromNode

      static Claim claimFromNode(com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.ObjectReader objectReader)
      Helper method to create a Claim representation from the given JsonNode.
      Parameters:
      node - the JsonNode to convert into a Claim.
      Returns:
      a valid Claim instance. If the node is null or missing, a NullClaim will be returned.