diff options
Diffstat (limited to 'pdf-as-pdfbox-2/src/main/java/at/gv')
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) { |