You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@santuario.apache.org by buko <bu...@gmail.com> on 2018/07/17 09:49:37 UTC

Recovering XML Signature via JAXB

We’d like to start with a JAXB object (Document) and then serialize and sign it into a new JAXB object (SignedDocument). Then we’d like to embed the SignedDocument into another object (Message) and sign that to produce a new JAXB object (SignedMessage).

We can create the secure XMLStreamWriter easily enough and sign the document easily enough but it’s not clear how we actually read the generated signature back using JAXB. 

What’s interesting is Santuario appears to contain JAXB bindings for the XML Signature Schema in https://github.com/apache/santuario-java/tree/trunk/src/main/java/org/apache/xml/security/binding/xmldsig. But there’s no binding for the ‘Signature’ element.

Any ideas here? Is this possible? Is there a test that shows how to use the JAXB bindings?


Re: Recovering XML Signature via JAXB

Posted by Colm O hEigeartaigh <co...@apache.org>.
According to the schema, the Signature Element is a SignatureType:

<element name="Signature" type="ds:SignatureType"/>

and the SignatureType is available in the bindings directory:

https://github.com/apache/santuario-java/blob/trunk/src/main/java/org/apache/xml/security/binding/xmldsig/SignatureType.java

The JAXB bindings are used by the streaming XML Security implementation,
and are not designed to be used in a standalone way. You might be able to
re-use the streaming code for your purpose though. Take a look at some of
the tests, for example:

https://github.com/apache/santuario-java/blob/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureVerificationTest.java

Colm.

On Tue, Jul 17, 2018 at 10:49 AM, buko <bu...@gmail.com> wrote:

>
>
> We’d like to start with a JAXB object (Document) and then serialize and
> sign it into a new JAXB object (SignedDocument). Then we’d like to embed
> the SignedDocument into another object (Message) and sign that to produce a
> new JAXB object (SignedMessage).
>
>
>
> We can create the secure XMLStreamWriter easily enough and sign the
> document easily enough but it’s not clear how we actually read the
> generated signature back using JAXB.
>
>
>
> What’s interesting is Santuario appears to contain JAXB bindings for the
> XML Signature Schema in https://github.com/apache/
> santuario-java/tree/trunk/src/main/java/org/apache/xml/
> security/binding/xmldsig. But there’s no binding for the ‘Signature’
> element.
>
>
>
> Any ideas here? Is this possible? Is there a test that shows how to use
> the JAXB bindings?
>
>
>



-- 
Colm O hEigeartaigh

Talend Community Coder
http://coders.talend.com