diff options
-rw-r--r-- | build.gradle | 2 | ||||
-rw-r--r-- | pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/Main.java | 4 | ||||
-rw-r--r-- | pdf-as-lib/src/main/resources/config/config.zip | bin | 1276569 -> 1276569 bytes | |||
-rw-r--r-- | pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/Positioning.java | 8 | ||||
-rw-r--r-- | pdf-as-web/build.gradle | 3 | ||||
-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 |
9 files changed, 59 insertions, 8 deletions
diff --git a/build.gradle b/build.gradle index f8ecfad6..cb63098e 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ task wrapper(type: Wrapper) { allprojects { apply plugin: 'com.github.ben-manes.versions' repositories { mavenCentral() } - version = '4.1.2' + version = '4.1.3' } configurations { diff --git a/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/Main.java b/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/Main.java index 455fd808..4aceb329 100644 --- a/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/Main.java +++ b/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/Main.java @@ -457,7 +457,7 @@ public class Main { //make output file protected from copying and extraction content - if(configuration.hasValue(DEFAULT_CONFIG_PROTECT_PDF) && IConfigurationConstants.TRUE.equalsIgnoreCase(configuration.getValue(DEFAULT_CONFIG_PROTECT_PDF))) + /*if(configuration.hasValue(DEFAULT_CONFIG_PROTECT_PDF) && IConfigurationConstants.TRUE.equalsIgnoreCase(configuration.getValue(DEFAULT_CONFIG_PROTECT_PDF))) { SecureRandom random = new SecureRandom(); byte seed[] = random.generateSeed(50); @@ -473,7 +473,7 @@ public class Main { document.save(outputPdfFile); document.close(); logger.info("Added Protection Parameters"); - } + }*/ } private static void perform_verify(CommandLine cli) throws Exception { diff --git a/pdf-as-lib/src/main/resources/config/config.zip b/pdf-as-lib/src/main/resources/config/config.zip Binary files differindex a10f4f52..0b61bfdd 100644 --- a/pdf-as-lib/src/main/resources/config/config.zip +++ b/pdf-as-lib/src/main/resources/config/config.zip diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/Positioning.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/Positioning.java index 680abe6d..1a51b4db 100644 --- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/Positioning.java +++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/Positioning.java @@ -29,6 +29,7 @@ import java.io.IOException; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDPage; +import org.apache.pdfbox.pdmodel.PDPageTree; import org.apache.pdfbox.pdmodel.common.PDRectangle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -170,7 +171,7 @@ public class Positioning { page = pos.getPage(); // System.out.println("XXXXPAGE="+page+" doc_pages="+doc_pages); - if (page > doc_pages) { + if (page > doc_pages && page!=1) { make_new_page = true; page = doc_pages; // throw new PDFDocumentException(227, "Page number is to big(=" @@ -178,14 +179,15 @@ public class Positioning { // ") cannot be parsed."); } - if (page < doc_pages) { + if (page < doc_pages && page!=1) { page = page - 1; } } PDPage pdPage = pdfDataSource.getPage(page-1); - + //PDPage pdPage = pdfDataSource.getPages().get(page); + PDRectangle cropBox = pdPage.getCropBox(); // fallback to MediaBox if Cropbox not available! 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 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 |