aboutsummaryrefslogtreecommitdiff
path: root/signature-standards/sigs-pades/src/main
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2013-11-12 12:26:10 +0100
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2013-11-12 12:26:10 +0100
commit7b2e2b640b0f392183f7927f692936950d3fabfc (patch)
treeffd4acccb62f2679ff613bf0cd8cd0850186b465 /signature-standards/sigs-pades/src/main
parentdd43264f702c5e0351cc63835862c55f3e847634 (diff)
downloadpdf-as-4-7b2e2b640b0f392183f7927f692936950d3fabfc.tar.gz
pdf-as-4-7b2e2b640b0f392183f7927f692936950d3fabfc.tar.bz2
pdf-as-4-7b2e2b640b0f392183f7927f692936950d3fabfc.zip
SecurityLayer commands included
Diffstat (limited to 'signature-standards/sigs-pades/src/main')
-rw-r--r--signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/PAdESSigner.java72
-rw-r--r--signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/package-info.java8
2 files changed, 80 insertions, 0 deletions
diff --git a/signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/PAdESSigner.java b/signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/PAdESSigner.java
new file mode 100644
index 00000000..91237d98
--- /dev/null
+++ b/signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/PAdESSigner.java
@@ -0,0 +1,72 @@
+package at.gv.egiz.pdfas.sigs.pades;
+
+import iaik.x509.X509Certificate;
+
+import java.io.IOException;
+import java.security.cert.CertificateException;
+import java.util.Iterator;
+
+import org.apache.pdfbox.exceptions.SignatureException;
+import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature;
+
+import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
+import at.gv.egiz.pdfas.lib.api.sign.IPlainSigner;
+import at.gv.egiz.sl.CreateCMSSignatureRequestType;
+import at.gv.egiz.sl.CreateCMSSignatureResponseType;
+import at.gv.egiz.sl.InfoboxAssocArrayPairType;
+import at.gv.egiz.sl.InfoboxReadRequestType;
+import at.gv.egiz.sl.InfoboxReadResponseType;
+import at.gv.egiz.sl.util.BKUSLConnector;
+import at.gv.egiz.sl.util.ISLConnector;
+import at.gv.egiz.sl.util.BaseSLConnector;
+
+public class PAdESSigner implements IPlainSigner {
+
+ private ISLConnector connector;
+
+ public PAdESSigner(ISLConnector connector) {
+ this.connector = connector;
+ }
+
+ public X509Certificate getCertificate() throws PdfAsException {
+ X509Certificate certificate = null;
+ try {
+ InfoboxReadRequestType request = connector
+ .createInfoboxReadRequest();
+ InfoboxReadResponseType response = connector
+ .sendInfoboxReadRequest(request);
+
+ Iterator<InfoboxAssocArrayPairType> iterator = response
+ .getAssocArrayData().getPair().iterator();
+
+ while (iterator.hasNext()) {
+ InfoboxAssocArrayPairType pair = iterator.next();
+ if (pair.getKey().equals("SecureSignatureKeypair")) {
+ byte[] certData = pair.getBase64Content();
+ certificate = new X509Certificate(certData);
+ break;
+ }
+ }
+ } catch (CertificateException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return certificate;
+ }
+
+ public byte[] sign(byte[] input, int[] byteRange) throws PdfAsException {
+ CreateCMSSignatureRequestType request = connector.createCMSRequest(input, byteRange);
+ CreateCMSSignatureResponseType response = connector.sendCMSRequest(request);
+
+ return response.getCMSSignature();
+ }
+
+ public String getPDFSubFilter() {
+ return PDSignature.SUBFILTER_ETSI_CADES_DETACHED.getName();
+ }
+
+ public String getPDFFilter() {
+ return PDSignature.FILTER_ADOBE_PPKLITE.getName();
+ }
+
+}
diff --git a/signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/package-info.java b/signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/package-info.java
new file mode 100644
index 00000000..5c74ace3
--- /dev/null
+++ b/signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/package-info.java
@@ -0,0 +1,8 @@
+/**
+ *
+ */
+/**
+ * @author afitzek
+ *
+ */
+package at.gv.egiz.pdfas.sigs.pades; \ No newline at end of file