Claus Ibsen created CAMEL-27705:
-----------------------------------
Summary: camel-xmlsecurity: secureValidation=false no-op, null
consumer, header metadata, doc defaults
Key: CAMEL-27705
URL: https://issues.apache.org/jira/browse/CAMEL-27705
Project: Camel
Issue Type: Bug
Components: camel-xmlsecurity
Reporter: Claus Ibsen
Fix For: 4.24.0
Found while improving the option descriptions of camel-xmlsecurity for
CAMEL-23832 (commit
https://github.com/apache/camel/commit/8881eb854cf4aeb459054efd22266f22ded8de2a).
These are separate problems of the component; the descriptions commit only
documents the current behavior.
h4. 1. secureValidation=false has no effect
{{XmlVerifierProcessor.verify()}} sets
{{org.apache.jcp.xml.dsig.secureValidation}} and
{{org.jcp.xml.dsig.secureValidation}} to true only when the
{{secureValidation}} option is true, and sets nothing when it is false. The
Apache Santuario 4.0.4 provider that the component uses treats an unset
property as secure validation enabled
({{org.apache.jcp.xml.dsig.internal.dom.Utils.secureValidation()}} defaults to
true). So {{secureValidation=false}} changes nothing, while the option suggests
that it turns secure validation off.
Proposed change: either set both properties to the value of the option, or
deprecate the option.
h4. 2. XmlVerifierEndpoint.createConsumer() returns null
{{XmlVerifierEndpoint.createConsumer()}} returns {{null}}, while
{{XmlSignerEndpoint.createConsumer()}} throws
{{UnsupportedOperationException("XML Signature endpoints are not meant to be
consumed from.")}}. A route that starts from {{xmlsecurity-verify:...}}
therefore gets a null consumer instead of a clear error.
{{XmlVerifierEndpoint.doInit()}} also has an empty {{if}} block for an
outputNodeSearch value that starts with #.
Proposed change: throw the same {{UnsupportedOperationException}} as the signer
endpoint, and remove the empty block.
h4. 3. Header CamelXmlSignatureXpathsToIdAttributes has the wrong javaType and
scheme
The header is declared with {{@Metadata(javaType = "String")}} in
{{XmlSignatureConstants}}, but {{XmlSignerProcessor.getXpathToIdAttributes()}}
casts the header value to {{List<XPathFilterParameterSpec>}}, so a String value
fails with a {{ClassCastException}}. The header also has no {{applicableFor =
SCHEME_SIGN}}, so the catalog lists it for xmlsecurity-verify, which does not
read it.
Proposed change: {{javaType =
"java.util.List<javax.xml.crypto.dsig.spec.XPathFilterParameterSpec>"}} and
{{applicableFor = SCHEME_SIGN}}.
h4. 4. The XAdES headers are listed for xmlsecurity-verify
The six headers {{CamelXmlSignatureXAdESQualifyingPropertiesId}},
{{CamelXmlSignatureXAdESSignedDataObjectPropertiesId}},
{{CamelXmlSignatureXAdESSignedSignaturePropertiesId}},
{{CamelXmlSignatureXAdESDataObjectFormatEncoding}},
{{CamelXmlSignatureXAdESNamespace}} and {{CamelXmlSignatureXAdESPrefix}} have
no {{applicableFor}}, so the catalog lists them for both schemes. Only
{{XAdESSignatureProperties}}, which the signer calls through its {{properties}}
option, reads them.
Proposed change: add {{applicableFor = SCHEME_SIGN}} to these six headers.
h4. 5. The doc pages give wrong defaults
The body of {{xmlsecurity-sign-component.adoc}} and
{{xmlsecurity-verify-component.adoc}} says "In the example, the default
signature algorithm http://www.w3.org/2000/09/xmldsig#rsa-sha1 is used", and
the XML structure listings say that {{http://www.w3.org/2006/12/xml-c14n11}} is
added to the transforms by default. In {{XmlSignerConfiguration}} the default
signature algorithm is {{http://www.w3.org/2001/04/xmldsig-more#rsa-sha256}}
and the default transform is
{{http://www.w3.org/TR/2001/REC-xml-c14n-20010315}}.
Proposed change: correct both statements on both pages.
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)