From 27e22c7a57839db3fbd73bd4dbe4bfbe92a29abb Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Wed, 14 Jun 2023 15:20:41 +0200 Subject: fix(web): catch possible nullPointerException in case of wrong or unknown session cookie --- .../src/main/java/at/gv/egiz/pdfas/web/servlets/PDFData.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (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/servlets/PDFData.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFData.java index bf45745d..4e613ed4 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFData.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFData.java @@ -37,6 +37,7 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import at.gv.egiz.pdfas.api.processing.PdfasSignResponse; import at.gv.egiz.pdfas.api.processing.SignedDocument; import at.gv.egiz.pdfas.api.ws.PDFASVerificationResponse; import at.gv.egiz.pdfas.web.config.WebConfiguration; @@ -85,7 +86,15 @@ public class PDFData extends HttpServlet { protected void process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - if (PdfAsHelper.getPdfSigningResponse(request).getSignedPdfs().isEmpty()) { + PdfasSignResponse resultObject = PdfAsHelper.getPdfSigningResponse(request); + + if (resultObject == null) { + log.warn("No data for session with Id: {}", request.getSession().getId()); + PdfAsHelper.setSessionException(request, response, + "No signed pdf document available.", null); + PdfAsHelper.gotoError(getServletContext(), request, response); + + } else if (resultObject.getSignedPdfs().isEmpty()) { log.info("No signed pdf document available."); PdfAsHelper.setSessionException(request, response, "No signed pdf document available.", null); -- cgit v1.2.3