Bug 242091 - Web services explorer inserts spurious CRLF in a long authentication header
Summary: Web services explorer inserts spurious CRLF in a long authentication header
Status: RESOLVED FIXED
Alias: None
Product: WTP Webservices
Classification: WebTools
Component: wst.ws (show other bugs)
Version: 3.0   Edit
Hardware: PC Linux
: P3 critical (vote)
Target Milestone: 3.0.1   Edit
Assignee: Andrew Mak CLA
QA Contact: Kathy Chan CLA
URL:
Whiteboard: PMC_approved
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2008-07-25 11:45 EDT by Chris Rose CLA
Modified: 2009-02-11 21:55 EST (History)
2 users (show)

See Also:
david_williams: pmc_approved+
kathy: pmc_approved? (raghunathan.srinivasan)
kathy: pmc_approved? (naci.dai)
kathy: pmc_approved? (deboer)
kathy: pmc_approved? (neil.hauge)
kathy: pmc_approved? (kaloyan)


Attachments
strip new line from encoded string (2.48 KB, patch)
2008-07-28 12:57 EDT, Andrew Mak CLA
bjorn.freeman-benson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Rose CLA 2008-07-25 11:45:14 EDT
Build ID: I20080609-1311

Steps To Reproduce:
1. Create a new dynamic web project
2. Import any WSDL for a service that requires HTTP basic authentication
3. Configure TCP monitor to monitor the web service invocation
4. Open the WSDL in web services explorer
5. Invoke a method on the service
6. Set the username to something 59 characters long
7. Set the password to something 18 characters long
8. Execute the service

In the TCP monitor you'll see that the authentication line is wrapped at 98 characters.

More information:
This problem causes errors invoking services on WebSphere, which fails attempting to parse the header:

Exception = com.ibm.wsspi.genericbnf.exception.MalformedMessageException
Source = HttpInboundLink.handleNewInformation
probeid = 1
Stack Dump = com.ibm.wsspi.genericbnf.exception.MalformedMessageException: Invalid CRLF found in header name
        at com.ibm.ws.genericbnf.impl.BNFHeadersImpl.findHeaderLength(BNFHeadersImpl.java:5489)
        at com.ibm.ws.genericbnf.impl.BNFHeadersImpl.parseHeaderName(BNFHeadersImpl.java:5531)
        at com.ibm.ws.genericbnf.impl.BNFHeadersImpl.parseHeaders(BNFHeadersImpl.java:2100)
        at com.ibm.ws.genericbnf.impl.GenericMessageImpl.parseMessage(GenericMessageImpl.java:353)
...
Comment 1 Valentin Baciu CLA 2008-07-25 12:45:41 EDT
Thank you for reporting this bug. I have tried to assign to what I believe is the correct component. For guidance on how to select the correct component in future bug reports, please refer to:
https://bugs.eclipse.org/bugs/describecomponents.cgi?product=Web+Tools
Comment 2 Kathy Chan CLA 2008-07-25 13:23:18 EDT
Hi Chris,

A couple of questions for you.  If you don't use the TCP/IP monitor (or user TCP/IP monitor with just use a userid and password that's normal length, e.g. 8 to 10 characters), could you invoke the Web service OK with the Web Services Explorer?  Is this Linux specific or happens on Windows as well.

I am tentatively targetting this to WTP 3.0.1 based on the severity of the problem you've assigned it to.  This might be re-targetted based on further investigation of the problem.

Andrew, could you please take a look at this problem? Thanks!

Comment 3 Chris Rose CLA 2008-07-25 15:28:16 EDT
Shortening the username results in a successful invocation
Removing the TCP monitor from the connection results in a failed invocation.  The WS Explorer status shows this:

IWAB0135E An unexpected error has occurred
400
Bad Request

(side note:  it would be a killer feature if I could, say, copy the contents of that buffer to the clipboard!)

The WAS log shows the same exception again.

Comment 4 Andrew Mak CLA 2008-07-28 11:55:53 EDT
Looks like this is a known bug/limitation in Sun's Base64Encoder [1].  It does not appear that a fix has been released.  It's possible to workaround this limitation by removing the extra newline from the encoded string.  Will work on a patch for this.

[1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6459815
Comment 5 Andrew Mak CLA 2008-07-28 12:57:24 EDT
Created attachment 108553 [details]
strip new line from encoded string
Comment 6 Andrew Mak CLA 2008-07-28 16:21:08 EDT
Problem Summary:
When using WSE to test a Web service requiring Basic Auth, and it encounters a very long authorization string, the authorization header is split into 2 lines. This results in an invalid header so the Web service cannot be involved.

Cause:
This is an underlying bug in Sun's Base64Encoder [1] which has a limit to the length of the encoded string. Newline characters are inserted when that limit is reached, hence the extra line in the auth header.
[1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6459815

Fix:
A fix to Base64Encoder is not available yet. We can workaround this problem by stripping out these extra newline characters from the encoded string. Fix has been tested and is quite safe.
Comment 7 Kathy Chan CLA 2008-07-29 14:28:47 EDT
Patch reviewed.  PMC, please approve for WTP 3.0.1.
Comment 8 David Williams CLA 2008-07-30 01:32:08 EDT
I'm ok with this quick fix for 3.0.1, but it's unfortunate we haven't gotten rid of that sun internal class. I think this small fix is the safest thing to do for 3.0.1, though. 

Accordingly, I've set the target of bug 121120 to be 3.1 M1. Perhaps _this_ scenario (with the original code, not the work around) would be an interesting test case for the "new" encoder? 

thanks, 
Comment 9 Peter Moogk CLA 2008-07-30 15:03:31 EDT
The changes for this defect have been committed and released to the HEAD and V301 stream under v200807301838.
Comment 10 Kathy Chan CLA 2008-10-27 14:18:10 EDT
This defect has been in resolve state for a while.  Please verify this with the appropriate WTP driver which can be found in:

http://download.eclipse.org/webtools/downloads/

We would verify and close the defect on the originator's behalf if it has not been verified 2 weeks after it's been changed to Verified state.
Comment 11 Kathy Chan CLA 2009-02-11 21:55:31 EST
This bug has been in resolved state for a while.  Please verify this defect with the latest WTP 3.0.4 or WTP 3.5 build from:

http://download.eclipse.org/webtools/downloads/

If this is not verified within 2 weeks, we'll be verifying the bug on your behalf.  Thanks!