Class DefaultXmlSignature2Message

  • All Implemented Interfaces:
    XmlSignature2Message

    public class DefaultXmlSignature2Message
    extends Object
    implements 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.

      In the enveloping XML signature case, the message body is determined from a referenced Object element in the following way:

      • 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.
      This does mean that the enveloping XML signature must have either the structure
           
           <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>
           
       
    • Field Detail

      • OUTPUT_NODE_SEARCH_TYPE_DEFAULT

        public static final String OUTPUT_NODE_SEARCH_TYPE_DEFAULT
        Search type 'Default' for determining the output node.
        See Also:
        Constant Field Values
      • OUTPUT_NODE_SEARCH_TYPE_ELEMENT_NAME

        public static final String OUTPUT_NODE_SEARCH_TYPE_ELEMENT_NAME
        Search type 'ElementName' for determining the output element.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultXmlSignature2Message

        public DefaultXmlSignature2Message()
    • Method Detail

      • checkStringSarchValueNotEmpty

        protected void checkStringSarchValueNotEmpty​(String searchValue,
                                                     String outputNodeSearchType)
                                              throws Exception
        Throws:
        Exception
      • removeSignatureElements

        protected void removeSignatureElements​(Node node)
        Removes the Signature elements from the document.
      • isEnveloping

        protected boolean isEnveloping​(XmlSignature2Message.Input input)
        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; otherwise false
        Throws:
        Exception
      • 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 method #getReferencesForMessageMapping(ReferencesAndObjects)
        relevantObjects - input from method #getObjectsForMessageMapping(ReferencesAndObjects)
        Returns:
        dom structure
        Throws:
        Exception - if an error occurs
      • addManifestReferencedObjects

        protected void addManifestReferencedObjects​(List<XMLObject> allObjects,
                                                    List<XMLObject> referencedObjects,
                                                    String manifestId)
      • getSameDocumentReferenceUri

        protected String getSameDocumentReferenceUri​(Reference ref)