Search in sources :

Example 1 with UmaScopeDescription

use of org.xdi.oxauth.model.uma.persistence.UmaScopeDescription in project oxTrust by GluuFederation.

the class ScopeDescriptionService method generateInumForNewScopeDescription.

/**
 * Generate new inum for scope description
 *
 * @return New inum for scope description
 */
public String generateInumForNewScopeDescription() {
    UmaScopeDescription scopeDescription = new UmaScopeDescription();
    String newInum = null;
    do {
        newInum = generateInumForNewScopeDescriptionImpl();
        String newDn = getDnForScopeDescription(newInum);
        scopeDescription.setDn(newDn);
    } while (ldapEntryManager.contains(scopeDescription));
    return newInum;
}
Also used : UmaScopeDescription(org.xdi.oxauth.model.uma.persistence.UmaScopeDescription)

Example 2 with UmaScopeDescription

use of org.xdi.oxauth.model.uma.persistence.UmaScopeDescription in project oxTrust by GluuFederation.

the class ScopeDescriptionService method findScopeDescriptions.

/**
 * Search scope descriptions by pattern
 *
 * @param pattern Pattern
 * @param sizeLimit Maximum count of results
 * @return List of scope descriptions
 */
public List<UmaScopeDescription> findScopeDescriptions(String pattern, int sizeLimit) {
    String[] targetArray = new String[] { pattern };
    Filter oxIdFilter = Filter.createSubstringFilter("oxId", null, targetArray, null);
    Filter displayNameFilter = Filter.createSubstringFilter(OxTrustConstants.displayName, null, targetArray, null);
    Filter searchFilter = Filter.createORFilter(oxIdFilter, displayNameFilter);
    List<UmaScopeDescription> result = ldapEntryManager.findEntries(getDnForScopeDescription(null), UmaScopeDescription.class, searchFilter, sizeLimit);
    return result;
}
Also used : Filter(org.gluu.search.filter.Filter) UmaScopeDescription(org.xdi.oxauth.model.uma.persistence.UmaScopeDescription)

Example 3 with UmaScopeDescription

use of org.xdi.oxauth.model.uma.persistence.UmaScopeDescription in project oxTrust by GluuFederation.

the class ScopeDescriptionDownloadAction method getScopeDescription.

private UmaScopeDescription getScopeDescription() {
    try {
        scopeDescriptionService.prepareScopeDescriptionBranch();
    } catch (Exception ex) {
        log.error("Failed to initialize download action", ex);
        return null;
    }
    log.debug("Loading UMA scope description '{}'", this.scopeId);
    UmaScopeDescription scopeDescription;
    try {
        List<UmaScopeDescription> scopeDescriptions = scopeDescriptionService.findScopeDescriptionsById(this.scopeId);
        if (scopeDescriptions.size() != 1) {
            log.error("Failed to find scope description '{}'. Found: '{}'", this.scopeId, scopeDescriptions.size());
            return null;
        }
        scopeDescription = scopeDescriptions.get(0);
    } catch (BaseMappingException ex) {
        log.error("Failed to find scope description '{}'", this.scopeId, ex);
        return null;
    }
    return scopeDescription;
}
Also used : BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException) UmaScopeDescription(org.xdi.oxauth.model.uma.persistence.UmaScopeDescription) BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException)

Example 4 with UmaScopeDescription

use of org.xdi.oxauth.model.uma.persistence.UmaScopeDescription in project oxTrust by GluuFederation.

the class UpdateScopeDescriptionAction method add.

private String add() {
    if (this.scopeDescription != null) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    this.scopeDescription = new UmaScopeDescription();
    this.authorizationPolicies = getInitialAuthorizationPolicies();
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : UmaScopeDescription(org.xdi.oxauth.model.uma.persistence.UmaScopeDescription)

Example 5 with UmaScopeDescription

use of org.xdi.oxauth.model.uma.persistence.UmaScopeDescription in project oxTrust by GluuFederation.

the class ScopeDescriptionDownloadAction method downloadIcon.

public void downloadIcon() {
    byte[] resultFile = null;
    UmaScopeDescription scopeDescription = getScopeDescription();
    if (scopeDescription != null) {
        GluuImage gluuImage = imageService.getGluuImageFromXML(scopeDescription.getFaviconImageAsXml());
        try {
            resultFile = imageService.getThumImageData(gluuImage);
        } catch (Exception ex) {
            log.error("Failed to generate image response", ex);
        }
    }
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    if (resultFile == null) {
        HttpServletResponse response = (HttpServletResponse) externalContext.getResponse();
        FileDownloader.sendError(response, "Failed to prepare icon");
    } else {
        ContentDisposition contentDisposition = download ? ContentDisposition.ATTACHEMENT : ContentDisposition.NONE;
        ResponseHelper.downloadFile(scopeDescription.getId() + ".jpg", "image/jpeg", resultFile, contentDisposition, facesContext);
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) ContentDisposition(org.xdi.util.io.FileDownloader.ContentDisposition) UmaScopeDescription(org.xdi.oxauth.model.uma.persistence.UmaScopeDescription) ExternalContext(javax.faces.context.ExternalContext) GluuImage(org.xdi.model.GluuImage) HttpServletResponse(javax.servlet.http.HttpServletResponse) BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException)

Aggregations

UmaScopeDescription (org.xdi.oxauth.model.uma.persistence.UmaScopeDescription)6 BaseMappingException (org.gluu.persist.exception.mapping.BaseMappingException)3 ExternalContext (javax.faces.context.ExternalContext)1 FacesContext (javax.faces.context.FacesContext)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 Filter (org.gluu.search.filter.Filter)1 GluuImage (org.xdi.model.GluuImage)1 ContentDisposition (org.xdi.util.io.FileDownloader.ContentDisposition)1