All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nosi.webapps.igrp.pages.digitalsignature.DigitalSignatureController Maven / Gradle / Ivy

Go to download

IGRP Framework is a powerful and highly customizable platform developed by the Operational Nucleus for the Information Society (NOSi) to create web applications, it provides out of box, several modules to make easy to create stand-alone, production-grade web applications: authentication and access-control, business processes automation, reporting, page builder with automatic code generation and incorporation of the Once-Only-Principle, written in Java. IGRP Framework WAR - Contains some keys resources that give UI to IGRP Framework and others supports files.

There is a newer version: 2.0.0.241121-RCM
Show newest version
package nosi.webapps.igrp.pages.digitalsignature;

import nosi.core.webapp.Controller;//
import nosi.core.webapp.databse.helpers.ResultSet;//
import nosi.core.webapp.databse.helpers.QueryInterface;//
import java.io.IOException;//
import java.util.Base64;

import nosi.core.webapp.Core;//
import nosi.core.webapp.Igrp;
import nosi.core.webapp.Response;//
/* Start-Code-Block (import) */
/* End-Code-Block */
/*----#start-code(packages_import)----*/

import nosi.core.webapp.digicert.business.DigitalSignatureServices;
import nosi.core.webapp.helpers.Route;
import nosi.webapps.igrp.dao.CLob;
import nosi.webapps.igrp.dao.CertificatedSignatures;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/*----#end-code----*/

public class DigitalSignatureController extends Controller {
	public Response actionIndex() throws IOException, IllegalArgumentException, IllegalAccessException {
		DigitalSignature model = new DigitalSignature();
		model.load();
		DigitalSignatureView view = new DigitalSignatureView();
		/* Start-Code-Block (index) *//* End-Code-Block (index) */
		/*----#start-code(index)----*/

		/*----#end-code----*/
		view.setModel(model);
		return this.renderView(view);
	}
	/* Start-Code-Block (custom-actions) *//* End-Code-Block */
	/*----#start-code(custom_actions)----*/

	public Response actionSaveSignature() throws Exception {
		String xml = "";

		xml = xml + "" + DigitalSignatureServices.saveSignatureNGetUuid() + "";

       log.info("[xml=]{}", xml);

		return this.renderView(xml);
	}

	public Response actionDownloadCertificate() throws Exception {
		String uuid = Core.getParam("uuid");
		if (uuid != null) {
			DigitalSignatureServices ds = new DigitalSignatureServices();
			CertificatedSignatures cs = new CertificatedSignatures();

			cs = ds.getSignedByUuid(uuid);

           log.info("[Certificate=]{}", cs.getCertificate());

			if (Core.isNotNullOrZero(cs))
				return this.xSend(Base64.getDecoder().decode(cs.getCertificate()), cs.getName(), cs.getMime_type(),
						false);
			else
				throw new Exception("Certificate not found.");
		} else
			throw new Exception("Certificate identifier not present.");

	}

	public Response actionDownloadData() throws Exception {
		String uuid = Core.getParam("uuid");
		if (uuid != null) {
			DigitalSignatureServices ds = new DigitalSignatureServices();
			CertificatedSignatures cs = new CertificatedSignatures();

			cs = ds.getSignedByUuid(uuid);

			if (Core.isNotNullOrZero(cs))
				return this.xSend(Base64.getDecoder().decode(cs.getData()),  cs.getName(), cs.getMime_type(), false);
			else
				throw new Exception("Page not found.");
		} else
			throw new Exception("Page identifier not present.");
	}

	

	private static final Logger log = LogManager.getLogger(DigitalSignatureController.class);
	/*----#end-code----*/
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy