use of org.xdi.oxauth.model.uma.persistence.ResourceSet in project oxTrust by GluuFederation.
the class ResourceSetService method generateInumForNewResourceSet.
/**
* Generate new inum for resource set
*
* @return New inum for resource set
*/
public String generateInumForNewResourceSet() {
ResourceSet resourceSet = new ResourceSet();
String newInum = null;
do {
newInum = generateInumForNewResourceSetImpl();
String newDn = getDnForResourceSet(newInum);
resourceSet.setDn(newDn);
} while (ldapEntryManager.contains(resourceSet));
return newInum;
}
use of org.xdi.oxauth.model.uma.persistence.ResourceSet in project oxTrust by GluuFederation.
the class ResourceSetService method generateIdForNewResourceSet.
/**
* Generate new inum for resource set
*
* @return New inum for resource set
*/
public String generateIdForNewResourceSet() {
ResourceSet resourceSet = new ResourceSet();
long currentTime = System.currentTimeMillis();
String newInum = null;
do {
newInum = Long.toString(currentTime);
String newDn = getDnForResourceSet(newInum);
resourceSet.setDn(newDn);
} while (ldapEntryManager.contains(resourceSet));
return newInum;
}
use of org.xdi.oxauth.model.uma.persistence.ResourceSet in project oxTrust by GluuFederation.
the class UpdateResourceSetAction method add.
private String add() {
this.resourceSet = new ResourceSet();
this.scopes = new ArrayList<DisplayNameEntry>();
this.clients = new ArrayList<DisplayNameEntry>();
this.resources = new ArrayList<String>();
return OxTrustConstants.RESULT_SUCCESS;
}
use of org.xdi.oxauth.model.uma.persistence.ResourceSet in project oxAuth by GluuFederation.
the class UmaValidationService method validateResourceSet.
public void validateResourceSet(UmaPermission resourceSetPermissionRequest) {
String resourceSetId = resourceSetPermissionRequest.getResourceSetId();
if (StringHelper.isEmpty(resourceSetId)) {
log.error("Resource set id is empty");
throw new WebApplicationException(Response.status(BAD_REQUEST).entity(errorResponseFactory.getUmaJsonErrorResponse(UmaErrorResponseType.INVALID_RESOURCE_SET_ID)).build());
}
ResourceSet resourceSet;
try {
ResourceSet exampleResourceSet = new ResourceSet();
exampleResourceSet.setDn(resourceSetService.getBaseDnForResourceSet());
exampleResourceSet.setId(resourceSetId);
List<ResourceSet> resourceSets = resourceSetService.findResourceSets(exampleResourceSet);
if (resourceSets.size() != 1) {
log.error("Resource set isn't registered or there are two resource set with same Id");
throw new WebApplicationException(Response.status(BAD_REQUEST).entity(errorResponseFactory.getUmaJsonErrorResponse(UmaErrorResponseType.INVALID_RESOURCE_SET_ID)).build());
}
resourceSet = resourceSets.get(0);
} catch (EntryPersistenceException ex) {
log.error("Resource set isn't registered");
throw new WebApplicationException(Response.status(BAD_REQUEST).entity(errorResponseFactory.getUmaJsonErrorResponse(UmaErrorResponseType.INVALID_RESOURCE_SET_ID)).build());
}
final List<String> scopeUrls = umaScopeService.getScopeUrlsByDns(resourceSet.getScopes());
if (!scopeUrls.containsAll(resourceSetPermissionRequest.getScopes())) {
log.error("At least one of the scope isn't registered");
throw new WebApplicationException(Response.status(BAD_REQUEST).entity(errorResponseFactory.getUmaJsonErrorResponse(UmaErrorResponseType.INVALID_RESOURCE_SET_SCOPE)).build());
}
}
Aggregations