From 091b70d41a2a544277612d9f41b0d321f057b0f9 Mon Sep 17 00:00:00 2001 From: emusic Date: Fri, 27 Jul 2018 12:58:16 +0200 Subject: adding transfer of pdf file via pdfurl --- .../at/gv/egiz/pdfas/web/helper/PdfAsHelper.java | 2 +- .../at/gv/egiz/pdfas/web/servlets/PDFURLData.java | 25 +++++++++++----------- 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'pdf-as-web/src/main/java/at/gv/egiz/pdfas') 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 4b69e5a8..23e16ec3 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 @@ -1228,7 +1228,7 @@ public class PdfAsHelper { JsonObject createCAdESSigParams = SL20JSONBuilderUtils.createCreateCAdESCommandParameters( pack.getRequestType().getKeyboxIdentifier(), - //statusRequest.getSignatureData(), + null, generateNSPdfURL(request,response), SL20Constants.SL20_COMMAND_PARAM_CREATE_SIG_CADES_CONTENTMODE_DETACHED, pack.getRequestType().getDataObject().getMetaInfo().getMimeType(), diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFURLData.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFURLData.java index 9dfa0d16..d4112cad 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFURLData.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFURLData.java @@ -1,14 +1,8 @@ package at.gv.egiz.pdfas.web.servlets; -import at.gv.egiz.pdfas.api.ws.PDFASVerificationResponse; import at.gv.egiz.pdfas.common.exceptions.PDFIOException; import at.gv.egiz.pdfas.common.utils.PDFUtils; import at.gv.egiz.pdfas.lib.api.StatusRequest; -import at.gv.egiz.pdfas.web.config.WebConfiguration; -import at.gv.egiz.pdfas.web.helper.PdfAsHelper; -import at.gv.egiz.pdfas.web.helper.PdfAsParameterExtractor; -import at.gv.egiz.pdfas.web.stats.StatisticEvent; -import at.gv.egiz.pdfas.web.stats.StatisticFrontend; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,7 +48,10 @@ public class PDFURLData extends HttpServlet { */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - this.process(request, response); + try { + this.process(request, response); + } catch (PDFIOException e) { + response.sendError(500, "internal server error"); } } protected void process(HttpServletRequest request, @@ -64,23 +61,27 @@ public class PDFURLData extends HttpServlet { StatusRequest statusRequest = (StatusRequest) session .getAttribute(PDF_STATUS); + if(statusRequest!=null) + { byte[] nonSignedData = statusRequest.getSignatureData(); if (nonSignedData != null) { byte[] blackoutnonSignedData = PDFUtils.blackOutSignature(nonSignedData, statusRequest.getSignatureDataByteRange()); - response.setContentType("application/pdf"); OutputStream os = response.getOutputStream(); os.write(blackoutnonSignedData); os.close(); + logger.debug("pdf file transfer finished"); } else { - PdfAsHelper.setSessionException(request, response, - "todo", null); - PdfAsHelper.gotoError(getServletContext(), request, response); - response.sendError(500, ''); + logger.info("no pdf document is found"); + response.sendError(500, "no signed data found"); + } + } else { + logger.info("no session found"); + response.sendError(500, "no signed data found"); } } } \ No newline at end of file -- cgit v1.2.3