Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracLoginException.java10
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracXmlRpcClient.java5
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/util/TracHttpClientTransportFactory.java32
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/Messages.java2
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracRepositorySettingsPage.java10
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/messages.properties1
6 files changed, 51 insertions, 9 deletions
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracLoginException.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracLoginException.java
index 8c6f03004..d8cd62939 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracLoginException.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracLoginException.java
@@ -20,6 +20,8 @@ public class TracLoginException extends TracException {
private static final long serialVersionUID = -6128773690643367414L;
+ private boolean ntlmAuthRequested;
+
public TracLoginException() {
}
@@ -27,4 +29,12 @@ public class TracLoginException extends TracException {
super(message);
}
+ public boolean isNtlmAuthRequested() {
+ return ntlmAuthRequested;
+ }
+
+ void setNtlmAuthRequested(boolean ntlmAuthRequested) {
+ this.ntlmAuthRequested = ntlmAuthRequested;
+ }
+
}
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracXmlRpcClient.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracXmlRpcClient.java
index 72bfb9486..3d3325af1 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracXmlRpcClient.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracXmlRpcClient.java
@@ -38,6 +38,7 @@ import org.apache.commons.httpclient.auth.AuthScheme;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.auth.BasicScheme;
import org.apache.commons.httpclient.auth.DigestScheme;
+import org.apache.commons.httpclient.auth.NTLMScheme;
import org.apache.commons.httpclient.methods.HeadMethod;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
@@ -163,7 +164,9 @@ public class TracXmlRpcClient extends AbstractTracClient implements ITracWikiCli
System.err.println(location.getUrl() + ": Unauthorized (" + e.code + ")"); //$NON-NLS-1$ //$NON-NLS-2$
}
digestScheme = null;
- throw new TracLoginException();
+ TracLoginException exception = new TracLoginException();
+ exception.setNtlmAuthRequested(e.getAuthScheme() instanceof NTLMScheme);
+ throw exception;
} else if (e.code == HttpStatus.SC_FORBIDDEN) {
if (DEBUG_AUTH) {
System.err.println(location.getUrl() + ": Forbidden (" + e.code + ")"); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/util/TracHttpClientTransportFactory.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/util/TracHttpClientTransportFactory.java
index de6495258..a0b29d5b9 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/util/TracHttpClientTransportFactory.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/util/TracHttpClientTransportFactory.java
@@ -22,7 +22,9 @@ import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.HttpVersion;
+import org.apache.commons.httpclient.auth.AuthScheme;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.xmlrpc.XmlRpcException;
@@ -90,21 +92,25 @@ public class TracHttpClientTransportFactory implements XmlRpcTransportFactory {
protected InputStream getInputStream() throws XmlRpcException {
int responseCode = method.getStatusCode();
if (responseCode != HttpURLConnection.HTTP_OK) {
- throw new TracHttpException(responseCode);
+ TracHttpException e = new TracHttpException(responseCode);
+ if (responseCode == HttpStatus.SC_UNAUTHORIZED) {
+ e.setAuthScheme(method.getHostAuthState().getAuthScheme());
+ }
+ throw e;
}
try {
return method.getResponseBodyAsStream();
} catch (HttpException e) {
- throw new XmlRpcClientException("Error in HTTP transport: " + e.getMessage(), e); //$NON-NLS-1$
+ throw new XmlRpcClientException("Error in HTTP transport: " + e.getMessage(), e);
} catch (IOException e) {
- throw new XmlRpcClientException("I/O error in server communication: " + e.getMessage(), e); //$NON-NLS-1$
+ throw new XmlRpcClientException("I/O error in server communication: " + e.getMessage(), e);
}
}
@Override
protected String getUserAgent() {
- return WebUtil.getUserAgent(""); //$NON-NLS-1$
+ return WebUtil.getUserAgent("");
}
@Override
@@ -168,7 +174,7 @@ public class TracHttpClientTransportFactory implements XmlRpcTransportFactory {
}
public String getContentType() {
- return "text/xml"; //$NON-NLS-1$
+ return "text/xml";
}
public boolean isRepeatable() {
@@ -216,10 +222,10 @@ public class TracHttpClientTransportFactory implements XmlRpcTransportFactory {
if (t instanceof XmlRpcException) {
throw (XmlRpcException) t;
} else {
- throw new XmlRpcException("Unexpected exception: " + t.getMessage(), t); //$NON-NLS-1$
+ throw new XmlRpcException("Unexpected exception: " + t.getMessage(), t);
}
} catch (IOException e) {
- throw new XmlRpcException("I/O error while communicating with HTTP server: " + e.getMessage(), e); //$NON-NLS-1$
+ throw new XmlRpcException("I/O error while communicating with HTTP server: " + e.getMessage(), e);
}
}
@@ -229,8 +235,18 @@ public class TracHttpClientTransportFactory implements XmlRpcTransportFactory {
private static final long serialVersionUID = 9032521978140685830L;
+ private AuthScheme authScheme;
+
public TracHttpException(int responseCode) {
- super(responseCode, "HTTP Error " + responseCode); //$NON-NLS-1$
+ super(responseCode, "HTTP Error " + responseCode);
+ }
+
+ public AuthScheme getAuthScheme() {
+ return authScheme;
+ }
+
+ public void setAuthScheme(AuthScheme authScheme) {
+ this.authScheme = authScheme;
}
}
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/Messages.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/Messages.java
index eec8b8dcf..e6c9afe86 100644
--- a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/Messages.java
+++ b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/Messages.java
@@ -109,5 +109,7 @@ public class Messages extends NLS {
public static String TracRepositorySettingsPage_No_Trac_repository_found_at_url;
+ public static String TracRepositorySettingsPage_NTLM_authentication_requested_Error;
+
public static String TracRepositorySettingsPage_Trac_Repository_Settings;
}
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracRepositorySettingsPage.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracRepositorySettingsPage.java
index 62bbd5afe..d67a1b026 100644
--- a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracRepositorySettingsPage.java
+++ b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/TracRepositorySettingsPage.java
@@ -21,6 +21,8 @@ import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
+import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
+import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.internal.trac.core.TracClientFactory;
import org.eclipse.mylyn.internal.trac.core.TracCorePlugin;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
@@ -186,6 +188,14 @@ public class TracRepositorySettingsPage extends AbstractRepositorySettingsPage {
throw new CoreException(RepositoryStatus.createStatus(repositoryUrl, IStatus.ERROR,
TracUiPlugin.ID_PLUGIN, INVALID_REPOSITORY_URL));
} catch (TracLoginException e) {
+ if (e.isNtlmAuthRequested()) {
+ AuthenticationCredentials credentials = taskRepository.getCredentials(AuthenticationType.REPOSITORY);
+ if (!credentials.getUserName().contains("\\")) { //$NON-NLS-1$
+ throw new CoreException(
+ RepositoryStatus.createStatus(repositoryUrl, IStatus.ERROR, TracUiPlugin.ID_PLUGIN,
+ Messages.TracRepositorySettingsPage_NTLM_authentication_requested_Error));
+ }
+ }
throw new CoreException(RepositoryStatus.createStatus(repositoryUrl, IStatus.ERROR,
TracUiPlugin.ID_PLUGIN, INVALID_LOGIN));
} catch (TracPermissionDeniedException e) {
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/messages.properties b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/messages.properties
index a1b5ede07..aadda7252 100644
--- a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/messages.properties
+++ b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/wizard/messages.properties
@@ -52,4 +52,5 @@ TracRepositorySettingsPage_Authentication_credentials_valid_Update_to_latest_Xml
TracRepositorySettingsPage_Automatic__Use_Validate_Settings_=Automatic (Use Validate Settings)
TracRepositorySettingsPage_EXAMPLE_HTTP_TRAC_EDGEWALL_ORG=Example: http://trac.edgewall.org
TracRepositorySettingsPage_No_Trac_repository_found_at_url=No Trac repository found at url
+TracRepositorySettingsPage_NTLM_authentication_requested_Error=NTLM authentication failed. Verify that the username is in the format 'DOMAIN\\user' and NTLM v1 is used.
TracRepositorySettingsPage_Trac_Repository_Settings=Trac Repository Settings

Back to the top