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

java.lang.Object
  extended by org.apache.camel.component.xmlsecurity.api.XmlSignatureHelper

public final class XmlSignatureHelper
extends Object

Helps to construct the transformations and the canonicalization methods for the XML Signature generator.


Nested Class Summary
static class XmlSignatureHelper.XPathAndFilter
           
 
Method Summary
static AlgorithmMethod getBase64Transform()
          Returns a configuration for a base64 transformation.
static AlgorithmMethod getCanonicalizationMethod(String algorithm)
          Returns a configuration for a canonicalization algorithm.
static AlgorithmMethod getCanonicalizationMethod(String algorithm, List<String> inclusiveNamespacePrefixes)
          Returns a configuration for a canonicalization algorithm.
static Document getDocument(Node node)
           
static AlgorithmMethod getEnvelopedTransform()
           
static List<Node> getTextAndElementChildren(Node node)
           
static List<AlgorithmMethod> getTransforms(List<AlgorithmMethod> list)
           
static AlgorithmMethod getXPath2Transform(List<XmlSignatureHelper.XPathAndFilter> xpathAndFilterList)
          Returns a configuration for an XPATH2 transformation which consists of several XPATH expressions.
static AlgorithmMethod getXPath2Transform(List<XmlSignatureHelper.XPathAndFilter> xpathAndFilterList, Map<String,String> namespaceMap)
          Returns a configuration for an XPATH2 transformation which consists of several XPATH expressions.
static AlgorithmMethod getXPath2Transform(String xpath, String filter)
          Returns a configuration for an XPATH2 transformation.
static AlgorithmMethod getXPath2Transform(String xpath, String filter, Map<String,String> namespaceMap)
          Returns a configuration for an XPATH2 transformation which consists of several XPATH expressions.
static XPathExpression getXPathExpression(XPathFilterParameterSpec xpathFilter)
           
static XPathFilterParameterSpec getXpathFilter(String xpath, Map<String,String> namespaceMap)
           
static AlgorithmMethod getXPathTransform(String xpath)
          Returns a configuration for an XPATH transformation.
static AlgorithmMethod getXPathTransform(String xpath, Map<String,String> namespaceMap)
          Returns a configuration for an XPATH transformation which needs a namespace map.
static AlgorithmMethod getXslTranform(InputStream is)
          Returns a configuration for an XSL transformation.
static AlgorithmMethod getXslTransform(String path)
          Returns a configuration for an XSL transformation.
static DocumentBuilder newDocumentBuilder(Boolean disallowDoctypeDecl)
           
protected static InputStream readXslTransform(String path)
           
static byte[] tranformTextNodeToByteArray(Node node)
           
static void transformNonTextNodeToOutputStream(Node node, OutputStream os, boolean omitXmlDeclaration)
           
static void transformToOutputStream(Node node, OutputStream os, boolean omitXmlDeclaration)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getCanonicalizationMethod

public static AlgorithmMethod getCanonicalizationMethod(String algorithm)
Returns a configuration for a canonicalization algorithm.

Parameters:
algorithm - algorithm URI
Returns:
canonicalization
Throws:
IllegalArgumentException - if algorithm is null

getCanonicalizationMethod

public static AlgorithmMethod getCanonicalizationMethod(String algorithm,
                                                        List<String> inclusiveNamespacePrefixes)
Returns a configuration for a canonicalization algorithm.

Parameters:
algorithm - algorithm URI
inclusiveNamespacePrefixes - namespace prefixes which should be treated like in the inclusive canonicalization, only relevant if the algorithm is exclusive
Returns:
canonicalization
Throws:
IllegalArgumentException - if algorithm is null

getEnvelopedTransform

public static AlgorithmMethod getEnvelopedTransform()

getBase64Transform

public static AlgorithmMethod getBase64Transform()
Returns a configuration for a base64 transformation.

Returns:
Base64 transformation

getXPathTransform

public static AlgorithmMethod getXPathTransform(String xpath)
Returns a configuration for an XPATH transformation.

Parameters:
xpath - XPATH expression
Returns:
XPATH transformation
Throws:
IllegalArgumentException - if xpath is null

getXPathTransform

public static AlgorithmMethod getXPathTransform(String xpath,
                                                Map<String,String> namespaceMap)
Returns a configuration for an XPATH transformation which needs a namespace map.

Parameters:
xpath - XPATH expression
namespaceMap - namespace map, key is the prefix, value is the namespace, can be null
Returns:
XPATH transformation
Throws:
IllegalArgumentException - if xpath is null

getXpathFilter

