org.apache.camel.component.xmlsecurity.api
Class DefaultXmlSignature2Message

java.lang.Object
  extended by org.apache.camel.component.xmlsecurity.api.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.

Default Output Node Search:


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.camel.component.xmlsecurity.api.XmlSignature2Message
XmlSignature2Message.Input
 
Field Summary
static String OUTPUT_NODE_SEARCH_TYPE_DEFAULT
          Search type 'Default' for determining the output node.
static String OUTPUT_NODE_SEARCH_TYPE_ELEMENT_NAME
          Search type 'ElementName' for determining the output element.
static String OUTPUT_NODE_SEARCH_TYPE_XPATH
          Search type 'XPath' for determining the output node.
 
Constructor Summary
DefaultXmlSignature2Message()
           
 
Method Summary
protected  void addManifestReferencedObjects(List<XMLObject> allObjects, List<XMLObject> referencedObjects, String manifestId)
           
protected  void checkSearchValueNotNull(XmlSignature2Message.Input input)
           
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 getNodeForMessageBodyInNonEnvelopedCase(XmlSignature2Message.Input input)
           
protected  String getNonEmptyStringSearchValue(XmlSignature2Message.Input input)
           
protected  List<XMLObject> getObjectsForMessageMapping(XmlSignature2Message.Input input)
          Returns the objects which must be taken into account for the mapping to the camel message.
protected  Node getOutputElementViaLocalNameAndNamespace(XmlSignature2Message.Input input)
           
protected  Node getOutputNodeViaXPath(XmlSignature2Message.Input input)
           
protected  Manifest getReferencedManifest(List<XMLObject> objects, String id)
           
protected  XMLObject getReferencedObject(List<XMLObject> objects, String id)
           
protected  List<XMLObject> getReferencedSameDocumentObjects(List<Reference> relevantReferences, List<XMLObject> relevantObjects)
           
protected  List<Reference> getReferencesForMessageMapping(XmlSignature2Message.Input input)
          Returns the references whose referenced objects are taken into account for the message body.
protected  String getSameDocumentReferenceUri(Reference ref)
           
protected  boolean isEnveloped(XmlSignature2Message.Input input)
          Returns the enveloped data in case of an enveloped XML signature.
 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

OUTPUT_NODE_SEARCH_TYPE_XPATH

public static final String OUTPUT_NODE_SEARCH_TYPE_XPATH
Search type 'XPath' for determining the output node. Search value must be of type XPathFilterParameterSpec.

See Also:
Constant Field Values
Constructor Detail

DefaultXmlSignature2Message

public DefaultXmlSignature2Message()
Method Detail

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 interface XmlSignature2Message
Parameters:
input - input
output - output message
Throws:
Exception

transformNodeToByteArrayAndSetToOutputMessage

protected void transformNodeToByteArrayAndSetToOutputMessage(XmlSignature2Message.Input input,
                                                             org.apache.camel.Message output,
                                                             Node node)
                                                      throws TransformerFactoryConfigurationError,
                                                             TransformerConfigurationException,
                                                             TransformerException,
                                                             IOException
Throws:
TransformerFactoryConfigurationError
TransformerConfigurationException
TransformerException
IOException

getOutputNodeViaXPath

protected Node getOutputNodeViaXPath(XmlSignature2Message.Input input)
                              throws Exception
Throws:
Exception

getOutputElementViaLocalNameAndNamespace

protected Node getOutputElementViaLocalNameAndNamespace(XmlSignature2Message.Input input)
                                                 throws Exception
Throws:
Exception

getNonEmptyStringSearchValue

protected String getNonEmptyStringSearchValue(XmlSignature2Message.Input input)
                                       throws Exception
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

protected void checkSearchValueNotNull(XmlSignature2Message.Input input)
                                throws Exception
Throws:
Exception

getNodeForMessageBodyInNonEnvelopedCase

protected Node getNodeForMessageBodyInNonEnvelopedCase(XmlSignature2Message.Input input)
                                                throws Exception
Throws:
Exception

removeSignatureElements

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

Parameters:
doc - document

isEnveloped

protected boolean isEnveloped(XmlSignature2Message.Input input)
                       throws Exception
Returns the enveloped data in case of an enveloped XML signature.

Parameters:
input - references of signed info and objects
Returns:
true if there exists a reference with URI = "" and with Transform.ENVELOPED transform; otherwise false
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 method #getReferencesForMessageMapping(ReferencesAndObjects)
relevantObjects - input from method #getObjectsForMessageMapping(ReferencesAndObjects)
Returns:
dom structure
Throws:
Exception - if an error occurs

getReferencedSameDocumentObjects

protected List<XMLObject> getReferencedSameDocumentObjects(List<Reference> relevantReferences,
                                                           List<XMLObject> relevantObjects)

addManifestReferencedObjects

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

getSameDocumentReferenceUri

protected String getSameDocumentReferenceUri(Reference ref)

getReferencedManifest

protected Manifest getReferencedManifest(List<XMLObject> objects,
                                         String id)

getReferencedObject

protected XMLObject getReferencedObject(List<XMLObject> objects,
                                        String id)


Apache Camel