From 85b644b1e7a10aa74196613b0daa921d8d721934 Mon Sep 17 00:00:00 2001 From: emusic Date: Wed, 27 Jun 2018 13:04:48 +0200 Subject: small changes in pdfa --- build.gradle | 2 +- .../src/main/java/at/gv/egiz/pdfas/cli/Main.java | 18 --------------- .../configuration/cfg/advancedconfig.properties | 5 +---- pdf-as-lib/src/main/resources/config/config.zip | Bin 1276569 -> 1276510 bytes .../impl/signing/pdfbox2/PADESPDFBOXSigner.java | 5 +++-- .../lib/impl/stamping/pdfbox2/PDFBoxTable.java | 1 - .../at/gv/egiz/pdfas/web/servlets/PDFData.java | 25 --------------------- 7 files changed, 5 insertions(+), 51 deletions(-) diff --git a/build.gradle b/build.gradle index cb63098e..622e296f 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.3' + version = '4.1.4' } 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 4aceb329..1ab434d0 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 @@ -456,24 +456,6 @@ public class Main { System.out.println("Signed document " + outputFile); //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))) - { - SecureRandom random = new SecureRandom(); - byte seed[] = random.generateSeed(50); - String ownerPassword = new String(seed, StandardCharsets.UTF_8); - PDDocument document = PDDocument.load(outputPdfFile); - 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(outputPdfFile); - document.close(); - logger.info("Added Protection Parameters"); - }*/ } private static void perform_verify(CommandLine cli) throws Exception { diff --git a/pdf-as-lib/src/configuration/cfg/advancedconfig.properties b/pdf-as-lib/src/configuration/cfg/advancedconfig.properties index 858b652f..c004757c 100644 --- a/pdf-as-lib/src/configuration/cfg/advancedconfig.properties +++ b/pdf-as-lib/src/configuration/cfg/advancedconfig.properties @@ -106,8 +106,5 @@ default.verifier.01=at.gv.egiz.pdfas.sigs.pades.PAdESVerifier #sigblock.placement.debug.file=/home/user/temp/debugImg.png #runtime.backend=PDFBOX_2_BACKEND -################## -# Protect PDF files from copying and extractiong content -# Set values to be true|false|unchanged -default.protectPDF = true + diff --git a/pdf-as-lib/src/main/resources/config/config.zip b/pdf-as-lib/src/main/resources/config/config.zip index 0b61bfdd..84770c37 100644 Binary files a/pdf-as-lib/src/main/resources/config/config.zip and b/pdf-as-lib/src/main/resources/config/config.zip differ diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java index 5db09ea1..897218e5 100644 --- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java +++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java @@ -132,7 +132,6 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants { COSDocument visualSignatureDocumentGuard = null; try { - doc = pdfObject.getDocument(); SignaturePlaceholderData signaturePlaceholderData = PlaceholderFilter @@ -359,7 +358,9 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants { COSBase base = root.getCOSObject().getItem(COSName.OUTPUT_INTENTS); InputStream colorProfile = null; - colorProfile = this.getClass().getResourceAsStream("/icm/sRGB.icm"); + //colorProfile = this.getClass().getResourceAsStream("/icm/sRGB.icm"); + colorProfile = this.getClass().getResourceAsStream("/icm/sRGB Color Space Profile.icm"); + //Set output intents for PDF/A conformity// try { PDOutputIntent intent = new PDOutputIntent(doc, colorProfile); diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxTable.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxTable.java index bb692f06..bc634dc5 100644 --- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxTable.java +++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxTable.java @@ -85,7 +85,6 @@ public class PDFBoxTable { case Entry.TYPE_CAPTION: case Entry.TYPE_VALUE: String value = (String) cell.getValue(); - //Check if the used value font supports all characters in string PDFont f = null; try{ 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 4d3d1872..bc773ec8 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 @@ -95,31 +95,6 @@ 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"); -- cgit v1.2.3