private void handleExternalScopes(List<String> p_scopeUrls, List<String> result) throws LDAPException { for (String scopeUrl : p_scopeUrls) { final Filter filter = Filter.create(String.format("&(oxUrl=%s)", scopeUrl)); final List<ScopeDescription> entries = ldapEntryManager.findEntries(baseDn(), ScopeDescription.class, filter); if (entries != null && !entries.isEmpty()) { result.add(entries.get(0).getDn()); } else { // scope is not in ldap, add it dynamically final Boolean addAutomatically = ConfigurationFactory.instance().getConfiguration().getUmaAddScopesAutomatically(); if (addAutomatically != null && addAutomatically) { final String inum = inumService.generateInum(); final ScopeDescription newScope = new ScopeDescription(); newScope.setInum(inum); newScope.setUrl(scopeUrl); newScope.setDisplayName( scopeUrl); // temp solution : need extract info from scope description on resource // server newScope.setId( UmaScopeType.EXTERNAL_AUTO .getValue()); // dummy id : not sure what to put right now as id is required by // @NotNull annotation newScope.setType(InternalExternal.EXTERNAL_AUTO); final boolean persisted = persist(newScope); if (persisted) { result.add(newScope.getDn()); } } else { throw new WebApplicationException( Response.status(Response.Status.BAD_REQUEST) .entity( errorResponseFactory.getUmaJsonErrorResponse( UmaErrorResponseType.INVALID_RESOURCE_SET_SCOPE)) .build()); } } } }