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;
}
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;
}
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;
}
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;
}
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);
}
}
Aggregations