Class XmlSignatureHelper
java.lang.Object
org.apache.camel.component.xmlsecurity.api.XmlSignatureHelper
Helps to construct the transformations and the canonicalization methods for the XML Signature generator.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic AlgorithmMethodReturns a configuration for a base64 transformation.static AlgorithmMethodgetCanonicalizationMethod(String algorithm) Returns a configuration for a canonicalization algorithm.static AlgorithmMethodgetCanonicalizationMethod(String algorithm, List<String> inclusiveNamespacePrefixes) Returns a configuration for a canonicalization algorithm.static DocumentgetDocument(Node node) static AlgorithmMethodstatic List<AlgorithmMethod> getTransforms(List<AlgorithmMethod> list) static AlgorithmMethodgetXPath2Transform(String xpath, String filter) Returns a configuration for an XPATH2 transformation.static AlgorithmMethodReturns a configuration for an XPATH2 transformation which consists of several XPATH expressions.static AlgorithmMethodgetXPath2Transform(List<XmlSignatureHelper.XPathAndFilter> xpathAndFilterList) Returns a configuration for an XPATH2 transformation which consists of several XPATH expressions.static AlgorithmMethodgetXPath2Transform(List<XmlSignatureHelper.XPathAndFilter> xpathAndFilterList, Map<String, String> namespaceMap) Returns a configuration for an XPATH2 transformation which consists of several XPATH expressions.static XPathExpressiongetXPathExpression(XPathFilterParameterSpec xpathFilter) static XPathFilterParameterSpecgetXpathFilter(String xpath) static XPathFilterParameterSpecgetXpathFilter(String xpath, Map<String, String> namespaceMap) static AlgorithmMethodgetXPathTransform(String xpath) Returns a configuration for an XPATH transformation.static AlgorithmMethodgetXPathTransform(String xpath, Map<String, String> namespaceMap) Returns a configuration for an XPATH transformation which needs a namespace map.static AlgorithmMethodReturns a configuration for an XSL transformation.static AlgorithmMethodgetXslTransform(String path) Returns a configuration for an XSL transformation.static DocumentBuildernewDocumentBuilder(Boolean disallowDoctypeDecl) static DocumentBuildernewDocumentBuilder(Boolean disallowDoctypeDecl, Schema schema) protected static InputStreamreadXslTransform(String path) static byte[]Deprecated.static byte[]tranformTextNodeToByteArray(Node node, String encoding) Trannsforms a text node to byte array using a certain character encoding.static voidtransformNonTextNodeToOutputStream(Node node, OutputStream os, boolean omitXmlDeclaration) Deprecated.static voidtransformNonTextNodeToOutputStream(Node node, OutputStream os, boolean omitXmlDeclaration, String encoding) Serializes a node using a certain character encoding.static voidtransformToOutputStream(Node node, OutputStream os, boolean omitXmlDeclaration) Deprecated.static voidtransformToOutputStream(Node node, OutputStream os, boolean omitXmlDeclaration, String encoding)
-
Method Details
-
getCanonicalizationMethod
Returns a configuration for a canonicalization algorithm.- Parameters:
algorithm- algorithm URI- Returns:
- canonicalization
- Throws:
IllegalArgumentException- if algorithm isnull
-
getCanonicalizationMethod
public static AlgorithmMethod getCanonicalizationMethod(String algorithm, List<String> inclusiveNamespacePrefixes) Returns a configuration for a canonicalization algorithm.- Parameters:
algorithm- algorithm URIinclusiveNamespacePrefixes- namespace prefixes which should be treated like in the inclusive canonicalization, only relevant if the algorithm is exclusive- Returns:
- canonicalization
- Throws:
IllegalArgumentException- if algorithm isnull
-
getEnvelopedTransform
-
getBase64Transform
Returns a configuration for a base64 transformation.- Returns:
- Base64 transformation
-
getXPathTransform
Returns a configuration for an XPATH transformation.- Parameters:
xpath- XPATH expression- Returns:
- XPATH transformation
- Throws:
IllegalArgumentException- if xpath isnull
-
getXPathTransform
Returns a configuration for an XPATH transformation which needs a namespace map.- Parameters:
xpath- XPATH expressionnamespaceMap- namespace map, key is the prefix, value is the namespace, can benull- Returns:
- XPATH transformation
- Throws:
IllegalArgumentException- if xpath isnull
-
getXpathFilter
public static XPathFilterParameterSpec getXpathFilter(String xpath, Map<String, String> namespaceMap) -
getXpathFilter
-
getXPathExpression
public static XPathExpression getXPathExpression(XPathFilterParameterSpec xpathFilter) throws XPathExpressionException - Throws:
XPathExpressionException
-
getXPath2Transform
Returns a configuration for an XPATH2 transformation.- Parameters:
xpath- XPATH expressionfilter- possible values are "intersect", "subtract", "union"- Returns:
- XPATH transformation
- Throws:
IllegalArgumentException- if xpath or filter isnull, 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:
namespaceMap- namespace map, key is the prefix, value is the namespace, can benull- Returns:
- XPATH transformation
- Throws:
IllegalArgumentException- if xpathAndFilterList isnullor 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 filtersnamespaceMap- namespace map, key is the prefix, value is the namespace, can benull- Returns:
- XPATH transformation
- Throws:
IllegalArgumentException- if xpathAndFilterList isnullor 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 isnullor empty, or the specified filte values are neither "intersect", nor "subtract", nor "union"
-
getXslTransform
Returns a configuration for an XSL transformation.- Parameters:
path- path to the XSL file in the classpath- Returns:
- XSL transform
- Throws:
IllegalArgumentException- if path isnullIllegalStateException- if the XSL file cannot be foundException- 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 isnullException- if an error during the reading of the XSL file occursSAXExceptionIOExceptionParserConfigurationException
-
readXslTransform
- Throws:
Exception
-
getTransforms
-
getTextAndElementChildren
-
newDocumentBuilder
public static DocumentBuilder newDocumentBuilder(Boolean disallowDoctypeDecl) throws ParserConfigurationException - Throws:
ParserConfigurationException
-
newDocumentBuilder
public static DocumentBuilder newDocumentBuilder(Boolean disallowDoctypeDecl, Schema schema) throws ParserConfigurationException - Throws:
ParserConfigurationException
-
transformToOutputStream
public static void transformToOutputStream(Node node, OutputStream os, boolean omitXmlDeclaration, String encoding) throws Exception - Throws:
Exception
-
transformToOutputStream
@Deprecated public static void transformToOutputStream(Node node, OutputStream os, boolean omitXmlDeclaration) throws Exception Deprecated.- Throws:
Exception
-
transformNonTextNodeToOutputStream
@Deprecated public static void transformNonTextNodeToOutputStream(Node node, OutputStream os, boolean omitXmlDeclaration) throws Exception Deprecated.- Throws:
Exception
-
transformNonTextNodeToOutputStream
public static void transformNonTextNodeToOutputStream(Node node, OutputStream os, boolean omitXmlDeclaration, String encoding) throws Exception Serializes a node using a certain character encoding.- Parameters:
node- DOM node to serializeos- output stream, to which the node is serializedomitXmlDeclaration- indicator whether to omit the XML declaration or notencoding- character encoding, can benull, ifnullthen "UTF-8" is used- Throws:
Exception
-
tranformTextNodeToByteArray
Deprecated.usetranformTextNodeToByteArray(Node, String)instead. -
tranformTextNodeToByteArray
Trannsforms a text node to byte array using a certain character encoding.- Parameters:
node- text nodeencoding- character encoding, can benull, ifnullthen UTF-8 is used- Returns:
- byte array,
nullif the node has not text content - Throws:
IllegalStateException- if the encoding is not supported
-
getDocument
-