From 7b2e2b640b0f392183f7927f692936950d3fabfc Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Tue, 12 Nov 2013 12:26:10 +0100 Subject: SecurityLayer commands included --- .../at/gv/egiz/pdfas/web/helper/PDFASSession.java | 37 ++++++++ .../at/gv/egiz/pdfas/web/helper/package-info.java | 8 ++ .../java/at/gv/egiz/pdfas/web/package-info.java | 8 ++ .../gv/egiz/pdfas/web/servlets/DataURLServlet.java | 37 ++++++++ .../egiz/pdfas/web/servlets/ProvidePDFServlet.java | 37 ++++++++ .../at/gv/egiz/pdfas/web/servlets/SignServlet.java | 69 ++++++++++++++ .../gv/egiz/pdfas/web/servlets/VerifyServlet.java | 61 +++++++++++++ .../gv/egiz/pdfas/web/servlets/package-info.java | 8 ++ pdf-as-web/src/main/webapp/WEB-INF/web.xml | 101 +++++++++++++++++++++ pdf-as-web/src/main/webapp/signstart.jsp | 14 +++ pdf-as-web/src/main/webapp/verifystart.jsp | 13 +++ 11 files changed, 393 insertions(+) create mode 100644 pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PDFASSession.java create mode 100644 pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/package-info.java create mode 100644 pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/package-info.java create mode 100644 pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/DataURLServlet.java create mode 100644 pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ProvidePDFServlet.java create mode 100644 pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/SignServlet.java create mode 100644 pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyServlet.java create mode 100644 pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/package-info.java create mode 100644 pdf-as-web/src/main/webapp/WEB-INF/web.xml create mode 100644 pdf-as-web/src/main/webapp/signstart.jsp create mode 100644 pdf-as-web/src/main/webapp/verifystart.jsp (limited to 'pdf-as-web/src') diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PDFASSession.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PDFASSession.java new file mode 100644 index 00000000..9207847d --- /dev/null +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PDFASSession.java @@ -0,0 +1,37 @@ +package at.gv.egiz.pdfas.web.helper; + +import java.io.Serializable; + +import at.gv.egiz.pdfas.lib.api.Configuration; +import at.gv.egiz.pdfas.lib.api.StatusRequest; +import at.gv.egiz.pdfas.lib.api.sign.SignParameter; + +public class PDFASSession implements Serializable { + + public static final String SESSION_TAG = "PDFASSession"; + + private StatusRequest statusRequest; + private SignParameter signParameter; + private Configuration config; + + public PDFASSession(SignParameter parameter) { + this.signParameter = parameter; + } + + public StatusRequest getStatusRequest() { + return statusRequest; + } + + public void setStatusRequest(StatusRequest statusRequest) { + this.statusRequest = statusRequest; + } + + public SignParameter getSignParameter() { + return signParameter; + } + + public void setSignParameter(SignParameter signParameter) { + this.signParameter = signParameter; + } + +} diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/package-info.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/package-info.java new file mode 100644 index 00000000..5f9a6b5d --- /dev/null +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/package-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * @author afitzek + * + */ +package at.gv.egiz.pdfas.web.helper; \ No newline at end of file diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/package-info.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/package-info.java new file mode 100644 index 00000000..937390f0 --- /dev/null +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/package-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * @author afitzek + * + */ +package at.gv.egiz.pdfas.web; \ No newline at end of file diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/DataURLServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/DataURLServlet.java new file mode 100644 index 00000000..93586c1a --- /dev/null +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/DataURLServlet.java @@ -0,0 +1,37 @@ +package at.gv.egiz.pdfas.web.servlets; + +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * Servlet implementation class DataURL + */ +public class DataURLServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + /** + * @see HttpServlet#HttpServlet() + */ + public DataURLServlet() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // TODO Auto-generated method stub + } + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // TODO Auto-generated method stub + } + +} diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ProvidePDFServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ProvidePDFServlet.java new file mode 100644 index 00000000..26f42840 --- /dev/null +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ProvidePDFServlet.java @@ -0,0 +1,37 @@ +package at.gv.egiz.pdfas.web.servlets; + +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * Servlet implementation class ProvidePDF + */ +public class ProvidePDFServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + /** + * @see HttpServlet#HttpServlet() + */ + public ProvidePDFServlet() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // TODO Auto-generated method stub + } + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // TODO Auto-generated method stub + } + +} diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/SignServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/SignServlet.java new file mode 100644 index 00000000..9ea6f354 --- /dev/null +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/SignServlet.java @@ -0,0 +1,69 @@ +package at.gv.egiz.pdfas.web.servlets; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import at.gv.egiz.pdfas.common.exceptions.PdfAsException; +import at.gv.egiz.pdfas.lib.api.ByteArrayDataSource; +import at.gv.egiz.pdfas.lib.api.Configuration; +import at.gv.egiz.pdfas.lib.api.PdfAs; +import at.gv.egiz.pdfas.lib.api.PdfAsFactory; +import at.gv.egiz.pdfas.lib.api.StatusRequest; +import at.gv.egiz.pdfas.lib.api.sign.SignParameter; + +/** + * Servlet implementation class Sign + */ +public class SignServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + /** + * Default constructor. + */ + public SignServlet() { + // TODO Auto-generated constructor stub + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse + * response) + */ + protected void doGet(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + response.getWriter() + .println( + "HelloBODY"); + } + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse + * response) + */ + protected void doPost(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + // TODO Auto-generated method stub + } + + protected void doSignature(HttpServletRequest request, + HttpServletResponse response, byte[] pdfData) { + try { + PdfAs pdfAs = PdfAsFactory.createPdfAs(null); + // TODO: Build configuration and Sign Parameters + Configuration config = pdfAs.getConfiguration(); + SignParameter signParameter = PdfAsFactory.createSignParameter( + config, new ByteArrayDataSource(pdfData)); + + + + StatusRequest statusRequest = pdfAs.startSign(signParameter); + + } catch (PdfAsException e) { + e.printStackTrace(); + } + } + +} diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyServlet.java new file mode 100644 index 00000000..d4303a5f --- /dev/null +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyServlet.java @@ -0,0 +1,61 @@ +package at.gv.egiz.pdfas.web.servlets; + +import java.io.IOException; +import java.util.List; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import at.gv.egiz.pdfas.lib.api.ByteArrayDataSource; +import at.gv.egiz.pdfas.lib.api.Configuration; +import at.gv.egiz.pdfas.lib.api.PdfAs; +import at.gv.egiz.pdfas.lib.api.PdfAsFactory; +import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter; +import at.gv.egiz.pdfas.lib.api.verify.VerifyResult; + +/** + * Servlet implementation class VerifyServlet + */ +public class VerifyServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + /** + * @see HttpServlet#HttpServlet() + */ + public VerifyServlet() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // TODO Auto-generated method stub + } + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // TODO Auto-generated method stub + } + + protected void doVerify(HttpServletRequest request, HttpServletResponse response, + byte[] pdfData, int whichSignature) { + PdfAs pdfAs = PdfAsFactory.createPdfAs(null); + Configuration conf = pdfAs.getConfiguration(); + VerifyParameter parameter = PdfAsFactory.createVerifyParameter(conf, new ByteArrayDataSource(pdfData)); + parameter.setWhichSignature(whichSignature); + + List results = pdfAs.verify(parameter); + + // Create HTML Snippet for each Verification Result + // Put these results into the web page + // Or create a JSON response with the verification results for automated processing + + } + +} diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/package-info.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/package-info.java new file mode 100644 index 00000000..6be370f0 --- /dev/null +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/package-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * @author afitzek + * + */ +package at.gv.egiz.pdfas.web.servlets; \ No newline at end of file diff --git a/pdf-as-web/src/main/webapp/WEB-INF/web.xml b/pdf-as-web/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000..13149b7f --- /dev/null +++ b/pdf-as-web/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,101 @@ + + + + + + PDF-AS-WEB + + PDF-AS-WEB Application + + + + + + + + + SignServlet + + The Sign Servlet allows Users to Sign PDF Documents ... + + at.gv.egiz.pdfas.web.servlets.SignServlet + 5 + + + ProvidePDF + ProvidePDF + + at.gv.egiz.pdfas.web.servlets.ProvidePDF + + + DataURL + DataURL + + at.gv.egiz.pdfas.web.servlets.DataURL + + + VerifyServlet + VerifyServlet + + at.gv.egiz.pdfas.web.servlets.VerifyServlet + + + + + + SignServlet + /Sign + + + ProvidePDF + /ProvidePDF + + + DataURL + /DataURL + + + VerifyServlet + /VerifyServlet + + + + + + 30 + + + + signstart.jsp + + + \ No newline at end of file diff --git a/pdf-as-web/src/main/webapp/signstart.jsp b/pdf-as-web/src/main/webapp/signstart.jsp new file mode 100644 index 00000000..596f04dc --- /dev/null +++ b/pdf-as-web/src/main/webapp/signstart.jsp @@ -0,0 +1,14 @@ + + + + +

Sign PDF-Dokument

+
+ + + + + +
+ + \ No newline at end of file diff --git a/pdf-as-web/src/main/webapp/verifystart.jsp b/pdf-as-web/src/main/webapp/verifystart.jsp new file mode 100644 index 00000000..cf8187bf --- /dev/null +++ b/pdf-as-web/src/main/webapp/verifystart.jsp @@ -0,0 +1,13 @@ + + + + +

Verify PDF-Dokument

+
+ + + + +
+ + \ No newline at end of file -- cgit v1.2.3