You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by "Frank Cornelis (JIRA)" <ji...@apache.org> on 2013/11/11 10:56:17 UTC

[jira] [Created] (SANTUARIO-370) XPath2 prefix

Frank Cornelis created SANTUARIO-370:
----------------------------------------

             Summary: XPath2 prefix
                 Key: SANTUARIO-370
                 URL: https://issues.apache.org/jira/browse/SANTUARIO-370
             Project: Santuario
          Issue Type: Bug
          Components: Java
    Affects Versions: Java 1.5.5
            Reporter: Frank Cornelis
            Assignee: Colm O hEigeartaigh


When using an XPath2 filter, and you don't add:
domSignContext.putNamespacePrefix(Transform.XPATH2, "xpath2");
the marshalling completely fails as XPath receives a ds: prefix, instead of a prefix pointing to 
http://www.w3.org/2002/06/xmldsig-filter2

This should not happen.

Example code:
DOMSignContext domSignContext = new DOMSignContext(privateKey, parentElement);
domSignContext.setDefaultNamespacePrefix("ds");
// next is required for correct marshalling
domSignContext.putNamespacePrefix(Transform.XPATH2, "xpath2");

XMLSignatureFactory xmlSignatureFactory = XMLSignatureFactory
	.getInstance("DOM", new XMLDSigRI());

List<Reference> references = new LinkedList<Reference>();
List<Transform> transforms = new LinkedList<Transform>();
List<XPathType> types = new LinkedList<XPathType>();
Map<String, String> xpathNamespaceMap = new HashMap<String, String>();
xpathNamespaceMap.put("ds", "http://www.w3.org/2000/09/xmldsig#");
types.add(new XPathType("/descendant::*[name()='ds:Signature']",
	XPathType.Filter.SUBTRACT, xpathNamespaceMap));
Transform envelopedTransform = xmlSignatureFactory.newTransform(
	CanonicalizationMethod.XPATH2, new XPathFilter2ParameterSpec(
						types));
transforms.add(envelopedTransform);
transforms.add(xmlSignatureFactory.newTransform(
	CanonicalizationMethod.EXCLUSIVE,
	(C14NMethodParameterSpec) null));
	Reference reference = xmlSignatureFactory.newReference("",
		xmlSignatureFactory.newDigestMethod(DigestMethod.SHA256, null),
				transforms, null, null);
		references.add(reference);
...



--
This message was sent by Atlassian JIRA
(v6.1#6144)