This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • XMLSecurity DataFormat

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

XMLSecurity Data Format

Available as of Camel 2.0

The XMLSecurity DataFormat facilitates encryption and decryption of XML payloads at the Document, Element and Element Content levels (including simultaneous multi-node encryption/decryption using XPATH).

...

In order to encrypt the payload, the marshal processor needs to be applied on the route followed by the encryptXMLsecureXML() tag.

Unmarshal

In order to decrypt the payload, the unmarshal processor needs to be applied on the route followed by the encryptXMLsecureXML() tag.

Examples  

Given below are several examples of how marshalling could be performaed at the Document, Element and Content levels.

  • Full Payload encryption/decryption
    Code Block
    from("direct:start").
        marshal().encryptXMLsecureXML().
        unmarshal().encryptXMLsecureXML().
    to("direct:end");
    
  • Partial Payload Content Only encryption/decryption
    Code Block
    String tagXPATH = "//cheesesites/italy/cheese";
    boolean secureTagContent = true;
    ...
    from("direct:start").
        marshal().encryptXMLsecureXML(tagXPATH , secureTagContent ).
        unmarshal().encryptXMLsecureXML(tagXPATH , secureTagContent).
    to("direct:end");
    
  • Partial Multi Node Payload Content Only encryption/decryption
    Code Block
    String tagXPATH = "//cheesesites/*/cheese";
    boolean secureTagContent = true;
    ....
    from("direct:start").
        marshal().encryptXMLsecureXML(tagXPATH , secureTagContent ).
        unmarshal().encryptXMLsecureXML(tagXPATH , secureTagContent).
    to("direct:end");
    
  • Partial Payload Content Only encryption/decryption with choice of passPhrase(password)
    Code Block
    String tagXPATH = "//cheesesites/italy/cheese";
    boolean secureTagContent = true;
    ....
    byte[]String passPhrase = "Just another 24 Byte key".getBytes();
    from("direct:start").
        marshal().encryptXMLsecureXML(tagXPATH , secureTagContent , passPhrase).
        unmarshal().encryptXMLsecureXML(tagXPATH , secureTagContent, passPhrase).
    to("direct:end");
    
  • Partial Payload Content Only encryption/decryption with passPhrase(password) and Algorithm 
    Code Block
    import org.apache.xml.security.encryption.XMLCipher;
    ....
    String tagXPATH = "//cheesesites/italy/cheese";
    boolean secureTagContent = true;
    byte[]String passPhrase = "Just another 24 Byte key".getBytes();
    String algorithm= XMLCipher.TRIPLEDES;
    from("direct:start").
        marshal().encryptXMLsecureXML(tagXPATH , secureTagContent , passPhrase, algorithm).
        unmarshal().encryptXMLsecureXML(tagXPATH , secureTagContent, passPhrase, algorithm).
    to("direct:end");
    

Dependencies

This data format is provided in the camel-xmlsecurity component.