diff options
author | slewis | 2009-03-27 16:23:14 +0000 |
---|---|---|
committer | slewis | 2009-03-27 16:23:14 +0000 |
commit | 46f7b505becc15416efb1ff0a8ad857c18662f3f (patch) | |
tree | 549f86a5da85bb577b1eb7adcd3e75ab8b0ecd55 | |
parent | 44f3f24ef9ff1fee0d7c3763de4f55f791ef0c46 (diff) | |
download | org.eclipse.ecf-46f7b505becc15416efb1ff0a8ad857c18662f3f.tar.gz org.eclipse.ecf-46f7b505becc15416efb1ff0a8ad857c18662f3f.tar.xz org.eclipse.ecf-46f7b505becc15416efb1ff0a8ad857c18662f3f.zip |
Changed prefs and organized imports to eliminate * importsRelease_2_0
3 files changed, 210 insertions, 6 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/.settings/org.eclipse.jdt.ui.prefs b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 000000000..5584a826e --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,57 @@ +#Fri Mar 27 09:22:14 PDT 2009 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=_core +formatter_settings_version=11 +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=; +org.eclipse.jdt.ui.ondemandthreshold=99 +org.eclipse.jdt.ui.staticondemandthreshold=99 +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=true +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=false +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java index 8a400b812..c079a80c7 100644 --- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java +++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java @@ -8,21 +8,46 @@ ******************************************************************************/ package org.eclipse.ecf.provider.filetransfer.httpclient; -import java.io.*; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import javax.security.auth.login.LoginException; -import org.apache.commons.httpclient.*; -import org.apache.commons.httpclient.auth.*; +import org.apache.commons.httpclient.Credentials; +import org.apache.commons.httpclient.Header; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpConnection; +import org.apache.commons.httpclient.HttpException; +import org.apache.commons.httpclient.HttpState; +import org.apache.commons.httpclient.HttpVersion; +import org.apache.commons.httpclient.NTCredentials; +import org.apache.commons.httpclient.UsernamePasswordCredentials; +import org.apache.commons.httpclient.auth.AuthScheme; +import org.apache.commons.httpclient.auth.AuthScope; +import org.apache.commons.httpclient.auth.CredentialsNotAvailableException; +import org.apache.commons.httpclient.auth.CredentialsProvider; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.protocol.Protocol; import org.apache.commons.httpclient.util.DateUtil; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; import org.eclipse.ecf.core.identity.ID; -import org.eclipse.ecf.core.security.*; +import org.eclipse.ecf.core.security.Callback; +import org.eclipse.ecf.core.security.CallbackHandler; +import org.eclipse.ecf.core.security.IConnectContext; +import org.eclipse.ecf.core.security.NameCallback; +import org.eclipse.ecf.core.security.ObjectCallback; +import org.eclipse.ecf.core.security.UnsupportedCallbackException; import org.eclipse.ecf.core.util.Proxy; import org.eclipse.ecf.core.util.ProxyAddress; -import org.eclipse.ecf.filetransfer.*; +import org.eclipse.ecf.filetransfer.IFileRangeSpecification; +import org.eclipse.ecf.filetransfer.IFileTransferPausable; +import org.eclipse.ecf.filetransfer.IncomingFileTransferException; +import org.eclipse.ecf.filetransfer.InvalidFileRangeSpecificationException; import org.eclipse.ecf.filetransfer.identity.IFileID; import org.eclipse.ecf.internal.provider.filetransfer.httpclient.Activator; import org.eclipse.ecf.internal.provider.filetransfer.httpclient.Messages; diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/SslProtocolSocketFactory.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/SslProtocolSocketFactory.java new file mode 100644 index 000000000..9d467641a --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/SslProtocolSocketFactory.java @@ -0,0 +1,122 @@ +/**************************************************************************** + * Copyright (c) 2004 Composent, Inc. 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Composent, Inc. - initial API and implementation + *****************************************************************************/ + +package org.eclipse.ecf.provider.filetransfer.httpclient; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.net.UnknownHostException; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import org.apache.commons.httpclient.ConnectTimeoutException; +import org.apache.commons.httpclient.Credentials; +import org.apache.commons.httpclient.ProxyClient; +import org.apache.commons.httpclient.UsernamePasswordCredentials; +import org.apache.commons.httpclient.auth.AuthScope; +import org.apache.commons.httpclient.params.HttpConnectionParams; +import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.ecf.core.util.Proxy; +import org.eclipse.ecf.core.util.ProxyAddress; +import org.eclipse.ecf.internal.provider.filetransfer.httpclient.Activator; +import org.eclipse.ecf.internal.provider.filetransfer.httpclient.Messages; + +public class SslProtocolSocketFactory implements ProtocolSocketFactory { + + private SSLContext sslContext; + + private Proxy proxy; + + public SslProtocolSocketFactory(Proxy proxy) { + this.proxy = proxy; + } + + private SSLContext getSslContext() { + if (sslContext == null) { + try { + sslContext = SSLContext + .getInstance(Messages.SslProtocolSocketFactory_SSLContext_Instance); + sslContext.init(null, + new TrustManager[] { new HttpClientSslTrustManager() }, + null); + } catch (Exception e) { + Activator + .getDefault().log( + new Status( + IStatus.ERROR, + Activator.PLUGIN_ID, + 1111, + Messages.SslProtocolSocketFactory_Status_Create_Error, + e)); + } + } + return sslContext; + } + + public Socket createSocket(String remoteHost, int remotePort) + throws IOException, UnknownHostException { + return getSslContext().getSocketFactory().createSocket(remoteHost, + remotePort); + } + + public Socket createSocket(String remoteHost, int remotePort, + InetAddress clientHost, int clientPort) throws IOException, + UnknownHostException { + return getSslContext().getSocketFactory().createSocket(remoteHost, + remotePort, clientHost, clientPort); + } + + public Socket createSocket(String remoteHost, int remotePort, + InetAddress clientHost, int clientPort, HttpConnectionParams params) + throws IOException, UnknownHostException, ConnectTimeoutException { + if (params == null || params.getConnectionTimeout() == 0) + return getSslContext().getSocketFactory().createSocket(remoteHost, + remotePort, clientHost, clientPort); + + if (proxy != null && !Proxy.NO_PROXY.equals(proxy)) { + ProxyClient proxyClient = new ProxyClient(); + + ProxyAddress address = proxy.getAddress(); + proxyClient.getHostConfiguration().setProxy(address.getHostName(), + address.getPort()); + proxyClient.getHostConfiguration().setHost(remoteHost, remotePort); + String proxyUsername = proxy.getUsername(); + String proxyPassword = proxy.getPassword(); + if (proxyUsername != null && !proxyUsername.equals("")) { //$NON-NLS-1$ + Credentials credentials = new UsernamePasswordCredentials( + proxyUsername, proxyPassword); + AuthScope proxyAuthScope = new AuthScope(address.getHostName(), + address.getPort(), AuthScope.ANY_REALM); + proxyClient.getState().setProxyCredentials(proxyAuthScope, + credentials); + } + + ProxyClient.ConnectResponse response = proxyClient.connect(); + if (response.getSocket() != null) { + // tunnel SSL via the resultant socket + Socket sslsocket = getSslContext().getSocketFactory() + .createSocket(response.getSocket(), remoteHost, + remotePort, true); + return sslsocket; + } + } + // Direct connection + Socket socket = getSslContext().getSocketFactory().createSocket(); + socket.bind(new InetSocketAddress(clientHost, clientPort)); + socket.connect(new InetSocketAddress(remoteHost, remotePort), params + .getConnectionTimeout()); + return socket; + } + +} |