MCPcopy Index your code
hub / github.com/auth0/java-jwt / JsonNodeClaim

Class JsonNodeClaim

lib/src/main/java/com/auth0/jwt/impl/JsonNodeClaim.java:22–182  ·  view source on GitHub ↗

The JsonNodeClaim retrieves a claim value from a JsonNode object.

Source from the content-addressed store, hash-verified

20 * The JsonNodeClaim retrieves a claim value from a JsonNode object.
21 */
22class JsonNodeClaim implements Claim {
23
24 private final ObjectCodec codec;
25 private final JsonNode data;
26
27 private JsonNodeClaim(JsonNode node, ObjectCodec codec) {
28 this.data = node;
29 this.codec = codec;
30 }
31
32 @Override
33 public Boolean asBoolean() {
34 return isMissing() || isNull() || !data.isBoolean() ? null : data.asBoolean();
35 }
36
37 @Override
38 public Integer asInt() {
39 return isMissing() || isNull() || !data.isNumber() ? null : data.asInt();
40 }
41
42 @Override
43 public Long asLong() {
44 return isMissing() || isNull() || !data.isNumber() ? null : data.asLong();
45 }
46
47 @Override
48 public Double asDouble() {
49 return isMissing() || isNull() || !data.isNumber() ? null : data.asDouble();
50 }
51
52 @Override
53 public String asString() {
54 return isMissing() || isNull() || !data.isTextual() ? null : data.asText();
55 }
56
57 @Override
58 public Date asDate() {
59 if (isMissing() || isNull() || !data.canConvertToLong()) {
60 return null;
61 }
62 long seconds = data.asLong();
63 return new Date(seconds * 1000);
64 }
65
66 @Override
67 public Instant asInstant() {
68 if (isMissing() || isNull() || !data.canConvertToLong()) {
69 return null;
70 }
71 long seconds = data.asLong();
72 return Instant.ofEpochSecond(seconds);
73 }
74
75 @Override
76 @SuppressWarnings("unchecked")
77 public <T> T[] asArray(Class<T> clazz) throws JWTDecodeException {
78 if (isMissing() || isNull() || !data.isArray()) {
79 return null;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…