Ticket #12418

java.net.Authenticator doesn't work
Open Date: 2008-04-27 11:46 Last Update: 2008-04-29 12:02

Reporter:
(Anonymous)
Owner:
Type:
Status:
Open [Owner assigned]
Component:
MileStone:
(None)
Priority:
5 - Medium
Severity:
5 - Medium
Resolution:
Accepted
File:
None

Details

The following lines of code add HTTP BASIC
Authentication Header Token to the http request
message, like
"Authorization: Basic base64encoded(username:password)".

The code works fine under desktop JVM, while in
mysaifu, 401 UNAUTHORIZED is returned.

Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication
getPasswordAuthentication() {
return new PasswordAuthentication
(username, password.toCharArray());
}
});

Ticket History (3/3 Histories)

2008-04-28 09:44 Updated by: freebeans
  • Owner Update from (None) to freebeans
  • Resolution Update from None to Accepted
2008-04-29 10:41 Updated by: freebeans
Comment
Logged In: YES
user_id=14530

I checked source code of gnu.java.net package, I'm not sure
bug it seems that GNU Classpath does not support
java.net.Authenticator.
2008-04-29 12:02 Updated by: None
Comment
Logged In: NO

No biggie. I have a workaround of adding an HTTP BASIC
Authentication header via java.net.HttpURLConnection class
as follows,

httpURLConnection.setRequestProperty("Authorization",
"Basic
"+Base64.encodeBytes((username+":"+password).getBytes()));

along with the Base64 class from here,

http://iharder.sourceforge.net/current/java/base64/

Thanks

Attachment File List

No attachments

Edit

Please login to add comment to this ticket » Login