diff options
author | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2015-02-25 12:51:08 +0100 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2015-02-25 12:51:08 +0100 |
commit | df68bda01aee151df006900accd418ad06b303d7 (patch) | |
tree | d6012afa70dfede9cf0119061a3fb5f079d6c02c | |
parent | 23a283834becf8323489231ed5c48725f9716bb6 (diff) | |
download | pdf-as-4-df68bda01aee151df006900accd418ad06b303d7.tar.gz pdf-as-4-df68bda01aee151df006900accd418ad06b303d7.tar.bz2 pdf-as-4-df68bda01aee151df006900accd418ad06b303d7.zip |
PDF-AS Web QR Code content integration
-rw-r--r-- | pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/SimpleTest.java | 9 | ||||
-rw-r--r-- | pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java | 54 |
2 files changed, 58 insertions, 5 deletions
diff --git a/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/SimpleTest.java b/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/SimpleTest.java index e73f0d95..bf22e10d 100644 --- a/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/SimpleTest.java +++ b/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/SimpleTest.java @@ -52,19 +52,20 @@ public class SimpleTest { signParameters.setConnector(Connector.JKS); signParameters.setPosition(null); signParameters.setProfile("SIGNATURBLOCK_SMALL_DE"); - signParameters.setKeyIdentifier("test"); + signParameters.setQRCodeContent("https://docs.google.com/document/d/1DSE9aO8-q9PAlRPyYpH1sgont4rSB_Q5BCeS-X3p6WA/edit?usp=sharing"); + //signParameters.setKeyIdentifier("test"); PDFASSignRequest request = new PDFASSignRequest(); request.setInputData(inputData); request.setParameters(signParameters); request.setRequestID("SOME TEST ID"); - + //URL endpoint = new //URL("http://demo.egiz.gv.at/demoportal-pdf_as/wssign?wsdl"); //URL endpoint = new // URL("http://www.buergerkarte.at/pdf-as-extern-4/wssign?wsdl"); - //String baseUrl = "http://demo.egiz.gv.at/demoportal-pdf_as/"; - String baseUrl = "http://localhost:8080/pdf-as-web/services/"; + String baseUrl = "http://demo.egiz.gv.at/demoportal-pdf_as/services/"; + //String baseUrl = "http://localhost:8080/pdf-as-web/services/"; //URL endpoint = new URL( // "http://192.168.56.10/pdf-as-web/wssign?wsdl"); diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java index 1869dbb5..2e337f04 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java @@ -547,8 +547,36 @@ public class PdfAsHelper { signParameter.setPlainSigner(signer); + String profile = params.getProfile(); + + //PdfAsHelper.getQRCodeContent(request); + // Get QR Code Content form param + String qrCodeContent = params.getQRCodeContent(); + + if(qrCodeContent != null) { + if(profile == null) { + // get default Profile + profile = config.getValue("sig_obj.type.default"); + } + + if(profile == null) { + logger.warn("Failed to determine default profile! Using hard coded!"); + profile = "SIGNATURBLOCK_SMALL_DE"; + } + + ByteArrayOutputStream qrbaos = new ByteArrayOutputStream(); + try { + String key = "sig_obj." + profile + ".value.SIG_LABEL"; + QRCodeGenerator.generateQRCode(qrCodeContent, qrbaos, 200); + String value = Base64.encodeBase64String(qrbaos.toByteArray()); + config.setValue(key, value); + } finally { + IOUtils.closeQuietly(qrbaos); + } + } + // set Signature Profile (null use default ...) - signParameter.setSignatureProfileId(params.getProfile()); + signParameter.setSignatureProfileId(profile); // set Signature Position signParameter.setSignaturePosition(params.getPosition()); @@ -625,6 +653,30 @@ public class PdfAsHelper { session.setAttribute(PDF_SIGNER, signer); session.setAttribute(PDF_SL_INTERACTIVE, connector); + String qrCodeContent = PdfAsHelper.getQRCodeContent(request); + + if(qrCodeContent != null) { + if(profile == null) { + // get default Profile + profile = config.getValue("sig_obj.type.default"); + } + + if(profile == null) { + logger.warn("Failed to determine default profile! Using hard coded!"); + profile = "SIGNATURBLOCK_SMALL_DE"; + } + + ByteArrayOutputStream qrbaos = new ByteArrayOutputStream(); + try { + String key = "sig_obj." + profile + ".value.SIG_LABEL"; + QRCodeGenerator.generateQRCode(qrCodeContent, qrbaos, 200); + String value = Base64.encodeBase64String(qrbaos.toByteArray()); + config.setValue(key, value); + } finally { + IOUtils.closeQuietly(qrbaos); + } + } + // set Signature Profile (null use default ...) signParameter.setSignatureProfileId(profile); |