use of org.richfaces.model.UploadedFile in project oxTrust by GluuFederation.
the class CustomAttributeAction method uploadImage.
public void uploadImage(FileUploadEvent event) {
UploadedFile uploadedFile = event.getUploadedFile();
this.uploadedImage = null;
try {
GluuImage image = imageService.constructImage(identity.getUser(), uploadedFile);
image.setStoreTemporary(true);
if (imageService.createImageFiles(image)) {
this.uploadedImage = image;
}
} finally {
try {
uploadedFile.delete();
} catch (IOException ex) {
log.error("Failed to remove temporary image", ex);
}
}
}
use of org.richfaces.model.UploadedFile in project oxTrust by GluuFederation.
the class UpdateAsimbaSPRequestorAction method uploadFile.
public String uploadFile(FileUploadEvent event) {
log.info("uploadFile() Requestor", spRequestor);
try {
UploadedFile uploadedFile = event.getUploadedFile();
String filepath = asimbaService.saveSPRequestorMetadataFile(uploadedFile);
spRequestor.setMetadataFile(filepath);
spRequestor.setMetadataUrl("");
facesMessages.add(FacesMessage.SEVERITY_INFO, "File uploaded");
} catch (Exception e) {
log.error("Requestor metadata - uploadFile() exception", e);
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Requestor metadata - uploadFile exception", e);
return OxTrustConstants.RESULT_FAILURE;
}
return OxTrustConstants.RESULT_SUCCESS;
}
use of org.richfaces.model.UploadedFile in project oxTrust by GluuFederation.
the class UpdateAsimbaSPRequestorAction method uploadCertificateFile.
public String uploadCertificateFile(FileUploadEvent event) {
log.info("uploadCertificateFile() Requestor", spRequestor);
try {
UploadedFile uploadedFile = event.getUploadedFile();
uploadedCertBytes = ServiceUtil.readFully(uploadedFile.getInputStream());
// check alias for valid url
String id = spRequestor.getId();
if (id != null && id.trim().toLowerCase().startsWith("http")) {
id = id.trim();
// this would check for the protocol
URL u = new URL(id);
// does the extra checking required for validation of
u.toURI();
// URI
String message = asimbaXMLConfigurationService.addCertificateFile(uploadedFile, spRequestor.getId());
// display message
if (!OxTrustConstants.RESULT_SUCCESS.equals(message)) {
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Add Certificate ERROR: ", message);
} else {
facesMessages.add(FacesMessage.SEVERITY_INFO, "Certificate uploaded");
}
} else {
facesMessages.add(FacesMessage.SEVERITY_INFO, "Add valid URL to ID");
}
} catch (Exception e) {
log.info("Requestor certificate - uploadCertificateFile() exception", e);
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Add Certificate ERROR: ", e.getMessage());
return OxTrustConstants.RESULT_VALIDATION_ERROR;
}
return OxTrustConstants.RESULT_SUCCESS;
}
use of org.richfaces.model.UploadedFile in project oxTrust by GluuFederation.
the class UpdateAsimbaIDPAction method uploadFile.
public String uploadFile(FileUploadEvent event) {
log.info("uploadFile() call for IDP");
try {
UploadedFile uploadedFile = event.getUploadedFile();
String filepath = asimbaService.saveIDPMetadataFile(uploadedFile, idp);
idp.setMetadataFile(filepath);
idp.setMetadataUrl("");
facesMessages.add(FacesMessage.SEVERITY_INFO, "File uploaded");
} catch (Exception e) {
log.error("IDP metadata - uploadFile() exception", e);
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Requestor metadata - uploadFile exception", e);
return OxTrustConstants.RESULT_FAILURE;
}
return OxTrustConstants.RESULT_SUCCESS;
}
use of org.richfaces.model.UploadedFile in project oxTrust by GluuFederation.
the class UpdateAsimbaIDPAction method uploadCertificateFile.
public String uploadCertificateFile(FileUploadEvent event) {
log.info("uploadCertificateFile() call for IDP");
try {
UploadedFile uploadedFile = event.getUploadedFile();
uploadedCertBytes = ServiceUtil.readFully(uploadedFile.getInputStream());
// check alias for valid url
String id = idp.getId();
if (id != null && id.trim().toLowerCase().startsWith("http")) {
id = id.trim();
// this would check for the protocol
URL u = new URL(id);
// does the extra checking required for validation of URI
u.toURI();
String message = asimbaXMLConfigurationService.addCertificateFile(uploadedFile, id);
// display message
if (!OxTrustConstants.RESULT_SUCCESS.equals(message)) {
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Add Certificate ERROR: ", message);
} else {
facesMessages.add(FacesMessage.SEVERITY_INFO, "Certificate uploaded");
}
} else {
facesMessages.add(FacesMessage.SEVERITY_INFO, "Add valid URL to ID");
}
} catch (Exception e) {
log.info("IDP certificate - uploadCertificateFile() exception", e);
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Add Certificate ERROR: ", e.getMessage());
return OxTrustConstants.RESULT_VALIDATION_ERROR;
}
return OxTrustConstants.RESULT_SUCCESS;
}
Aggregations