Ignore:
Timestamp:
2008-06-26T19:50:30+02:00 (16 years ago)
Author:
framm
Message:
  • patch for usernames with international characters. please revert this immediately if it causes any trouble. submitted by danilo@….
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/OsmConnection.java

    r627 r662  
    99import java.net.HttpURLConnection;
    1010import java.net.PasswordAuthentication;
     11import java.nio.ByteBuffer;
     12import java.nio.CharBuffer;
     13import java.nio.charset.Charset;
     14import java.nio.charset.CharsetEncoder;
     15import java.nio.charset.CharacterCodingException;
    1116
    1217import javax.swing.JCheckBox;
     
    129134        }
    130135
    131         protected void addAuth(HttpURLConnection con) {
    132         con.addRequestProperty("Authorization", "Basic "+Base64.encode(Main.pref.get("osm-server.username")+":"+Main.pref.get("osm-server.password")));
     136        protected void addAuth(HttpURLConnection con) throws CharacterCodingException {
     137            CharsetEncoder encoder = Charset.forName("UTF-8").newEncoder();
     138            String auth = Main.pref.get("osm-server.username") + ":" + Main.pref.get("osm-server.password");
     139            ByteBuffer bytes = encoder.encode(CharBuffer.wrap(auth));
     140            con.addRequestProperty("Authorization", "Basic "+Base64.encode(bytes));
    133141    }
    134142}
Note: See TracChangeset for help on using the changeset viewer.