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);
}
}
use of org.xdi.oxauth.model.uma.persistence.UmaScopeDescription in project oxTrust by GluuFederation.
the class UpdateScopeDescriptionAction method save.
public String save() {
updateAuthorizationPolicies();
this.scopeDescription.setDisplayName(this.scopeDescription.getDisplayName().trim());
if (this.update) {
// Update scope description
try {
scopeDescriptionService.updateScopeDescription(this.scopeDescription);
} catch (BaseMappingException ex) {
log.error("Failed to update scope description '{}'", this.scopeDescription.getId(), ex);
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to update UMA resource '#{updateScopeDescriptionAction.scopeDescription.displayName}'");
return OxTrustConstants.RESULT_FAILURE;
}
log.debug("Scope description were updated successfully");
facesMessages.add(FacesMessage.SEVERITY_INFO, "UMA resource '#{updateScopeDescriptionAction.scopeDescription.displayName}' updated successfully");
return OxTrustConstants.RESULT_SUCCESS;
} else {
// Check if scope description with this name already exist
UmaScopeDescription exampleScopeDescription = new UmaScopeDescription();
exampleScopeDescription.setDn(scopeDescriptionService.getDnForScopeDescription(null));
exampleScopeDescription.setId(scopeDescription.getId());
String inum = scopeDescriptionService.generateInumForNewScopeDescription();
String scopeDescriptionDn = scopeDescriptionService.getDnForScopeDescription(inum);
this.scopeDescription.setInum(inum);
this.scopeDescription.setDn(scopeDescriptionDn);
this.scopeDescription.setOwner(identity.getUser().getDn());
this.scopeDescription.setId(scopeDescription.getId());
// Save scope description
try {
scopeDescriptionService.addScopeDescription(this.scopeDescription);
} catch (BaseMappingException ex) {
log.error("Failed to add new UMA resource '{}'", this.scopeDescription.getId(), ex);
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to add new UMA resource");
return OxTrustConstants.RESULT_FAILURE;
}
log.debug("Scope description were add successfully");
facesMessages.add(FacesMessage.SEVERITY_INFO, "New UMA resource '#{updateScopeDescriptionAction.scopeDescription.displayName}' added successfully");
conversationService.endConversation();
this.update = true;
this.scopeInum = inum;
return OxTrustConstants.RESULT_UPDATE;
}
}
Aggregations