You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/08/28 08:25:53 UTC

[camel] branch master updated: CAMEL-15470: camel-crypto-cms - fix issue with set signer.

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 4ad148a  CAMEL-15470: camel-crypto-cms - fix issue with set signer.
4ad148a is described below

commit 4ad148acdf886d600bcfa6c4480700f6e442b30e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Aug 28 10:25:20 2020 +0200

    CAMEL-15470: camel-crypto-cms - fix issue with set signer.
---
 .../component/crypto/cms/CryptoCmsComponent.java   |  8 ++-----
 .../component/crypto/cms/CryptoCmsEndpoint.java    |  1 +
 .../component/crypto/cms/CryptoCmsProducer.java    | 11 +--------
 .../crypto/cms/sig/SignedDataCreator.java          |  4 ++--
 .../cms/sig/SignedDataCreatorConfiguration.java    | 26 +++++++++++-----------
 .../dsl/CryptoCmsEndpointBuilderFactory.java       | 17 +-------------
 6 files changed, 20 insertions(+), 47 deletions(-)

diff --git a/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/CryptoCmsComponent.java b/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/CryptoCmsComponent.java
index b6c987a..5325bba 100644
--- a/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/CryptoCmsComponent.java
+++ b/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/CryptoCmsComponent.java
@@ -42,6 +42,7 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Deprecated
 @Component("crypto-cms")
 public class CryptoCmsComponent extends DefaultComponent {
 
@@ -61,12 +62,7 @@ public class CryptoCmsComponent extends DefaultComponent {
     }
 
     @Override
-    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { // NOPMD
-                                                                                                                      // called
-                                                                                                                      // method
-                                                                                                                      // setProperties
-                                                                                                                      // throws
-                                                                                                                      // Exception
+    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
         ObjectHelper.notNull(getCamelContext(), "CamelContext");
 
         String scheme;
diff --git a/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/CryptoCmsEndpoint.java b/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/CryptoCmsEndpoint.java
index 2aa19be..7f6ce41 100644
--- a/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/CryptoCmsEndpoint.java
+++ b/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/CryptoCmsEndpoint.java
@@ -33,6 +33,7 @@ import org.apache.camel.support.DefaultEndpoint;
 /**
  * Encrypt, decrypt, sign and verify data in CMS Enveloped Data format.
  */
+@Deprecated
 @UriEndpoint(firstVersion = "2.20.0", scheme = "crypto-cms", title = "Crypto CMS", syntax = "crypto-cms:cryptoOperation:name",
              producerOnly = true, category = { Category.SECURITY, Category.TRANSFORMATION })
 public class CryptoCmsEndpoint extends DefaultEndpoint {
diff --git a/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/CryptoCmsProducer.java b/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/CryptoCmsProducer.java
index e4fa678..dbbcc8f 100644
--- a/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/CryptoCmsProducer.java
+++ b/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/CryptoCmsProducer.java
@@ -22,8 +22,6 @@ import org.apache.camel.Processor;
 import org.apache.camel.support.DefaultProducer;
 
 public class CryptoCmsProducer extends DefaultProducer {
-    // private static final Logger log =
-    // LoggerFactory.getLogger(CmsProducer.class);
 
     private Processor processor;
 
@@ -33,15 +31,8 @@ public class CryptoCmsProducer extends DefaultProducer {
     }
 
     @Override
-    public void process(Exchange exchange) throws Exception { // NOPMD a
-                                                             // processor can
-                                                             // throw any
-                                                             // exception
-                                                             // try {
+    public void process(Exchange exchange) throws Exception {
         processor.process(exchange);
-        // } catch (Exception e) {
-        // exchange.setException(e);
-        // }
     }
 
 }
diff --git a/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/sig/SignedDataCreator.java b/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/sig/SignedDataCreator.java
index 2a91a59..0a5a0e8 100644
--- a/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/sig/SignedDataCreator.java
+++ b/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/sig/SignedDataCreator.java
@@ -75,10 +75,10 @@ public class SignedDataCreator extends CryptoCmsMarshallerAbstract {
 
         CMSSignedDataStreamGenerator gen = new CMSSignedDataStreamGenerator();
 
-        if (config.getSigner().isEmpty()) {
+        if (config.getSignerList().isEmpty()) {
             throw new CryptoCmsException("No signer information configured");
         }
-        for (SignerInfo signer : config.getSigner()) {
+        for (SignerInfo signer : config.getSignerList()) {
             // these certificates are sent within the signature
             LOG.debug("Signer info: {}", signer);
             X509Certificate signerCert = signer.getCertificate(exchange);
diff --git a/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/sig/SignedDataCreatorConfiguration.java b/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/sig/SignedDataCreatorConfiguration.java
index d0d617d..db17854 100644
--- a/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/sig/SignedDataCreatorConfiguration.java
+++ b/components/camel-crypto-cms/src/main/java/org/apache/camel/component/crypto/cms/sig/SignedDataCreatorConfiguration.java
@@ -37,7 +37,8 @@ public class SignedDataCreatorConfiguration extends CryptoCmsMarshallerConfigura
 
     @UriParam(label = "sign", javaType = "java.lang.String",
               description = "Signer information: reference to bean(s) which implements org.apache.camel.component.crypto.cms.api.SignerInfo. Multiple values can be separated by comma")
-    private List<SignerInfo> signer = new ArrayList<>();
+    private String signer;
+    private final List<SignerInfo> signerList = new ArrayList<>();
 
     public SignedDataCreatorConfiguration(CamelContext context) {
         super(context);
@@ -55,14 +56,10 @@ public class SignedDataCreatorConfiguration extends CryptoCmsMarshallerConfigura
         this.includeContent = includeContent;
     }
 
-    public List<SignerInfo> getSigner() {
+    public String getSigner() {
         return signer;
     }
 
-    public void setSigner(List<SignerInfo> signer) {
-        this.signer = signer;
-    }
-
     public void setSigner(String signer) {
         String[] values = signer.split(",");
         for (String s : values) {
@@ -78,19 +75,22 @@ public class SignedDataCreatorConfiguration extends CryptoCmsMarshallerConfigura
         }
     }
 
+    public void setSigner(SignerInfo signer) {
+        addSigner(signer);
+    }
+
     public void addSigner(SignerInfo info) {
-        if (this.signer == null) {
-            this.signer = new ArrayList<>();
-        }
-        this.signer.add(info);
+        this.signerList.add(info);
     }
 
-    public void init() throws CryptoCmsException {
+    public List<SignerInfo> getSignerList() {
+        return signerList;
+    }
 
-        if (signer.isEmpty()) {
+    public void init() throws CryptoCmsException {
+        if (signerList.isEmpty()) {
             logErrorAndThrow(LOG, "No signer set.");
         }
-
     }
 
 }
diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CryptoCmsEndpointBuilderFactory.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CryptoCmsEndpointBuilderFactory.java
index 76eb8e8..61c5834 100644
--- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CryptoCmsEndpointBuilderFactory.java
+++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CryptoCmsEndpointBuilderFactory.java
@@ -395,22 +395,7 @@ public interface CryptoCmsEndpointBuilderFactory {
          * org.apache.camel.component.crypto.cms.api.SignerInfo. Multiple values
          * can be separated by comma.
          * 
-         * The option is a:
-         * <code>java.util.List&lt;org.apache.camel.component.crypto.cms.sig.SignerInfo&gt;</code> type.
-         * 
-         * Group: sign
-         */
-        default CryptoCmsEndpointBuilder signer(List<Object> signer) {
-            doSetProperty("signer", signer);
-            return this;
-        }
-        /**
-         * Signer information: reference to bean(s) which implements
-         * org.apache.camel.component.crypto.cms.api.SignerInfo. Multiple values
-         * can be separated by comma.
-         * 
-         * The option will be converted to a
-         * <code>java.util.List&lt;org.apache.camel.component.crypto.cms.sig.SignerInfo&gt;</code> type.
+         * The option is a: <code>java.lang.String</code> type.
          * 
          * Group: sign
          */