diff options
author | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-10-31 09:38:35 +0100 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-10-31 09:38:35 +0100 |
commit | fed2e4a84d0d7e3ffa714e7c0685247be76715fb (patch) | |
tree | afb10f68483b2faa42c41a93bf94cc70db08cb1b /pdf-as-lib/src/main/java/at/gv/egiz/pdfas | |
parent | d72748087e8a7272b68a1b5e7c2d1b7c239515d9 (diff) | |
download | pdf-as-4-fed2e4a84d0d7e3ffa714e7c0685247be76715fb.tar.gz pdf-as-4-fed2e4a84d0d7e3ffa714e7c0685247be76715fb.tar.bz2 pdf-as-4-fed2e4a84d0d7e3ffa714e7c0685247be76715fb.zip |
better integration of Process Information
Diffstat (limited to 'pdf-as-lib/src/main/java/at/gv/egiz/pdfas')
3 files changed, 74 insertions, 6 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/BKUHeaderHolder.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/BKUHeaderHolder.java new file mode 100644 index 00000000..f66f0c11 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/BKUHeaderHolder.java @@ -0,0 +1,9 @@ +package at.gv.egiz.pdfas.lib.impl; + +import java.util.List; + +import at.gv.egiz.sl.util.BKUHeader; + +public interface BKUHeaderHolder { + public List<BKUHeader> getProcessInfo(); +} diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java index aa524cc9..8e86364b 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java @@ -61,6 +61,7 @@ import at.gv.egiz.pdfas.lib.impl.signing.PDFASSignatureExtractor; import at.gv.egiz.pdfas.lib.impl.status.OperationStatus; import at.gv.egiz.pdfas.lib.impl.status.RequestedSignature; import at.gv.egiz.pdfas.lib.util.SignatureUtils; +import at.gv.egiz.sl.util.BKUHeader; public class PdfAsImpl implements PdfAs, IConfigurationConstants, ErrorConstants { @@ -160,9 +161,34 @@ public class PdfAsImpl implements PdfAs, IConfigurationConstants, status.setRequestedSignature(requestedSignature); + try { requestedSignature.setCertificate(status.getSignParamter() .getPlainSigner().getCertificate(parameter)); - + } finally { + if (parameter instanceof BKUHeaderHolder) { + BKUHeaderHolder holder = (BKUHeaderHolder) parameter; + + Iterator<BKUHeader> bkuHeaderIt = holder.getProcessInfo() + .iterator(); + + while (bkuHeaderIt.hasNext()) { + BKUHeader header = bkuHeaderIt.next(); + if ("Server".equalsIgnoreCase(header.getName())) { + requestedSignature + .getStatus() + .getMetaInformations() + .put(ErrorConstants.STATUS_INFO_SIGDEVICEVERSION, + header.getValue()); + } else if (ErrorConstants.STATUS_INFO_SIGDEVICE.equalsIgnoreCase(header.getName())) { + requestedSignature + .getStatus() + .getMetaInformations() + .put(ErrorConstants.STATUS_INFO_SIGDEVICE, + header.getValue()); + } + } + } + } // Only use this profileID because validation was done in // RequestedSignature String signatureProfileID = requestedSignature @@ -177,11 +203,35 @@ public class PdfAsImpl implements PdfAs, IConfigurationConstants, // this.stampPdf(status); // Create signature - - signer.signPDF(status.getPdfObject(), requestedSignature, signer + try { + signer.signPDF(status.getPdfObject(), requestedSignature, signer .buildSignaturInterface(status.getSignParamter() .getPlainSigner(), parameter, requestedSignature)); - + } finally { + if (parameter instanceof BKUHeaderHolder) { + BKUHeaderHolder holder = (BKUHeaderHolder) parameter; + + Iterator<BKUHeader> bkuHeaderIt = holder.getProcessInfo() + .iterator(); + + while (bkuHeaderIt.hasNext()) { + BKUHeader header = bkuHeaderIt.next(); + if ("Server".equalsIgnoreCase(header.getName())) { + requestedSignature + .getStatus() + .getMetaInformations() + .put(ErrorConstants.STATUS_INFO_SIGDEVICEVERSION, + header.getValue()); + } else if (ErrorConstants.STATUS_INFO_SIGDEVICE.equalsIgnoreCase(header.getName())) { + requestedSignature + .getStatus() + .getMetaInformations() + .put(ErrorConstants.STATUS_INFO_SIGDEVICE, + header.getValue()); + } + } + } + } // ================================================================ // Create SignResult SignResult result = createSignResult(status); diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignParameterImpl.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignParameterImpl.java index 9584e1bf..d2786f53 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignParameterImpl.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignParameterImpl.java @@ -24,19 +24,25 @@ package at.gv.egiz.pdfas.lib.impl; import java.io.OutputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import javax.activation.DataSource; import at.gv.egiz.pdfas.lib.api.Configuration; import at.gv.egiz.pdfas.lib.api.sign.IPlainSigner; import at.gv.egiz.pdfas.lib.api.sign.SignParameter; +import at.gv.egiz.sl.util.BKUHeader; -public class SignParameterImpl extends PdfAsParameterImpl implements SignParameter { +public class SignParameterImpl extends PdfAsParameterImpl implements SignParameter, BKUHeaderHolder { protected String signatureProfileId = null; protected String signaturePosition = null; protected DataSource output = null; protected IPlainSigner signer = null; protected OutputStream outputStream = null; + protected List<BKUHeader> processInfo = new ArrayList<BKUHeader>(); public SignParameterImpl(Configuration configuration, DataSource dataSource, OutputStream outputStream) { @@ -74,5 +80,8 @@ public class SignParameterImpl extends PdfAsParameterImpl implements SignParamet public OutputStream getSignatureResult() { return outputStream; } - + + public List<BKUHeader> getProcessInfo() { + return processInfo; + } } |