Changeset 2748 in josm for trunk/src/org/openstreetmap/josm/io/auth/JosmPreferencesCredentialManager.java
- Timestamp:
- 2010-01-06T20:35:56+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/auth/JosmPreferencesCredentialManager.java
r2711 r2748 6 6 7 7 import org.openstreetmap.josm.Main; 8 import org.openstreetmap.josm.data.oauth.OAuthToken; 8 9 import org.openstreetmap.josm.gui.io.CredentialDialog; 9 import org.openstreetmap.josm.gui.preferences.ProxyPreferences; 10 import org.openstreetmap.josm.gui.preferences.server.ProxyPreferencesPanel; 10 11 11 12 /** … … 32 33 return new PasswordAuthentication(user, password == null ? new char[0] : password.toCharArray()); 33 34 case PROXY: 34 user = Main.pref.get(ProxyPreferences.PROXY_USER, null); 35 password = Main.pref.get(ProxyPreferences.PROXY_PASS, null); 35 user = Main.pref.get(ProxyPreferencesPanel.PROXY_USER, null); 36 password = Main.pref.get(ProxyPreferencesPanel.PROXY_PASS, null); 36 37 if (user == null) 37 38 return null; … … 57 58 break; 58 59 case PROXY: 59 Main.pref.put( "proxy.username", credentials.getUserName());60 Main.pref.put(ProxyPreferencesPanel.PROXY_USER, credentials.getUserName()); 60 61 if (credentials.getPassword() == null) { 61 Main.pref.put( "proxy.password", null);62 Main.pref.put(ProxyPreferencesPanel.PROXY_PASS, null); 62 63 } else { 63 Main.pref.put( "proxy.password", String.valueOf(credentials.getPassword()));64 Main.pref.put(ProxyPreferencesPanel.PROXY_PASS, String.valueOf(credentials.getPassword())); 64 65 } 65 66 break; … … 104 105 return response; 105 106 } 107 108 109 /** 110 * Lookup the current OAuth Access Token to access the OSM server. Replies null, if no 111 * Access Token is currently managed by this CredentialManager. 112 * 113 * @return the current OAuth Access Token to access the OSM server. 114 * @throws CredentialsManagerException thrown if something goes wrong 115 */ 116 public OAuthToken lookupOAuthAccessToken() throws CredentialsManagerException { 117 String accessTokenKey = Main.pref.get("oauth.access-token.key", null); 118 String accessTokenSecret = Main.pref.get("oauth.access-token.secret", null); 119 if (accessTokenKey == null && accessTokenSecret == null) 120 return null; 121 return new OAuthToken(accessTokenKey, accessTokenSecret); 122 } 123 124 /** 125 * Stores the OAuth Access Token <code>accessToken</code>. 126 * 127 * @param accessToken the access Token. null, to remove the Access Token. 128 * @throws CredentialsManagerException thrown if something goes wrong 129 */ 130 public void storeOAuthAccessToken(OAuthToken accessToken) throws CredentialsManagerException { 131 if (accessToken == null) { 132 Main.pref.put("oauth.access-token.key", null); 133 Main.pref.put("oauth.access-token.secret", null); 134 } else { 135 Main.pref.put("oauth.access-token.key", accessToken.getKey()); 136 Main.pref.put("oauth.access-token.secret", accessToken.getSecret()); 137 } 138 } 106 139 }
Note:
See TracChangeset
for help on using the changeset viewer.