aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-web/src
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-web/src')
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java15
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFURLData.java86
2 files changed, 97 insertions, 4 deletions
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 1cef0796..4b69e5a8 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
@@ -125,6 +125,7 @@ public class PdfAsHelper {
private static final String PDF_ERROR_PAGE = "/ErrorPage";
private static final String PDF_PROVIDE_PAGE = "/ProvidePDF";
private static final String PDF_PDFDATA_PAGE = "/PDFData";
+ private static final String PDF_PDFDATAURL_PAGE = "/PDFURLData";
private static final String PDF_DATAURL_PAGE = "/DataURL";
private static final String PDF_SL20_DATAURL_PAGE = "/DataURLSL20";
private static final String PDF_USERENTRY_PAGE = "/userentry";
@@ -1144,7 +1145,7 @@ public class PdfAsHelper {
SL20Constants.SL20_PAYLOAD, SL20Constants.SL20_SIGNEDPAYLOAD,
command, signedCommand);
- //store requestId
+ //store requestId
request.getSession(false).setAttribute(PDF_SESSION_PREFIX + SL20Constants.SL20_REQID, reqId);
//forward SL2.0 command
@@ -1193,7 +1194,7 @@ public class PdfAsHelper {
} else if (slConnector instanceof SL20Connector) {
//convert byte range
-
+
int[] exclude_range = PDFUtils.buildExcludeRange(statusRequest.getSignatureDataByteRange());
logger.info("Exclude Byte Range: " + exclude_range[0] + " " + exclude_range[1]);
@@ -1227,8 +1228,8 @@ public class PdfAsHelper {
JsonObject createCAdESSigParams =
SL20JSONBuilderUtils.createCreateCAdESCommandParameters(
pack.getRequestType().getKeyboxIdentifier(),
- data,
- null,
+ //statusRequest.getSignatureData(),
+ generateNSPdfURL(request,response),
SL20Constants.SL20_COMMAND_PARAM_CREATE_SIG_CADES_CONTENTMODE_DETACHED,
pack.getRequestType().getDataObject().getMetaInfo().getMimeType(),
padesCompatibel ,
@@ -1580,6 +1581,12 @@ public class PdfAsHelper {
return generateURL(request, response, PDF_PDFDATA_PAGE);
}
+ public static String generateNSPdfURL(HttpServletRequest request,
+ HttpServletResponse response) {
+ return generateURL(request, response, PDF_PDFDATAURL_PAGE);
+ }
+
+
public static String generateUserEntryURL(String storeId) {
String publicURL = WebConfiguration.getPublicURL();
if (publicURL == null) {
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
new file mode 100644
index 00000000..9dfa0d16
--- /dev/null
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFURLData.java
@@ -0,0 +1,86 @@
+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;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class PDFURLData extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+ private static final String PDF_STATUS = "PDF_STATUS";
+
+
+ private static final Logger logger = LoggerFactory.getLogger(PDFData.class);
+
+ /**
+ * @see HttpServlet#HttpServlet()
+ */
+ public PDFURLData() {
+ super();
+ }
+
+ /**
+ * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
+ * response)
+ */
+ protected void doGet(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ try {
+ this.process(request, response);
+ } catch (PDFIOException e) {
+ response.sendError(500, "file cannot be transfered");
+ }
+ }
+
+ /**
+ * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
+ * response)
+ */
+ protected void doPost(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ this.process(request, response);
+ }
+
+ protected void process(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException, PDFIOException {
+
+ HttpSession session = request.getSession();
+ StatusRequest statusRequest = (StatusRequest) session
+ .getAttribute(PDF_STATUS);
+
+ 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();
+
+ } else {
+ PdfAsHelper.setSessionException(request, response,
+ "todo", null);
+ PdfAsHelper.gotoError(getServletContext(), request, response);
+ response.sendError(500, '');
+ }
+ }
+} \ No newline at end of file