@Test(expected = JwtAuthenticationException.class) public void testExceptionThrownIfLastPasswordResetDateCannotBeExtractedFromTokenClaims() { when(claims.get(JwtUtils.CLAIM_KEY_LAST_PASSWORD_CHANGE_DATE)).thenReturn(null); jwtUtils.getLastPasswordResetDateFromTokenClaims(claims); verify(claims, times(1)).get(JwtUtils.CLAIM_KEY_LAST_PASSWORD_CHANGE_DATE); }
Date getLastPasswordResetDateFromTokenClaims(Claims claims) { Date lastPasswordResetDate; try { lastPasswordResetDate = new Date((Long) claims.get(CLAIM_KEY_LAST_PASSWORD_CHANGE_DATE)); } catch (Exception e) { final String errorMsg = "Failed to extract lastPasswordResetDate claim from token!"; LOG.error(errorMsg, e); throw new JwtAuthenticationException(errorMsg, e); } return lastPasswordResetDate; }
JwtUtils { Date getLastPasswordResetDateFromTokenClaims(Claims claims) { Date lastPasswordResetDate; try { lastPasswordResetDate = new Date((Long) claims.get(CLAIM_KEY_LAST_PASSWORD_CHANGE_DATE)); } catch (Exception e) { final String errorMsg = "Failed to extract lastPasswordResetDate claim from token!"; LOG.error(errorMsg, e); throw new JwtAuthenticationException(errorMsg, e); } return lastPasswordResetDate; } }
JwtUtils { Date getLastPasswordResetDateFromTokenClaims(Claims claims) { Date lastPasswordResetDate; try { lastPasswordResetDate = new Date((Long) claims.get(CLAIM_KEY_LAST_PASSWORD_CHANGE_DATE)); } catch (Exception e) { final String errorMsg = "Failed to extract lastPasswordResetDate claim from token!"; LOG.error(errorMsg, e); throw new JwtAuthenticationException(errorMsg, e); } return lastPasswordResetDate; }  }
JwtUtils { Date getLastPasswordResetDateFromTokenClaims(Claims claims) { Date lastPasswordResetDate; try { lastPasswordResetDate = new Date((Long) claims.get(CLAIM_KEY_LAST_PASSWORD_CHANGE_DATE)); } catch (Exception e) { final String errorMsg = "Failed to extract lastPasswordResetDate claim from token!"; LOG.error(errorMsg, e); throw new JwtAuthenticationException(errorMsg, e); } return lastPasswordResetDate; }  Claims validateTokenAndGetClaims(String token); String createToken(JwtUser userDetails); boolean canTokenBeRefreshed(Claims claims, Date lastPasswordReset); String refreshToken(String token); String getUsernameFromTokenClaims(Claims claims); List<GrantedAuthority> getRolesFromTokenClaims(Claims claims); }
JwtUtils { Date getLastPasswordResetDateFromTokenClaims(Claims claims) { Date lastPasswordResetDate; try { lastPasswordResetDate = new Date((Long) claims.get(CLAIM_KEY_LAST_PASSWORD_CHANGE_DATE)); } catch (Exception e) { final String errorMsg = "Failed to extract lastPasswordResetDate claim from token!"; LOG.error(errorMsg, e); throw new JwtAuthenticationException(errorMsg, e); } return lastPasswordResetDate; }  Claims validateTokenAndGetClaims(String token); String createToken(JwtUser userDetails); boolean canTokenBeRefreshed(Claims claims, Date lastPasswordReset); String refreshToken(String token); String getUsernameFromTokenClaims(Claims claims); List<GrantedAuthority> getRolesFromTokenClaims(Claims claims);  }