aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-pdfbox-2/src/main
diff options
context:
space:
mode:
authorbschnalzer <bianca.schnalzer@egiz.gv.at>2017-12-11 14:33:24 +0100
committerbschnalzer <bianca.schnalzer@egiz.gv.at>2017-12-11 14:33:24 +0100
commita9fb8ac7fa73d2908735d8016609e15c954bcbdf (patch)
tree4450a14778e1032444a5e18592b4d4c67f011b74 /pdf-as-pdfbox-2/src/main
parent38c6ea7e6014f800a87c72f7bf830a7b4397cbf3 (diff)
downloadpdf-as-4-a9fb8ac7fa73d2908735d8016609e15c954bcbdf.tar.gz
pdf-as-4-a9fb8ac7fa73d2908735d8016609e15c954bcbdf.tar.bz2
pdf-as-4-a9fb8ac7fa73d2908735d8016609e15c954bcbdf.zip
ProtectPDF, PDFA
Diffstat (limited to 'pdf-as-pdfbox-2/src/main')
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java51
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxTable.java2
2 files changed, 34 insertions, 19 deletions
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 090986a5..e27597d1 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
@@ -24,6 +24,7 @@
package at.gv.egiz.pdfas.lib.impl.signing.pdfbox2;
import at.gv.egiz.pdfas.lib.api.Configuration;
+import at.gv.egiz.pdfas.lib.util.PDDocumentUtil;
import iaik.x509.X509Certificate;
import java.awt.Graphics2D;
@@ -602,7 +603,6 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- /*/ Check if document should be protected*/
synchronized (doc) {
doc.saveIncremental(bos);
@@ -612,6 +612,38 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
}
+
+ /*/ Check if document should be protected*/
+ //Check if doc has to be protected//
+ if (requestedSignature.getStatus().getSettings().hasValue(DEFAULT_CONFIG_PROTECT_PDF)) {
+ //TODO: Test and Check ProtectionSettings// --> overwritten DefaultSecHandler and PDDocumentUtil
+ if (IConfigurationConstants.TRUE.equalsIgnoreCase(requestedSignature.getStatus().getSettings().getValue(IConfigurationConstants.DEFAULT_CONFIG_PROTECT_PDF)))
+ { //Protect document before setting output
+ //Policies for docs
+ AccessPermission ap = doc.getCurrentAccessPermission();
+ ap.setCanModify(false);
+ ap.setCanExtractForAccessibility(false);
+ ap.setCanAssembleDocument(false);
+ ap.setCanExtractContent(false);
+ //StandardProtectionPolicy spp = new StandardProtectionPolicy("", "", ap);
+ //doc = PDDocument.load(pdfObject.getSignedDocument(), spp.getOwnerPassword());
+ //PDDocumentUtil docProtected = new PDDocumentUtil();
+ //docProtected.protect(spp);
+
+ //TODO Save File Settings to signed document//
+ //Byte-Array and PDF-File//
+ //doc = docProtected;
+ //doc.close();
+
+ logger.info("Added Protection Parameters");
+
+ }
+
+ }
+
+
+
+
/*
Check if resulting pdf is PDF-A conform
*/
@@ -619,23 +651,6 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
runPDFAPreflight(new ByteArrayDataSource(pdfObject.getSignedDocument()));
}
- /*Check if doc has to be protected*/
- /* if (requestedSignature.getStatus().getSettings().hasValue(DEFAULT_CONFIG_PROTECT_PDF)) {
- if (IConfigurationConstants.TRUE.equalsIgnoreCase(requestedSignature.getStatus().getSettings().getValue(IConfigurationConstants.DEFAULT_CONFIG_PROTECT_PDF)))
- { //Protect document before setting output
- //Policies for docs
- AccessPermission ap = doc.getCurrentAccessPermission();
- ap.setReadOnly();
- ap.setCanModify(false);
- ap.setCanExtractForAccessibility(false);
- doc = new PDDocument(doc.getDocument(),null,ap);
- logger.info("Added Protection Parameters");
- }
-
- }
-*/
-
-
} catch (IOException e1) {
e1.printStackTrace();
}
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 17ee60be..bb692f06 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
@@ -157,7 +157,7 @@ public class PDFBoxTable {
padding = style.getPadding();
bgColor = style.getBgColor();
-
+
try {
normalizeContent(abstractTable);
} catch (PdfAsException e) {