use of org.xdi.oxauth.model.uma.persistence.ScopeDescription in project oxTrust by GluuFederation.
the class UpdateResourceSetAction method acceptSelectScopes.
public void acceptSelectScopes() {
Set<String> addedScopeInums = getAddedScopesInums();
for (SelectableEntity<ScopeDescription> availableScope : this.availableScopes) {
ScopeDescription scopeDescription = availableScope.getEntity();
String scopeDescriptionInum = scopeDescription.getInum();
if (availableScope.isSelected() && !addedScopeInums.contains(scopeDescriptionInum)) {
addScope(scopeDescription);
}
if (!availableScope.isSelected() && addedScopeInums.contains(scopeDescriptionInum)) {
removeScope(scopeDescriptionInum);
}
}
}
use of org.xdi.oxauth.model.uma.persistence.ScopeDescription in project oxAuth by GluuFederation.
the class ScopeService method handleExternalScopes.
private void handleExternalScopes(List<String> scopeUrls, List<String> result) throws LDAPException {
for (String scopeUrl : 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 = appConfiguration.getUmaAddScopesAutomatically();
if (addAutomatically != null && addAutomatically) {
final String inum = inumService.generateInum();
final ScopeDescription newScope = new ScopeDescription();
newScope.setInum(inum);
newScope.setUrl(scopeUrl);
// temp solution : need extract info from scope description on resource server
newScope.setDisplayName(scopeUrl);
// dummy id : not sure what to put right now as id is required by @NotNull annotation
newScope.setId(UmaScopeType.EXTERNAL_AUTO.getValue());
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());
}
}
}
}
Aggregations