Search in sources :

Example 1 with NetworkAuthenticator

use of jgnash.ui.net.NetworkAuthenticator in project jgnash by ccavanaugh.

the class Main method setupNetworking.

/**
     * Setup the networking to handle authentication requests and work http proxies correctly.
     */
private static void setupNetworking() {
    final Preferences auth = Preferences.userRoot().node(NetworkAuthenticator.NODEHTTP);
    if (auth.getBoolean(NetworkAuthenticator.USEPROXY, false)) {
        String proxyHost = auth.get(NetworkAuthenticator.PROXYHOST, "");
        String proxyPort = auth.get(NetworkAuthenticator.PROXYPORT, "");
        System.getProperties().put("http.proxyHost", proxyHost);
        System.getProperties().put("http.proxyPort", proxyPort);
        // this will deal with any authentication requests properly
        java.net.Authenticator.setDefault(new NetworkAuthenticator());
        System.out.println(ResourceUtils.getString("Message.Proxy") + proxyHost + ":" + proxyPort);
    }
}
Also used : NetworkAuthenticator(jgnash.ui.net.NetworkAuthenticator) Preferences(java.util.prefs.Preferences) PortablePreferences(jgnash.util.prefs.PortablePreferences)

Aggregations

Preferences (java.util.prefs.Preferences)1 NetworkAuthenticator (jgnash.ui.net.NetworkAuthenticator)1 PortablePreferences (jgnash.util.prefs.PortablePreferences)1