You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by "Colm O hEigeartaigh (JIRA)" <ji...@apache.org> on 2013/11/11 11:55:18 UTC

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

    [ https://issues.apache.org/jira/browse/SANTUARIO-370?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13818862#comment-13818862 ] 

Colm O hEigeartaigh commented on SANTUARIO-370:
-----------------------------------------------


Could you submit a working test-case that I can run (instead of a code snippet)?

Colm.

> 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)