Ticket #12418

java.net.Authenticator doesn't work
Eröffnet am: 2008-04-27 11:46 Letztes Update: 2008-04-29 12:02

Auswertung:
(Anonym)
Verantwortlicher:
Typ:
Status:
Offen [Owner assigned]
Komponente:
Meilenstein:
(Keine)
Priorität:
5 - Mittel
Schweregrad:
5 - Mittel
Lösung:
Accepted
Datei:
Keine

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-Verlauf (3/3 Historien)

2008-04-28 09:44 Aktualisiert von: freebeans
  • Verantwortlicher Update from (Keine) to freebeans
  • Lösung Update from Keine to Accepted
2008-04-29 10:41 Aktualisiert von: freebeans
Kommentar
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 Aktualisiert von: None
Kommentar
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

Dateianhangliste

Keine Anhänge

Bearbeiten

Please login to add comment to this ticket » Anmelden