• Post Reply Bookmark Topic Watch Topic
  • New Topic

Authentication with https  RSS feed

 
Ashwin B Philar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!!
I have j2sdk1.4.0_01 installed on my machine.
I am getting the following error:
"Exception in thread "main" java.io.IOException: Server returned HTTP response co
de: 401 for URL: https://X:Y@ABC/cgi-bin/x.cgi"
I have used the sample program, URLReader from Sun's site. It works fine with sites that do not ask for authentication, but fails for site that asks for authentication.
I am using correct user name and password as I can directly access the page through a browser.
Please let me know what can be amiss.
Thanks in advance.
Ashwin
 
Rune Salthaug
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ashwin,
URLs in the form https://X:Y@ABC/cgi-bin/x.cgi is really just a notation which your browser (IE and perhaps Netscape too?) understands and uses to include authentication data in the http-header when requesting https://ABC/cgi-bin/x.cgi
Correct me if I'm wrong, but I don't think including credentials in the URL is according to standards from w3c. That's probably why your Java-code fails.
The solution is to add the necessary HTTP-header to your request. The name of this header is Authorization, and the value should something like:
Basic username :p assword
The username :p assword will also have to be encoded, probably with Base64.
Hope this can give you a hint of what the problem might be.
-Rune
[ June 28, 2002: Message edited by: Peter den Haan ]
 
Rune Salthaug
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops, sorry about the unintentional in my previous post. They should be replaced by : followed by p
-Rune
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just tick the "Disable smilies in this post" option (below the edit and graemlins windows).
- Peter
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!