Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Maven users will need to add the following dependency to their pom.xml for this component:

Code Block
xml
xml

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-crypto</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>

...

As mentioned Camel provides a pair of crypto endpoints to create and verify signatures

Code Block

crypto:sign:name[?options]
crypto:verify:name[?options]

...

Div
classconfluenceTableSmall

Name

Type

Default

Description

algorithm

String

SHA1WithDSA

The name of the JCE Signature algorithm that will be used.

alias

String

null

An alias name that will be used to select a key from the keystore.

bufferSize

Integer

2048

the size of the buffer used in the signature process.

certificate

Certificate

null

A Certificate used to verify the signature of the exchange's payload. Either this or a Public Key is required.

keystore

KeyStore

null

A reference to a JCE Keystore that stores keys and certificates used to sign and verify.

keyStoreParameters Camel 2.14.1KeyStoreParametersnullA reference to a Camel KeyStoreParameters Object which wraps a Java KeyStore Object

provider

String

null

The name of the JCE Security Provider that should be used.

privateKey

PrivateKey

null

The private key used to sign the exchange's payload.

publicKey

PublicKey

null

The public key used to verify the signature of the exchange's payload.

secureRandom

secureRandom

null

A reference to a SecureRandom object that will be used to initialize the Signature service.

password

char[]

null

The password for to access the private key from the keystore.

clearHeaders

String

true

Remove camel crypto headers from Message after a verify operation (value can be "true"/"false").

...

Wiki Markup
{snippet:id=keystore|lang=xml|url=camel/trunk/components/camel-crypto/src/test/resources/org/apache/camel/component/crypto/SpringSignatureTests.xml}

Camel 2.14.1

It is also possible to use a Camel KeyStoreParameters Object instead of specifying a Keystore directly. Here is an example in Spring:

{snippet:id=keystoreParameters|lang=xml|url=camel/trunk/components/camel-crypto/src/test/resources/org/apache/camel/component/crypto/SpringSignatureTests.xml}

3) Changing JCE Provider and Algorithm

...

The header would be set as follows

Code Block

Exchange unsigned = getMandatoryEndpoint("direct:alias-sign").createExchange();
unsigned.getIn().setBody(payload);
unsigned.getIn().setHeader(DigitalSignatureConstants.KEYSTORE_ALIAS, "bob");
unsigned.getIn().setHeader(DigitalSignatureConstants.KEYSTORE_PASSWORD, "letmein".toCharArray());
template.send("direct:alias-sign", unsigned);
Exchange signed = getMandatoryEndpoint("direct:alias-sign").createExchange();
signed.getIn().copyFrom(unsigned.getOut());
signed.getIn().setHeader(KEYSTORE_ALIAS, "bob");
template.send("direct:alias-verify", signed);

Include Page
Endpoint See Also
Endpoint See Also