diff options
author | spingel | 2011-05-23 23:17:20 +0000 |
---|---|---|
committer | spingel | 2011-05-23 23:17:20 +0000 |
commit | 6e09047310b6697daa9af5b0776fd133eae5aaf5 (patch) | |
tree | a33bbe8bc410929e899ccbcbeb122b7245e32b52 /org.eclipse.mylyn.trac.core | |
parent | 0ac6a4ddb230533230ec21afa06125a67189d768 (diff) | |
download | org.eclipse.mylyn.tasks-6e09047310b6697daa9af5b0776fd133eae5aaf5.tar.gz org.eclipse.mylyn.tasks-6e09047310b6697daa9af5b0776fd133eae5aaf5.tar.xz org.eclipse.mylyn.tasks-6e09047310b6697daa9af5b0776fd133eae5aaf5.zip |
RESOLVED - bug 295050: [api] request enhanced support of client-certificates
https://bugs.eclipse.org/bugs/show_bug.cgi?id=295050
Diffstat (limited to 'org.eclipse.mylyn.trac.core')
5 files changed, 54 insertions, 1 deletions
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/AbstractTracClient.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/AbstractTracClient.java index 4f575e831..c9246a9c5 100644 --- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/AbstractTracClient.java +++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/AbstractTracClient.java @@ -44,6 +44,11 @@ import org.eclipse.mylyn.internal.trac.core.model.TracVersion; */ public abstract class AbstractTracClient implements ITracClient { + /** + * Artificial status code to indicate that SSL cert authentication failed. + */ + public static final int SC_CERT_AUTH_FAILED = 499; + protected static final boolean DEBUG_AUTH = Boolean.valueOf(Platform.getDebugOption("org.eclipse.mylyn.trac.core/debug/authentication")); //$NON-NLS-1$ protected static final String USER_AGENT = "TracConnector"; //$NON-NLS-1$ diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracSslCertificateException.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracSslCertificateException.java new file mode 100644 index 000000000..519ee1adc --- /dev/null +++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracSslCertificateException.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2011 Tasktop Technologies. + * 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Tasktop Technologies - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylyn.internal.trac.core.client; + +/** + * @author Steffen Pingel + */ +public class TracSslCertificateException extends TracException { + + private static final long serialVersionUID = -693879319319751584L; + + public TracSslCertificateException() { + super("Opening of the certificate keystore failed"); + } + +} diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracWebClient.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracWebClient.java index dcef06aa1..1554ab944 100644 --- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracWebClient.java +++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracWebClient.java @@ -48,6 +48,7 @@ import org.eclipse.mylyn.commons.net.HtmlStreamTokenizer; import org.eclipse.mylyn.commons.net.HtmlStreamTokenizer.Token; import org.eclipse.mylyn.commons.net.HtmlTag; import org.eclipse.mylyn.commons.net.Policy; +import org.eclipse.mylyn.commons.net.SslCertificateException; import org.eclipse.mylyn.commons.net.UnsupportedRequestException; import org.eclipse.mylyn.commons.net.WebUtil; import org.eclipse.mylyn.internal.trac.core.TracCorePlugin; @@ -157,6 +158,11 @@ public class TracWebClient extends AbstractTracClient { if (needsReauthentication(code, monitor)) { continue; } + } catch (SslCertificateException e) { + if (needsReauthentication(SC_CERT_AUTH_FAILED, monitor)) { + continue; + } + throw e; } finally { WebUtil.releaseConnection(method, monitor); } @@ -183,6 +189,8 @@ public class TracWebClient extends AbstractTracClient { authenticationType = AuthenticationType.REPOSITORY; } else if (code == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) { authenticationType = AuthenticationType.PROXY; + } else if (code == SC_CERT_AUTH_FAILED) { + authenticationType = AuthenticationType.CERTIFICATE; } else { return false; } 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 9d687d313..6440cf6e8 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 @@ -232,6 +232,11 @@ public class TracXmlRpcClient extends AbstractTracClient implements ITracWikiCli System.err.println(location.getUrl() + ": Proxy authentication required (" + code + ")"); //$NON-NLS-1$ //$NON-NLS-2$ } throw new TracProxyAuthenticationException(); + } else if (code == SC_CERT_AUTH_FAILED) { + if (DEBUG_AUTH) { + System.err.println(location.getUrl() + ": Certificate authentication failed (" + code + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + } + throw new TracSslCertificateException(); } return false; } @@ -474,6 +479,13 @@ public class TracXmlRpcClient extends AbstractTracClient implements ITracWikiCli throw e; } lastException = e; + } catch (TracSslCertificateException e) { + try { + location.requestCredentials(AuthenticationType.CERTIFICATE, null, monitor); + } catch (UnsupportedRequestException ignored) { + throw e; + } + lastException = e; } } if (lastException != null) { 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 74b67212b..84e08ebb0 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 @@ -40,7 +40,9 @@ import org.apache.xmlrpc.util.HttpUtil; import org.apache.xmlrpc.util.XmlRpcIOException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.mylyn.commons.net.AbstractWebLocation; +import org.eclipse.mylyn.commons.net.SslCertificateException; import org.eclipse.mylyn.commons.net.WebUtil; +import org.eclipse.mylyn.internal.trac.core.client.AbstractTracClient; import org.xml.sax.SAXException; /** @@ -224,11 +226,12 @@ public class TracHttpClientTransportFactory implements XmlRpcTransportFactory { } else { throw new XmlRpcException("Unexpected exception: " + t.getMessage(), t); //$NON-NLS-1$ } + } catch (SslCertificateException e) { + throw new TracHttpException(AbstractTracClient.SC_CERT_AUTH_FAILED); } catch (IOException e) { throw new XmlRpcException("I/O error while communicating with HTTP server: " + e.getMessage(), e); //$NON-NLS-1$ } } - } public static class TracHttpException extends XmlRpcException { |