diff options
author | emusic <emina.music@egiz.gv.at> | 2018-05-14 16:38:43 +0200 |
---|---|---|
committer | emusic <emina.music@egiz.gv.at> | 2018-05-14 16:38:43 +0200 |
commit | 797634c687c6f44d314e4baa3fed220d142eed73 (patch) | |
tree | 56dc1ce81e81ff100261aa779a68dcbc61ecc0e5 /pdf-as-web/src/main | |
parent | 0a59371516348ba36163128060e02e997099fcbd (diff) | |
download | pdf-as-4-4.1.3.tar.gz pdf-as-4-4.1.3.tar.bz2 pdf-as-4-4.1.3.zip |
changes in pdf-as-lib4.1.3
Diffstat (limited to 'pdf-as-web/src/main')
-rw-r--r-- | pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java | 13 | ||||
-rw-r--r-- | pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFData.java | 37 | ||||
-rw-r--r-- | pdf-as-web/src/main/webapp/assets/img/localBKU.png | bin | 6650 -> 1750 bytes | |||
-rw-r--r-- | pdf-as-web/src/main/webapp/assets/img/mobileBKU.png | bin | 6269 -> 1811 bytes |
4 files changed, 48 insertions, 2 deletions
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 Binary files differindex 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 diff --git a/pdf-as-web/src/main/webapp/assets/img/mobileBKU.png b/pdf-as-web/src/main/webapp/assets/img/mobileBKU.png Binary files differindex 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 |