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 172021 Details for
Bug 312228
[Net] Improve core.net authentication capabilities
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
second version of the patch
312228.txt (text/plain), 5.17 KB, created by
Krzysztof Kazmierczyk
on 2010-06-16 04:31:24 EDT
(
hide
)
Description:
second version of the patch
Filename:
MIME Type:
Creator:
Krzysztof Kazmierczyk
Created:
2010-06-16 04:31:24 EDT
Size:
5.17 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.net >Index: src/org/eclipse/ui/internal/net/Activator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/Activator.java,v >retrieving revision 1.2 >diff -u -r1.2 Activator.java >--- src/org/eclipse/ui/internal/net/Activator.java 20 Nov 2008 15:50:07 -0000 1.2 >+++ src/org/eclipse/ui/internal/net/Activator.java 16 Jun 2010 08:30:12 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007, 2008 IBM Corporation and others. >+ * Copyright (c) 2007, 2010 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 >@@ -13,8 +13,11 @@ > *******************************************************************************/ > package org.eclipse.ui.internal.net; > >+import org.eclipse.core.net.proxy.IProxyData; >+import org.eclipse.core.net.proxy.IProxyService; > import org.eclipse.ui.plugin.AbstractUIPlugin; > import org.osgi.framework.BundleContext; >+import org.osgi.framework.ServiceReference; > > /** > * The activator class controls the plug-in life cycle >@@ -27,6 +30,9 @@ > // The shared instance > private static Activator plugin; > >+ // The bundle context >+ private BundleContext context; >+ > /** > * The constructor > */ >@@ -44,12 +50,23 @@ > } > > public void start(BundleContext context) throws Exception { >- super.start(context); >+ super.start(context); >+ this.context = context; > } > > public void stop(BundleContext context) throws Exception { > plugin = null; > super.stop(context); >+ context = null; >+ } >+ >+ public IProxyData[] getProxyData() { >+ if (context == null) { >+ return null; >+ } >+ ServiceReference proxyServiceReference = context.getServiceReference(IProxyService.class.getName()); >+ IProxyService proxyService = (IProxyService) context.getService(proxyServiceReference); >+ context.ungetService(proxyServiceReference); >+ return proxyService.getProxyData(); > } >- > } >Index: src/org/eclipse/ui/internal/net/auth/NetAuthenticator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/auth/NetAuthenticator.java,v >retrieving revision 1.1 >diff -u -r1.1 NetAuthenticator.java >--- src/org/eclipse/ui/internal/net/auth/NetAuthenticator.java 26 Feb 2007 18:16:44 -0000 1.1 >+++ src/org/eclipse/ui/internal/net/auth/NetAuthenticator.java 16 Jun 2010 08:30:12 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 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,15 +10,54 @@ > *******************************************************************************/ > package org.eclipse.ui.internal.net.auth; > >-import java.net.*; >+import java.net.Authenticator; >+import java.net.InetAddress; >+import java.net.PasswordAuthentication; >+import java.util.HashSet; >+import java.util.Set; >+ >+import org.eclipse.core.net.proxy.IProxyData; >+import org.eclipse.ui.internal.net.Activator; > > public class NetAuthenticator extends Authenticator { >+ >+ /* >+ * This set stores all used proxy hosts. Hosts are stored to avoid >+ * repeatable attempts to server if proxy credentials for the server are >+ * invalid. >+ * The access to the this set must be synchronized. >+ */ >+ private Set usedProxyHosts = new HashSet(); > > /* > * @see Authenticator#getPasswordAuthentication() > */ > protected PasswordAuthentication getPasswordAuthentication() { >- // String protocol = getRequestingProtocol(); >+ IProxyData[] proxyDatas = Activator.getDefault().getProxyData(); >+ if (proxyDatas != null && proxyDatas.length > 0) { >+ for (int i = 0; i < proxyDatas.length; i++) { >+ final IProxyData iProxyData = proxyDatas[i]; >+ final String proxyHost = iProxyData.getHost(); >+ int proxyPort = iProxyData.getPort(); >+ >+ // Assuming that if proxy host and port from proxy data is the >+ // same as requesting host/port it is request for proxy >+ // authentication. >+ if (proxyHost != null && proxyHost.equals(getRequestingHost()) >+ && proxyPort == getRequestingPort()) { >+ synchronized (usedProxyHosts) { >+ if (!usedProxyHosts.contains(proxyHost)) { >+ usedProxyHosts.add(proxyHost); >+ return new PasswordAuthentication( >+ iProxyData.getUserId(), >+ iProxyData.getPassword().toCharArray()); >+ } >+ } >+ } >+ } >+ } >+ >+ // String protocol = getRequestingProtocol(); > InetAddress address = getRequestingSite(); // can be null; > // int port = getRequestingPort(); > String prompt = getRequestingPrompt(); // realm or message, not documented that can be null
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 312228
:
171414
| 172021