Changeset 4874 in josm for trunk/src/org/openstreetmap/josm/data/ServerSidePreferences.java
- Timestamp:
- 26.01.2012 21:52:34 (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/ServerSidePreferences.java
r4612 r4874 15 15 import java.net.URL; 16 16 import java.net.URLConnection; 17 import java.util.Collection;18 import java.util.Collections;19 import java.util.LinkedList;20 import java.util.StringTokenizer;21 import java.util.Map.Entry;22 17 23 18 import javax.swing.JOptionPane; … … 26 21 import org.openstreetmap.josm.Main; 27 22 import org.openstreetmap.josm.io.OsmConnection; 28 import org.openstreetmap.josm.io.OsmTransferException;29 23 import org.openstreetmap.josm.tools.Base64; 30 24 … … 36 30 */ 37 31 public class ServerSidePreferences extends Preferences { 38 public class MissingPassword extends Exception{32 public static class MissingPassword extends Exception{ 39 33 public String realm; 40 34 public MissingPassword(String r) { … … 56 50 String username = get("applet.username"); 57 51 String password = get("applet.password"); 58 if(password.isEmpty() && username.isEmpty()) 52 if(password.isEmpty() && username.isEmpty()) { 59 53 con.addRequestProperty("Authorization", "Basic "+Base64.encode(username+":"+password)); 54 } 60 55 con.connect(); 61 56 if(username.isEmpty() && con instanceof HttpURLConnection 62 && ((HttpURLConnection) con).getResponseCode()63 == HttpURLConnection.HTTP_UNAUTHORIZED) {57 && ((HttpURLConnection) con).getResponseCode() 58 == HttpURLConnection.HTTP_UNAUTHORIZED) { 64 59 String t = ((HttpURLConnection) con).getHeaderField("WWW-Authenticate"); 65 60 t = t.replace("Basic realm=\"","").replace("\"",""); … … 88 83 String username = get("applet.username"); 89 84 String password = get("applet.password"); 90 if(password.isEmpty() && username.isEmpty()) 85 if(password.isEmpty() && username.isEmpty()) { 91 86 con.addRequestProperty("Authorization", "Basic "+Base64.encode(username+":"+password)); 87 } 92 88 con.setRequestMethod("POST"); 93 89 con.setDoOutput(true); … … 103 99 tr("Information"), 104 100 JOptionPane.INFORMATION_MESSAGE 105 );101 ); 106 102 } catch (Exception e) { 107 103 e.printStackTrace(); … … 111 107 tr("Error"), 112 108 JOptionPane.ERROR_MESSAGE 113 );109 ); 114 110 } 115 111 } … … 127 123 tr("Error"), 128 124 JOptionPane.ERROR_MESSAGE 129 );125 ); 130 126 } 131 127 this.connection = connection;
Note: See TracChangeset
for help on using the changeset viewer.
