Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTTP response 407 with 1.4.2

Status
Not open for further replies.

harmmeijer

Programmer
Mar 1, 2001
869
CN
I am behind a windows proxy that requires authentication.
When opening the following url and pressing "download now" I used to get the same 407 error since SUN did not support the MS authintication type used to authenticate the user (which our proxy requires and is a default setting for MS proxy).
Now version 1.4.2 (beta) does support this and after installing it I do get the dialog requesting me for the authentication info (user and password) so Yipeee.
I wrote an app that uses an URL where I get the 407 again and I don't know how to invoke the dialog asking me for the authentication info (I don't get this dialog).
Here is the code.

import java.util.*;
import java.net.*;
import java.io.*;
import java.applet.*;
import java.awt.*;

public class testURL {
public static void main(String[] args) {

//How I compile the app
//javac -verbose -bootclasspath "C:\Program Files\Java\j2re1.4.2\lib\rt.jar" testURL.java
//setting proxy when running the app
//java -DproxySet=true -DproxyHost=proxyname -DproxyPort=port testURL

URLConnection con;
int intChar = 0;
StringBuffer strbufAll = new StringBuffer();
String str = new String();
int i = 0;
java.net.URL uu;
try{
uu = new URL(" con = uu.openConnection();
con.setDoInput(true);
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
while((intChar = in.read())!=-1){
strbufAll.append((char) intChar);
}
}catch(Exception e){
e.printStackTrace();
}
System.out.print(strbufAll.toString());
}

}




Greetings, Harm Meijer
 
>> When opening the following url
When opening it how? Using what?

>> I don't know how to invoke the dialog asking me for the
>> authentication info (I don't get this dialog).

If you are referring to the dialog that is generated by a browser those dialogs are supplied by the browser application. In some cases they may be accessing some OS Kernel API to produce the dialog but they certainly are not part of the Java API.


-pete
 
Opening (then click "download now") with IE and JRE 1.4.2 (beta) will not show me the dialog generated by the browser because IE automatically sends authentication. Only when I were to be logged on as a user that is not allowed IE would show me the dialog.
The dialog asking me for user and password is a java window because the applet on the page thries to communicate with the originating server through our windows proxy thus requiring authentication. Probably the programm has a try and catch on the 407 error.

I was wondering how to set authentication (NOT applet) in my application so my programm can communicate with the Internet.



Greetings, Harm Meijer
 
Harm,

I'm having trouble understanding exactly what your trying to accomplish. So as a guess, have you tried using java.net.Authenticator?

-pete
 
Yes, but I cannot find the original code. I solved it by installing "crosoft proxy client".
Thanks for your help.



Greetings, Harm Meijer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top