@Test void testGetLtpaTokenException() { for (String jwtToken : new String[] {"header.body.sign", "wrongJwtToken", ""}) { try { authService.getLtpaToken(jwtToken); fail(); } catch (TokenNotValidException e) { assertTrue(e.getMessage().contains("Token is not valid.")); } } }
public String getLtpaToken(String jwtToken) { final String withoutSign = removeSign(jwtToken); try { return Jwts.parserBuilder() .build() .parseClaimsJwt(withoutSign) .getBody() .get(LTPA_CLAIM_NAME, String.class); } catch (RuntimeException exception) { throw handleJwtParserException(exception); } }
AuthenticationService { public String getLtpaToken(String jwtToken) { final String withoutSign = removeSign(jwtToken); try { return Jwts.parserBuilder() .build() .parseClaimsJwt(withoutSign) .getBody() .get(LTPA_CLAIM_NAME, String.class); } catch (RuntimeException exception) { throw handleJwtParserException(exception); } } }
AuthenticationService { public String getLtpaToken(String jwtToken) { final String withoutSign = removeSign(jwtToken); try { return Jwts.parserBuilder() .build() .parseClaimsJwt(withoutSign) .getBody() .get(LTPA_CLAIM_NAME, String.class); } catch (RuntimeException exception) { throw handleJwtParserException(exception); } }  }
AuthenticationService { public String getLtpaToken(String jwtToken) { final String withoutSign = removeSign(jwtToken); try { return Jwts.parserBuilder() .build() .parseClaimsJwt(withoutSign) .getBody() .get(LTPA_CLAIM_NAME, String.class); } catch (RuntimeException exception) { throw handleJwtParserException(exception); } }  @PostConstruct void afterPropertiesSet(); String createJwtToken(String username, String domain, String ltpaToken); @CacheEvict(value = CACHE_VALIDATION_JWT_TOKEN, key = "#jwtToken") @Cacheable(value = CACHE_INVALIDATED_JWT_TOKENS, key = "#jwtToken", condition = "#jwtToken != null") Boolean invalidateJwtToken(String jwtToken, boolean distribute); @Cacheable(value = CACHE_INVALIDATED_JWT_TOKENS, unless = "true", key = "#jwtToken", condition = "#jwtToken != null") Boolean isInvalidated(String jwtToken); @Cacheable(value = CACHE_VALIDATION_JWT_TOKEN, key = "#jwtToken", condition = "#jwtToken != null") TokenAuthentication validateJwtToken(String jwtToken); @CachePut(value = "validationJwtToken", key = "#jwtToken", condition = "#jwtToken != null") TokenAuthentication createTokenAuthentication(String user, String jwtToken); boolean distributeInvalidate(String toInstanceId); TokenAuthentication validateJwtToken(TokenAuthentication token); QueryResponse parseJwtToken(String jwtToken); Optional<String> getJwtTokenFromRequest(HttpServletRequest request); String getLtpaTokenWithValidation(String jwtToken); String getLtpaToken(String jwtToken); }
AuthenticationService { public String getLtpaToken(String jwtToken) { final String withoutSign = removeSign(jwtToken); try { return Jwts.parserBuilder() .build() .parseClaimsJwt(withoutSign) .getBody() .get(LTPA_CLAIM_NAME, String.class); } catch (RuntimeException exception) { throw handleJwtParserException(exception); } }  @PostConstruct void afterPropertiesSet(); String createJwtToken(String username, String domain, String ltpaToken); @CacheEvict(value = CACHE_VALIDATION_JWT_TOKEN, key = "#jwtToken") @Cacheable(value = CACHE_INVALIDATED_JWT_TOKENS, key = "#jwtToken", condition = "#jwtToken != null") Boolean invalidateJwtToken(String jwtToken, boolean distribute); @Cacheable(value = CACHE_INVALIDATED_JWT_TOKENS, unless = "true", key = "#jwtToken", condition = "#jwtToken != null") Boolean isInvalidated(String jwtToken); @Cacheable(value = CACHE_VALIDATION_JWT_TOKEN, key = "#jwtToken", condition = "#jwtToken != null") TokenAuthentication validateJwtToken(String jwtToken); @CachePut(value = "validationJwtToken", key = "#jwtToken", condition = "#jwtToken != null") TokenAuthentication createTokenAuthentication(String user, String jwtToken); boolean distributeInvalidate(String toInstanceId); TokenAuthentication validateJwtToken(TokenAuthentication token); QueryResponse parseJwtToken(String jwtToken); Optional<String> getJwtTokenFromRequest(HttpServletRequest request); String getLtpaTokenWithValidation(String jwtToken); String getLtpaToken(String jwtToken);  }