This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch df2 in repository https://gitbox.apache.org/repos/asf/camel.git
commit d7d5c0469d23844b9ce28321539825e68bc8abbe Author: Claus Ibsen <[email protected]> AuthorDate: Mon Aug 18 14:38:43 2025 +0200 CAMEL-22354: dataformats - Align all data formats getter setters to model --- .../crypto/CryptoDataFormatConfigurer.java | 22 ++++++++ .../org/apache/camel/converter/crypto/crypto.json | 6 +- .../camel/converter/crypto/CryptoDataFormat.java | 58 ++++++++++++++----- .../converter/crypto/CryptoDataFormatTest.java | 10 ++-- .../crypto/SpringCryptoDataFormatTest.xml | 28 +++++----- ...EncapsulationCryptoRoundTripCHACHA7539Test.java | 2 +- ...erateEncapsulationCryptoRoundTripGRAINTest.java | 2 +- .../org/apache/camel/model/dataformat/crypto.json | 6 +- .../camel/model/dataformat/CryptoDataFormat.java | 65 +++++++++++----------- .../reifier/dataformat/CBORDataFormatReifier.java | 2 +- .../dataformat/CryptoDataFormatReifier.java | 8 +-- .../java/org/apache/camel/xml/in/ModelParser.java | 6 +- .../java/org/apache/camel/xml/out/ModelWriter.java | 6 +- .../org/apache/camel/yaml/out/ModelWriter.java | 6 +- 14 files changed, 140 insertions(+), 87 deletions(-) diff --git a/components/camel-crypto/src/generated/java/org/apache/camel/converter/crypto/CryptoDataFormatConfigurer.java b/components/camel-crypto/src/generated/java/org/apache/camel/converter/crypto/CryptoDataFormatConfigurer.java index 2890ab4353e..fe76126d0dc 100644 --- a/components/camel-crypto/src/generated/java/org/apache/camel/converter/crypto/CryptoDataFormatConfigurer.java +++ b/components/camel-crypto/src/generated/java/org/apache/camel/converter/crypto/CryptoDataFormatConfigurer.java @@ -23,8 +23,12 @@ public class CryptoDataFormatConfigurer extends org.apache.camel.support.compone static { Map<String, Object> map = new CaseInsensitiveMap(); map.put("Algorithm", java.lang.String.class); + map.put("AlgorithmParameterSpec", java.security.spec.AlgorithmParameterSpec.class); map.put("BufferSize", int.class); map.put("CryptoProvider", java.lang.String.class); + map.put("InitVector", byte[].class); + map.put("Inline", boolean.class); + map.put("Key", java.security.Key.class); map.put("MacAlgorithm", java.lang.String.class); map.put("ShouldAppendHMAC", boolean.class); ALL_OPTIONS = map; @@ -35,10 +39,16 @@ public class CryptoDataFormatConfigurer extends org.apache.camel.support.compone CryptoDataFormat target = (CryptoDataFormat) obj; switch (ignoreCase ? name.toLowerCase() : name) { case "algorithm": target.setAlgorithm(property(camelContext, java.lang.String.class, value)); return true; + case "algorithmparameterspec": + case "algorithmParameterSpec": target.setAlgorithmParameterSpec(property(camelContext, java.security.spec.AlgorithmParameterSpec.class, value)); return true; case "buffersize": case "bufferSize": target.setBufferSize(property(camelContext, int.class, value)); return true; case "cryptoprovider": case "cryptoProvider": target.setCryptoProvider(property(camelContext, java.lang.String.class, value)); return true; + case "initvector": + case "initVector": target.setInitVector(property(camelContext, byte[].class, value)); return true; + case "inline": target.setInline(property(camelContext, boolean.class, value)); return true; + case "key": target.setKey(property(camelContext, java.security.Key.class, value)); return true; case "macalgorithm": case "macAlgorithm": target.setMacAlgorithm(property(camelContext, java.lang.String.class, value)); return true; case "shouldappendhmac": @@ -56,10 +66,16 @@ public class CryptoDataFormatConfigurer extends org.apache.camel.support.compone public Class<?> getOptionType(String name, boolean ignoreCase) { switch (ignoreCase ? name.toLowerCase() : name) { case "algorithm": return java.lang.String.class; + case "algorithmparameterspec": + case "algorithmParameterSpec": return java.security.spec.AlgorithmParameterSpec.class; case "buffersize": case "bufferSize": return int.class; case "cryptoprovider": case "cryptoProvider": return java.lang.String.class; + case "initvector": + case "initVector": return byte[].class; + case "inline": return boolean.class; + case "key": return java.security.Key.class; case "macalgorithm": case "macAlgorithm": return java.lang.String.class; case "shouldappendhmac": @@ -73,10 +89,16 @@ public class CryptoDataFormatConfigurer extends org.apache.camel.support.compone CryptoDataFormat target = (CryptoDataFormat) obj; switch (ignoreCase ? name.toLowerCase() : name) { case "algorithm": return target.getAlgorithm(); + case "algorithmparameterspec": + case "algorithmParameterSpec": return target.getAlgorithmParameterSpec(); case "buffersize": case "bufferSize": return target.getBufferSize(); case "cryptoprovider": case "cryptoProvider": return target.getCryptoProvider(); + case "initvector": + case "initVector": return target.getInitVector(); + case "inline": return target.isInline(); + case "key": return target.getKey(); case "macalgorithm": case "macAlgorithm": return target.getMacAlgorithm(); case "shouldappendhmac": diff --git a/components/camel-crypto/src/generated/resources/META-INF/org/apache/camel/converter/crypto/crypto.json b/components/camel-crypto/src/generated/resources/META-INF/org/apache/camel/converter/crypto/crypto.json index c8e6de4c22f..a1ac745524f 100644 --- a/components/camel-crypto/src/generated/resources/META-INF/org/apache/camel/converter/crypto/crypto.json +++ b/components/camel-crypto/src/generated/resources/META-INF/org/apache/camel/converter/crypto/crypto.json @@ -18,10 +18,10 @@ "properties": { "id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" }, "algorithm": { "index": 1, "kind": "attribute", "displayName": "Algorithm", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The JCE algorithm name indicating the cryptographic algorithm that will be used." }, - "keyRef": { "index": 2, "kind": "attribute", "displayName": "Key Ref", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Refers to the secret key to lookup from the register to use." }, + "key": { "index": 2, "kind": "attribute", "displayName": "Key", "group": "common", "required": false, "type": "object", "javaType": "java.security.Key", "deprecated": false, "autowired": false, "secret": false, "description": "Refers to the secret key to lookup from the register to use." }, "cryptoProvider": { "index": 3, "kind": "attribute", "displayName": "Crypto Provider", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The name of the JCE Security Provider that should be used." }, - "initVectorRef": { "index": 4, "kind": "attribute", "displayName": "Init Vector Ref", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Refers to a byte array containing the Initialization Vector that will be used to initialize the Cipher." }, - "algorithmParameterRef": { "index": 5, "kind": "attribute", "displayName": "Algorithm Parameter Ref", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A JCE AlgorithmParameterSpec used to initialize the Cipher. Will lookup the type using the given name as a java.security.spec.AlgorithmParameterSpec type." }, + "initVector": { "index": 4, "kind": "attribute", "displayName": "Init Vector", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "byte[]", "deprecated": false, "autowired": false, "secret": false, "description": "Refers to a byte array containing the Initialization Vector that will be used to initialize the Cipher." }, + "algorithmParameterSpec": { "index": 5, "kind": "attribute", "displayName": "Algorithm Parameter Spec", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "java.security.spec.AlgorithmParameterSpec", "deprecated": false, "autowired": false, "secret": false, "description": "A JCE AlgorithmParameterSpec used to initialize the Cipher. Will lookup the type using the given name as a java.security.spec.AlgorithmParameterSpec type." }, "bufferSize": { "index": 6, "kind": "attribute", "displayName": "Buffer Size", "group": "common", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "4096", "description": "The size of the buffer used in the signature process." }, "macAlgorithm": { "index": 7, "kind": "attribute", "displayName": "Mac Algorithm", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HmacSHA1", "description": "The JCE algorithm name indicating the Message Authentication algorithm." }, "shouldAppendHMAC": { "index": 8, "kind": "attribute", "displayName": "Should Append HMAC", "group": "common", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Flag indicating that a Message Authentication Code should be calculated and appended to the encrypted data." }, diff --git a/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/CryptoDataFormat.java b/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/CryptoDataFormat.java index 1fbb1ddd138..eb044995960 100644 --- a/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/CryptoDataFormat.java +++ b/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/CryptoDataFormat.java @@ -74,13 +74,13 @@ public class CryptoDataFormat extends ServiceSupport implements DataFormat, Data private static final String INIT_VECTOR = "CamelCryptoInitVector"; private String algorithm; private String cryptoProvider; - private Key configuredkey; + private Key key; private int bufferSize = 4096; - private byte[] initializationVector; + private byte[] initVector; private boolean inline; private String macAlgorithm = "HmacSHA1"; private boolean shouldAppendHMAC = true; - private AlgorithmParameterSpec parameterSpec; + private AlgorithmParameterSpec algorithmParameterSpec; public CryptoDataFormat() { } @@ -91,7 +91,7 @@ public class CryptoDataFormat extends ServiceSupport implements DataFormat, Data public CryptoDataFormat(String algorithm, Key key, String cryptoProvider) { this.algorithm = algorithm; - this.configuredkey = key; + this.key = key; this.cryptoProvider = cryptoProvider; } @@ -110,8 +110,8 @@ public class CryptoDataFormat extends ServiceSupport implements DataFormat, Data } if (mode == ENCRYPT_MODE || mode == DECRYPT_MODE) { - if (parameterSpec != null) { - cipher.init(mode, key, parameterSpec); + if (algorithmParameterSpec != null) { + cipher.init(mode, key, algorithmParameterSpec); } else if (iv != null) { cipher.init(mode, key, new IvParameterSpec(iv)); } else { @@ -250,7 +250,7 @@ public class CryptoDataFormat extends ServiceSupport implements DataFormat, Data private byte[] getInitializationVector(Exchange exchange) { byte[] iv = exchange.getIn().getHeader(INIT_VECTOR, byte[].class); if (iv == null) { - iv = initializationVector; + iv = initVector; } return iv; } @@ -260,14 +260,18 @@ public class CryptoDataFormat extends ServiceSupport implements DataFormat, Data if (key != null) { exchange.getIn().setHeader(KEY, null); } else { - key = configuredkey; + key = this.key; } return key; } - public void setInitializationVector(byte[] initializationVector) { - if (initializationVector != null) { - this.initializationVector = initializationVector; + public byte[] getInitVector() { + return initVector; + } + + public void setInitVector(byte[] initVector) { + if (initVector != null) { + this.initVector = initVector; } } @@ -277,12 +281,30 @@ public class CryptoDataFormat extends ServiceSupport implements DataFormat, Data * will need to be read from the stream. Requires that the formatter has been configured with an init vector that is * valid for the given algorithm. * - * @param inline true if the initialization vector should be inlined in the stream. + * @param inline true if the initialization vector should be inlined in the stream. + * @deprecated use {@link #setInline(boolean)} */ + @Deprecated public void setShouldInlineInitializationVector(boolean inline) { this.inline = inline; } + public boolean isInline() { + return inline; + } + + /** + * Meant for use with a Symmetric block Cipher and specifies that the initialization vector should be written to the + * cipher stream ahead of the encrypted ciphertext. When the payload is to be decrypted this initialization vector + * will need to be read from the stream. Requires that the formatter has been configured with an init vector that is + * valid for the given algorithm. + * + * @param inline true if the initialization vector should be inlined in the stream. + */ + public void setInline(boolean inline) { + this.inline = inline; + } + public String getAlgorithm() { return algorithm; } @@ -294,12 +316,16 @@ public class CryptoDataFormat extends ServiceSupport implements DataFormat, Data this.algorithm = algorithm; } + public AlgorithmParameterSpec getAlgorithmParameterSpec() { + return algorithmParameterSpec; + } + /** * Sets a custom {@link AlgorithmParameterSpec} that should be used to configure the Cipher. Note that if an * Initalization vector is provided then the IvParameterSpec will be used and any value set here will be ignored */ public void setAlgorithmParameterSpec(AlgorithmParameterSpec parameterSpec) { - this.parameterSpec = parameterSpec; + this.algorithmParameterSpec = parameterSpec; } public String getCryptoProvider() { @@ -335,11 +361,15 @@ public class CryptoDataFormat extends ServiceSupport implements DataFormat, Data this.shouldAppendHMAC = shouldAppendHMAC; } + public Key getKey() { + return key; + } + /** * Set the key that should be used to encrypt or decrypt incoming encrypted exchanges. */ public void setKey(Key key) { - this.configuredkey = key; + this.key = key; } public int getBufferSize() { diff --git a/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/CryptoDataFormatTest.java b/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/CryptoDataFormatTest.java index f8c31663c33..cb738b783e2 100644 --- a/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/CryptoDataFormatTest.java +++ b/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/CryptoDataFormatTest.java @@ -195,7 +195,7 @@ public class CryptoDataFormatTest extends CamelTestSupport { byte[] initializationVector = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }; CryptoDataFormat cryptoFormat = new CryptoDataFormat("DES/CBC/PKCS5Padding", generator.generateKey()); - cryptoFormat.setInitializationVector(initializationVector); + cryptoFormat.setInitVector(initializationVector); from("direct:init-vector") .marshal(cryptoFormat) @@ -212,7 +212,7 @@ public class CryptoDataFormatTest extends CamelTestSupport { SecretKey key = generator.generateKey(); CryptoDataFormat cryptoFormat = new CryptoDataFormat("DES/CBC/PKCS5Padding", key); - cryptoFormat.setInitializationVector(initializationVector); + cryptoFormat.setInitVector(initializationVector); cryptoFormat.setShouldInlineInitializationVector(true); CryptoDataFormat decryptFormat = new CryptoDataFormat("DES/CBC/PKCS5Padding", key); decryptFormat.setShouldInlineInitializationVector(true); @@ -317,7 +317,7 @@ public class CryptoDataFormatTest extends CamelTestSupport { Key key = generator.generateKey(); CryptoDataFormat encCryptoFormat = new CryptoDataFormat("DES/CBC/PKCS5Padding", key); - encCryptoFormat.setInitializationVector(iv); + encCryptoFormat.setInitVector(iv); encCryptoFormat.setShouldInlineInitializationVector(true); CryptoDataFormat decCryptoFormat = new CryptoDataFormat("DES/CBC/PKCS5Padding", key); @@ -376,7 +376,7 @@ public class CryptoDataFormatTest extends CamelTestSupport { GCMParameterSpec paramSpec = new GCMParameterSpec(128, iv); CryptoDataFormat cryptoFormat = new CryptoDataFormat("AES/GCM/NoPadding", generator.generateKey()); - cryptoFormat.setInitializationVector(iv); + cryptoFormat.setInitVector(iv); cryptoFormat.setShouldInlineInitializationVector(true); cryptoFormat.setAlgorithmParameterSpec(paramSpec); @@ -396,7 +396,7 @@ public class CryptoDataFormatTest extends CamelTestSupport { CryptoDataFormat cryptoFormat = new CryptoDataFormat(); cryptoFormat.setKey(generator.generateKey()); - cryptoFormat.setInitializationVector(iv); + cryptoFormat.setInitVector(iv); // cryptoFormat.setAlgorithm("DES/CBC/PKCS5Padding"); from("direct:no-algorithm") diff --git a/components/camel-crypto/src/test/resources/org/apache/camel/component/crypto/SpringCryptoDataFormatTest.xml b/components/camel-crypto/src/test/resources/org/apache/camel/component/crypto/SpringCryptoDataFormatTest.xml index 3c3899bd323..278c58b57bd 100644 --- a/components/camel-crypto/src/test/resources/org/apache/camel/component/crypto/SpringCryptoDataFormatTest.xml +++ b/components/camel-crypto/src/test/resources/org/apache/camel/component/crypto/SpringCryptoDataFormatTest.xml @@ -26,28 +26,28 @@ <!-- START SNIPPET: e1 --> <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> <dataFormats> - <crypto id="basic" algorithm="DES" keyRef="desKey" /> + <crypto id="basic" algorithm="DES" key="desKey" /> <!-- START SNIPPET: init-vector --> - <crypto id="initvector" algorithm="DES/CBC/PKCS5Padding" keyRef="desKey" initVectorRef="initializationVector" /> + <crypto id="initvector" algorithm="DES/CBC/PKCS5Padding" key="desKey" initVector="initializationVector" /> <!-- END SNIPPET: init-vector --> <!-- START SNIPPET: inline --> - <crypto id="inline" algorithm="DES/CBC/PKCS5Padding" keyRef="desKey" initVectorRef="initializationVector" + <crypto id="inline" algorithm="DES/CBC/PKCS5Padding" key="desKey" initVector="initializationVector" inline="true" /> - <crypto id="inline-decrypt" algorithm="DES/CBC/PKCS5Padding" keyRef="desKey" inline="true" /> + <crypto id="inline-decrypt" algorithm="DES/CBC/PKCS5Padding" key="desKey" inline="true" /> <!-- END SNIPPET: inline --> <!-- START SNIPPET: hmac --> - <crypto id="hmac" algorithm="DES" keyRef="desKey" shouldAppendHMAC="true" /> + <crypto id="hmac" algorithm="DES" key="desKey" shouldAppendHMAC="true" /> <!-- END SNIPPET: hmac --> <!-- START SNIPPET: hmac-algorithm --> - <crypto id="hmac-algorithm" algorithm="DES" keyRef="desKey" macAlgorithm="HmacMD5" shouldAppendHMAC="true" /> + <crypto id="hmac-algorithm" algorithm="DES" key="desKey" macAlgorithm="HmacMD5" shouldAppendHMAC="true" /> <!-- END SNIPPET: hmac-algorithm --> <!-- START SNIPPET: hmac-sha-256-algorithm --> - <crypto id="hmac-sha-256-algorithm" algorithm="DES" keyRef="desKey" macAlgorithm="HmacSHA256" shouldAppendHMAC="true" /> + <crypto id="hmac-sha-256-algorithm" algorithm="DES" key="desKey" macAlgorithm="HmacSHA256" shouldAppendHMAC="true" /> <!-- END SNIPPET: hmac-sha-256-algorithm --> <!-- START SNIPPET: header-key --> @@ -55,22 +55,22 @@ <!-- END SNIPPET: header-key --> <!-- START SNIPPET: tripledes-ecb-encryption --> - <crypto id="tripledes-ecb-encryption" algorithm="DESede/ECB/PKCS5Padding" keyRef="desEdeKey" /> + <crypto id="tripledes-ecb-encryption" algorithm="DESede/ECB/PKCS5Padding" key="desEdeKey" /> <!-- END SNIPPET: tripledes-ecb-encryption --> <!-- START SNIPPET: tripledes-cbc-encryption --> - <crypto id="tripledes-cbc-encryption-encrypt" algorithm="DESede/CBC/PKCS5Padding" keyRef="desEdeKey" initVectorRef="initializationVector" inline="true" /> - <crypto id="tripledes-cbc-encryption-decrypt" algorithm="DESede/CBC/PKCS5Padding" keyRef="desEdeKey" inline="true" /> + <crypto id="tripledes-cbc-encryption-encrypt" algorithm="DESede/CBC/PKCS5Padding" key="desEdeKey" initVector="initializationVector" inline="true" /> + <crypto id="tripledes-cbc-encryption-decrypt" algorithm="DESede/CBC/PKCS5Padding" key="desEdeKey" inline="true" /> <!-- END SNIPPET: tripledes-cbc-encryption --> <!-- START SNIPPET: aes-128-ecb-encryption --> - <crypto id="aes-128-ecb-encryption" algorithm="AES/ECB/PKCS5Padding" keyRef="aesKey" /> + <crypto id="aes-128-ecb-encryption" algorithm="AES/ECB/PKCS5Padding" key="aesKey" /> <!-- END SNIPPET: aes-128-ecb-encryption --> - <crypto id="aes-gcm-encryption" algorithm="AES/GCM/NoPadding" keyRef="aesKey" algorithmParameterRef="gcmParamSpec" /> - <crypto id="inline-aes-gcm-encryption" algorithm="AES/GCM/NoPadding" keyRef="aesKey" algorithmParameterRef="gcmParamSpec" initVectorRef="initializationVector" inline="true"/> + <crypto id="aes-gcm-encryption" algorithm="AES/GCM/NoPadding" key="aesKey" algorithmParameterSpec="gcmParamSpec" /> + <crypto id="inline-aes-gcm-encryption" algorithm="AES/GCM/NoPadding" key="aesKey" algorithmParameterSpec="gcmParamSpec" initVector="initializationVector" inline="true"/> - <crypto id="des-no-algorithm" keyRef="desKey" initVectorRef="initializationVector" /> + <crypto id="des-no-algorithm" key="desKey" initVector="initializationVector" /> </dataFormats> <route> diff --git a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationCryptoRoundTripCHACHA7539Test.java b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationCryptoRoundTripCHACHA7539Test.java index 025ef1f6e67..22dc12493fa 100644 --- a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationCryptoRoundTripCHACHA7539Test.java +++ b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationCryptoRoundTripCHACHA7539Test.java @@ -59,7 +59,7 @@ public class PQCMLKEMGenerateEncapsulationCryptoRoundTripCHACHA7539Test extends protected RouteBuilder createRouteBuilder() { CryptoDataFormat cryptoFormat = new CryptoDataFormat("CHACHA7539", null); byte[] initializationVector = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b }; - cryptoFormat.setInitializationVector(initializationVector); + cryptoFormat.setInitVector(initializationVector); return new RouteBuilder() { @Override public void configure() { diff --git a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationCryptoRoundTripGRAINTest.java b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationCryptoRoundTripGRAINTest.java index 03e35bd374f..068507d14c3 100644 --- a/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationCryptoRoundTripGRAINTest.java +++ b/components/camel-pqc/src/test/java/org/apache/camel/component/pqc/PQCMLKEMGenerateEncapsulationCryptoRoundTripGRAINTest.java @@ -59,7 +59,7 @@ public class PQCMLKEMGenerateEncapsulationCryptoRoundTripGRAINTest extends Camel protected RouteBuilder createRouteBuilder() { CryptoDataFormat cryptoFormat = new CryptoDataFormat("GRAIN128", null); byte[] initializationVector = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b }; - cryptoFormat.setInitializationVector(initializationVector); + cryptoFormat.setInitVector(initializationVector); return new RouteBuilder() { @Override public void configure() { diff --git a/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/dataformat/crypto.json b/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/dataformat/crypto.json index 15955ae7717..792087934b0 100644 --- a/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/dataformat/crypto.json +++ b/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/dataformat/crypto.json @@ -15,10 +15,10 @@ "properties": { "id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" }, "algorithm": { "index": 1, "kind": "attribute", "displayName": "Algorithm", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The JCE algorithm name indicating the cryptographic algorithm that will be used." }, - "keyRef": { "index": 2, "kind": "attribute", "displayName": "Key Ref", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Refers to the secret key to lookup from the register to use." }, + "key": { "index": 2, "kind": "attribute", "displayName": "Key", "group": "common", "required": false, "type": "object", "javaType": "java.security.Key", "deprecated": false, "autowired": false, "secret": false, "description": "Refers to the secret key to lookup from the register to use." }, "cryptoProvider": { "index": 3, "kind": "attribute", "displayName": "Crypto Provider", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The name of the JCE Security Provider that should be used." }, - "initVectorRef": { "index": 4, "kind": "attribute", "displayName": "Init Vector Ref", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Refers to a byte array containing the Initialization Vector that will be used to initialize the Cipher." }, - "algorithmParameterRef": { "index": 5, "kind": "attribute", "displayName": "Algorithm Parameter Ref", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A JCE AlgorithmParameterSpec used to initialize the Cipher. Will lookup the type using the given name as a java.security.spec.AlgorithmParameterSpec type." }, + "initVector": { "index": 4, "kind": "attribute", "displayName": "Init Vector", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "byte[]", "deprecated": false, "autowired": false, "secret": false, "description": "Refers to a byte array containing the Initialization Vector that will be used to initialize the Cipher." }, + "algorithmParameterSpec": { "index": 5, "kind": "attribute", "displayName": "Algorithm Parameter Spec", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "java.security.spec.AlgorithmParameterSpec", "deprecated": false, "autowired": false, "secret": false, "description": "A JCE AlgorithmParameterSpec used to initialize the Cipher. Will lookup the type using the given name as a java.security.spec.AlgorithmParameterSpec type." }, "bufferSize": { "index": 6, "kind": "attribute", "displayName": "Buffer Size", "group": "common", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "4096", "description": "The size of the buffer used in the signature process." }, "macAlgorithm": { "index": 7, "kind": "attribute", "displayName": "Mac Algorithm", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HmacSHA1", "description": "The JCE algorithm name indicating the Message Authentication algorithm." }, "shouldAppendHMAC": { "index": 8, "kind": "attribute", "displayName": "Should Append HMAC", "group": "common", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Flag indicating that a Message Authentication Code should be calculated and appended to the encrypted data." }, diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/CryptoDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/CryptoDataFormat.java index 146222aa961..09bc96c5368 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/CryptoDataFormat.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/CryptoDataFormat.java @@ -37,16 +37,17 @@ public class CryptoDataFormat extends DataFormatDefinition { @XmlAttribute private String algorithm; @XmlAttribute - private String keyRef; + @Metadata(javaType = "java.security.Key") + private String key; @XmlAttribute @Metadata(label = "advanced") private String cryptoProvider; @XmlAttribute - @Metadata(label = "advanced") - private String initVectorRef; + @Metadata(label = "advanced", javaType = "byte[]") + private String initVector; @XmlAttribute - @Metadata(label = "advanced") - private String algorithmParameterRef; + @Metadata(label = "advanced", javaType = "java.security.spec.AlgorithmParameterSpec") + private String algorithmParameterSpec; @XmlAttribute @Metadata(javaType = "java.lang.Integer", defaultValue = "4096") private String bufferSize; @@ -67,10 +68,10 @@ public class CryptoDataFormat extends DataFormatDefinition { protected CryptoDataFormat(CryptoDataFormat source) { super(source); this.algorithm = source.algorithm; - this.keyRef = source.keyRef; + this.key = source.key; this.cryptoProvider = source.cryptoProvider; - this.initVectorRef = source.initVectorRef; - this.algorithmParameterRef = source.algorithmParameterRef; + this.initVector = source.initVector; + this.algorithmParameterSpec = source.algorithmParameterSpec; this.bufferSize = source.bufferSize; this.macAlgorithm = source.macAlgorithm; this.shouldAppendHMAC = source.shouldAppendHMAC; @@ -80,10 +81,10 @@ public class CryptoDataFormat extends DataFormatDefinition { private CryptoDataFormat(Builder builder) { this(); this.algorithm = builder.algorithm; - this.keyRef = builder.keyRef; + this.key = builder.key; this.cryptoProvider = builder.cryptoProvider; - this.initVectorRef = builder.initVectorRef; - this.algorithmParameterRef = builder.algorithmParameterRef; + this.initVector = builder.initVector; + this.algorithmParameterSpec = builder.algorithmParameterSpec; this.bufferSize = builder.bufferSize; this.macAlgorithm = builder.macAlgorithm; this.shouldAppendHMAC = builder.shouldAppendHMAC; @@ -117,30 +118,30 @@ public class CryptoDataFormat extends DataFormatDefinition { this.cryptoProvider = cryptoProvider; } - public String getKeyRef() { - return keyRef; + public String getKey() { + return key; } /** * Refers to the secret key to lookup from the register to use. */ - public void setKeyRef(String keyRef) { - this.keyRef = keyRef; + public void setKey(String key) { + this.key = key; } - public String getInitVectorRef() { - return initVectorRef; + public String getInitVector() { + return initVector; } /** * Refers to a byte array containing the Initialization Vector that will be used to initialize the Cipher. */ - public void setInitVectorRef(String initVectorRef) { - this.initVectorRef = initVectorRef; + public void setInitVector(String initVector) { + this.initVector = initVector; } - public String getAlgorithmParameterRef() { - return algorithmParameterRef; + public String getAlgorithmParameterSpec() { + return algorithmParameterSpec; } /** @@ -148,8 +149,8 @@ public class CryptoDataFormat extends DataFormatDefinition { * <p/> * Will lookup the type using the given name as a {@link java.security.spec.AlgorithmParameterSpec} type. */ - public void setAlgorithmParameterRef(String algorithmParameterRef) { - this.algorithmParameterRef = algorithmParameterRef; + public void setAlgorithmParameterSpec(String algorithmParameterSpec) { + this.algorithmParameterSpec = algorithmParameterSpec; } public String getBufferSize() { @@ -205,10 +206,10 @@ public class CryptoDataFormat extends DataFormatDefinition { public static class Builder implements DataFormatBuilder<CryptoDataFormat> { private String algorithm; - private String keyRef; + private String key; private String cryptoProvider; - private String initVectorRef; - private String algorithmParameterRef; + private String initVector; + private String algorithmParameterSpec; private String bufferSize; private String macAlgorithm = "HmacSHA1"; private String shouldAppendHMAC; @@ -233,16 +234,16 @@ public class CryptoDataFormat extends DataFormatDefinition { /** * Refers to the secret key to lookup from the register to use. */ - public Builder keyRef(String keyRef) { - this.keyRef = keyRef; + public Builder key(String key) { + this.key = key; return this; } /** * Refers to a byte array containing the Initialization Vector that will be used to initialize the Cipher. */ - public Builder initVectorRef(String initVectorRef) { - this.initVectorRef = initVectorRef; + public Builder initVector(String initVector) { + this.initVector = initVector; return this; } @@ -251,8 +252,8 @@ public class CryptoDataFormat extends DataFormatDefinition { * <p/> * Will lookup the type using the given name as a {@link java.security.spec.AlgorithmParameterSpec} type. */ - public Builder algorithmParameterRef(String algorithmParameterRef) { - this.algorithmParameterRef = algorithmParameterRef; + public Builder algorithmParameterSpec(String algorithmParameterSpec) { + this.algorithmParameterSpec = algorithmParameterSpec; return this; } diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/CBORDataFormatReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/CBORDataFormatReifier.java index 095b938f98f..30a22efa95a 100644 --- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/CBORDataFormatReifier.java +++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/CBORDataFormatReifier.java @@ -31,7 +31,7 @@ public class CBORDataFormatReifier extends DataFormatReifier<CBORDataFormat> { @Override protected void prepareDataFormatConfig(Map<String, Object> properties) { // must be a reference value - properties.put("xmlMapper", asRef(definition.getObjectMapper())); + properties.put("objectMapper", asRef(definition.getObjectMapper())); properties.put("unmarshalType", or(definition.getUnmarshalType(), definition.getUnmarshalTypeName())); properties.put("collectionType", or(definition.getCollectionType(), definition.getCollectionTypeName())); properties.put("useList", definition.getUseList()); diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/CryptoDataFormatReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/CryptoDataFormatReifier.java index 4e98a50197c..da8eea300e0 100644 --- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/CryptoDataFormatReifier.java +++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/CryptoDataFormatReifier.java @@ -30,11 +30,11 @@ public class CryptoDataFormatReifier extends DataFormatReifier<CryptoDataFormat> @Override protected void prepareDataFormatConfig(Map<String, Object> properties) { - properties.put("key", asRef(definition.getKeyRef())); - properties.put("algorithmParameterSpec", asRef(definition.getAlgorithmParameterRef())); - properties.put("initializationVector", asRef(definition.getInitVectorRef())); + properties.put("key", asRef(definition.getKey())); + properties.put("algorithmParameterSpec", asRef(definition.getAlgorithmParameterSpec())); + properties.put("initVector", asRef(definition.getInitVector())); properties.put("shouldAppendHMAC", definition.getShouldAppendHMAC()); - properties.put("shouldInlineInitializationVector", definition.getInline()); + properties.put("inline", definition.getInline()); properties.put("algorithm", definition.getAlgorithm()); properties.put("cryptoProvider", definition.getCryptoProvider()); properties.put("macAlgorithm", definition.getMacAlgorithm()); diff --git a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java index 5130f3f431a..34e236a746c 100644 --- a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java +++ b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java @@ -1801,12 +1801,12 @@ public class ModelParser extends BaseParser { protected CryptoDataFormat doParseCryptoDataFormat() throws IOException, XmlPullParserException { return doParse(new CryptoDataFormat(), (def, key, val) -> switch (key) { case "algorithm": def.setAlgorithm(val); yield true; - case "algorithmParameterRef": def.setAlgorithmParameterRef(val); yield true; + case "algorithmParameterSpec": def.setAlgorithmParameterSpec(val); yield true; case "bufferSize": def.setBufferSize(val); yield true; case "cryptoProvider": def.setCryptoProvider(val); yield true; - case "initVectorRef": def.setInitVectorRef(val); yield true; + case "initVector": def.setInitVector(val); yield true; case "inline": def.setInline(val); yield true; - case "keyRef": def.setKeyRef(val); yield true; + case "key": def.setKey(val); yield true; case "macAlgorithm": def.setMacAlgorithm(val); yield true; case "shouldAppendHMAC": def.setShouldAppendHMAC(val); yield true; default: yield identifiedTypeAttributeHandler().accept(def, key, val); diff --git a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java index 3756c8fb2de..e382c074e94 100644 --- a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java +++ b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java @@ -2477,10 +2477,10 @@ public class ModelWriter extends BaseWriter { doWriteAttribute("shouldAppendHMAC", def.getShouldAppendHMAC(), "true"); doWriteAttribute("inline", def.getInline(), "false"); doWriteAttribute("macAlgorithm", def.getMacAlgorithm(), "HmacSHA1"); - doWriteAttribute("algorithmParameterRef", def.getAlgorithmParameterRef(), null); - doWriteAttribute("initVectorRef", def.getInitVectorRef(), null); + doWriteAttribute("initVector", def.getInitVector(), null); doWriteAttribute("cryptoProvider", def.getCryptoProvider(), null); - doWriteAttribute("keyRef", def.getKeyRef(), null); + doWriteAttribute("algorithmParameterSpec", def.getAlgorithmParameterSpec(), null); + doWriteAttribute("key", def.getKey(), null); doWriteAttribute("bufferSize", def.getBufferSize(), "4096"); doWriteAttribute("algorithm", def.getAlgorithm(), null); endElement(name); diff --git a/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/ModelWriter.java b/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/ModelWriter.java index f3c38429c25..ca55f674c34 100644 --- a/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/ModelWriter.java +++ b/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/ModelWriter.java @@ -2477,10 +2477,10 @@ public class ModelWriter extends BaseWriter { doWriteAttribute("shouldAppendHMAC", def.getShouldAppendHMAC(), "true"); doWriteAttribute("inline", def.getInline(), "false"); doWriteAttribute("macAlgorithm", def.getMacAlgorithm(), "HmacSHA1"); - doWriteAttribute("algorithmParameterRef", def.getAlgorithmParameterRef(), null); - doWriteAttribute("initVectorRef", def.getInitVectorRef(), null); + doWriteAttribute("initVector", def.getInitVector(), null); doWriteAttribute("cryptoProvider", def.getCryptoProvider(), null); - doWriteAttribute("keyRef", def.getKeyRef(), null); + doWriteAttribute("algorithmParameterSpec", def.getAlgorithmParameterSpec(), null); + doWriteAttribute("key", def.getKey(), null); doWriteAttribute("bufferSize", def.getBufferSize(), "4096"); doWriteAttribute("algorithm", def.getAlgorithm(), null); endElement(name);
