@Test public void hasAttributeShouldReturnFalseOnNoneAlgorithm() throws Exception { boolean authorized = sut.hasAttribute("admin", true, TOKEN_NONE_ALGORITHM); assertThat(authorized).isFalse(); }
public boolean hasAttribute(String attributeName, Object expectedValue, String token) { try { Jwts .parser() .require(attributeName, expectedValue) .setSigningKey(pubKeyProvider.get()) .parseClaimsJws(token); return true; } catch (JwtException e) { LOGGER.info("Jwt validation failed for claim {} to {}", attributeName, expectedValue, e); return false; } }
JwtTokenVerifier { public boolean hasAttribute(String attributeName, Object expectedValue, String token) { try { Jwts .parser() .require(attributeName, expectedValue) .setSigningKey(pubKeyProvider.get()) .parseClaimsJws(token); return true; } catch (JwtException e) { LOGGER.info("Jwt validation failed for claim {} to {}", attributeName, expectedValue, e); return false; } } }
JwtTokenVerifier { public boolean hasAttribute(String attributeName, Object expectedValue, String token) { try { Jwts .parser() .require(attributeName, expectedValue) .setSigningKey(pubKeyProvider.get()) .parseClaimsJws(token); return true; } catch (JwtException e) { LOGGER.info("Jwt validation failed for claim {} to {}", attributeName, expectedValue, e); return false; } } @Inject @VisibleForTesting  JwtTokenVerifier(PublicKeyProvider pubKeyProvider); }
JwtTokenVerifier { public boolean hasAttribute(String attributeName, Object expectedValue, String token) { try { Jwts .parser() .require(attributeName, expectedValue) .setSigningKey(pubKeyProvider.get()) .parseClaimsJws(token); return true; } catch (JwtException e) { LOGGER.info("Jwt validation failed for claim {} to {}", attributeName, expectedValue, e); return false; } } @Inject @VisibleForTesting  JwtTokenVerifier(PublicKeyProvider pubKeyProvider); boolean verify(String token); String extractLogin(String token); boolean hasAttribute(String attributeName, Object expectedValue, String token); }
JwtTokenVerifier { public boolean hasAttribute(String attributeName, Object expectedValue, String token) { try { Jwts .parser() .require(attributeName, expectedValue) .setSigningKey(pubKeyProvider.get()) .parseClaimsJws(token); return true; } catch (JwtException e) { LOGGER.info("Jwt validation failed for claim {} to {}", attributeName, expectedValue, e); return false; } } @Inject @VisibleForTesting  JwtTokenVerifier(PublicKeyProvider pubKeyProvider); boolean verify(String token); String extractLogin(String token); boolean hasAttribute(String attributeName, Object expectedValue, String token);  }