diff --git a/security-jwt/src/main/java/io/micronaut/security/token/jwt/signature/jwks/JwksSignatureUtils.java b/security-jwt/src/main/java/io/micronaut/security/token/jwt/signature/jwks/JwksSignatureUtils.java index 80fd4b8b96..df7736a404 100644 --- a/security-jwt/src/main/java/io/micronaut/security/token/jwt/signature/jwks/JwksSignatureUtils.java +++ b/security-jwt/src/main/java/io/micronaut/security/token/jwt/signature/jwks/JwksSignatureUtils.java @@ -32,6 +32,7 @@ import java.util.Collections; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; /** @@ -71,10 +72,7 @@ public static boolean verify(SignedJWT jwt, JWKSet jwkSet, JwkValidator jwkValid * @return whether this signature configuration supports this algorithm */ public static boolean supports(JWSAlgorithm algorithm, JWKSet jwkSet) { - return jwkSet.getKeys() - .stream() - .map(JWK::getAlgorithm) - .anyMatch(algorithm::equals); + return supports(algorithm, jwkSet.getKeys()); } /** @@ -88,6 +86,7 @@ public static boolean supports(JWSAlgorithm algorithm, List keys) { return keys .stream() .map(JWK::getAlgorithm) + .filter(Objects::nonNull) .anyMatch(algorithm::equals); } @@ -106,6 +105,7 @@ public static String supportedAlgorithmsMessage(JWKSet jwkSet) { public static String supportedAlgorithmsMessage(List keys) { return keys.stream() .map(JWK::getAlgorithm) + .filter(Objects::nonNull) .map(Algorithm::getName) .distinct() .reduce((a, b) -> a + ", " + b)