Revision 8884 trunk/libraries/libCorePlugin/src/com/iver/core/preferences/network/FirewallPage.java

View differences:

FirewallPage.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.7  2006-10-18 07:55:43  jaume
46
* Revision 1.8  2006-11-20 17:29:43  fjp
47
* Fallo proxy con usuario y contrase?a
48
*
49
* Revision 1.7  2006/10/18 07:55:43  jaume
47 50
* *** empty log message ***
48 51
*
49 52
* Revision 1.6  2006/08/22 12:23:05  jaume
......
103 106

  
104 107
import java.awt.event.ActionEvent;
105 108
import java.awt.event.ActionListener;
109
import java.net.Authenticator;
106 110
import java.net.MalformedURLException;
111
import java.net.PasswordAuthentication;
107 112
import java.net.URL;
108 113
import java.util.Properties;
109 114
import java.util.prefs.Preferences;
110 115

  
111 116
import javax.swing.ImageIcon;
112 117
import javax.swing.JCheckBox;
113
import javax.swing.JOptionPane;
114 118
import javax.swing.JPanel;
115 119
import javax.swing.JPasswordField;
116 120
import javax.swing.JTextField;
......
137 141
	protected static String id = FirewallPage.class.getName();
138 142
	private ImageIcon icon;
139 143

  
144
	private static final class ProxyAuth extends Authenticator {
145
		private PasswordAuthentication auth;
146

  
147
		private ProxyAuth(String user, String pass) {
148
			auth = new PasswordAuthentication(user, pass.toCharArray());
149
		}
150

  
151
		protected PasswordAuthentication getPasswordAuthentication() {
152
			return auth;
153
		}
154
	}
155

  
140 156
	public FirewallPage() {
141 157
		super();
142 158
		icon = new ImageIcon(this.getClass().getClassLoader().getResource("images/shield.png"));
......
231 247
			prefs.putBoolean("firewall.http.enabled", httpEnabled.isSelected());
232 248
			prefs.put("firewall.http.host", httpHost.getText());
233 249
			prefs.put("firewall.http.port", httpPort.getText());
234
			prefs.put("firewall.http.user", httpUser.getText());
235
			prefs.put("firewall.http.password", new String(httpPass.getPassword()));
250
			String proxyUser = httpUser.getText();
251
			String proxyPassword = new String(httpPass.getPassword());
252
			prefs.put("firewall.http.user", proxyUser);
253
			prefs.put("firewall.http.password", proxyPassword);
236 254
			prefs.put("firewall.http.nonProxyHosts", httpNonProxy.getText());
237 255

  
238 256
			if (httpEnabled.isSelected()) {
239 257
				systemSettings.put("http.proxyHost", httpURL.getHost());
240 258
				systemSettings.put("http.proxyPort", httpURL.getPort()+"");
241
				systemSettings.put("http.proxyUserName", httpUser.getText());
242
				systemSettings.put("http.proxyPassword", httpPass.getPassword());
259
				systemSettings.put("http.proxyUserName", proxyUser);
260
				systemSettings.put("http.proxyPassword", proxyPassword);
243 261
			} else {
244 262
				systemSettings.remove("http.proxyHost");
245 263
				systemSettings.remove("http.proxyPort");
......
248 266
			}
249 267

  
250 268
			System.setProperties(systemSettings);
269
			if (proxyUser != null )
270
			{
271
				Authenticator.setDefault(new ProxyAuth(proxyUser,
272
				                                proxyPassword));
273
			} else {
274
				Authenticator.setDefault(new ProxyAuth("", ""));
275
			}
276
			
251 277
		} catch (MalformedURLException e) {
252 278
			if (httpEnabled.isSelected()) {
253 279
				throw new StoreException(PluginServices.getText(this, "options.firewall.http.incorrect_host"),e);

Also available in: Unified diff