Ignore:
Timestamp:
2017-09-09T17:12:43+02:00 (7 years ago)
Author:
Don-vip
Message:

see #15229 - see #15182 - remove GUI references from DefaultProxySelector

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  
    1919
    2020import org.openstreetmap.josm.Main;
    21 import org.openstreetmap.josm.gui.preferences.server.ProxyPreferencesPanel;
    22 import org.openstreetmap.josm.gui.preferences.server.ProxyPreferencesPanel.ProxyPolicy;
    2321import org.openstreetmap.josm.tools.Logging;
    2422
    2523/**
    2624 * This is the default proxy selector used in JOSM.
    27  *
     25 * @since 2641
    2826 */
    2927public 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";
    3045
    3146    private static final List<Proxy> NO_PROXY_LIST = Collections.singletonList(Proxy.NO_PROXY);
     
    111126     */
    112127    public final void initFromPreferences() {
    113         String value = Main.pref.get(ProxyPreferencesPanel.PROXY_POLICY);
     128        String value = Main.pref.get(PROXY_POLICY);
    114129        if (value.isEmpty()) {
    115130            proxyPolicy = ProxyPolicy.NO_PROXY;
     
    118133            if (proxyPolicy == null) {
    119134                Logging.warn(tr("Unexpected value for preference ''{0}'' found. Got ''{1}''. Will use no proxy.",
    120                         ProxyPreferencesPanel.PROXY_POLICY, value));
     135                        PROXY_POLICY, value));
    121136                proxyPolicy = ProxyPolicy.NO_PROXY;
    122137            }
    123138        }
    124         String host = Main.pref.get(ProxyPreferencesPanel.PROXY_HTTP_HOST, null);
    125         int port = parseProxyPortValue(ProxyPreferencesPanel.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));
    126141        httpProxySocketAddress = null;
    127142        if (proxyPolicy.equals(ProxyPolicy.USE_HTTP_PROXY)) {
     
    134149        }
    135150
    136         host = Main.pref.get(ProxyPreferencesPanel.PROXY_SOCKS_HOST, null);
    137         port = parseProxyPortValue(ProxyPreferencesPanel.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));
    138153        socksProxySocketAddress = null;
    139154        if (proxyPolicy.equals(ProxyPolicy.USE_SOCKS_PROXY)) {
     
    146161        }
    147162        proxyExceptions = new HashSet<>(
    148             Main.pref.getCollection(ProxyPreferencesPanel.PROXY_EXCEPTIONS,
     163            Main.pref.getCollection(PROXY_EXCEPTIONS,
    149164                    Arrays.asList("localhost", IPV4_LOOPBACK, IPV6_LOOPBACK))
    150165        );
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r12804 r12805  
    5050 * It is conceivable to extract this into an interface later and create various
    5151 * classes implementing the interface, to be able to talk to various kinds of servers.
    52  * @ince 1523
     52 * @since 1523
    5353 */
    5454public class OsmApi extends OsmConnection {
  • trunk/src/org/openstreetmap/josm/io/auth/JosmPreferencesCredentialAgent.java

    r8510 r12805  
    1313import org.openstreetmap.josm.Main;
    1414import org.openstreetmap.josm.data.oauth.OAuthToken;
    15 import org.openstreetmap.josm.gui.preferences.server.ProxyPreferencesPanel;
    1615import org.openstreetmap.josm.gui.widgets.HtmlPanel;
     16import org.openstreetmap.josm.io.DefaultProxySelector;
    1717import org.openstreetmap.josm.io.OsmApi;
    1818
     
    2020 * This is the default credentials agent in JOSM. It keeps username and password for both
    2121 * the OSM API and an optional HTTP proxy in the JOSM preferences file.
    22  *
     22 * @since 2641
    2323 */
    2424public class JosmPreferencesCredentialAgent extends AbstractCredentialsAgent {
     
    4949            return new PasswordAuthentication(user, password == null ? new char[0] : password.toCharArray());
    5050        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);
    5353            if (user == null)
    5454                return null;
     
    8484            break;
    8585        case PROXY:
    86             Main.pref.put(ProxyPreferencesPanel.PROXY_USER, credentials.getUserName());
     86            Main.pref.put(DefaultProxySelector.PROXY_USER, credentials.getUserName());
    8787            if (credentials.getPassword() == null) {
    88                 Main.pref.put(ProxyPreferencesPanel.PROXY_PASS, null);
     88                Main.pref.put(DefaultProxySelector.PROXY_PASS, null);
    8989            } else {
    90                 Main.pref.put(ProxyPreferencesPanel.PROXY_PASS, String.valueOf(credentials.getPassword()));
     90                Main.pref.put(DefaultProxySelector.PROXY_PASS, String.valueOf(credentials.getPassword()));
    9191            }
    9292            break;
Note: See TracChangeset for help on using the changeset viewer.