Revision 41524 trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/firewall/DefaultFirewallConfiguration.java

View differences:

DefaultFirewallConfiguration.java
36 36

  
37 37
        Properties systemSettings = System.getProperties();
38 38
        if (this.isEnabled()) {
39
            if ("https://".equalsIgnoreCase(this.getHost().getProtocol())) {
40
                systemSettings.put("https.proxyHost", this.getHost().getHost());
41
                systemSettings.put("https.proxyPort", String.valueOf(this.getHost().getPort()));
42
            } else {
43
                systemSettings.put("http.proxyHost", this.getHost().getHost());
44
                systemSettings.put("http.proxyPort", String.valueOf(this.getHost().getPort()));
39
            if( this.getHost()!=null ) {
40
                if ("https://".equalsIgnoreCase(this.getHost().getProtocol())) {
41
                    systemSettings.put("https.proxyHost", this.getHost().getHost());
42
                    systemSettings.put("https.proxyPort", String.valueOf(this.getHost().getPort()));
43
                } else {
44
                    systemSettings.put("http.proxyHost", this.getHost().getHost());
45
                    systemSettings.put("http.proxyPort", String.valueOf(this.getHost().getPort()));
46
                }
45 47
            }
46 48
            systemSettings.put("http.proxyUserName", this.getUserName());
47 49
            systemSettings.put("http.proxyPassword", this.getPassword());
......
79 81
    public void setEnabled(boolean enabled) {
80 82
        prefs.putBoolean("firewall.http.enabled", enabled);
81 83
    }
82

  
84
    
83 85
    public URL getHost() {
84 86
        if (this.host == null) {
85 87
            String host = prefs.get("firewall.socks.host", "");
......
88 90
        }
89 91
        return this.host;
90 92
    }
91

  
93
    
92 94
    public void setHost(URL host) {
93
        prefs.put("firewall.socks.host", host.getHost());
94
        prefs.put("firewall.socks.port", String.valueOf(host.getPort()));
95
        if (host == null) {
96
            prefs.put("firewall.socks.host", "");
97
            prefs.put("firewall.socks.port", "");
98
        } else {
99
            prefs.put("firewall.socks.host", host.getHost());
100
            prefs.put("firewall.socks.port", String.valueOf(host.getPort()));
101
        }
95 102
        this.host = host;
96 103
    }
97 104

  
98 105
    public boolean setHost(String host, String port) {
99 106
        StringBuilder b = new StringBuilder();
100

  
107
        URL hosturl = null;
108
        
101 109
        if (StringUtils.isBlank(host)) {
102
            this.host = null;
110
            hosturl = null;
103 111
        } else {
104 112
            if (!(host.toLowerCase().startsWith("http://")
105 113
                    || host.toLowerCase().startsWith("https://"))) {
......
111 119
                b.append(port);
112 120
            }
113 121
            try {
114
                this.host = new URL(b.toString());
122
                hosturl = new URL(b.toString());
115 123
            } catch (MalformedURLException ex) {
116 124
                return false;
117 125
            }
118 126
        }
119
        if (this.host == null) {
120
            prefs.put("firewall.http.host", "");
121
            prefs.put("firewall.http.port", "");
122
        } else {
123
            prefs.put("firewall.http.host", this.host.getHost());
124
            prefs.put("firewall.http.port", String.valueOf(this.host.getPort()));
125
        }
127
        this.setHost(hosturl);
126 128
        return true;
127 129
    }
128 130

  

Also available in: Unified diff