@@ -61,12 +61,12 @@ public static class BaseVerification implements Verification {
6161 /**
6262 * Require a specific Issuer ("iss") claim.
6363 *
64- * @param issuer the required Issuer value
64+ * @param issuer the required Issuer value. If multiple values are given, the claim must at least match one of them
6565 * @return this same Verification instance.
6666 */
6767 @ Override
68- public Verification withIssuer (String issuer ) {
69- requireClaim (PublicClaims .ISSUER , issuer );
68+ public Verification withIssuer (String ... issuer ) {
69+ requireClaim (PublicClaims .ISSUER , issuer == null ? null : Arrays . asList ( issuer ) );
7070 return this ;
7171 }
7272
@@ -90,7 +90,7 @@ public Verification withSubject(String subject) {
9090 */
9191 @ Override
9292 public Verification withAudience (String ... audience ) {
93- requireClaim (PublicClaims .AUDIENCE , Arrays .asList (audience ));
93+ requireClaim (PublicClaims .AUDIENCE , audience == null ? null : Arrays .asList (audience ));
9494 return this ;
9595 }
9696
@@ -398,7 +398,6 @@ private void verifyClaims(DecodedJWT jwt, Map<String, Object> claims) throws Tok
398398 for (Map .Entry <String , Object > entry : claims .entrySet ()) {
399399 switch (entry .getKey ()) {
400400 case PublicClaims .AUDIENCE :
401- //noinspection unchecked
402401 assertValidAudienceClaim (jwt .getAudience (), (List <String >) entry .getValue ());
403402 break ;
404403 case PublicClaims .EXPIRES_AT :
@@ -411,7 +410,7 @@ private void verifyClaims(DecodedJWT jwt, Map<String, Object> claims) throws Tok
411410 assertValidDateClaim (jwt .getNotBefore (), (Long ) entry .getValue (), false );
412411 break ;
413412 case PublicClaims .ISSUER :
414- assertValidStringClaim ( entry . getKey (), jwt .getIssuer (), (String ) entry .getValue ());
413+ assertValidIssuerClaim ( jwt .getIssuer (), (List < String > ) entry .getValue ());
415414 break ;
416415 case PublicClaims .JWT_ID :
417416 assertValidStringClaim (entry .getKey (), jwt .getId (), (String ) entry .getValue ());
@@ -486,4 +485,10 @@ private void assertValidAudienceClaim(List<String> audience, List<String> value)
486485 throw new InvalidClaimException ("The Claim 'aud' value doesn't contain the required audience." );
487486 }
488487 }
488+
489+ private void assertValidIssuerClaim (String issuer , List <String > value ) {
490+ if (issuer == null || !value .contains (issuer )) {
491+ throw new InvalidClaimException ("The Claim 'iss' value doesn't match the required issuer." );
492+ }
493+ }
489494}
0 commit comments