Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 93624 Details for
Bug 214796
[Proxy] org.eclipse.core.net bundle should not require org.eclipse.core.runtime
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Sample patch for the security part - with lazy caching of login credentials
patch CoreNet Lazy.txt (text/plain), 9.01 KB, created by
Oleg Besedin
on 2008-03-26 11:55:23 EDT
(
hide
)
Description:
Sample patch for the security part - with lazy caching of login credentials
Filename:
MIME Type:
Creator:
Oleg Besedin
Created:
2008-03-26 11:55:23 EDT
Size:
9.01 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.net >Index: src/org/eclipse/core/internal/net/ProxyType.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyType.java,v >retrieving revision 1.10 >diff -u -r1.10 ProxyType.java >--- src/org/eclipse/core/internal/net/ProxyType.java 19 Feb 2008 21:06:25 -0000 1.10 >+++ src/org/eclipse/core/internal/net/ProxyType.java 26 Mar 2008 15:41:40 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >+ * Copyright (c) 2007, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -10,14 +10,15 @@ > *******************************************************************************/ > package org.eclipse.core.internal.net; > >-import java.net.MalformedURLException; >-import java.net.URL; >-import java.util.*; >+import java.util.Properties; > > import org.eclipse.core.net.proxy.IProxyData; >-import org.eclipse.core.runtime.*; >+import org.eclipse.core.runtime.Assert; > import org.eclipse.core.runtime.preferences.IEclipsePreferences; >-import org.eclipse.core.runtime.preferences.IEclipsePreferences.*; >+import org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener; >+import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; >+import org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent; >+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; > import org.eclipse.osgi.util.NLS; > import org.osgi.service.prefs.BackingStoreException; > import org.osgi.service.prefs.Preferences; >@@ -48,20 +49,7 @@ > public static final int NEVER_SET = 2; > public static int socksSystemPropertySetting; > >- /* >- * Fields used to cache authentication information in the keyring >- */ >- private static final String INFO_PROXY_USER = "user"; //$NON-NLS-1$ >- private static final String INFO_PROXY_PASS = "pass"; //$NON-NLS-1$ >- private static final URL FAKE_URL; > static { >- URL temp = null; >- try { >- temp = new URL("http://org.eclipse.core.net.proxy.auth");//$NON-NLS-1$ >- } catch (MalformedURLException e) { >- // Should never fail >- } >- FAKE_URL = temp; > String value = System.getProperty(PROP_SOCKS_SYSTEM_PROPERTY_HANDLING); > if (value == null) { > socksSystemPropertySetting = ONLY_SET_FOR_1_5_OR_LATER; >@@ -135,7 +123,6 @@ > int port = node.getInt(PREF_PROXY_PORT, -1); > boolean requiresAuth = node.getBoolean(PREF_PROXY_HAS_AUTH, false); > ProxyData proxyData = new ProxyData(type, host, port, requiresAuth); >- loadProxyAuth(proxyData); > if (verifyFlag == VERIFY_EMPTY) { > // We are initializing so verify that the system properties are empty > verifySystemPropertiesEmpty(type); >@@ -151,7 +138,6 @@ > IProxyData oldData = getProxyData(VERIFY_EQUAL); > if (oldData.equals(proxyData)) > return false; >- saveProxyAuth(proxyData); > try { > updatingPreferences = true; > updatePreferences(proxyData); >@@ -476,46 +462,6 @@ > ((IEclipsePreferences)getPreferenceNode()).addPreferenceChangeListener(this); > } > >- private Map getAuthInfo() { >- // Retrieve username and password from keyring. >- Map authInfo = Platform.getAuthorizationInfo(FAKE_URL, getName(), ""); //$NON-NLS-1$ >- return authInfo != null ? authInfo : Collections.EMPTY_MAP; >- } >- >- private void loadProxyAuth(IProxyData data) { >- Map authInfo = getAuthInfo(); >- data.setUserid((String)authInfo.get(INFO_PROXY_USER)); >- data.setPassword((String)authInfo.get(INFO_PROXY_PASS)); >- } >- >- private void saveProxyAuth(IProxyData data) { >- Map authInfo = getAuthInfo(); >- if (authInfo.size() == 0) { >- authInfo = new java.util.HashMap(4); >- } >- String proxyUser = data.getUserId(); >- if (proxyUser != null && data.getHost() != null) { >- authInfo.put(INFO_PROXY_USER, proxyUser); >- } else { >- authInfo.remove(INFO_PROXY_USER); >- } >- String proxyPass = data.getPassword(); >- if (proxyPass != null && data.getHost() != null) { >- authInfo.put(INFO_PROXY_PASS, proxyPass); >- } else { >- authInfo.remove(INFO_PROXY_PASS); >- } >- try { >- if (authInfo.isEmpty()) { >- Platform.flushAuthorizationInfo(FAKE_URL, getName(), ""); //$NON-NLS-1$ >- } else { >- Platform.addAuthorizationInfo(FAKE_URL, getName(), "", authInfo); //$NON-NLS-1$ >- } >- } catch (CoreException e) { >- Activator.logError(e.getMessage(), e); >- } >- } >- > private synchronized boolean hasJavaNetProxyClass() { > try { > Class proxyClass = Class.forName("java.net.Proxy"); //$NON-NLS-1$ >Index: src/org/eclipse/core/internal/net/ProxyData.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyData.java,v >retrieving revision 1.2 >diff -u -r1.2 ProxyData.java >--- src/org/eclipse/core/internal/net/ProxyData.java 9 Apr 2007 19:21:02 -0000 1.2 >+++ src/org/eclipse/core/internal/net/ProxyData.java 26 Mar 2008 15:41:40 -0000 >@@ -11,8 +11,21 @@ > package org.eclipse.core.internal.net; > > import org.eclipse.core.net.proxy.IProxyData; >+import org.eclipse.equinox.security.storage.ISecurePreferences; >+import org.eclipse.equinox.security.storage.SecurePreferencesFactory; >+import org.eclipse.equinox.security.storage.StorageException; > > public class ProxyData implements IProxyData { >+ >+ /** >+ * Absolute path to the node for the cached proxy information >+ */ >+ private static final String PREFERENCES_CONTEXT = "/org.eclipse.core.net.proxy.auth"; //$NON-NLS-1$ >+ /* >+ * Fields used to cache authentication information in the keyring >+ */ >+ private static final String INFO_PROXY_USER = "user"; //$NON-NLS-1$ >+ private static final String INFO_PROXY_PASS = "pass"; //$NON-NLS-1$ > > private String type; > private String host; >@@ -20,6 +33,8 @@ > private String user; > private String password; > private boolean requiresAuthentication; >+ >+ private boolean authenticationLoaded = false; > > public ProxyData(String type, String host, int port, boolean requiresAuthentication) { > this.type = type; >@@ -37,6 +52,8 @@ > } > > public String getPassword() { >+ if (!authenticationLoaded) >+ load(); > return password; > } > >@@ -49,6 +66,8 @@ > } > > public String getUserId() { >+ if (!authenticationLoaded) >+ load(); > return user; > } > >@@ -60,6 +79,16 @@ > > public void setPassword(String password) { > this.password = password; >+ >+ ISecurePreferences node = getNode(); >+ if (node == null) >+ return; >+ try { >+ node.put(INFO_PROXY_PASS, this.password, true /* store encrypted */); >+ } catch (StorageException e) { >+ Activator.logError(e.getMessage(), e); >+ return; >+ } > } > > public void setPort(int port) { >@@ -69,6 +98,16 @@ > public void setUserid(String userid) { > this.user = userid; > requiresAuthentication = userid != null; >+ >+ ISecurePreferences node = getNode(); >+ if (node == null) >+ return; >+ try { >+ node.put(INFO_PROXY_USER, this.user, true /* store encrypted */); >+ } catch (StorageException e) { >+ Activator.logError(e.getMessage(), e); >+ return; >+ } > } > > public boolean isRequiresAuthentication() { >@@ -83,4 +122,28 @@ > requiresAuthentication = false; > } > >+ private ISecurePreferences getNode() { >+ ISecurePreferences root = SecurePreferencesFactory.getDefault(); >+ if (root == null) >+ return null; >+ ISecurePreferences node = root.node(PREFERENCES_CONTEXT); >+ if (type != null && type.length() != 0) >+ return node.node(type); >+ return node; >+ } >+ >+ private void load() { >+ authenticationLoaded = true; >+ ISecurePreferences node = getNode(); >+ if (node == null) >+ return; >+ try { >+ user = node.get(INFO_PROXY_USER, null); >+ password = node.get(INFO_PROXY_PASS, null); >+ } catch (StorageException e) { >+ Activator.logError(e.getMessage(), e); >+ } >+ } >+ >+ > } >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.net/META-INF/MANIFEST.MF,v >retrieving revision 1.5 >diff -u -r1.5 MANIFEST.MF >--- META-INF/MANIFEST.MF 7 Feb 2008 11:16:35 -0000 1.5 >+++ META-INF/MANIFEST.MF 26 Mar 2008 15:41:39 -0000 >@@ -6,7 +6,8 @@ > Bundle-Activator: org.eclipse.core.internal.net.Activator > Bundle-Vendor: %PLUGIN_PROVIDER > Bundle-Localization: plugin >-Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)" >+Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)", >+ org.eclipse.equinox.security;bundle-version="[1.0.0,2.0.0)" > Eclipse-LazyStart: true > Export-Package: org.eclipse.core.internal.net;x-internal:=true, > org.eclipse.core.net.proxy
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 214796
:
86498
|
93623
| 93624 |
94562
|
96057
|
96079
|
96575