Howto disable HTTP integrated windows authentication

Hello,

I've tried to use URL/HTTPURLConnection on Windows 2003 with java5, and for my suprise it performs integrated windows authentication!

This is neat! I wanted it so many times in the past, but for this specific project I need to forward my own credentials...

How can I disable the integrated authentication, so that I may specify my own credentials?

The authenticator is not event called if integrated windows authentication is set on the IIS side.

If I leave only Basic authentication it works as expected, and as it used to work with older JVMs... :)

But I must allow users to login to IIS using integrate windows authentication...

So how can I instruct the JVM to always use the authenticator?

Best Regards,

Alon Bar-Lev.

Code:

public static class MyAuthenticator extends java.net.Authenticator {

String user;

String password;

MyAuthenticator (String user, String password) {

this.user = user;

this.password = password;

}

protected java.net.PasswordAuthentication getPasswordAuthentication () {

return new java.net.PasswordAuthentication (user, password.toCharArray ());

}

}

public

static

byte[]

getBytesToEndOfStream (

java.io.InputStream is

) throws java.io.IOException {

final int chunkSize = 2048; byte[] buf = new byte[chunkSize];int count;

java.io.ByteArrayOutputStream byteStream = new java.io.ByteArrayOutputStream (chunkSize);

while ((count=is.read (buf)) != -1) {

byteStream.write (buf, 0, count);

}

return byteStream.toByteArray ();

}

public static java.lang.String do (

String strURL,

String user,

String password

) throws

java.net.MalformedURLException,

java.io.IOException

{

if (user != null) java.net.Authenticator.setDefault (new MyAuthenticator (user, password));

java.net.URL url = new java.net.URL (strURL);

return new String (getBytesToEndOfStream (url.openConnection ().getInputStream ()));

}

[2105 byte] By [alonbla] at [2007-10-3 4:39:52]
# 1

This is a machine-depedent setting (and every User can set it different, given they have rights).

IWA is obviously a Windows NT service (and yes XP is an upgraded version of NT, do a "ver" check and you'll see it is Windows NT version 5.1).

Under the Internet Options control panel, and advanced tab, you can unselect the IWA option.

However, you (and all other Users) would have to disable that feature, as well as the machine acting as server.

watertownjordana at 2007-7-14 22:43:48 > top of Java-index,Core,Core APIs...
# 2
Thank you for your reply.However, I am looking of a way to to that using code, so that I can disable the integrated authentication for this connection only.Thanks!
alonbla at 2007-7-14 22:43:48 > top of Java-index,Core,Core APIs...