mace-opensaml-users - RE: [OpenSAML] XML altered after basic unmarshal-marshall sequence
Subject: OpenSAML user discussion
List archive
- From: Paolo Selvini <>
- To: "" <>
- Subject: RE: [OpenSAML] XML altered after basic unmarshal-marshall sequence
- Date: Thu, 8 May 2008 23:48:10 +0200
- Accept-language: it-IT, en-US
- Acceptlanguage: it-IT, en-US
Hi Chad and thanks for the explanation.
So, if I've got it right, you are saying I might be using a ISO-8859-1 file
encoding with a UTF-8 DOM encoding.
The original file encoding is ISO-8859-1 (confirmed also by some tools like
XML-Spy). The output file has the same encoding as well. You can find both
files enclosed.
By looking at the code I am using, you can see that I am indeed calling the
XMLHelper.writeNode() function to write the output file. I am enclosing again
the code for your convenience.
If I omit the unmarshall-marshall code (lines 31 through 39) and leave just
the initial parsing and the final serialization, the original file is
preserved intact in the output, i.e.: no change in encoding declaration at
the top. So my guess is that something happens in the process of
unmarshalling-marshalling.
I don't intend to bother, but this is happening also during the process of
signing the metadata files with those accented chars: the really only wrong
thing with the signed output is the initial XML preamble stating the
encoding: UTF-8 instead of ISO-8859-1. Everything else is fine. The output
file encoding as written to disk is ok. If I manually change the preamble to
make it read "ISO-8859-1" instead of "UTF-8", the verification of the file is
ok as well: it is just a matter of wrong declaration.
So my actual problem here seems to be how to have a ISO-8859-1 DOM encoding,
so that when I write the file with XMLHelper.writeNode(myNode, FileWriter)
the preamble does not get altered.
Thanks again for your precious support!
Paolo
-----Original Message-----
From: Chad La Joie
[mailto:]
Sent: giovedì 8 maggio 2008 16.54
To:
Subject: Re: [OpenSAML] XML altered after basic unmarshal-marshall sequence
You need to understand how encoding works in the various places.
Files have a particular encoding and that's what your java.io classes operate
on. The DOM has an independent encoding which indicates the encoding used
for the containers of data within the DOM. You can (and I've accidentally
done it before) use different encodings for each.
So, what have you is correct. It's doing exactly what you told it to.
Take UTF-8 DOM and write it out to a file encoded with another encoding.
As I already told you the last time you asked, you can use the
XMLHelper.writeNode method to do this.
XMLHelper.writeNode(youNode, new FileWrite("/path/to/you/file.xml"))
Paolo Selvini wrote:
> I am doing a very simple test in order to better understand the cause of
> another problem about XML encoding with OpenSAML.
> The test is the following: take a very simple and empty SAML metadata
> file like
>
> <?xml version="1.0" encoding="ISO-8859-1"?> <md:EntityDescriptor
> xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"/>
>
> and process it with the code attached to this message. The code parses the
> file with a Reader forcing ISO-8859-1 encoding, processes it through
> unmarshalling and marshalling and then, without doing any modification to
> it, saves it back to disk with a Writer, forcing encoding ISO-8859-1. The
> output is the following:
>
> <?xml version="1.0" encoding="UTF-8"?><md:EntityDescriptor
> xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"/>
>
> You may notice the difference in the <?xml... > header, where the encoding
> has been altered.
> Does anybody know the cause and any possible solution / workaround?
>
> I'm using OpenSAML-J 2.1.0.
>
> thanks,
> Paolo
>
>
>
>
>
>
>
> ________________________________
> Le informazioni contenute in questa comunicazione e negli allegati sono
> riservate; e' vietato a soggetti diversi dai destinatari qualsiasi uso,
> copia, diffusione di quanto in essi contenuto.
> Se avete ricevuto questa copia per errore, vi preghiamo di distruggerla
> immediatamente ed informarci via e-mail.
>
> Prima di stampare questa e-mail consideratene l'impatto sull'ambiente.
> Grazie per la collaborazione.
>
>
> This e-mail and any attachment(s) are strictly confidential. This message
> must not be copied, disclosed or used by anybody other than the intended
> recipient(s).
> If you are not the intended recipient, please inform the sender by e-mail
> and destroy this message immediately.
>
> Please consider the environment before printing this e-mail. Thank you for
> your cooperation.
>
--
SWITCH
Serving Swiss Universities
--------------------------
Chad La Joie, Software Engineer, Security Werdstrasse 2, P.O. Box, 8021
Zürich, Switzerland phone +41 44 268 15 75, fax +41 44 268 15 68
,
http://www.switch.ch
Le informazioni contenute in questa comunicazione e negli allegati sono
riservate; e' vietato a soggetti diversi dai destinatari qualsiasi uso,
copia, diffusione di quanto in essi contenuto.
Se avete ricevuto questa copia per errore, vi preghiamo di distruggerla
immediatamente ed informarci via e-mail.
Prima di stampare questa e-mail consideratene l'impatto sull'ambiente. Grazie
per la collaborazione.
This e-mail and any attachment(s) are strictly confidential. This message
must not be copied, disclosed or used by anybody other than the intended
recipient(s).
If you are not the intended recipient, please inform the sender by e-mail and
destroy this message immediately.
Please consider the environment before printing this e-mail. Thank you for
your cooperation.
Attachment:
XmlReadWrite.java
Description: XmlReadWrite.java
<?xml version="1.0" encoding="ISO-8859-1"?> <md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"/>
<?xml version="1.0" encoding="UTF-8"?><md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"/>
- XML altered after basic unmarshal-marshall sequence, Paolo Selvini, 05/08/2008
- Re: [OpenSAML] XML altered after basic unmarshal-marshall sequence, Chad La Joie, 05/08/2008
- RE: [OpenSAML] XML altered after basic unmarshal-marshall sequence, Paolo Selvini, 05/08/2008
- Re: [OpenSAML] XML altered after basic unmarshal-marshall sequence, Chad La Joie, 05/08/2008
Archive powered by MHonArc 2.6.16.