Changeset 3344 in josm for trunk/src/org
- Timestamp:
- 2010-06-26T21:09:24+02:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r3194 r3344 719 719 } 720 720 synchronized public void removeFromCollection(String key, String value) { 721 List<String> a = new ArrayList<String>(getCollection(key, null));721 List<String> a = new ArrayList<String>(getCollection(key, Collections.<String>emptyList())); 722 722 a.remove(value); 723 723 putCollection(key, a); -
trunk/src/org/openstreetmap/josm/gui/io/UploadStrategy.java
r3083 r3344 64 64 */ 65 65 public static UploadStrategy getFromPreferences() { 66 String v = Main.pref.get("osm-server.upload-strategy" );66 String v = Main.pref.get("osm-server.upload-strategy", null); 67 67 if (v == null) { 68 68 // legacy support. Until 12/2009 we had osm-server.atomic-upload only. … … 70 70 // When the preferences are saved the next time, "osm-server.upload-strategy" 71 71 // will be inserted. 72 v = Main.pref.get("osm-server.atomic-upload" );72 v = Main.pref.get("osm-server.atomic-upload", null); 73 73 if (v != null) { 74 74 Main.pref.removeFromCollection("osm-server.atomic-upload", v); 75 } else { 76 v = ""; 75 77 } 76 78 v = v.trim().toLowerCase(); -
trunk/src/org/openstreetmap/josm/io/OsmConnection.java
r2990 r3344 73 73 * 74 74 * @param con the connection 75 * @throws OsmTransferException thrown i ssomething went wrong. Check for nested exceptions75 * @throws OsmTransferException thrown if something went wrong. Check for nested exceptions 76 76 */ 77 77 protected void addBasicAuthorizationHeader(HttpURLConnection con) throws OsmTransferException { -
trunk/src/org/openstreetmap/josm/io/auth/CredentialsManagerFactory.java
r3083 r3344 17 17 */ 18 18 static public CredentialsManager getCredentialManager() { 19 if (instance == null) 20 return new JosmPreferencesCredentialManager(); 19 if (instance == null) { 20 instance = new JosmPreferencesCredentialManager(); 21 } 21 22 return instance; 22 23 } -
trunk/src/org/openstreetmap/josm/io/auth/JosmPreferencesCredentialManager.java
r3083 r3344 4 4 import java.net.PasswordAuthentication; 5 5 import java.net.Authenticator.RequestorType; 6 import java.util.HashMap; 7 import java.util.Map; 6 8 7 9 import org.openstreetmap.josm.Main; … … 17 19 public class JosmPreferencesCredentialManager implements CredentialsManager { 18 20 21 Map<RequestorType, PasswordAuthentication> memoryCredentialsCache = new HashMap<RequestorType, PasswordAuthentication>(); 19 22 /** 20 23 * @see CredentialsManager#lookup(RequestorType) … … 80 83 CredentialsManagerResponse response = new CredentialsManagerResponse(); 81 84 82 if (noSuccessWithLastResponse|| username.equals("") || password.equals("")) { 85 /* 86 * Last request was successful and there was no credentials stored 87 * in file. -> Try to recall credentials that have been entered 88 * manually in this session. 89 */ 90 if (!noSuccessWithLastResponse && credentials == null && memoryCredentialsCache.containsKey(requestorType)) { 91 PasswordAuthentication pa = memoryCredentialsCache.get(requestorType); 92 response.setUsername(pa.getUserName()); 93 response.setPassword(pa.getPassword()); 94 response.setCanceled(false); 95 /* 96 * Prompt the user for credentials. This happens the first time each 97 * josm start if the user does not save the credentials to preference 98 * file (username=="") and each time after authentication failed 99 * (noSuccessWithLastResponse == true). 100 */ 101 } else if (noSuccessWithLastResponse || username.equals("") || password.equals("")) { 83 102 CredentialDialog dialog = null; 84 103 switch(requestorType) { … … 97 116 response.getPassword() 98 117 )); 118 /* 119 * User decides not to save credentials to file. Keep it 120 * in memory so we don't have to ask over and over again. 121 */ 122 } else { 123 PasswordAuthentication pa = new PasswordAuthentication(dialog.getUsername(), dialog.getPassword()); 124 memoryCredentialsCache.put(requestorType, pa); 99 125 } 126 /* 127 * We got it from file. 128 */ 100 129 } else { 101 130 response.setUsername(username);
Note:
See TracChangeset
for help on using the changeset viewer.