@PostConstruct public void validate() { if (countBeans(AuthorizationServerEndpointsConfiguration.class) > 0) { // If we are an authorization server we don't need remote resource token // services return; } if (countBeans(ResourceServerTokenServicesConfiguration.class) == 0) { // If we are not a resource server or an SSO client we don't need remote // resource token services return; } if (!StringUtils.hasText(this.clientId)) { return; } try { doValidate(); } catch (BindException ex) { throw new IllegalStateException(ex); } }
@Override public void validate(Object target, Errors errors) { if (countBeans(AuthorizationServerEndpointsConfiguration.class) > 0) { // If we are an authorization server we don't need remote resource token // services return; } if (countBeans(ResourceServerTokenServicesConfiguration.class) == 0) { // If we are not a resource server or an SSO client we don't need remote // resource token services return; } ResourceServerProperties resource = (ResourceServerProperties) target; if (StringUtils.hasText(this.clientId)) { if (!StringUtils.hasText(this.clientSecret)) { if (!StringUtils.hasText(resource.getUserInfoUri())) { errors.rejectValue("userInfoUri", "missing.userInfoUri", "Missing userInfoUri (no client secret available)"); } } else { if (isPreferTokenInfo() && !StringUtils.hasText(resource.getTokenInfoUri())) { if (StringUtils.hasText(getJwt().getKeyUri()) || StringUtils.hasText(getJwt().getKeyValue())) { // It's a JWT decoder return; } if (!StringUtils.hasText(resource.getUserInfoUri())) { errors.rejectValue("tokenInfoUri", "missing.tokenInfoUri", "Missing tokenInfoUri and userInfoUri and there is no " + "JWT verifier key"); } } } } }