Results 1 to 2 of 2
  1. #1
    Dikla is offline Member
    Join Date
    Aug 2008
    Posts
    2
    Rep Power
    0

    Question Proxy Authentication - Cannot login as multiple users

    Hello there,

    I have a class that open connections to URLs through a proxy. The proxy requires authentication, using NTLM protocol.

    I need to connect to one URL with a specific username and password, and then to another URL with another username/password combination.

    I tried using the java.net.Authenticator class, but found out that there is no option to change the credentials when using it. Meaning that if I sent correct username and password, all the next connections will use these credentials, and ignore the other credentials I supply.

    Then I tried using the "Authorization" request property, like that:

    Java Code:
    String userPassword = username + ":" + password;
    String encoding = new sun.misc.BASE64Encoder().encode(userPassword.getBytes());
    		
    urlConnection.setRequestProperty("Authorization", "Basic " + encoding);

    This also does not solve the problem. :(

    I test it like that: I send wrong credentials, and get 407 response code. Then I send correct credentials and get 200 response code. Then I send wrong credentials again, and I get 200.

    I follow redirections and I see that for every URL the proxy requests for username and password, so this is not a proxy problem.

    How can it be that the correct username and password are "remembered"?

    Thanks,
    Dikla

  2. #2
    Dikla is offline Member
    Join Date
    Aug 2008
    Posts
    2
    Rep Power
    0

    Default Solution

    The solution is to set the request property Proxy-Authorization and not Authorization...

Similar Threads

  1. proxy server with caching........?
    By 05bit044 in forum Networking
    Replies: 1
    Last Post: 08-03-2008, 09:10 PM
  2. Jakarta FTP via proxy server
    By megalon in forum Networking
    Replies: 0
    Last Post: 07-24-2008, 11:12 AM
  3. Replies: 0
    Last Post: 06-25-2008, 01:41 PM
  4. Multiple Users
    By peiceonly in forum Threads and Synchronization
    Replies: 5
    Last Post: 06-09-2008, 10:17 AM
  5. Accounts of users
    By Eric in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 06-27-2007, 05:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •