XMLSecurity Data Format
The XMLSecurity Data Format facilitates encryption and decryption of XML payloads at the Document, Element, and Element Content levels (including simultaneous multi-node encryption/decryption using XPath). To sign messages using the XML Signature specification, please see the Camel XML Security component.
The encryption capability is based on formats supported using the Apache XML Security (Santuario) project. Symmetric encryption/decryption is currently supported using Triple-DES and AES (128, 192, and 256) encryption formats. Additional formats can be easily added later as needed. This capability allows Camel users to encrypt/decrypt payloads while being dispatched or received along a route.
Available as of Camel 2.9
The XMLSecurity Data Format supports asymmetric key encryption. In this encryption model a symmetric key is generated and used to perform XML content encryption or decryption. This "content encryption key" is then itself encrypted using an asymmetric encryption algorithm that leverages the recipient's public key as the "key encryption key". Use of an asymmetric key encryption algorithm ensures that only the holder of the recipient's private key can access the generated symmetric encryption key. Thus, only the private key holder can decode the message. The XMLSecurity Data Format handles all of the logic required to encrypt and decrypt the message content and encryption key(s) using asymmetric key encryption.
The XMLSecurity Data Format also has improved support for namespaces when processing the XPath queries that select content for encryption. A namespace definition mapping can be included as part of the data format configuration. This enables true namespace matching, even if the prefix values in the XPath query and the target xml document are not equivalent strings.
The XPath reference to the XML Element selected for encryption/decryption. If no tag is specified, the entire payload is encrypted/decrypted.
A boolean value to specify whether the XML Element is to be encrypted or the contents of the XML Element
false = Element Level
true = Element Content Level
A String used as passPhrase to encrypt/decrypt content. The passPhrase has to be provided. If no passPhrase is specified, a default passPhrase is used. The passPhrase needs to be put together in conjunction with the appropriate encryption algorithm. For example using
TRIPLEDES the passPhase can be a
"Only another 24 Byte key"
The cipher algorithm to be used for encryption/decryption of the XML message content. The available choices are:
XMLCipher.AES_128_GCM Camel 2.12
XMLCipher.AES_192_GCM Camel 2.12
XMLCipher.AES_256_GCM Camel 2.12
A map of namespace values indexed by prefix. The index values must match the prefixes used in the
secureTag XPath query.
Asymmetric Encryption Options
These options can be applied in addition to relevant the Basic options to use asymmetric key encryption.
The key alias to be used when retrieving the recipient's public or private key from a KeyStore when performing asymmetric key encryption or decryption.
The cipher algorithm to be used for encryption/decryption of the asymmetric key. The available choices are:
Configuration options for creating and loading a KeyStore instance that represents the sender's trustStore or recipient's keyStore.
Camel 2.10.2 / 2.11: The password to be used for retrieving the private key from the KeyStore. This key is used for asymmetric decryption.
Camel 2.12 The digest algorithm to use with the RSA OAEP algorithm. The available choices are:
Camel 2.12 The MGF Algorithm to use with the RSA OAEP algorithm. The available choices are:
Key Cipher Algorithm
As of Camel 2.12.0, the default Key Cipher Algorithm is now XMLCipher.RSA_OAEP instead of XMLCipher.RSA_v1dot5. Usage of XMLCipher.RSA_v1dot5 is discouraged due to various attacks. Requests that use RSA v1.5 as the key cipher algorithm will be rejected unless it has been explicitly configured as the key cipher algorithm.
In order to encrypt the payload, the
marshal processor needs to be applied on the route followed by the
In order to decrypt the payload, the
unmarshal processor needs to be applied on the route followed by the
Given below are several examples of how marshalling could be performed at the Document, Element, and Content levels.
Full Payload encryption/decryption
Partial Payload Content Only encryption/decryption
Partial Multi Node Payload Content Only encryption/decryption
Partial Payload Content Only encryption/decryption with choice of passPhrase(password)
Partial Payload Content Only encryption/decryption with passPhrase(password) and Algorithm
Partial Payload Content with Namespace support
A namespace prefix that is defined as part of the
camelContext definition can be re-used in context within the data format
secureTag attribute of the
Asymmetric Key Encryption
Spring XML Sender
Spring XML Recipient
This data format is provided within the camel-xmlsecurity component.