axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trebor iksrazal <iksra...@yahoo.com>
Subject possible bug in SOAPPart::setContent
Date Tue, 02 Dec 2003 18:31:21 GMT
Hello everyone,

Im using axis out of cvs from nov26 with Client and
Service Handlers to do XML Encryption, via the apache
xml security project. 

Everything is fine using Serialization to convert
SOAPMessage to Document and vice-versa. However, due
to performance problems, I'd like to take advantage of
SOAPPart implementing Document as of SAAJ 1.2 . 

Anyways, what I seem to be finding is that there are
added trailing spaces to a really long text node, such
as in this documents CipherValue Element: 

bad transformed element from SOAPPart: <?xml
version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <soapenv:Body>

    <ns1:serv_consultaResponse
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="urn:hacker2">

      <xenc:EncryptedData
Type="http://www.w3.org/2001/04/xmlenc#Element"
xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
    <xenc:EncryptionMethod
Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/>
    <xenc:CipherData>
     <xenc:CipherValue>
d82zxNwJ1095RD822VYvG9FsJxgBDOJJCkVD7NK7iRqVY3ejcdk8y+GUJ1PJkhHlMKvt4SDOqi8P
eFZpycK7rs1Iq6NEFeBHWnceFM6SMuD4C05UENolZZYxPGOhL0/nOc0UPZVtGhZ4Rd0FH6BOJQgM
r3oYx+GvyJSf021FlASp8EM4leak8jn3/a7S/I6YUCnGkgi1Vn52vqhQ3kuOFzLRLd9cMKlBYi23
oVLa6IuYukQzWP15j/PbMdl9GcvUQUrsYZjQWFMFacXQJJKKGwCZjGnRo0L5LXeYLYb8YEKMzPA/
gi/rR7eewrUFbQfjh85497fX8iwxFbpYLeucA6KTHSvl/tOEvwdA17+TVJ5Kj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cr32eVOLTyj0dJESd
TPZopjuK6CRcIJns+SHKyO3IgQit6LsOjZnbebPw/IUlXD5Y5S+qGtWRvZ0sDyLf1tpjCqUQhSq4
A00yfyA/m49QTWr51OVvYy+PsRK5LBRXDkB0V5ux32ynig6WVGlDnlBAgMXvB756fUZL8ssJPwjL
Rw/nZqdVSJXsR8x/SHjiINY4kbmzeD4WOJgvXIE98gBz8L5aSYlwFSwMwf1q96YDCWttY36DeWkO
Yl1ZNGJovyNmXUn0WaGOR0v/YQfku3WK0D55lUDuLPh6RKFl9AE0qsrEOY8k4Kct//RUm7jL/mUl
7AC5MNz94/wBHx17nX2fPpm5KZ3kpLpM9+Vei8GAlOVhZeP96vcgE46hJRfDfLBmuznsa4sx4/Wo
VCtwDp3SUnokALvE3bHyECFNxPC+l9Ean2PeC8qTNFFZwdBSAFJfp8v5aW3ba1vXAHCxq2U/vxm5
IuRI8IsI0FojP2pYoYkwqkFlGBuXG9u2H+VFoOCQjEKvKYz8fIS8GY7ztVERqvAiO+7pktUFed3q
APMzsu/t4LZ5C/ZzvQrHMpxd/55v58EizDS2rMoPvE3b/FI4rVR7O8Sd1pGQZdnpbv9kUaz+qeeX
mi5CBsvesPGAhCmv2/yHVoW3T/aW09lC3Jbx0TpypP9op+3fxgezsyTe7c5c1H0=
    </xenc:CipherValue>
    </xenc:CipherData>
   </xenc:EncryptedData>

    </ns1:serv_consultaResponse>

  </soapenv:Body>

</soapenv:Envelope>

Lots of blank lines too, but ignoring that, it brakes
my encryption. 

The document should look like this:

Before SOAPPart set/get Content: <?xml version="1.0"
encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>   <ns1:serv_consulta
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="urn:hacker2">
<xenc:EncryptedData
Type="http://www.w3.org/2001/04/xmlenc#Element"
xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"><xenc:EncryptionMethod
Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"
xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"/><xenc:CipherData
xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"><xenc:CipherValue
xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">D4rRaaCz7E7mjUGqz3xRNuuAfY5Rl2Pwuc0oZr05pbeOMjTQWypD1zdKUPNU291lpwt+XV7qUXua
dWMnpEGnRqoV5m4Y57Y2l2PSNeeBJmK9ss+8mClJshS+phBesjA4AZOkZgXdB5xjDZUHulAQewtV
mkDQs6gfMDe0LG+23PTDFkTpocSfwldE0oxDUm5E8y5RB0U1Ov5p6eTTJ6JUC+/fYlhtBpPGyUvo
W2APvXkKcCTwgD2PGqNOM8zLOEtScP0+y/vHI1tAMzBkdGMF8CSojqhv5IXfiJ7yEdCmKfXssdxO
J+CIYGlpjjtc8gSg1vRKLkRpXIWsFzDHO7R8F9+Ljo2Intr68CkKtp1nO/ljPkOOPHS+pYzHjLdq
4tUjOR3LiaeR5HzsauWyiR1WGGnkj9AU3oaI0iQVLrl6b+r+TADsza3jdkjql5FwTIc3VnAm7TYp
KkMDMLE5l+tceeq9JgqqZQE6zw3/UG04cL8bNBzPZfa29MtOh50tu/PW/IqC+ADk/mAt9dgpL+0Z
KoFZBwMG9zw8bNQWNfk4sVvWroxWdiDB7/KWapGFDjJFtcH8y0ifKOvMkHDQGvg+I3JEhUKMT+5L
ill+mezBPWk4qjmksSJL2n9W9+nYqXw+RmcCyP4Vj3s=</xenc:CipherValue></xenc:CipherData></xenc:EncryptedData>
</ns1:serv_consulta>  </soapenv:Body>
</soapenv:Envelope>

My code using SOAPPart is:

 /** without serialization, theorectically giving
better performance
	public static SOAPMessage toSOAPMessage(Document doc)
throws
			TransformerConfigurationException,
TransformerException,  SOAPException, IOException,
XMLHelperException
        {
          System.out.println("Good Document: " +
XMLHelper.getXml(doc));
	  DOMSource src = new DOMSource(doc);

	  MessageFactory mf = MessageFactory.newInstance();
	  SOAPMessage soapMsg = mf.createMessage();
	  soapMsg.getSOAPPart().setContent(src);
	  return soapMsg;
        }


With serialization, and seemingly working fine:

public static Document toDocument(SOAPMessage soapMsg)
throws
				ParserConfigurationException, SAXException,
SOAPException, IOException {
		MyByteArrayOutputStream baos = new
MyByteArrayOutputStream();
		soapMsg.writeTo(baos);
		ByteArrayInputStream bais =
baos.getByteArrayInputStream();

      	DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance();
		dbf.setNamespaceAware(true);
		DocumentBuilder db = dbf.newDocumentBuilder();
		Document doc = db.parse(bais);
		return doc;
	}

I can get the SOAPPart implementation to work with
encryption by trimming the extra spaces via indeOf and
substring, etc. This fix happens after
SOAPPart::getContent  - I only confirmed setContent
adds the spaces. 

I'd be happy to supply more info. 

iksrazal

__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

Mime
View raw message