#53 Unable to send Basic authentication via WSDLReaderImpl

open
nobody
None
5
2010-09-14
2010-09-14
mkinsella
No

I came to this via Axis2, which is apparently making use of this code, when I found I couldn't collect WSDL data from an authenticated site using their wsdl2java script. I did some testing it with a quick-and-dirty PHP page to view what (if any) credentials were being passed. None were.

So, I looked into the source a bit to see what I could find.
I'm a little rusty on how java.net.URL is intended to work these days, but it seemed that the root of this issue lies in the class com.ibm.wsdl.util.StringUtils and its method getContentAsInputStream(URL url) doesn't seem to be sending any authentication when it calls url.openStream()

I believe the Java-approved approach for this is to extend the Authenticator class, so as a test, I added an inner class within StringUtils, and added one line to the getContentAsInputStream and was able to get access to the WSDL file using my credentials.
......
Here's my inner class...
.....

static class WSDLAuthenticator extends Authenticator {

public PasswordAuthentication getPasswordAuthentication() {
String[] userInfoParts = uri.getUserInfo().split(":");
return (new PasswordAuthentication(userInfoParts[0], userInfoParts[1].toCharArray()));
}
}
......
and I added this line after the if (url == null) block, to point the URL object to the Authenticator
......
Authenticator.setDefault(new WSDLAuthenticator());
.......

Not sure what the protocol is for suggesting patches to the wsdl4j project , but I suppose I'll cross my fingers that good karma will come my way if I try.

Anyway, thought I'd post this in case anyone finds it useful, or has other suggestions for how this is intended to work.
Thanks.

Discussion

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks