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 59343 Details for
Bug 172395
JIRA connector should support NTLM proxy authentication
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.
NTLM support for Proxy authentication
proxy-ntlm-support.patch (text/plain), 6.29 KB, created by
Steffen Pingel
on 2007-02-20 00:29:54 EST
(
hide
)
Description:
NTLM support for Proxy authentication
Filename:
MIME Type:
Creator:
Steffen Pingel
Created:
2007-02-20 00:29:54 EST
Size:
6.29 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylar.tasks.tests >Index: src/org/eclipse/mylar/tasks/tests/UrlConnectionUtilTest.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.tasks.tests/src/org/eclipse/mylar/tasks/tests/UrlConnectionUtilTest.java,v >retrieving revision 1.5 >diff -u -r1.5 UrlConnectionUtilTest.java >--- src/org/eclipse/mylar/tasks/tests/UrlConnectionUtilTest.java 7 Feb 2007 07:04:31 -0000 1.5 >+++ src/org/eclipse/mylar/tasks/tests/UrlConnectionUtilTest.java 20 Feb 2007 05:26:17 -0000 >@@ -8,8 +8,14 @@ > > package org.eclipse.mylar.tasks.tests; > >+import java.net.InetSocketAddress; >+import java.net.Proxy.Type; >+ > import junit.framework.TestCase; > >+import org.apache.commons.httpclient.NTCredentials; >+import org.apache.commons.httpclient.UsernamePasswordCredentials; >+import org.eclipse.mylar.core.net.AuthenticatedProxy; > import org.eclipse.mylar.core.net.WebClientUtil; > > public class UrlConnectionUtilTest extends TestCase { >@@ -35,5 +41,22 @@ > assertEquals("example.com", WebClientUtil.getDomain(url)); > assertEquals("", WebClientUtil.getRequestPath(url)); > } >+ >+ public void testCredentials() { >+ AuthenticatedProxy proxy = new AuthenticatedProxy(Type.HTTP, new InetSocketAddress(4567), "user", "password"); >+ UsernamePasswordCredentials credentials = (UsernamePasswordCredentials) WebClientUtil.getCredentials(proxy, new InetSocketAddress(1234)); >+ assertEquals("user", credentials.getUserName()); >+ assertEquals("password", credentials.getPassword()); >+ >+ proxy = new AuthenticatedProxy(Type.HTTP, new InetSocketAddress(4567), "domain\\user", "password"); >+ NTCredentials ntCredentials = (NTCredentials) WebClientUtil.getCredentials(proxy, new InetSocketAddress("mylar.eclipse.org", 1234)); >+ assertEquals("user", ntCredentials.getUserName()); >+ assertEquals("password", ntCredentials.getPassword()); >+ assertEquals("domain", ntCredentials.getDomain()); >+ assertEquals("mylar.eclipse.org", ntCredentials.getHost()); >+ } >+ >+ >+ > > } >#P org.eclipse.mylar >Index: src/org/eclipse/mylar/core/net/WebClientUtil.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar/src/org/eclipse/mylar/core/net/WebClientUtil.java,v >retrieving revision 1.3 >diff -u -r1.3 WebClientUtil.java >--- src/org/eclipse/mylar/core/net/WebClientUtil.java 19 Feb 2007 23:17:30 -0000 1.3 >+++ src/org/eclipse/mylar/core/net/WebClientUtil.java 20 Feb 2007 05:26:19 -0000 >@@ -17,6 +17,7 @@ > > import org.apache.commons.httpclient.Credentials; > import org.apache.commons.httpclient.HttpClient; >+import org.apache.commons.httpclient.NTCredentials; > import org.apache.commons.httpclient.UsernamePasswordCredentials; > import org.apache.commons.httpclient.auth.AuthScope; > import org.apache.commons.httpclient.params.HttpClientParams; >@@ -123,8 +124,7 @@ > client.getParams().setBooleanParameter(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, true); > client.getHttpConnectionManager().getParams().setSoTimeout(WebClientUtil.SOCKET_TIMEOUT); > client.getHttpConnectionManager().getParams().setConnectionTimeout(WebClientUtil.CONNNECT_TIMEOUT); >- >- >+ > if (proxySettings != null && !Proxy.NO_PROXY.equals(proxySettings) > && !WebClientUtil.repositoryUsesHttps(repositoryUrl) > && proxySettings.address() instanceof InetSocketAddress) { >@@ -132,8 +132,7 @@ > client.getHostConfiguration().setProxy(WebClientUtil.getDomain(address.getHostName()), address.getPort()); > if (proxySettings instanceof AuthenticatedProxy) { > AuthenticatedProxy authProxy = (AuthenticatedProxy) proxySettings; >- Credentials credentials = new UsernamePasswordCredentials(authProxy.getUserName(), authProxy >- .getPassword()); >+ Credentials credentials = getCredentials(authProxy, address); > AuthScope proxyAuthScope = new AuthScope(address.getHostName(), address.getPort(), AuthScope.ANY_REALM); > client.getState().setProxyCredentials(proxyAuthScope, credentials); > } >@@ -157,6 +156,17 @@ > } > } > >+ public static Credentials getCredentials(AuthenticatedProxy authProxy, InetSocketAddress address) { >+ String username = authProxy.getUserName(); >+ int i = username.indexOf("\\"); >+ if (i > 0 && i < username.length() - 1) { >+ return new NTCredentials(username.substring(i + 1), authProxy.getPassword(), address.getHostName(), username >+ .substring(0, i)); >+ } else { >+ return new UsernamePasswordCredentials(username, authProxy.getPassword()); >+ } >+ } >+ > /** utility method, should use TaskRepository.getProxy() */ > public static Proxy getProxy(String proxyHost, String proxyPort, String proxyUsername, String proxyPassword) { > boolean authenticated = (proxyUsername != null && proxyPassword != null && proxyUsername.length() > 0 && proxyPassword >Index: .refactorings/2007/2/8/refactorings.index >=================================================================== >RCS file: .refactorings/2007/2/8/refactorings.index >diff -N .refactorings/2007/2/8/refactorings.index >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .refactorings/2007/2/8/refactorings.index 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,1 @@ >+1171947703083 Extract method 'getCredentials' >Index: .refactorings/2007/2/8/refactorings.history >=================================================================== >RCS file: .refactorings/2007/2/8/refactorings.history >diff -N .refactorings/2007/2/8/refactorings.history >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .refactorings/2007/2/8/refactorings.history 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,4 @@ >+<?xml version="1.0" encoding="utf-8"?> >+<session version="1.0"> >+<refactoring comment="Extract method 'private static Credentials getCredentials(AuthenticatedProxy authProxy,InetSocketAddress address)' from 'org.eclipse.mylar.core.net.WebClientUtil.setupHttpClient()' to 'org.eclipse.mylar.core.net.WebClientUtil' - Original project: 'org.eclipse.mylar' - Method name: 'getCredentials' - Destination type: 'org.eclipse.mylar.core.net.WebClientUtil' - Declared visibility: 'private'" comments="false" description="Extract method 'getCredentials'" destination="0" exceptions="false" flags="786434" id="org.eclipse.jdt.ui.extract.method" input="/src<org.eclipse.mylar.core.net{WebClientUtil.java" name="getCredentials" replace="false" selection="4895 379" stamp="1171947703083" version="1.0" visibility="2"/> >+</session>
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 Raw
Actions:
View
Attachments on
bug 172395
: 59343 |
59344