Search in sources :

Example 6 with ResourceSet

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;
}
Also used : ResourceSet(org.xdi.oxauth.model.uma.persistence.ResourceSet)

Example 7 with ResourceSet

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;
}
Also used : ResourceSet(org.xdi.oxauth.model.uma.persistence.ResourceSet)

Example 8 with ResourceSet

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;
}
Also used : ResourceSet(org.xdi.oxauth.model.uma.persistence.ResourceSet) DisplayNameEntry(org.xdi.model.DisplayNameEntry)

Example 9 with ResourceSet

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());
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) ResourceSet(org.xdi.oxauth.model.uma.persistence.ResourceSet)

Aggregations

ResourceSet (org.xdi.oxauth.model.uma.persistence.ResourceSet)9 Filter (com.unboundid.ldap.sdk.Filter)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Response (javax.ws.rs.core.Response)1 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)1 DisplayNameEntry (org.xdi.model.DisplayNameEntry)1 PermissionTicket (org.xdi.oxauth.model.uma.PermissionTicket)1 Pair (org.xdi.util.Pair)1