/** * Validate scope validators in the oauth app. * * @param appScopeValidators list of scope validators * @param validationMsg validation msg list */ private void validateScopeValidators(String[] appScopeValidators, List<String> validationMsg) { OAuthAdminService oAuthAdminService = new OAuthAdminService(); List<String> scopeValidators = new ArrayList<>(Arrays.asList(oAuthAdminService.getAllowedScopeValidators())); Arrays.stream(appScopeValidators).forEach(validator -> { if (!scopeValidators.contains(validator)) { validationMsg.add(String.format("The scope validator %s is not available in the " + "server configuration. ", validator)); } }); }
/** * Get the scope validators registered by the user and filter the allowed ones. * * @param application Application user have registered. * @return List of scope validators. * @throws IdentityOAuthAdminException Identity OAuthAdmin exception. */ private String[] filterScopeValidators(OAuthConsumerAppDTO application) throws IdentityOAuthAdminException { List<String> scopeValidators = new ArrayList<>(Arrays.asList(getAllowedScopeValidators())); String[] requestedScopeValidators = application.getScopeValidators(); if (requestedScopeValidators == null) { requestedScopeValidators = new String[0]; } for (String requestedScopeValidator : requestedScopeValidators) { if (!scopeValidators.contains(requestedScopeValidator)) { throw new IdentityOAuthAdminException(requestedScopeValidator + " not allowed"); } } return requestedScopeValidators; }