aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-web
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-web')
-rw-r--r--pdf-as-web/build.gradle3
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java13
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFData.java37
-rw-r--r--pdf-as-web/src/main/webapp/assets/img/localBKU.pngbin6650 -> 1750 bytes
-rw-r--r--pdf-as-web/src/main/webapp/assets/img/mobileBKU.pngbin6269 -> 1811 bytes
5 files changed, 51 insertions, 2 deletions
diff --git a/pdf-as-web/build.gradle b/pdf-as-web/build.gradle
index 02176587..87e303af 100644
--- a/pdf-as-web/build.gradle
+++ b/pdf-as-web/build.gradle
@@ -49,6 +49,9 @@ dependencies {
compile project (':pdf-as-web-status')
compile project (':pdf-as-web-statistic-api')
compile group: 'commons-fileupload', name: 'commons-fileupload', version: '1.3.1'
+ compile group: 'org.apache.pdfbox', name: 'pdfbox', version: '2.0.3'
+ compile group: 'org.apache.pdfbox', name: 'pdfbox-tools', version: '2.0.3'
+ compile group: 'org.apache.pdfbox', name: 'preflight', version: '2.0.3'
compile group: 'opensymphony', name: 'sitemesh', version: '2.4.2'
compile "commons-codec:commons-codec:1.9"
compile 'org.apache.commons:commons-lang3:3.3.2'
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java
index 9b14df16..d63f698f 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java
@@ -586,4 +586,17 @@ public class WebConfiguration implements IConfigurationConstants {
}
return ivalue;
}
+
+
+ public static boolean isPdfProtected()
+ {
+ String value = properties.getProperty(DEFAULT_CONFIG_PROTECT_PDF);
+ if (value != null) {
+ if (value.equals("true")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
}
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 abbfc639..4d3d1872 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
@@ -23,8 +23,11 @@
******************************************************************************/
package at.gv.egiz.pdfas.web.servlets;
-import java.io.IOException;
-import java.io.OutputStream;
+import java.io.*;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.security.SecureRandom;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@@ -32,6 +35,11 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import at.gv.egiz.pdfas.web.config.WebConfiguration;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.encryption.AccessPermission;
+import org.apache.pdfbox.pdmodel.encryption.StandardProtectionPolicy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -87,6 +95,31 @@ public class PDFData extends HttpServlet {
if (signedData != null) {
+ /*if (WebConfiguration.isPdfProtected()) {
+ File tempFile = new File(System.getProperty("java.io.tmpdir"),"protect.pdf");
+ FileUtils.writeByteArrayToFile(tempFile, signedData);
+ Path tempPath = tempFile.toPath();
+ SecureRandom random = new SecureRandom();
+ byte seed[] = random.generateSeed(50);
+ String ownerPassword = new String(seed, StandardCharsets.UTF_8);
+ PDDocument document = PDDocument.load(tempFile);
+ AccessPermission accessPermission = new AccessPermission();
+ accessPermission.setCanExtractContent(false);
+ accessPermission.setCanExtractForAccessibility(true);
+ StandardProtectionPolicy spp = new StandardProtectionPolicy(ownerPassword, "", accessPermission);
+ spp.setEncryptionKeyLength(128);
+ spp.setPermissions(accessPermission);
+ document.protect(spp);
+ document.save(tempFile);
+ document.close();
+ //accessPermission.setCanModify(false);
+ signedData = Files.readAllBytes(tempPath);
+ logger.info("Added Protection Parameters");
+ if (tempFile.exists()) {
+ tempFile.delete();
+ }
+ }*/
+
if(WebConfiguration.isKeepSignedDocument()) {
if(PdfAsHelper.isSignedDataExpired(request, response)) {
logger.info("Destroying expired signed data in session");
diff --git a/pdf-as-web/src/main/webapp/assets/img/localBKU.png b/pdf-as-web/src/main/webapp/assets/img/localBKU.png
index 2ec41892..cd5069b5 100644
--- a/pdf-as-web/src/main/webapp/assets/img/localBKU.png
+++ b/pdf-as-web/src/main/webapp/assets/img/localBKU.png
Binary files differ
diff --git a/pdf-as-web/src/main/webapp/assets/img/mobileBKU.png b/pdf-as-web/src/main/webapp/assets/img/mobileBKU.png
index daa8fa3f..037de1bb 100644
--- a/pdf-as-web/src/main/webapp/assets/img/mobileBKU.png
+++ b/pdf-as-web/src/main/webapp/assets/img/mobileBKU.png
Binary files differ