You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@santuario.apache.org by Ramanathan Palaniappan <ra...@gmail.com> on 2006/04/25 04:02:10 UTC

Problem XML encryption and Decryption

Hi,

I have an application which sends an encrypted XML document (only a single
element is encrypted) to another process over SSL. I am able to encrypt,
decrypt and recover data as long as I am within the same application but
when I trasnmit the file over SSL, problems arise.

The other end decrypts the document and prints it properly.  But when I try
to recover the decrypted element's value using 
"getElementsbyTagName.item(0).getFirstChild().getValue()"
the value returned is an empty string. But indeed, I could see the value
being printed out at the receiver end if I print the entire docment by
serializing it.

Any help would be greatly appreciated.

Thanks,
Ram

Re: SOAP Header is not available for the messages created in Tomcat 5.5.17

Posted by Raul Benito <ra...@apache.org>.
Hi Nilantha,
I think you have choose the wrong mail list for this question. Axis
issues are discussed in its own list. Please forward this post to it.


Regards,

On 8/29/06, Nilantha Jayalath <Ni...@autodata.net> wrote:
>
>
>
>
> Hi,
>
> I have axis.jar (1.2.1) and saaj-impl.jar(1.3) in a same web application
> deployed in Tomcat 5.5.17. axis MessageFactoryImpl
> (org.apache.axis.soap.MessageFactoryImpl) gets preference
> over saaj-impl implementation
> (com.sun.xml.messaging.saaj.soap.MessageFactoryImpl) during
> the run time. I am facing issues due to this and need to use saaj
> implementation when I create SOAP messages.
>
>  My problem: there is no SOAP Header available when I try to put the
> signature in Tomcat 5.5. I am using "xmlsec-1.3.0". But If I try to add the
> header just after creating the messages ( "MessageFactory mf =
> MessageFactory.newInstance()") using "header.addHeaderElement" is says
> header is available.
>
>
>
> I have no issue in Tomcat 5.0.x and it uses sun implementation for the same
> app. Only in Tomcat 5.5.x it is looking for axis version even if
> saaj-impl.jar is available.
>
>
>
> This is how I am creating the signature.
>
>
>
> Element soapHeaderElement = (Element) ((Element) document
>
>
> .getFirstChild()).getElementsByTagNameNS(
>
>
> "http://schemas.xmlsoap.org/soap/envelope/", "Header")
>
>
> .item(0);
>
> sig = new XMLSignature(document, baseURI, signatureMethod);
>
>
>
> soapHeaderElement.appendChild(sig.getElement());
>
>
>
> As of my understanding I could try in  two ways. Either have saaj-impl
> message factory implementation loaded or have soap header available if axis
> version is getting used. Still I didn't get any idea from Tomcat user
> community for the option 1.  If someone could shed any light on this it
> would be really helpful.
>
>
>
> Note: I added a dummy element for the header in 5.5.17 environment but then
> I got an error saying "content not allowed in prolog…"
>
>
>
> Thank you
>
> Nilantha


-- 
http://r-bg.com

Re: Problem XML encryption and Decryption

Posted by Milan Tomic <to...@yahoo.com>.
It seems that your document was "changed/modified" a little bit (after decryption). By modified, I
mean, that it was "pretty printed". This:

<a><b>some text</b></a>

was changed into:

<a>
  <b>some text</b>
</a>

Code "getElementsbyTagName.item(0).getFirstChild().getValue()" returns first node and in your case
it is (node type is "text") space (32 in ASCII table), tab (9 in ASCII table), new line character
(10 in ASCII table) or carriage return (13 in ASCII table).

Your problem have nothing to do with XML decryption. You need to set preserveWhiteSpace(true) or
something similar to your XML parser (Xerces, MSXML...) and force it not to do pretty printing.

Hope it helps,
Milan


--- Ramanathan Palaniappan <ra...@gmail.com> wrote:

> Hi,
> 
> I have an application which sends an encrypted XML document (only a single
> element is encrypted) to another process over SSL. I am able to encrypt,
> decrypt and recover data as long as I am within the same application but
> when I trasnmit the file over SSL, problems arise.
> 
> The other end decrypts the document and prints it properly.  But when I try
> to recover the decrypted element's value using 
> "getElementsbyTagName.item(0).getFirstChild().getValue()"
> the value returned is an empty string. But indeed, I could see the value
> being printed out at the receiver end if I print the entire docment by
> serializing it.
> 
> Any help would be greatly appreciated.
> 
> Thanks,
> Ram
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Problem XML encryption and Decryption

Posted by Milan Tomic <to...@yahoo.com>.
> You need to set preserveWhiteSpace(true) or
> something similar to your XML parser (Xerces, MSXML...)
> and force it not to do pretty printing.

Or, even better, change this line:

getElementsbyTagName.item(0).getFirstChild().getValue()

into:

getElementsbyTagName("MyElement").item(0).getElementsbyTagName("MyOtherElement").item(0).getValue()

In other words reference elements with getElementsbyTagName(), not with getFirstChild().

Hope it helps,
Milan

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

SOAP Header is not available for the messages created in Tomcat 5.5.17

Posted by Nilantha Jayalath <Ni...@autodata.net>.
Hi,

I have axis.jar (1.2.1) and saaj-impl.jar(1.3) in a same web application
deployed in Tomcat 5.5.17. axis MessageFactoryImpl
(org.apache.axis.soap.MessageFactoryImpl) gets preference over saaj-impl
implementation (com.sun.xml.messaging.saaj.soap.MessageFactoryImpl)
during the run time. I am facing issues due to this and need to use saaj
implementation when I create SOAP messages. 

My problem: there is no SOAP Header available when I try to put the
signature in Tomcat 5.5. I am using "xmlsec-1.3.0". But If I try to add
the header just after creating the messages ( "MessageFactory mf =
MessageFactory.newInstance()") using "header.addHeaderElement" is says
header is available.

 

I have no issue in Tomcat 5.0.x and it uses sun implementation for the
same app. Only in Tomcat 5.5.x it is looking for axis version even if
saaj-impl.jar is available.

 

This is how I am creating the signature.

 

Element soapHeaderElement = (Element) ((Element) document

 
.getFirstChild()).getElementsByTagNameNS(

 
"http://schemas.xmlsoap.org/soap/envelope/", "Header")

                                                            .item(0);

sig = new XMLSignature(document, baseURI, signatureMethod);

 

soapHeaderElement.appendChild(sig.getElement());

 

As of my understanding I could try in  two ways. Either have saaj-impl
message factory implementation loaded or have soap header available if
axis version is getting used. Still I didn't get any idea from Tomcat
user community for the option 1.  If someone could shed any light on
this it would be really helpful.

 

Note: I added a dummy element for the header in 5.5.17 environment but
then I got an error saying "content not allowed in prolog..."

 

Thank you

Nilantha