From 89f53d196e10a1874cd61e3ee42f57dfd77eb856 Mon Sep 17 00:00:00 2001 From: emusic Date: Thu, 18 Jan 2018 17:36:08 +0100 Subject: protecting pdf file # Conflicts: # pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java --- .../gv/egiz/pdfas/lib/api/IConfigurationConstants.java | 12 +++++++++--- .../java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java | 8 ++++++++ .../lib/impl/configuration/GlobalConfiguration.java | 18 +++++++++++++++++- 3 files changed, 34 insertions(+), 4 deletions(-) (limited to 'pdf-as-lib/src/main/java/at/gv') diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java index f8f71f2f..713948ba 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java @@ -108,12 +108,18 @@ public interface IConfigurationConstants { public static final String BG_COLOR_DETECTION = "sigblock.placement.bgcolor.detection.enabled"; public static final String SIG_PLACEMENT_DEBUG_OUTPUT = "sigblock.placement.debug.file"; - - - /** * PADES Constants */ public static final String SIG_PADES_FORCE_FLAG= SIG_OBJECT + SEPERATOR+"PAdESCompatibility"; public static final String SIG_PADES_INTELL_FLAG = SIG_OBJECT + SEPERATOR+"CheckPAdESCompatibility"; + + + /** + * Protect PDF file from copying content and extracting + */ + + public static final String DEFAULT_CONFIG_PROTECT_COPY_PDF = DEFAULT_CONFIG_PROTECT_PDF + SEPERATOR + "accessCopy"; + public static final String DEFAULT_CONFIG_PROTECT_EXTRACT_PDF = DEFAULT_CONFIG_PROTECT_PDF + SEPERATOR + "canModify"; + } diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java index 72d182ed..c3c2b6fd 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java @@ -61,6 +61,11 @@ import at.gv.egiz.pdfas.lib.impl.SignParameterImpl; import at.gv.egiz.pdfas.lib.impl.VerifyParameterImpl; import at.gv.egiz.pdfas.lib.impl.configuration.ConfigValidatorLoader; + +import org.bouncycastle.jce.provider.BouncyCastleProvider; + +import org.bouncycastle.jce.provider.BouncyCastleProvider; + public class PdfAsFactory implements IConfigurationConstants { private static final Logger logger = LoggerFactory @@ -118,6 +123,9 @@ public class PdfAsFactory implements IConfigurationConstants { // TODO: register ECCelerate in second position when TLS issue is // fixed registerProvider(new ECCelerate(), -1); + + registerProvider( new BouncyCastleProvider(), -2); + } else { logger.info("Skipping Security Provider registration!"); } diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/GlobalConfiguration.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/GlobalConfiguration.java index d04f6878..a40c336d 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/GlobalConfiguration.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/GlobalConfiguration.java @@ -21,6 +21,7 @@ * The "NOTICE" text file is part of the distribution. Any derivative works * that you distribute must include a readable copy of the "NOTICE" text file. ******************************************************************************/ + package at.gv.egiz.pdfas.lib.impl.configuration; import at.gv.egiz.pdfas.common.settings.ISettings; @@ -46,5 +47,20 @@ public class GlobalConfiguration extends SpecificBaseConfiguration } return null; } - + + public String getDefaultCopyProtection() { + if(this.configuration.hasValue(DEFAULT_CONFIG_PROTECT_COPY_PDF)) { + return this.configuration.getValue(DEFAULT_CONFIG_PROTECT_COPY_PDF); + } + return null; + } + + public String getDefaultExtractProtection() { + if(this.configuration.hasValue(DEFAULT_CONFIG_PROTECT_EXTRACT_PDF)) { + return this.configuration.getValue(DEFAULT_CONFIG_PROTECT_EXTRACT_PDF); + } + return null; + } + + } -- cgit v1.2.3