aboutsummaryrefslogtreecommitdiff
path: root/signature-standards/sigs-pades/src/main/java/at/gv
diff options
context:
space:
mode:
authorbschnalzer <bianca.schnalzer@egiz.gv.at>2017-08-09 13:56:12 +0200
committerbschnalzer <bianca.schnalzer@egiz.gv.at>2017-08-09 13:56:14 +0200
commit7fe464cc98d714179b907c142bdd2fabfd009aa3 (patch)
tree328c53a9b60dfa1106c6b9d930d75ab127dce33f /signature-standards/sigs-pades/src/main/java/at/gv
parent17be060a4d2d79ee75036a2f785d4a4913f7935f (diff)
downloadpdf-as-4-4.1.1-RC.tar.gz
pdf-as-4-4.1.1-RC.tar.bz2
pdf-as-4-4.1.1-RC.zip
Fixed problem with PAdES Signatures, removed some attributes from CAdES signatures which are not required, minor bug fixes, implemented new style (lineCenter)4.1.1-RC
Diffstat (limited to 'signature-standards/sigs-pades/src/main/java/at/gv')
-rw-r--r--signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/PAdESSignerKeystore.java37
1 files changed, 34 insertions, 3 deletions
diff --git a/signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/PAdESSignerKeystore.java b/signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/PAdESSignerKeystore.java
index 7e236d30..0dcbfd9f 100644
--- a/signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/PAdESSignerKeystore.java
+++ b/signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/PAdESSignerKeystore.java
@@ -23,6 +23,7 @@
******************************************************************************/
package at.gv.egiz.pdfas.sigs.pades;
+import at.gv.egiz.pdfas.lib.api.IConfigurationConstants;
import iaik.asn1.ASN1Object;
import iaik.asn1.CodingException;
import iaik.asn1.ObjectID;
@@ -270,10 +271,22 @@ public class PAdESSignerKeystore implements IPlainSigner, PAdESConstants {
SignerInfo signerInfo) throws CertificateException,
NoSuchAlgorithmException, CodingException {
List<Attribute> attributes = new ArrayList<Attribute>();
+
setMimeTypeAttrib(attributes, mimeType);
setContentTypeAttrib(attributes);
setSigningCertificateAttrib(attributes, signingCertificate);
- //setSigningTimeAttrib(attributes, signingTime);
+ setSigningTimeAttrib(attributes, signingTime);
+ Attribute[] attributeArray = attributes
+ .toArray(new Attribute[attributes.size()]);
+ signerInfo.setSignedAttributes(attributeArray);
+ }
+
+ private void setAttributes(X509Certificate signingCertificate, SignerInfo signerInfo) throws CertificateException,
+ NoSuchAlgorithmException, CodingException {
+ List<Attribute> attributes = new ArrayList<Attribute>();
+
+ setContentTypeAttrib(attributes);
+ setSigningCertificateAttrib(attributes, signingCertificate);
Attribute[] attributeArray = attributes
.toArray(new Attribute[attributes.size()]);
signerInfo.setSignedAttributes(attributeArray);
@@ -283,7 +296,7 @@ public class PAdESSignerKeystore implements IPlainSigner, PAdESConstants {
RequestedSignature requestedSignature) throws PdfAsException {
try {
logger.info("Creating PAdES signature.");
-
+
requestedSignature.getStatus().getMetaInformations()
.put(ErrorConstants.STATUS_INFO_SIGDEVICE, SIGNATURE_DEVICE);
requestedSignature.getStatus().getMetaInformations()
@@ -298,7 +311,25 @@ public class PAdESSignerKeystore implements IPlainSigner, PAdESConstants {
SignedData si = new SignedData(input, SignedData.EXPLICIT);
si.addCertificates(new Certificate[] { cert });
- setAttributes("application/pdf", cert, new Date(), signer1);
+
+
+ //Check PAdES Flag
+ if (parameter.getConfiguration().hasValue(IConfigurationConstants.SIG_PADES_FORCE_FLAG))
+ {
+ if (IConfigurationConstants.TRUE.equalsIgnoreCase(parameter.getConfiguration().getValue(IConfigurationConstants.SIG_PADES_FORCE_FLAG)))
+ {
+ setAttributes(cert, signer1);
+ }
+ else
+ {
+ setAttributes("application/pdf", cert, new Date(), signer1);
+ }
+ }
+ else
+ {
+ setAttributes("application/pdf", cert, new Date(), signer1);
+ }
+
si.addSignerInfo(signer1);
InputStream dataIs = si.getInputStream();
byte[] buf = new byte[1024];