Changeset 12805 in josm for trunk/src/org/openstreetmap/josm/io
- Timestamp:
- 2017-09-09T17:12:43+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/DefaultProxySelector.java
r12620 r12805 19 19 20 20 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.gui.preferences.server.ProxyPreferencesPanel;22 import org.openstreetmap.josm.gui.preferences.server.ProxyPreferencesPanel.ProxyPolicy;23 21 import org.openstreetmap.josm.tools.Logging; 24 22 25 23 /** 26 24 * This is the default proxy selector used in JOSM. 27 * 25 * @since 2641 28 26 */ 29 27 public class DefaultProxySelector extends ProxySelector { 28 29 /** Property key for proxy policy */ 30 public static final String PROXY_POLICY = "proxy.policy"; 31 /** Property key for HTTP proxy host */ 32 public static final String PROXY_HTTP_HOST = "proxy.http.host"; 33 /** Property key for HTTP proxy port */ 34 public static final String PROXY_HTTP_PORT = "proxy.http.port"; 35 /** Property key for SOCKS proxy host */ 36 public static final String PROXY_SOCKS_HOST = "proxy.socks.host"; 37 /** Property key for SOCKS proxy port */ 38 public static final String PROXY_SOCKS_PORT = "proxy.socks.port"; 39 /** Property key for proxy username */ 40 public static final String PROXY_USER = "proxy.user"; 41 /** Property key for proxy password */ 42 public static final String PROXY_PASS = "proxy.pass"; 43 /** Property key for proxy exceptions list */ 44 public static final String PROXY_EXCEPTIONS = "proxy.exceptions"; 30 45 31 46 private static final List<Proxy> NO_PROXY_LIST = Collections.singletonList(Proxy.NO_PROXY); … … 111 126 */ 112 127 public final void initFromPreferences() { 113 String value = Main.pref.get(P roxyPreferencesPanel.PROXY_POLICY);128 String value = Main.pref.get(PROXY_POLICY); 114 129 if (value.isEmpty()) { 115 130 proxyPolicy = ProxyPolicy.NO_PROXY; … … 118 133 if (proxyPolicy == null) { 119 134 Logging.warn(tr("Unexpected value for preference ''{0}'' found. Got ''{1}''. Will use no proxy.", 120 P roxyPreferencesPanel.PROXY_POLICY, value));135 PROXY_POLICY, value)); 121 136 proxyPolicy = ProxyPolicy.NO_PROXY; 122 137 } 123 138 } 124 String host = Main.pref.get(P roxyPreferencesPanel.PROXY_HTTP_HOST, null);125 int port = parseProxyPortValue(P roxyPreferencesPanel.PROXY_HTTP_PORT, Main.pref.get(ProxyPreferencesPanel.PROXY_HTTP_PORT, null));139 String host = Main.pref.get(PROXY_HTTP_HOST, null); 140 int port = parseProxyPortValue(PROXY_HTTP_PORT, Main.pref.get(PROXY_HTTP_PORT, null)); 126 141 httpProxySocketAddress = null; 127 142 if (proxyPolicy.equals(ProxyPolicy.USE_HTTP_PROXY)) { … … 134 149 } 135 150 136 host = Main.pref.get(P roxyPreferencesPanel.PROXY_SOCKS_HOST, null);137 port = parseProxyPortValue(P roxyPreferencesPanel.PROXY_SOCKS_PORT, Main.pref.get(ProxyPreferencesPanel.PROXY_SOCKS_PORT, null));151 host = Main.pref.get(PROXY_SOCKS_HOST, null); 152 port = parseProxyPortValue(PROXY_SOCKS_PORT, Main.pref.get(PROXY_SOCKS_PORT, null)); 138 153 socksProxySocketAddress = null; 139 154 if (proxyPolicy.equals(ProxyPolicy.USE_SOCKS_PROXY)) { … … 146 161 } 147 162 proxyExceptions = new HashSet<>( 148 Main.pref.getCollection(P roxyPreferencesPanel.PROXY_EXCEPTIONS,163 Main.pref.getCollection(PROXY_EXCEPTIONS, 149 164 Arrays.asList("localhost", IPV4_LOOPBACK, IPV6_LOOPBACK)) 150 165 ); -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r12804 r12805 50 50 * It is conceivable to extract this into an interface later and create various 51 51 * classes implementing the interface, to be able to talk to various kinds of servers. 52 * @ ince 152352 * @since 1523 53 53 */ 54 54 public class OsmApi extends OsmConnection { -
trunk/src/org/openstreetmap/josm/io/auth/JosmPreferencesCredentialAgent.java
r8510 r12805 13 13 import org.openstreetmap.josm.Main; 14 14 import org.openstreetmap.josm.data.oauth.OAuthToken; 15 import org.openstreetmap.josm.gui.preferences.server.ProxyPreferencesPanel;16 15 import org.openstreetmap.josm.gui.widgets.HtmlPanel; 16 import org.openstreetmap.josm.io.DefaultProxySelector; 17 17 import org.openstreetmap.josm.io.OsmApi; 18 18 … … 20 20 * This is the default credentials agent in JOSM. It keeps username and password for both 21 21 * the OSM API and an optional HTTP proxy in the JOSM preferences file. 22 * 22 * @since 2641 23 23 */ 24 24 public class JosmPreferencesCredentialAgent extends AbstractCredentialsAgent { … … 49 49 return new PasswordAuthentication(user, password == null ? new char[0] : password.toCharArray()); 50 50 case PROXY: 51 user = Main.pref.get( ProxyPreferencesPanel.PROXY_USER, null);52 password = Main.pref.get( ProxyPreferencesPanel.PROXY_PASS, null);51 user = Main.pref.get(DefaultProxySelector.PROXY_USER, null); 52 password = Main.pref.get(DefaultProxySelector.PROXY_PASS, null); 53 53 if (user == null) 54 54 return null; … … 84 84 break; 85 85 case PROXY: 86 Main.pref.put( ProxyPreferencesPanel.PROXY_USER, credentials.getUserName());86 Main.pref.put(DefaultProxySelector.PROXY_USER, credentials.getUserName()); 87 87 if (credentials.getPassword() == null) { 88 Main.pref.put( ProxyPreferencesPanel.PROXY_PASS, null);88 Main.pref.put(DefaultProxySelector.PROXY_PASS, null); 89 89 } else { 90 Main.pref.put( ProxyPreferencesPanel.PROXY_PASS, String.valueOf(credentials.getPassword()));90 Main.pref.put(DefaultProxySelector.PROXY_PASS, String.valueOf(credentials.getPassword())); 91 91 } 92 92 break;
Note:
See TracChangeset
for help on using the changeset viewer.