Class XmlSignerProcessor
- All Implemented Interfaces:
org.apache.camel.Processor
In the enveloped XML signature case, the method XmlSignerConfiguration.getParentLocalName() must not return
null. In this case the parent element must be contained in the XML document provided by the message body
and the signature element is added as last child element of the parent element. If a KeyInfo instance is provided by
the KeyAccessor and XmlSignerConfiguration.getAddKeyInfoReference() is true, then also a
reference to the KeyInfo element is added. The generated XML signature has the following structure:
<[parent element]>
...
<Signature Id="[signature_id]">
<SignedInfo>
<Reference URI="">
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
(<Transform>)*
<DigestMethod>
<DigestValue>
</Reference>
(<Reference URI="#[keyinfo_Id]">
<Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<DigestMethod>
<DigestValue>
</Reference>)?
<!-- further references possible, see XmlSignerConfiguration#setProperties(XmlSignatureProperties) -->
</SignedInfo>
<SignatureValue>
(<KeyInfo Id="[keyinfo_id]">)?
<!-- Object elements possible, see XmlSignerConfiguration#setProperties(XmlSignatureProperties) -->
</Signature>
</[parent element]>
In the enveloping XML signature case, the generated XML signature has the following structure:
<Signature Id="[signature_id]">
<SignedInfo>
<Reference URI="#[object_id]" type="[optional_type_value]">
(<Transform>)*
<DigestMethod>
<DigestValue>
</Reference>
(<Reference URI="#[keyinfo_id]">
<Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<DigestMethod>
<DigestValue>
</Reference>)?
<!-- further references possible, see XmlSignerConfiguration#setProperties(XmlSignatureProperties) -->
</SignedInfo>
<SignatureValue>
(<KeyInfo Id="[keyinfo_id]">)?
<Object Id="[object_id]"/>
<!-- further Object elements possible, see XmlSignerConfiguration#setProperties(XmlSignatureProperties) -->
</Signature>
In the enveloping XML signature case, also message bodies containing plain text are supported. This must be indicated
via the header XmlSignatureConstants.HEADER_MESSAGE_IS_PLAIN_TEXT or via the configuration
XmlSignerConfiguration.getPlainText().
Detached signatures where the signature element is a sibling element to the signed element are supported. Those
elements can be signed which have ID attributes. The elements to be signed must be specified via xpath expressions
(see XmlSignerConfiguration.setXpathsToIdAttributes(List)) and the XML schema must be provided via the schema
resource URI (see method XmlSignatureConfiguration.setSchemaResourceUri(String). Elements with deeper hierarchy
level are signed first. This procedure can result in nested signatures.
In all cases, the digest algorithm is either read from the configuration method
XmlSignerConfiguration.getDigestAlgorithm() or calculated from the signature algorithm (
XmlSignerConfiguration.getSignatureAlgorithm(). The optional transforms are read from
XmlSignerConfiguration.getTransformMethods() .
In all cases, you can add additional references and objects which contain properties for the XML signature, see
XmlSignerConfiguration.setProperties(XmlSignatureProperties).
-
Field Summary
Fields inherited from class org.apache.camel.component.xmlsecurity.processor.XmlSignatureProcessor
context -
Constructor Summary
ConstructorsConstructorDescriptionXmlSignerProcessor(org.apache.camel.CamelContext context, XmlSignerConfiguration config) -
Method Summary
Modifier and TypeMethodDescriptionprotected ReferencecreateKeyInfoReference(XMLSignatureFactory fac, String keyInfoId, String digestAlgorithm) protected ReferencecreateReference(XMLSignatureFactory fac, String uri, String type, SignatureType sigType, String id, org.apache.camel.Message message) protected SignedInfocreateSignedInfo(XMLSignatureFactory fac, List<? extends Reference> refs) protected XMLObjectcreateXMLObject(XMLSignatureFactory fac, Node node, String id) protected StringgetContentReferenceType(org.apache.camel.Message message) getContentReferenceUris(org.apache.camel.Message message, SignatureType signatureType, Node messageBodyNode) protected Stringprotected NodegetMessageBodyNode(org.apache.camel.Message message) protected StringgetMessageEncoding(org.apache.camel.Message inMessage) getObjects(XmlSignatureProperties.Input input, XmlSignatureProperties.Output properties) protected ElementgetParentForEnvelopedCase(Document doc, org.apache.camel.Message inMessage) protected ElementgetParentOfSignature(org.apache.camel.Message inMessage, Node messageBodyNode, String contentReferenceURI, SignatureType sigType) getReferences(XmlSignatureProperties.Input input, XmlSignatureProperties.Output properties, String keyInfoId) protected SchemagetSchemaForSigner(org.apache.camel.Message message, org.apache.camel.support.processor.validation.ValidatorErrorHandler errorHandler) protected XmlSignatureProperties.Outputprotected List<XPathFilterParameterSpec> getXpathToIdAttributes(org.apache.camel.Message message) protected BooleanisPlainText(org.apache.camel.Message message) protected BooleanomitXmlDeclaration(org.apache.camel.Message message) protected DocumentparseInput(InputStream is, Boolean disallowDoctypeDecl, Schema schema, ErrorHandler errorHandler) voidprocess(org.apache.camel.Exchange exchange) protected voidsetOutputEncodingToMessageHeader(org.apache.camel.Message message) protected Documentsign(org.apache.camel.Message out) Methods inherited from class org.apache.camel.component.xmlsecurity.processor.XmlSignatureProcessor
clearMessageHeaders, getCamelContext, getSchema, getSchemaResourceUri, setCryptoContextProperties
-
Constructor Details
-
XmlSignerProcessor
-
-
Method Details
-
getConfiguration
- Specified by:
getConfigurationin classXmlSignatureProcessor
-
process
- Throws:
Exception
-
sign
- Throws:
Exception
-
getXpathToIdAttributes
-
getSignatureProperties
protected XmlSignatureProperties.Output getSignatureProperties(XmlSignatureProperties.Input input) throws Exception - Throws:
Exception
-
omitXmlDeclaration
-
createSignedInfo
protected SignedInfo createSignedInfo(XMLSignatureFactory fac, List<? extends Reference> refs) throws Exception - Throws:
Exception
-
getMessageBodyNode
- Throws:
Exception
-
getSchemaForSigner
protected Schema getSchemaForSigner(org.apache.camel.Message message, org.apache.camel.support.processor.validation.ValidatorErrorHandler errorHandler) throws XmlSignatureException, SAXException, IOException -
isPlainText
-
getParentOfSignature
protected Element getParentOfSignature(org.apache.camel.Message inMessage, Node messageBodyNode, String contentReferenceURI, SignatureType sigType) throws Exception - Throws:
Exception
-
getParentForEnvelopedCase
protected Element getParentForEnvelopedCase(Document doc, org.apache.camel.Message inMessage) throws Exception - Throws:
Exception
-
getReferences
protected List<? extends Reference> getReferences(XmlSignatureProperties.Input input, XmlSignatureProperties.Output properties, String keyInfoId) throws Exception - Throws:
Exception
-
getObjects
protected List<? extends XMLObject> getObjects(XmlSignatureProperties.Input input, XmlSignatureProperties.Output properties) -
getMessageEncoding
-
parseInput
protected Document parseInput(InputStream is, Boolean disallowDoctypeDecl, Schema schema, ErrorHandler errorHandler) throws ParserConfigurationException, IOException, XmlSignatureFormatException -
createReference
protected Reference createReference(XMLSignatureFactory fac, String uri, String type, SignatureType sigType, String id, org.apache.camel.Message message) throws InvalidAlgorithmParameterException, XmlSignatureException -
getContentReferenceType
-
getContentReferenceUris
protected List<String> getContentReferenceUris(org.apache.camel.Message message, SignatureType signatureType, Node messageBodyNode) throws XmlSignatureException, XPathExpressionException -
createXMLObject
-
getDigestAlgorithmUri
- Throws:
XmlSignatureException
-
createKeyInfoReference
protected Reference createKeyInfoReference(XMLSignatureFactory fac, String keyInfoId, String digestAlgorithm) throws Exception - Throws:
Exception
-
setOutputEncodingToMessageHeader
protected void setOutputEncodingToMessageHeader(org.apache.camel.Message message)
-