Hi Matthew,
This may be relevant it will depend on your setup but because your on a Windows platform I would start by checking that you actually do have the international charset version of the JVM installed.

See http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html

We have noticed that when doing unicode with charsets that the JVM is not setup to support on Windows crypto breaks.

Hope that helps some what.

Bradley

--
Bradley Beddoes
Lead Software Architect

Intient - "Open Source, Open Standards"
http://intient.com

mathew_pl wrote:
Hi everyone!

I've been spending hours on my problem and I cannot find any solution, so if
anyone could help me I'll be very thankfull.

Well... The problem is with Apache XML Security library. I have just written
small application to sign/encrypt/decrypt XML documents. Everything works
perfectly but one. When my XML document contains Polish characters like 'ś',
'ł', 'ę' and others there is a folowing exception thrown by jvm:

"[Fatal Error] :2:7: An invalid XML character (Unicode: 0x19) was found in
the element content o
f the document.
gov.mf.common.exceptions.SenderException: E_SENDER_DECRYPTION
at gov.mf.common.xml.encryption.EncryptTool.decrypt(Unknown Source)
at gov.mf.CERBER.TestCBR.main(Unknown Source)
Caused by: org.apache.xml.security.encryption.XMLEncryptionException: An
invalid XML character
(Unicode: 0x19) was found in the element content of the document.
Original Exception was org.xml.sax.SAXParseException: An invalid XML
character (Unicode: 0x19)
was found in the element content of the document.
at
org.apache.xml.security.encryption.XMLCipher$Serializer.deserialize(Unknown
Source)
at org.apache.xml.security.encryption.XMLCipher.decryptElement(Unknown
Source)
at org.apache.xml.security.encryption.XMLCipher.doFinal(Unknown Source)
... 2 more"

What's wrong? In my opinion, my XML file is UTF-8 encoded (written in XML
Spy, ultraedit32, notepad++ and many others editors). But maybe I'm wrong
and something is wrong with my file encoding?

What's the most interesting: I've downloaded some examples like two classes
(Encrypter.java and Decrypter.java) from XML apache Security website. For
example, in Encrypter class author does an example document on the fly,
making some nodes etc.. When I changed one textnode from: "Some simple text"
to "ąłęśóź" and tried to encrypt and decrypt it - I recieved the same error
:(  (of course source file was UTF-8 encoded). That would mean that
something is going wrong with encrypting Document, not parsing a file.

What's more interesting - encrypting and decrypting XML file which contains
only 'ł' character(s) success, but after decryption I have 'B' instead of
'ł'. That's the proof of encoding problem. For the other example, 'ó' is
successfully  encrypted and stays 'ó' after decryption. Ufortunately others
characters fails...
I've posted similar message at Java Forum but noone could help me...
I've put some code there so please take a look, maybe it would help.
Here is this thread:
http://forum.java.sun.com/thread.jspa?messageID=9457652&#9457652
XML Security topic becomes more and more popular nowadays so maybe some of
you had the same or similar problem and know the answer? Maybe something is
wrong with xmlsec-1.4.0.jar package? Please, help me if you can!

Oh, I would have forgotten...
Platform: Windows XP
IDE: Eclipse 3.2
Libraries: Apache XML Security - 1.4.0 RELEASE -->
http://xml.apache.org/security/
Java: 1.5.0_05   (java 1.5 update 5)

Thanks in advance for any advice.
Sorry for my bad English - I'm Polish :)

Matthew

Reply via email to