@Test public void notBeforeToken_shouldThrow() throws Exception { JSONObject payload = new JSONObject(); Instant instant = Instant.now().plus(Duration.ofMinutes(1)); payload.put(JwtNames.CLAIM_NOT_BEFORE, instant.getEpochSecond()); Jwt notBeforeToken = new Jwt(new JSONObject(), payload, Clock.systemUTC(), Duration.ZERO); assertThrows(JwtNotBeforeException.class, notBeforeToken::getIssuer); assertThrows(JwtNotBeforeException.class, notBeforeToken::getSubject); assertThrows(JwtNotBeforeException.class, notBeforeToken::getAudiences); assertThrows(JwtNotBeforeException.class, notBeforeToken::getJwtId); assertThrows(JwtNotBeforeException.class, () -> notBeforeToken.getClaim("blah")); assertThrows(JwtNotBeforeException.class, notBeforeToken::getAlgorithm); assertThrows(JwtNotBeforeException.class, notBeforeToken::getType); assertThrows(JwtNotBeforeException.class, notBeforeToken::getContentType); assertThrows(JwtNotBeforeException.class, notBeforeToken::getKeyId); }
public Object getClaim(String name) throws JwtExpiredException, JwtNotBeforeException { validateTimestampClaims(); try { return payload.get(name); } catch (JSONException ex) { return null; } }
Jwt { public Object getClaim(String name) throws JwtExpiredException, JwtNotBeforeException { validateTimestampClaims(); try { return payload.get(name); } catch (JSONException ex) { return null; } } }
Jwt { public Object getClaim(String name) throws JwtExpiredException, JwtNotBeforeException { validateTimestampClaims(); try { return payload.get(name); } catch (JSONException ex) { return null; } } Jwt(JSONObject header, JSONObject payload, Clock clock, Duration clockSkew); }
Jwt { public Object getClaim(String name) throws JwtExpiredException, JwtNotBeforeException { validateTimestampClaims(); try { return payload.get(name); } catch (JSONException ex) { return null; } } Jwt(JSONObject header, JSONObject payload, Clock clock, Duration clockSkew); String getIssuer(); String getSubject(); List<String> getAudiences(); String getJwtId(); Instant getExpiration(); Instant getNotBefore(); Instant getIssuedAt(); Object getClaim(String name); String getType(); String getContentType(); String getAlgorithm(); String getKeyId(); }
Jwt { public Object getClaim(String name) throws JwtExpiredException, JwtNotBeforeException { validateTimestampClaims(); try { return payload.get(name); } catch (JSONException ex) { return null; } } Jwt(JSONObject header, JSONObject payload, Clock clock, Duration clockSkew); String getIssuer(); String getSubject(); List<String> getAudiences(); String getJwtId(); Instant getExpiration(); Instant getNotBefore(); Instant getIssuedAt(); Object getClaim(String name); String getType(); String getContentType(); String getAlgorithm(); String getKeyId();  }