Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Authenticator Question

Thread Tools

Authenticator Question

No Comment
Posts: n/a
I am attempting to retrieve a file from a URL secured by IDC Security. I am
using the following to attempt to code for this:



public class MyAuthenticator extends Authenticator {

protected PasswordAuthentication getPasswordAuthentication() {

String userName = "username";

String password = "password";

return new PasswordAuthentication(userName, password.toCharArray());


URL url = new URL(sourceName);

HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();

Authenticator.setDefault(new MyAuthenticator());

((HttpURLConnection) urlConnection).setInstanceFollowRedirects(false);

InputStream inputStream = url.openStream();

// Now we can create our output stream, the new file name is applied here:

FileOutputStream fileOutputStream = new FileOutputStream(destinationName);


I am getting the message 'Server redirected to many times (5)' and a return
status code of 401, Unauthorized. Yet I am able to retrieve the file via my
browser with the same login credentials.

Can anyone tell me what I might be doing wrong?



Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fallback Authenticator Marian Schedenig Java 0 12-03-2007 01:51 PM
Authenticator mozilla apache notHere Java 2 10-13-2005 01:23 PM
Authenticator freesoft_2000 Java 2 07-23-2005 10:59 AM
HTTP 401.3 because not invoked JohnG Java 0 05-06-2005 11:38 AM with proxy -- does it work ??? Elwood P. Dowd Java 0 10-30-2003 12:39 AM