@Test public void expiredToken_shouldThrow() throws Exception { JSONObject payload = new JSONObject(); Instant instant = Instant.now().minus(Duration.ofMinutes(1)); payload.put(JwtNames.CLAIM_EXPIRATION, instant.getEpochSecond()); Jwt expiredToken = new Jwt(new JSONObject(), payload, Clock.systemUTC(), Duration.ZERO); assertThrows(JwtExpiredException.class, expiredToken::getIssuer); assertThrows(JwtExpiredException.class, expiredToken::getSubject); assertThrows(JwtExpiredException.class, expiredToken::getAudiences); assertThrows(JwtExpiredException.class, expiredToken::getJwtId); assertThrows(JwtExpiredException.class, () -> expiredToken.getClaim("blah")); assertThrows(JwtExpiredException.class, expiredToken::getAlgorithm); assertThrows(JwtExpiredException.class, expiredToken::getType); assertThrows(JwtExpiredException.class, expiredToken::getContentType); assertThrows(JwtExpiredException.class, expiredToken::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();  }