public static XPathFilterParameterSpec getXpathFilter(String xpath,
                                                      Map<String,String> namespaceMap)

getXPathExpression

public static XPathExpression getXPathExpression(XPathFilterParameterSpec xpathFilter)
                                          throws XPathExpressionException
Throws:
XPathExpressionException

getXPath2Transform

public static AlgorithmMethod getXPath2Transform(String xpath,
                                                 String filter)
Returns a configuration for an XPATH2 transformation.

Parameters:
xpath - XPATH expression
filter - possible values are "intersect", "subtract", "union"
Returns:
XPATH transformation
Throws:
IllegalArgumentException - if xpath or filter is null, or is neither "intersect", nor "subtract", nor "union"

getXPath2Transform

public static AlgorithmMethod getXPath2Transform(String xpath,
                                                 String filter,
                                                 Map<String,String> namespaceMap)
Returns a configuration for an XPATH2 transformation which consists of several XPATH expressions.

Parameters:
xpathAndFilterList - list of XPATH expressions with their filters
namespaceMap - namespace map, key is the prefix, value is the namespace, can be null
Returns:
XPATH transformation
Throws:
IllegalArgumentException - if xpathAndFilterList is null or empty, or the specified filter values are neither "intersect", nor "subtract", nor "union"

getXPath2Transform

public static AlgorithmMethod getXPath2Transform(List<XmlSignatureHelper.XPathAndFilter> xpathAndFilterList,
                                                 Map<String,String> namespaceMap)
Returns a configuration for an XPATH2 transformation which consists of several XPATH expressions.

Parameters:
xpathAndFilterList - list of XPATH expressions with their filters
namespaceMap - namespace map, key is the prefix, value is the namespace, can be null
Returns:
XPATH transformation
Throws:
IllegalArgumentException - if xpathAndFilterList is null or empty, or the specified filter values are neither "intersect", nor "subtract", nor "union"

getXPath2Transform

public static AlgorithmMethod getXPath2Transform(List<XmlSignatureHelper.XPathAndFilter> xpathAndFilterList)
Returns a configuration for an XPATH2 transformation which consists of several XPATH expressions.

Parameters:
xpathAndFilterList - list of XPATH expressions with their filters
Returns:
XPATH transformation
Throws:
IllegalArgumentException - if xpathAndFilterList is null or empty, or the specified filte values are neither "intersect", nor "subtract", nor "union"

getXslTransform

public static AlgorithmMethod getXslTransform(String path)
                                       throws Exception
Returns a configuration for an XSL transformation.

Parameters:
path - path to the XSL file in the classpath
Returns:
XSL transform
Throws:
IllegalArgumentException - if path is null
IllegalStateException - if the XSL file cannot be found
Exception - if an error during the reading of the XSL file occurs

getXslTranform

public static AlgorithmMethod getXslTranform(InputStream is)
                                      throws SAXException,
                                             IOException,
                                             ParserConfigurationException
Returns a configuration for an XSL transformation.

Parameters:
is - input stream of the XSL
Returns:
XSL transform
Throws:
IllegalArgumentException - if is is null
Exception - if an error during the reading of the XSL file occurs
SAXException
IOException
ParserConfigurationException

readXslTransform

protected static InputStream readXslTransform(String path)
                                       throws Exception
Throws:
Exception

getTransforms

public static List<AlgorithmMethod> getTransforms(List<AlgorithmMethod> list)

getTextAndElementChildren

public static List<Node> getTextAndElementChildren(Node node)

newDocumentBuilder

public static DocumentBuilder newDocumentBuilder(Boolean disallowDoctypeDecl)
                                          throws ParserConfigurationException
Throws:
ParserConfigurationException

transformToOutputStream

public static void transformToOutputStream(Node node,
                                           OutputStream os,
                                           boolean omitXmlDeclaration)
                                    throws TransformerFactoryConfigurationError,
                                           TransformerConfigurationException,
                                           TransformerException,
                                           IOException
Throws:
TransformerFactoryConfigurationError
TransformerConfigurationException
TransformerException
IOException

transformNonTextNodeToOutputStream

public static void transformNonTextNodeToOutputStream(Node node,
                                                      OutputStream os,
                                                      boolean omitXmlDeclaration)
                                               throws TransformerFactoryConfigurationError,
                                                      TransformerConfigurationException,
                                                      TransformerException
Throws:
TransformerFactoryConfigurationError
TransformerConfigurationException
TransformerException

tranformTextNodeToByteArray

public static byte[] tranformTextNodeToByteArray(Node node)

getDocument

public static Document getDocument(Node node)


Apache Camel