0

I'm trying to 1) compute the digital signature for an XML string, 2) unmarshall the XML string to a Java object, 3) marshall the object back to an XML string, and 4) re-compute signature, and verify against the signature from step 1.

Problem is that the namespace prefixes usually get changed during the round trip (steps 2-3), so I need a way to standardize them before and after the round trip. Otherwise, the digital signatures (steps 1 and 4) obviously won't match.

I figured I need something like PrefixRewrite="sequential" in section 2.5.4 of https://www.w3.org/TR/xml-c14n2/Overview_diff.html#sec-Example-PrefixRewriteSeq. I found a Python library that supposedly does that (https://github.com/dept2/c14n2py), but I can't seem to find a Java library with that option (org.apache.xml.security.c14n.Canonicalizer doesn't have it). I've also been able to hard-code the namespace prefixes in my marshaller, but that's not an acceptable solution for me.

Can anybody recommend a Java library for XML canonicalization with the PrefixRewrite="sequential" option?

Thanks!!

Boris
  • 1

1 Answers1

0

That python library c14n2py was written from sources of Java library, that lies nearby: https://github.com/dept2/c14n2 You could try to use it

Asdef
  • 11
  • 1
  • 1
    I already mentioned that GitHub page in my question and said that I need a Java library, not Python. – Boris Feb 18 '23 at 23:49