XML Security
Encrypt and decrypt XML payloads using Apache Santuario
What’s inside
-
XML Security Sign component, URI syntax:
xmlsecurity-sign:name -
XML Security Verify component, URI syntax:
xmlsecurity-verify:name
Please refer to the above links for usage and configuration details.
Maven coordinates
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-xmlsecurity-starter</artifactId>
</dependency> Spring Boot Auto-Configuration
The starter supports 63 options, which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
camel.component.xmlsecurity-sign.add-key-info-reference | Whether to add a reference to the KeyInfo element to the SignedInfo element, so that the signature value also protects the KeyInfo element against changes. Only used when keyAccessor returns a KeyInfo with an Id; DefaultKeyAccessor does so when the keystore has a certificate chain for the alias. | true | Boolean |
camel.component.xmlsecurity-sign.autowired-enabled | Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | Boolean |
camel.component.xmlsecurity-sign.base-uri | The base URI that relative URIs of the references are resolved against, set on the XMLSignContext of the signer and the XMLValidateContext of the verifier (XMLCryptoContext.setBaseURI). | String | |
camel.component.xmlsecurity-sign.canonicalization-method | The canonicalization method of the SignedInfo element, which is canonicalized before the signature value is calculated. Create it with XmlSignatureHelper.getCanonicalizationMethod(algorithm) or getCanonicalizationMethod(algorithm, inclusiveNamespacePrefixes). The default is Canonical XML 1.0 (http://www.w3.org/TR/2001/REC-xml-c14n-20010315). The option is a javax.xml.crypto.AlgorithmMethod type. | AlgorithmMethod | |
camel.component.xmlsecurity-sign.clear-headers | Whether to remove the CamelXmlSignature headers of this component from the message after signing or verifying. The CamelCharsetName header is kept. | true | Boolean |
camel.component.xmlsecurity-sign.content-object-id | The Id attribute of the Object element that holds the signed content of an enveloping signature, which the reference to the content points to. If not set, an Id made of an underscore and a random UUID is generated once and then used for all messages of the endpoint. Only used for an enveloping signature. | String | |
camel.component.xmlsecurity-sign.content-reference-type | The Type attribute of the reference to the signed content, for example http://www.w3.org/2000/09/xmldsig#Object. If not set, the reference has no Type attribute. The CamelXmlSignatureContentReferenceType header replaces this option. | String | |
camel.component.xmlsecurity-sign.content-reference-uri | The URI of the reference to the signed content of an enveloped signature. If not set, the URI is empty, which signs the whole document. A URI that points to an ID, such as #id, also requires schemaResourceUri, which declares the ID attributes. The CamelXmlSignatureContentReferenceUri header replaces this option. Not used for an enveloping or detached signature. | String | |
camel.component.xmlsecurity-sign.crypto-context-properties | Properties that are set on the XMLSignContext of the signer and the XMLValidateContext of the verifier, see XMLCryptoContext.setProperty and the properties that the XML signature provider supports. The verifier sets javax.xml.crypto.dsig.cacheReference and org.jcp.xml.dsig.validateManifests to true itself; these properties are set after that, so a value given here replaces the value that the verifier sets for the same property. | Object> | |
camel.component.xmlsecurity-sign.digest-algorithm | The URI of the digest algorithm of the references, for example http://www.w3.org/2001/04/xmlenc#sha512. If not set, the signer takes the digest algorithm that the URI of signatureAlgorithm names (SHA-1, SHA-224, SHA-256, SHA-384, SHA-512 or RIPEMD-160), and fails if it names none. | String | |
camel.component.xmlsecurity-sign.disallow-doctype-decl | Whether the parser rejects a message body that contains a DOCTYPE declaration. If false, a DOCTYPE declaration is allowed; external entities stay disabled either way. | true | Boolean |
camel.component.xmlsecurity-sign.enabled | Whether to enable auto configuration of the xmlsecurity-sign component. This is enabled by default. | Boolean | |
camel.component.xmlsecurity-sign.key-accessor | Provides the key that the signer signs with and the optional KeyInfo element that is added to the signature. Required: the signer fails without it. DefaultKeyAccessor of the package org.apache.camel.component.xmlsecurity.api reads the private key and the certificate chain of an alias from a java.security.KeyStore. The option is a org.apache.camel.component.xmlsecurity.api.KeyAccessor type. | KeyAccessor | |
camel.component.xmlsecurity-sign.lazy-start-producer | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | Boolean |
camel.component.xmlsecurity-sign.omit-xml-declaration | Whether to leave out the XML declaration of the output body. Has no effect when the output of the verifier is text. The CamelXmlSignatureOmitXmlDeclaration header replaces this option. | false | Boolean |
camel.component.xmlsecurity-sign.output-xml-encoding | The character encoding of the output body. If not set, UTF-8 is used. If set, the CamelCharsetName header is also set to it; for the verifier, the default xmlSignature2Message does this. | String | |
camel.component.xmlsecurity-sign.parent-local-name | The local name of the element to which an enveloped signature is added as the last child; setting it makes the signature enveloped. The first element of the document with this local name and the namespace of parentNamespace is used. Cannot be combined with parentXpath or xpathsToIdAttributes: the signer then fails. | String | |
camel.component.xmlsecurity-sign.parent-namespace | The namespace of the parentLocalName element. If not set, that element must have no namespace. | String | |
camel.component.xmlsecurity-sign.parent-xpath | An XPath, as a javax.xml.crypto.dsig.spec.XPathFilterParameterSpec created with XmlSignatureHelper.getXpathFilter, that selects the element to which an enveloped signature is added as the last child; the first element of the result is used. Setting it makes the signature enveloped. Cannot be combined with parentLocalName or xpathsToIdAttributes: the signer then fails. The option is a javax.xml.crypto.dsig.spec.XPathFilterParameterSpec type. | XPathFilterParameterSpec | |
camel.component.xmlsecurity-sign.plain-text | Whether the message body is plain text instead of an XML document. The signer then puts the text, decoded with plainTextEncoding, into the Object element of an enveloping signature; plain text cannot get an enveloped or detached signature. The CamelXmlSignatureMessageIsPlainText header replaces this option. | false | Boolean |
camel.component.xmlsecurity-sign.plain-text-encoding | The character encoding that the signer decodes a plain text message body with, see plainText. The CamelXmlSignaturePlainTextEncoding header replaces this option. | UTF-8 | String |
camel.component.xmlsecurity-sign.prefix-for-xml-signature-namespace | The namespace prefix of the elements of the XML signature namespace http://www.w3.org/2000/09/xmldsig#. If empty, the signature elements have no prefix. | ds | String |
camel.component.xmlsecurity-sign.properties | A bean that implements org.apache.camel.component.xmlsecurity.api.XmlSignatureProperties, which adds further references and Object elements to each signature and can set the Id of the Signature element. For XAdES-BES and XAdES-EPES signatures, use XAdESSignatureProperties or DefaultXAdESSignatureProperties. The option is a org.apache.camel.component.xmlsecurity.api.XmlSignatureProperties type. | XmlSignatureProperties | |
camel.component.xmlsecurity-sign.schema-resource-uri | The XML schema that the message body is validated against while it is parsed, loaded as a resource from the classpath by default. The schema also declares which attributes are of type ID, so it is required for a detached signature and when a reference URI points to an ID. The CamelXmlSignatureSchemaResourceUri header replaces this option. | String | |
camel.component.xmlsecurity-sign.signature-algorithm | The URI of the signature algorithm, which must fit the key of keyAccessor, for example http://www.w3.org/2001/04/xmldsig-more#rsa-sha512 or http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256. The default is RSA with SHA-256. | String | |
camel.component.xmlsecurity-sign.signature-id | The Id attribute of the Signature element. If not set, a new Id made of an underscore and a random UUID is generated for each signature; if empty, the Signature element has no Id attribute. The XmlSignatureProperties of the properties option can replace it, and XAdESSignatureProperties generates one when it is empty. | String | |
camel.component.xmlsecurity-sign.signer-configuration | A shared XmlSignerConfiguration that the endpoints of the component start from: the component copies it for each new endpoint and then sets the options of the endpoint URI on the copy. The option is a org.apache.camel.component.xmlsecurity.processor.XmlSignerConfiguration type. | XmlSignerConfiguration | |
camel.component.xmlsecurity-sign.transform-methods | The transforms of the reference to the signed content, which are applied to the content before its digest is calculated. Create them with the methods of XmlSignatureHelper. The default is Canonical XML 1.0 (http://www.w3.org/TR/2001/REC-xml-c14n-20010315), and for an enveloped signature the signer puts the enveloped-signature transform first when the list does not contain it. The CamelXmlSignatureTransformMethods header replaces this option. | AlgorithmMethod> | |
camel.component.xmlsecurity-sign.uri-dereferencer | To use a custom javax.xml.crypto.URIDereferencer that resolves the URIs of the references, for example to control which resources can be read. If not set, the dereferencer of the XML signature provider is used; the Apache Santuario provider, which the component uses, resolves only same-document URIs (fragments and XPointer) by default. The option is a javax.xml.crypto.URIDereferencer type. | URIDereferencer | |
camel.component.xmlsecurity-sign.xpaths-to-id-attributes | XPaths, as javax.xml.crypto.dsig.spec.XPathFilterParameterSpec created with XmlSignatureHelper.getXpathFilter, that select ID attributes; setting them makes the signatures detached. For each element with a selected ID attribute, the signer creates a signature whose reference URI is # followed by the attribute value, adds it as the last child of the parent of that element, and signs deeper elements first. Requires schemaResourceUri and cannot be combined with parentLocalName or parentXpath. The CamelXmlSignatureXpathsToIdAttributes header replaces this option. | XPathFilterParameterSpec> | |
camel.component.xmlsecurity-verify.autowired-enabled | Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | Boolean |
camel.component.xmlsecurity-verify.base-uri | The base URI that relative URIs of the references are resolved against, set on the XMLSignContext of the signer and the XMLValidateContext of the verifier (XMLCryptoContext.setBaseURI). | String | |
camel.component.xmlsecurity-verify.clear-headers | Whether to remove the CamelXmlSignature headers of this component from the message after signing or verifying. The CamelCharsetName header is kept. | true | Boolean |
camel.component.xmlsecurity-verify.crypto-context-properties | Properties that are set on the XMLSignContext of the signer and the XMLValidateContext of the verifier, see XMLCryptoContext.setProperty and the properties that the XML signature provider supports. The verifier sets javax.xml.crypto.dsig.cacheReference and org.jcp.xml.dsig.validateManifests to true itself; these properties are set after that, so a value given here replaces the value that the verifier sets for the same property. | Object> | |
camel.component.xmlsecurity-verify.disallow-doctype-decl | Whether the parser rejects a message body that contains a DOCTYPE declaration. If false, a DOCTYPE declaration is allowed; external entities stay disabled either way. | true | Boolean |
camel.component.xmlsecurity-verify.enabled | Whether to enable auto configuration of the xmlsecurity-verify component. This is enabled by default. | Boolean | |
camel.component.xmlsecurity-verify.key-selector | The javax.xml.crypto.KeySelector that provides the key to validate each Signature element with. Required: the verifier fails without it. DefaultKeySelector of the package org.apache.camel.component.xmlsecurity.api returns the public key of the certificate of an alias in a java.security.KeyStore, regardless of the KeyInfo of the signature. The option is a javax.xml.crypto.KeySelector type. | KeySelector | |
camel.component.xmlsecurity-verify.lazy-start-producer | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | Boolean |
camel.component.xmlsecurity-verify.omit-xml-declaration | Whether to leave out the XML declaration of the output body. Has no effect when the output of the verifier is text. The CamelXmlSignatureOmitXmlDeclaration header replaces this option. | false | Boolean |
camel.component.xmlsecurity-verify.output-node-search-type | How the default xmlSignature2Message finds the node that becomes the output body: Default, ElementName (the element that outputNodeSearch names) or XPath (the element, text or document node that the XPath of outputNodeSearch selects). Default returns the content of the single referenced Object element of an enveloping signature, and the whole document without its Signature elements for an enveloped or detached signature. | Default | String |
camel.component.xmlsecurity-verify.output-xml-encoding | The character encoding of the output body. If not set, UTF-8 is used. If set, the CamelCharsetName header is also set to it; for the verifier, the default xmlSignature2Message does this. | String | |
camel.component.xmlsecurity-verify.remove-signature-elements | Whether the default xmlSignature2Message removes all Signature elements of the namespace http://www.w3.org/2000/09/xmldsig# from the document before the output node is serialized. For the ElementName and XPath searches of an enveloped signature; the Default search always removes them for an enveloped or detached signature. | false | Boolean |
camel.component.xmlsecurity-verify.schema-resource-uri | The XML schema that the message body is validated against while it is parsed, loaded as a resource from the classpath by default. The schema also declares which attributes are of type ID, so it is required for a detached signature and when a reference URI points to an ID. The CamelXmlSignatureSchemaResourceUri header replaces this option. | String | |
camel.component.xmlsecurity-verify.secure-validation | Whether the verifier sets the properties org.apache.jcp.xml.dsig.secureValidation and org.jcp.xml.dsig.secureValidation to true, which makes the XML signature provider reject, for example, MD5 algorithms, more than 30 references and more than 5 transforms per reference. If false, the verifier does not set them and the default of the provider applies, which for the Apache Santuario provider is also secure validation. | true | Boolean |
camel.component.xmlsecurity-verify.uri-dereferencer | To use a custom javax.xml.crypto.URIDereferencer that resolves the URIs of the references, for example to control which resources can be read. If not set, the dereferencer of the XML signature provider is used; the Apache Santuario provider, which the component uses, resolves only same-document URIs (fragments and XPointer) by default. The option is a javax.xml.crypto.URIDereferencer type. | URIDereferencer | |
camel.component.xmlsecurity-verify.validation-failed-handler | Called when the core validation of a signature fails or throws an XMLSignatureException. The default DefaultValidationFailedHandler throws an XmlSignatureInvalidValueException when the signature value is invalid, an XmlSignatureInvalidContentHashException when the digest of a reference or of a manifest reference does not match, and an XmlSignatureInvalidKeyException or XmlSignatureException for an XMLSignatureException. If a custom handler returns true from ignoreCoreValidationFailure, the verifier treats the signature as valid. The option is a org.apache.camel.component.xmlsecurity.api.ValidationFailedHandler type. | ValidationFailedHandler | |
camel.component.xmlsecurity-verify.verifier-configuration | A shared XmlVerifierConfiguration that the endpoints of the component start from: the component copies it for each new endpoint and then sets the options of the endpoint URI on the copy. The option is a org.apache.camel.component.xmlsecurity.processor.XmlVerifierConfiguration type. | XmlVerifierConfiguration | |
camel.component.xmlsecurity-verify.xml-signature-checker | A bean that implements org.apache.camel.component.xmlsecurity.api.XmlSignatureChecker, which the verifier calls for each Signature element before its core validation, to check that the signature covers the content that the route expects (see http://www.w3.org/TR/xmldsig-bestpractices/#check-what-is-signed). An exception that it throws fails the exchange. If not set, no such check is done. The option is a org.apache.camel.component.xmlsecurity.api.XmlSignatureChecker type. | XmlSignatureChecker | |
camel.component.xmlsecurity-verify.xml-signature2-message | Maps the verified document to the body of the output message. The default DefaultXmlSignature2Message selects the output node with outputNodeSearchType, outputNodeSearch and removeSignatureElements. Its Default search returns the content of the single referenced Object element of an enveloping signature, and the whole document without its Signature elements for an enveloped or detached signature, which can contain content that no reference covers unless its enforceReferenceCoverage is set. The option is a org.apache.camel.component.xmlsecurity.api.XmlSignature2Message type. | XmlSignature2Message | |
camel.dataformat.xml-security.add-key-value-for-encrypted-key | Whether to add the public key used to encrypt the session key as a KeyValue in the EncryptedKey structure or not. | true | Boolean |
camel.dataformat.xml-security.digest-algorithm | The digest algorithm to use with the RSA OAEP algorithm. | SHA1 | String |
camel.dataformat.xml-security.enabled | Whether to enable auto configuration of the xmlSecurity data format. This is enabled by default. | Boolean | |
camel.dataformat.xml-security.key-cipher-algorithm | The cipher algorithm to be used for encryption/decryption of the asymmetric key. When not set, marshal uses RSA_OAEP when the recipientKeyAlias is set, and unmarshal decrypts with the symmetric key of the passPhrase. | String | |
camel.dataformat.xml-security.key-or-trust-store-parameters | Refers to a KeyStore instance to lookup in the registry, which is used for configuration options for creating and loading a KeyStore instance that represents the sender’s trustStore or recipient’s keyStore. The option is a org.apache.camel.support.jsse.KeyStoreParameters type. | String | |
camel.dataformat.xml-security.key-password | The password to be used for retrieving the private key from the KeyStore. This key is used for asymmetric decryption. | String | |
camel.dataformat.xml-security.mgf-algorithm | The MGF Algorithm to use with the RSA OAEP algorithm. | MGF1_SHA1 | String |
camel.dataformat.xml-security.namespace | Refers to a Map of XML Namespaces of prefix to uri mappings. | Map | |
camel.dataformat.xml-security.pass-phrase | A String used as passPhrase to encrypt/decrypt content. | String | |
camel.dataformat.xml-security.pass-phrase-byte | A byte[] used as passPhrase to encrypt/decrypt content. | Byte[] | |
camel.dataformat.xml-security.recipient-key-alias | 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. | String | |
camel.dataformat.xml-security.secure-tag | The XPath reference to the XML Element selected for encryption/decryption. If no tag is specified, the entire payload is encrypted/decrypted. | String | |
camel.dataformat.xml-security.secure-tag-contents | 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. | true | Boolean |
camel.dataformat.xml-security.xml-cipher-algorithm | The cipher algorithm to be used for encryption/decryption of the XML message content. | AES_256_GCM | String |