Revision 8884

View differences:

trunk/frameworks/_fwAndami/src/com/iver/andami/Launcher.java
61 61
import java.io.InputStreamReader;
62 62
import java.io.Reader;
63 63
import java.lang.reflect.InvocationTargetException;
64
import java.net.Authenticator;
64 65
import java.net.MalformedURLException;
66
import java.net.PasswordAuthentication;
65 67
import java.net.URL;
66 68
import java.net.URLConnection;
67 69
import java.security.AllPermission;
......
78 80
import java.util.Locale;
79 81
import java.util.Properties;
80 82
import java.util.TreeMap;
83
import java.util.prefs.Preferences;
81 84

  
82 85
import javax.jnlp.BasicService;
83 86
import javax.jnlp.ServiceManager;
......
137 140
 */
138 141
public class Launcher {
139 142
	private static Logger logger = Logger.getLogger(Launcher.class.getName());
143
	private static Preferences prefs = Preferences.userRoot().node( "gvsig.connection" );
140 144
	private static AndamiConfig andamiConfig;
141 145
	private static MultiSplashWindow splashWindow;
142 146
	private static String appName;
......
152 156
    private static ArrayList pluginsOrdered = new ArrayList();
153 157
    private static ArrayList extensions=new ArrayList();
154 158
    private static String appHomeDir = null;
159
    
160
	private static final class ProxyAuth extends Authenticator {
161
		private PasswordAuthentication auth;
162

  
163
		private ProxyAuth(String user, String pass) {
164
			auth = new PasswordAuthentication(user, pass.toCharArray());
165
		}
166

  
167
		protected PasswordAuthentication getPasswordAuthentication() {
168
			return auth;
169
		}
170
	}
171

  
155 172
	/**
156 173
	 * DOCUMENT ME!
157 174
	 *
......
245 262
    		// Mostrar la ventana de inicio
246 263
    		Frame f=new Frame();
247 264
    		splashWindow=new MultiSplashWindow(f);
265
    		
266
    		// Ponemos los datos del proxy
267
    		String host = prefs.get("firewall.http.host", "");
268
			String port = prefs.get("firewall.http.port", "");
248 269

  
270
			System.getProperties().put("http.proxyHost", host);
271
			System.getProperties().put("http.proxyPort", port);
272

  
273
    		// Ponemos el usuario y clave del proxy, si existe    		
274
    		String proxyUser = prefs.get("firewall.http.user",null);
275
    		String proxyPassword = prefs.get("firewall.http.password", null);
276
			if (proxyUser != null )
277
			{
278
				System.getProperties().put("http.proxyUserName", proxyUser);
279
				System.getProperties().put("http.proxyPassword", proxyPassword);
280

  
281
				Authenticator.setDefault(new ProxyAuth(proxyUser,
282
				                                proxyPassword));
283
			} else {
284
				Authenticator.setDefault(new ProxyAuth("", ""));
285
			}
286
    		
287

  
249 288
    		// TODO Buscar actualizaciones de los plugins
250 289
    		downloadExtensions(andamiConfig.getPluginsDirectory());
251 290

  
trunk/libraries/libCorePlugin/src/com/iver/core/preferences/network/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);
trunk/libraries/libCorePlugin/src/com/iver/core/preferences/network/NetworkPage.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.8  2006-09-12 10:11:25  jaume
46
* Revision 1.9  2006-11-20 17:29:43  fjp
47
* Fallo proxy con usuario y contrase?a
48
*
49
* Revision 1.8  2006/09/12 10:11:25  jaume
47 50
* *** empty log message ***
48 51
*
49 52
* Revision 1.7.4.1  2006/09/08 11:56:24  jaume
......
97 100

  
98 101
import java.awt.event.ActionEvent;
99 102
import java.awt.event.ActionListener;
103
import java.net.Authenticator;
104
import java.net.PasswordAuthentication;
100 105
import java.net.URL;
101 106

  
102 107
import javax.swing.ImageIcon;
......
119 124
	private JLabel lblNetworkStatus;
120 125
	private JToolBarButton btnRefresh;
121 126
	protected static String id;
127
	
122 128

  
123 129
	public NetworkPage() {
124 130
		super();

Also available in: Unified diff