@Test public void validationFails_when_TokenAudiencesAreEmpty() { Mockito.when(token.getAudiences()).thenReturn(Collections.emptySet()); ValidationResult result = new JwtAudienceValidator("any") .validate(token); assertThat(result.isErroneous()).isTrue(); assertThat(result.getErrorDescription()) .isEqualTo("Jwt token with audience [] is not issued for these clientIds: [any]."); }
@Override public ValidationResult validate(Token token) { Set<String> allowedAudiences = extractAudiencesFromToken(token); if (validateDefault(allowedAudiences) || validateAudienceOfXsuaaBrokerClone(allowedAudiences)) { return ValidationResults.createValid(); } return ValidationResults.createInvalid( "Jwt token with audience {} is not issued for these clientIds: {}.", token.getAudiences(), trustedClientIds); }
JwtAudienceValidator implements Validator<Token> { @Override public ValidationResult validate(Token token) { Set<String> allowedAudiences = extractAudiencesFromToken(token); if (validateDefault(allowedAudiences) || validateAudienceOfXsuaaBrokerClone(allowedAudiences)) { return ValidationResults.createValid(); } return ValidationResults.createInvalid( "Jwt token with audience {} is not issued for these clientIds: {}.", token.getAudiences(), trustedClientIds); } }
JwtAudienceValidator implements Validator<Token> { @Override public ValidationResult validate(Token token) { Set<String> allowedAudiences = extractAudiencesFromToken(token); if (validateDefault(allowedAudiences) || validateAudienceOfXsuaaBrokerClone(allowedAudiences)) { return ValidationResults.createValid(); } return ValidationResults.createInvalid( "Jwt token with audience {} is not issued for these clientIds: {}.", token.getAudiences(), trustedClientIds); } JwtAudienceValidator(String clientId); }
JwtAudienceValidator implements Validator<Token> { @Override public ValidationResult validate(Token token) { Set<String> allowedAudiences = extractAudiencesFromToken(token); if (validateDefault(allowedAudiences) || validateAudienceOfXsuaaBrokerClone(allowedAudiences)) { return ValidationResults.createValid(); } return ValidationResults.createInvalid( "Jwt token with audience {} is not issued for these clientIds: {}.", token.getAudiences(), trustedClientIds); } JwtAudienceValidator(String clientId); @Override ValidationResult validate(Token token); Set<String> getTrustedClientIds(); }
JwtAudienceValidator implements Validator<Token> { @Override public ValidationResult validate(Token token) { Set<String> allowedAudiences = extractAudiencesFromToken(token); if (validateDefault(allowedAudiences) || validateAudienceOfXsuaaBrokerClone(allowedAudiences)) { return ValidationResults.createValid(); } return ValidationResults.createInvalid( "Jwt token with audience {} is not issued for these clientIds: {}.", token.getAudiences(), trustedClientIds); } JwtAudienceValidator(String clientId); @Override ValidationResult validate(Token token); Set<String> getTrustedClientIds();  }