From ca26d2805186957ecf06ec0a9ff7b1606d49134d Mon Sep 17 00:00:00 2001 From: tkellner Date: Mon, 9 Dec 2013 18:26:07 +0000 Subject: Enable enveloping CMS signatures git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1243 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../egiz/bku/slcommands/impl/CreateCMSSignatureCommandImpl.java | 4 ++-- .../main/java/at/gv/egiz/bku/slcommands/impl/cms/Signature.java | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'bkucommon/src') diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateCMSSignatureCommandImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateCMSSignatureCommandImpl.java index 4825351b..cb974d06 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateCMSSignatureCommandImpl.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateCMSSignatureCommandImpl.java @@ -110,8 +110,8 @@ public class CreateCMSSignatureCommandImpl extends // DataObject, SigningCertificate, SigningTime Date signingTime = new Date(); try { - signature = new Signature(request.getDataObject(), signingCertificate, - signingTime, configurationFacade.getUseStrongHash()); + signature = new Signature(request.getDataObject(), request.getStructure(), + signingCertificate, signingTime, configurationFacade.getUseStrongHash()); } catch (Exception e) { log.error("Error creating CMS Signature.", e); throw new SLCommandException(4000); diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/cms/Signature.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/cms/Signature.java index 2c23f05b..749b0dbf 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/cms/Signature.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/cms/Signature.java @@ -88,10 +88,12 @@ public class Signature { @SuppressWarnings("unused") private String digestAlgorithmURI; - public Signature(CMSDataObjectRequiredMetaType dataObject, - X509Certificate signingCertificate, Date signingTime, boolean useStrongHash) throws NoSuchAlgorithmException, CertificateEncodingException, CertificateException, X509ExtensionException, InvalidParameterException, CodingException { + public Signature(CMSDataObjectRequiredMetaType dataObject, String structure, + X509Certificate signingCertificate, Date signingTime, boolean useStrongHash) + throws NoSuchAlgorithmException, CertificateEncodingException, CertificateException, X509ExtensionException, InvalidParameterException, CodingException { byte[] data = getContent(dataObject); - this.signedData = new SignedData(data, SignedData.EXPLICIT); + int mode = structure.equalsIgnoreCase("enveloping") ? SignedData.IMPLICIT : SignedData.EXPLICIT; + this.signedData = new SignedData(data, mode); setAlgorithmIDs(signingCertificate, useStrongHash); createSignerInfo(signingCertificate); setSignerCertificate(signingCertificate); -- cgit v1.2.3