@Test public void validate_tokenClientIdDoesNotMatchTrustedBrokerClientId() { Mockito.when(token.getAudiences()).thenReturn(Collections.emptySet()); Mockito.when(token.getClaimAsString(TokenClaims.XSUAA.CLIENT_ID)) .thenReturn("sb-clone-app-id!b123|xxx" + XSUAA_BROKER_XSAPPNAME); ValidationResult result = new JwtAudienceValidator(XSUAA_BROKER_XSAPPNAME) .validate(token); assertThat(result.isValid()).isFalse(); }
@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();  }