Class DefaultXmlSignature2Message
java.lang.Object
org.apache.camel.component.xmlsecurity.api.DefaultXmlSignature2Message
- All Implemented Interfaces:
XmlSignature2Message
Maps the XML signature to a camel message. A output node is determined from the XML signature document via a node
search and then serialized and set to the output message body.
There are three output node search types supported: "Default", "ElementName", and "XPath". All these search types support enveloped XML signature or enveloping XML signature.
- The "ElementName" search uses the local name and namespace specified in the search value to determine the output element from the XML signature document. With the input parameter 'RemoveSignatureElements", you can specify whether the signature elements should be removed from the resulting output document. This flag shall be used for enveloped XML signatures.
- The "XPath" search uses an XPath expression to evaluate the output node. In this case the output node can be of type Element, TextNode, or Document. With the input parameter 'RemoveSignatureElements", you can specify whether the signature elements should be removed from the resulting output document. This flag shall be used for enveloped XML signatures.
- The "Default" search is explained in more detail below.
Default Output Node Search:
-
In the enveloped XML signature case, the XML document without the signature part is returned in the message body.
- Only same document references are taken into account (URI must start with '#').
- Also indirect same document references to an object via manifest are taken into account.
- The resulting number of object references must be 1.
- The referenced object must contain exactly 1
DOMStructure
. - The node of the DOMStructure is serialized to a byte array and added as body to the message.
In the enveloping XML signature case, the message body is determined from a referenced Object element in the following way:
<Signature>
<SignedInfo>
<Reference URI="#object"/>
<!-- further references possible but they must not point to an Object or Manifest containing an object reference -->
...
</SignedInfo>
<Object Id="object">
<!-- contains the DOM node which should be extracted to the message body -->
<Object>
<!-- further object elements possible which are not referenced-->
...
(<KeyInfo>)?
</Signature>
or the structure
<Signature>
<SignedInfo>
<Reference URI="#manifest"/>
<!-- further references are possible but they must not point to an Object or other manifest containing an object reference -->
...
</SignedInfo>
<Object >
<Manifest Id="manifest">
<Reference URI=#object/>
</Manifest>
</Objet>
<Object Id="object">
<!-- contains the DOM node which should be extracted to the message body -->
</Object>
<!-- further object elements possible which are not referenced -->
...
(<KeyInfo>)?
</Signature>
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.camel.component.xmlsecurity.api.XmlSignature2Message
XmlSignature2Message.Input
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addManifestReferencedObjects
(List<XMLObject> allObjects, List<XMLObject> referencedObjects, String manifestId) protected void
protected void
checkSearchValueOfType
(Class<?> cl, XmlSignature2Message.Input input) protected void
checkStringSarchValueNotEmpty
(String searchValue, String outputNodeSearchType) protected DOMStructure
getDomStructureForMessageBody
(List<Reference> relevantReferences, List<XMLObject> relevantObjects) Returns the DOM structure which is transformed to a byte array and set to the camel message body.protected Node
protected String
Returns the objects which must be taken into account for the mapping to the camel message.protected Node
protected Node
protected Manifest
getReferencedManifest
(List<XMLObject> objects, String id) protected XMLObject
getReferencedObject
(List<XMLObject> objects, String id) getReferencedSameDocumentObjects
(List<Reference> relevantReferences, List<XMLObject> relevantObjects) Returns the references whose referenced objects are taken into account for the message body.protected String
protected boolean
Checks whether the XML document has as root element the signature element.void
mapToMessage
(XmlSignature2Message.Input input, org.apache.camel.Message output) Maps the references and objects of an XML signature to the camel message.protected Boolean
omitXmlDeclaration
(org.apache.camel.Message message, XmlSignature2Message.Input input) protected void
removeSignatureElements
(Node node) Removes the Signature elements from the document.protected void
transformNodeToByteArrayAndSetToOutputMessage
(XmlSignature2Message.Input input, org.apache.camel.Message output, Node node)
-
Field Details
-
OUTPUT_NODE_SEARCH_TYPE_DEFAULT
Search type 'Default' for determining the output node.- See Also:
-
OUTPUT_NODE_SEARCH_TYPE_ELEMENT_NAME
Search type 'ElementName' for determining the output element.- See Also:
-
OUTPUT_NODE_SEARCH_TYPE_XPATH
Search type 'XPath' for determining the output node. Search value must be of typeXPathFilterParameterSpec
.- See Also:
-
-
Constructor Details
-
DefaultXmlSignature2Message
public DefaultXmlSignature2Message()
-
-
Method Details
-
mapToMessage
public void mapToMessage(XmlSignature2Message.Input input, org.apache.camel.Message output) throws Exception Description copied from interface:XmlSignature2Message
Maps the references and objects of an XML signature to the camel message.- Specified by:
mapToMessage
in interfaceXmlSignature2Message
- Parameters:
input
- inputoutput
- output message- Throws:
Exception
-
transformNodeToByteArrayAndSetToOutputMessage
protected void transformNodeToByteArrayAndSetToOutputMessage(XmlSignature2Message.Input input, org.apache.camel.Message output, Node node) throws Exception - Throws:
Exception
-
getOutputNodeViaXPath
- Throws:
Exception
-
getOutputElementViaLocalNameAndNamespace
protected Node getOutputElementViaLocalNameAndNamespace(XmlSignature2Message.Input input) throws Exception - Throws:
Exception
-
getNonEmptyStringSearchValue
- Throws:
Exception
-
checkSearchValueOfType
protected void checkSearchValueOfType(Class<?> cl, XmlSignature2Message.Input input) throws Exception - Throws:
Exception
-
checkStringSarchValueNotEmpty
protected void checkStringSarchValueNotEmpty(String searchValue, String outputNodeSearchType) throws Exception - Throws:
Exception
-
checkSearchValueNotNull
- Throws:
Exception
-
getNodeForMessageBodyInEnvelopingCase
protected Node getNodeForMessageBodyInEnvelopingCase(XmlSignature2Message.Input input) throws Exception - Throws:
Exception
-
removeSignatureElements
Removes the Signature elements from the document. -
isEnveloping
Checks whether the XML document has as root element the signature element.- Parameters:
input
- XML signature input- Returns:
true
if the root element of the xml signature document is the signature element; otherwisefalse
- Throws:
Exception
-
omitXmlDeclaration
protected Boolean omitXmlDeclaration(org.apache.camel.Message message, XmlSignature2Message.Input input) -
getReferencesForMessageMapping
protected List<Reference> getReferencesForMessageMapping(XmlSignature2Message.Input input) throws Exception Returns the references whose referenced objects are taken into account for the message body. This message you can use to filter the relevant references from the references provided by the input parameter.- Parameters:
input
- references and objects- Returns:
- relevant references for the mapping to the camel message
- Throws:
Exception
- if an error occurs
-
getObjectsForMessageMapping
protected List<XMLObject> getObjectsForMessageMapping(XmlSignature2Message.Input input) throws Exception Returns the objects which must be taken into account for the mapping to the camel message.- Parameters:
input
- references and objects- Returns:
- relevant objects for the mapping to camel message
- Throws:
Exception
- if an error occurs
-
getDomStructureForMessageBody
protected DOMStructure getDomStructureForMessageBody(List<Reference> relevantReferences, List<XMLObject> relevantObjects) throws Exception Returns the DOM structure which is transformed to a byte array and set to the camel message body.- Parameters:
relevantReferences
- input from methodgetReferencesForMessageMapping(ReferencesAndObjects)
relevantObjects
- input from methodgetObjectsForMessageMapping(ReferencesAndObjects)
- Returns:
- dom structure
- Throws:
Exception
- if an error occurs
-
getReferencedSameDocumentObjects
-
addManifestReferencedObjects
-
getSameDocumentReferenceUri
-
getReferencedManifest
-
getReferencedObject
-