org.eclipse.ecf.provider.filetransfer.httpclient_4.0.200.v20120610-1946

16:43:11.268 INFO  jd.cli.Main - Decompiling org.eclipse.ecf.provider.filetransfer.httpclient_4.0.200.v20120610-1946.jar
package org.eclipse.ecf.internal.provider.filetransfer.httpclient;

import javax.net.ssl.SSLSocketFactory;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ecf.core.util.LogHelper;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.service.log.LogService;
import org.osgi.util.tracker.ServiceTracker;

public class Activator
  implements BundleActivator
{
  public static final String PLUGIN_ID = "org.eclipse.ecf.provider.filetransfer.httpclient";
  private static Activator plugin;
  private BundleContext context = null;
  private ServiceTracker logServiceTracker = null;
  private ServiceTracker sslSocketFactoryTracker;
  private ISSLSocketFactoryModifier sslSocketFactoryModifier;
  private ConnectionManagerHelper cmHelper;
  
  public BundleContext getContext()
  {
    return context;
  }
  
  public void start(BundleContext ctxt)
    throws Exception
  {
    plugin = this;
    context = ctxt;
    try
    {
      Class socketFactoryModifierClass = Class.forName("org.eclipse.ecf.internal.provider.filetransfer.httpclient.ssl.SSLSocketFactoryModifier");
      sslSocketFactoryModifier = ((ISSLSocketFactoryModifier)socketFactoryModifierClass.newInstance());
    }
    catch (ClassNotFoundException localClassNotFoundException) {}catch (Throwable t)
    {
      log(new Status(4, "org.eclipse.ecf.provider.filetransfer.httpclient", "Unexpected Error in Activator.start", t));
    }
  }
  
  public ConnectionManagerHelper getConnectionManagerHelper()
  {
    if (cmHelper == null) {
      cmHelper = new ConnectionManagerHelper();
    }
    return cmHelper;
  }
  
  public ISSLSocketFactoryModifier getSSLSocketFactoryModifier()
  {
    return sslSocketFactoryModifier;
  }
  
  public void stop(BundleContext ctxt)
    throws Exception
  {
    if (sslSocketFactoryModifier != null)
    {
      sslSocketFactoryModifier.dispose();
      sslSocketFactoryModifier = null;
    }
    if (sslSocketFactoryTracker != null) {
      sslSocketFactoryTracker.close();
    }
    if (logServiceTracker != null) {
      logServiceTracker.close();
    }
    if (cmHelper != null) {
      cmHelper.shutdown();
    }
    context = null;
    plugin = null;
  }
  
  public static synchronized Activator getDefault()
  {
    if (plugin == null) {
      plugin = new Activator();
    }
    return plugin;
  }
  
  protected LogService getLogService()
  {
    if (logServiceTracker == null)
    {
      logServiceTracker = new ServiceTracker(context, LogService.class.getName(), null);
      logServiceTracker.open();
    }
    return (LogService)logServiceTracker.getService();
  }
  
  public void log(IStatus status)
  {
    LogService logService = getLogService();
    if (logService != null) {
      logService.log(LogHelper.getLogCode(status), LogHelper.getLogMessage(status), status.getException());
    }
  }
  
  public SSLSocketFactory getSSLSocketFactory()
  {
    if (sslSocketFactoryTracker == null)
    {
      sslSocketFactoryTracker = new ServiceTracker(context, SSLSocketFactory.class.getName(), null);
      sslSocketFactoryTracker.open();
    }
    return (SSLSocketFactory)sslSocketFactoryTracker.getService();
  }
  
  public static void logNoProxyWarning(Throwable e)
  {
    Activator a = getDefault();
    if (a != null) {
      a.log(new Status(2, "org.eclipse.ecf.provider.filetransfer.httpclient", 4, "Warning: Platform proxy API not available", e));
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.internal.provider.filetransfer.httpclient.Activator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.internal.provider.filetransfer.httpclient;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.ecf.filetransfer.events.socket.ISocketClosedEvent;
import org.eclipse.ecf.filetransfer.events.socket.ISocketConnectedEvent;
import org.eclipse.ecf.filetransfer.events.socket.ISocketCreatedEvent;
import org.eclipse.ecf.filetransfer.events.socket.ISocketEvent;
import org.eclipse.ecf.filetransfer.events.socket.ISocketListener;

public class ConnectingSocketMonitor
  implements ISocketListener
{
  private Map connectingSockets;
  
  public ConnectingSocketMonitor(int initialCapacity)
  {
    connectingSockets = Collections.synchronizedMap(new HashMap(initialCapacity));
  }
  
  public ConnectingSocketMonitor()
  {
    connectingSockets = Collections.synchronizedMap(new HashMap());
  }
  
  public Collection getConnectingSockets()
  {
    return Collections.unmodifiableCollection(connectingSockets.keySet());
  }
  
  public void clear()
  {
    connectingSockets.clear();
  }
  
  public void handleSocketEvent(ISocketEvent event)
  {
    if ((event instanceof ISocketCreatedEvent)) {
      connectingSockets.put(event.getFactorySocket(), event);
    } else if ((event instanceof ISocketConnectedEvent)) {
      connectingSockets.remove(event.getFactorySocket());
    } else if ((event instanceof ISocketClosedEvent)) {
      connectingSockets.remove(event.getFactorySocket());
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.internal.provider.filetransfer.httpclient.ConnectingSocketMonitor
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.internal.provider.filetransfer.httpclient;

import java.util.Map;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpConnectionManager;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.params.HttpClientParams;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.eclipse.ecf.core.util.Trace;
import org.eclipse.ecf.filetransfer.IRetrieveFileTransferOptions;
import org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientOptions;

public class ConnectionManagerHelper
{
  public static final int DEFAULT_CONNECTION_TIMEOUT = HttpClientOptions.RETRIEVE_DEFAULT_CONNECTION_TIMEOUT;
  public static final int DEFAULT_READ_TIMEOUT = HttpClientOptions.RETRIEVE_DEFAULT_READ_TIMEOUT;
  private MultiThreadedHttpConnectionManager connectionManager;
  
  private static int getIntegerProperty(String prop, int intDefault)
  {
    int retVal = intDefault;
    String systemProp = System.getProperty(prop);
    if (systemProp != null) {
      try
      {
        retVal = Integer.parseInt(systemProp);
      }
      catch (NumberFormatException e)
      {
        Trace.trace("org.eclipse.ecf.provider.filetransfer.httpclient", "Bad value for property '" + prop + "' : " + e + ". Using default value " + intDefault + ".");
      }
    }
    return retVal;
  }
  
  private static long getLongProperty(String prop, long longDefault)
  {
    long retVal = longDefault;
    String systemProp = System.getProperty(prop);
    if (systemProp != null) {
      try
      {
        retVal = Long.parseLong(systemProp);
      }
      catch (NumberFormatException e)
      {
        Trace.trace("org.eclipse.ecf.provider.filetransfer.httpclient", "Bad value for property '" + prop + "' : " + e + ". Using default value " + longDefault + ".");
      }
    }
    return retVal;
  }
  
  private static boolean shouldReuseConnectionsOption()
  {
    boolean retVal = true;
    String systemProp = System.getProperty("org.eclipse.ecf.provider.filetransfer.httpclient.reuseConnections.enabled");
    if (systemProp != null) {
      retVal = Boolean.valueOf(systemProp).booleanValue();
    }
    return retVal;
  }
  
  public static int getConnectTimeout(Map options)
  {
    int result = DEFAULT_CONNECTION_TIMEOUT;
    Map localOptions = options;
    if (localOptions != null)
    {
      Object o = localOptions.get(IRetrieveFileTransferOptions.CONNECT_TIMEOUT);
      if (o != null)
      {
        if ((o instanceof Integer)) {
          result = ((Integer)o).intValue();
        } else if ((o instanceof String)) {
          result = new Integer((String)o).intValue();
        }
        return result;
      }
      o = localOptions.get("org.eclipse.ecf.provider.filetransfer.httpclient.retrieve.connectTimeout");
      if (o != null) {
        if ((o instanceof Integer)) {
          result = ((Integer)o).intValue();
        } else if ((o instanceof String)) {
          result = new Integer((String)o).intValue();
        }
      }
    }
    return result;
  }
  
  public static int getSocketReadTimeout(Map options)
  {
    int result = DEFAULT_READ_TIMEOUT;
    Map localOptions = options;
    if (localOptions != null)
    {
      Object o = localOptions.get(IRetrieveFileTransferOptions.READ_TIMEOUT);
      if (o != null)
      {
        if ((o instanceof Integer)) {
          result = ((Integer)o).intValue();
        } else if ((o instanceof String)) {
          result = new Integer((String)o).intValue();
        }
        return result;
      }
      o = localOptions.get("org.eclipse.ecf.provider.filetransfer.httpclient.retrieve.readTimeout");
      if (o != null) {
        if ((o instanceof Integer)) {
          result = ((Integer)o).intValue();
        } else if ((o instanceof String)) {
          result = new Integer((String)o).intValue();
        }
      }
    }
    return result;
  }
  
  public synchronized void initConnectionManager(HttpClient httpClient, Map options)
  {
    if (!shouldReuseConnectionsOption())
    {
      Trace.trace("org.eclipse.ecf.provider.filetransfer.httpclient", "Connections are not reused. To reuse connections set system property 'org.eclipse.ecf.provider.filetransfer.httpclient.reuseConnections.enabled' to true.");
      initParameters(httpClient, new MultiThreadedHttpConnectionManager(), false, options);
      return;
    }
    if (connectionManager == null)
    {
      connectionManager = new MultiThreadedHttpConnectionManager();
      Trace.trace("org.eclipse.ecf.provider.filetransfer.httpclient", "Created shared connection manager.");
    }
    else
    {
      Trace.trace("org.eclipse.ecf.provider.filetransfer.httpclient", "Reusing shared connection manager.");
    }
    initParameters(httpClient, connectionManager, true, options);
  }
  
  private static void initParameters(HttpClient httpClient, HttpConnectionManager cm, boolean cmIsShared, Map options)
  {
    if (cmIsShared)
    {
      long closeIdlePeriod = getLongProperty("org.eclipse.ecf.provider.filetransfer.httpclient.poolCloseIdle", 180000L);
      if (closeIdlePeriod > 0L)
      {
        Trace.trace("org.eclipse.ecf.provider.filetransfer.httpclient", "Closing connections which were idle at least " + closeIdlePeriod + " milliseconds.");
        cm.closeIdleConnections(closeIdlePeriod);
      }
    }
    httpClient.setHttpConnectionManager(cm);
    int readTimeout = getSocketReadTimeout(options);
    cm.getParams().setSoTimeout(readTimeout);
    int connectTimeout = getConnectTimeout(options);
    cm.getParams().setConnectionTimeout(connectTimeout);
    if (cmIsShared)
    {
      HttpConnectionManagerParams cmParams = cm.getParams();
      int maxHostConnections = getIntegerProperty("org.eclipse.ecf.provider.filetransfer.httpclient.maxConnectionsPerHost", 4);
      int maxTotalConnections = getIntegerProperty("org.eclipse.ecf.provider.filetransfer.httpclient.maxConnectionsTotal", 200);
      
      cmParams.setDefaultMaxConnectionsPerHost(maxHostConnections);
      cmParams.setMaxTotalConnections(maxTotalConnections);
      long connectionManagerTimeout = getLongProperty("org.eclipse.ecf.provider.filetransfer.httpclient.poolConnectionTimeout", 0L);
      httpClient.getParams().setConnectionManagerTimeout(connectionManagerTimeout);
    }
  }
  
  public synchronized void shutdown()
  {
    if (connectionManager != null)
    {
      connectionManager.shutdown();
      connectionManager = null;
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.internal.provider.filetransfer.httpclient.ConnectionManagerHelper
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.internal.provider.filetransfer.httpclient;

public abstract interface ConnectionOptions
{
  public static final String PROP_REUSE_CONNECTIONS = "org.eclipse.ecf.provider.filetransfer.httpclient.reuseConnections.enabled";
  public static final boolean REUSE_CONNECTIONS_DEFAULT = true;
  public static final String PROP_MAX_TOTAL_CONNECTIONS = "org.eclipse.ecf.provider.filetransfer.httpclient.maxConnectionsTotal";
  public static final int MAX_TOTAL_CONNECTIONS_DEFAULT = 200;
  public static final String PROP_MAX_CONNECTIONS_PER_HOST = "org.eclipse.ecf.provider.filetransfer.httpclient.maxConnectionsPerHost";
  public static final int MAX_CONNECTIONS_PER_HOST_DEFAULT = 4;
  public static final String PROP_POOL_CONNECTION_TIMEOUT = "org.eclipse.ecf.provider.filetransfer.httpclient.poolConnectionTimeout";
  public static final long POOL_CONNECTION_TIMEOUT_DEFAULT = 0L;
  public static final String PROP_POOL_CLOSE_IDLE_PERIOD = "org.eclipse.ecf.provider.filetransfer.httpclient.poolCloseIdle";
  public static final long POOL_CLOSE_IDLE_PERIOD_DEFAULT = 180000L;
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.internal.provider.filetransfer.httpclient.ConnectionOptions
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.internal.provider.filetransfer.httpclient;

public abstract interface DebugOptions
{
  public static final String DEBUG = "org.eclipse.ecf.provider.filetransfer.httpclient/debug";
  public static final String EXCEPTIONS_CATCHING = "org.eclipse.ecf.provider.filetransfer.httpclient/debug/exceptions/catching";
  public static final String EXCEPTIONS_THROWING = "org.eclipse.ecf.provider.filetransfer.httpclient/debug/exceptions/throwing";
  public static final String METHODS_ENTERING = "org.eclipse.ecf.provider.filetransfer.httpclient/debug/methods/entering";
  public static final String METHODS_EXITING = "org.eclipse.ecf.provider.filetransfer.httpclient/debug/methods/exiting";
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.internal.provider.filetransfer.httpclient.DebugOptions
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.internal.provider.filetransfer.httpclient;

import org.eclipse.ecf.filetransfer.events.socket.ISocketEvent;
import org.eclipse.ecf.filetransfer.events.socket.ISocketListener;

class ECFHttpClientProtocolSocketFactory$1
  implements ISocketListener
{
  public void handleSocketEvent(ISocketEvent event) {}
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.internal.provider.filetransfer.httpclient.ECFHttpClientProtocolSocketFactory.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.internal.provider.filetransfer.httpclient;

import java.io.IOException;
import java.net.Socket;
import javax.net.SocketFactory;
import org.eclipse.ecf.filetransfer.events.socketfactory.INonconnectedSocketFactory;

class ECFHttpClientProtocolSocketFactory$2
  implements INonconnectedSocketFactory
{
  private final SocketFactory val$socketFactory;
  
  ECFHttpClientProtocolSocketFactory$2(SocketFactory paramSocketFactory)
  {
    val$socketFactory = paramSocketFactory;
  }
  
  public Socket createSocket()
    throws IOException
  {
    return val$socketFactory.createSocket();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.internal.provider.filetransfer.httpclient.ECFHttpClientProtocolSocketFactory.2
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.internal.provider.filetransfer.httpclient;

import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import javax.net.SocketFactory;
import org.apache.commons.httpclient.params.HttpConnectionParams;
import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
import org.eclipse.core.runtime.Assert;
import org.eclipse.ecf.filetransfer.events.socket.ISocketEvent;
import org.eclipse.ecf.filetransfer.events.socket.ISocketEventSource;
import org.eclipse.ecf.filetransfer.events.socket.ISocketListener;
import org.eclipse.ecf.filetransfer.events.socketfactory.INonconnectedSocketFactory;
import org.eclipse.ecf.provider.filetransfer.events.socket.SocketEventCreateUtil;

public class ECFHttpClientProtocolSocketFactory
  implements ProtocolSocketFactory
{
  protected ISocketEventSource source;
  private INonconnectedSocketFactory unconnectedFactory;
  private ISocketListener socketConnectListener;
  private static final ISocketListener NULL_SOCKET_EVENT_LISTENER = new ISocketListener()
  {
    public void handleSocketEvent(ISocketEvent event) {}
  };
  
  public ECFHttpClientProtocolSocketFactory(INonconnectedSocketFactory unconnectedFactory, ISocketEventSource source, ISocketListener socketConnectListener)
  {
    Assert.isNotNull(unconnectedFactory);
    Assert.isNotNull(source);
    this.unconnectedFactory = unconnectedFactory;
    this.source = source;
    this.socketConnectListener = (socketConnectListener != null ? socketConnectListener : NULL_SOCKET_EVENT_LISTENER);
  }
  
  public ECFHttpClientProtocolSocketFactory(SocketFactory socketFactory, ISocketEventSource source, ISocketListener socketConnectListener)
  {
    this(new INonconnectedSocketFactory()
    {
      public Socket createSocket()
        throws IOException
      {
        return ECFHttpClientProtocolSocketFactory.this.createSocket();
      }
    }, source, socketConnectListener);
  }
  
  public Socket createSocket(String host, int port, InetAddress clientHost, int clientPort)
    throws IOException, UnknownHostException
  {
    InetSocketAddress remoteInetAddress = new InetSocketAddress(host, port);
    InetSocketAddress localInetAddress = new InetSocketAddress(clientHost, clientPort);
    return createSocket(remoteInetAddress, localInetAddress, 0);
  }
  
  public Socket createSocket(String host, int port, InetAddress localAddress, int localPort, HttpConnectionParams params)
    throws IOException, UnknownHostException, SocketTimeoutException
  {
    InetSocketAddress remoteInetAddress = new InetSocketAddress(host, port);
    InetSocketAddress localInetAddress = new InetSocketAddress(localAddress, localPort);
    return createSocket(remoteInetAddress, localInetAddress, params);
  }
  
  private Socket createSocket(InetSocketAddress remoteInetAddress, InetSocketAddress localInetAddress, HttpConnectionParams params)
    throws IOException, UnknownHostException, SocketTimeoutException
  {
    if (params == null) {
      throw new IllegalArgumentException("Parameters may not be null");
    }
    int timeout = params.getConnectionTimeout();
    return createSocket(remoteInetAddress, localInetAddress, timeout);
  }
  
  protected Socket createSocket()
    throws IOException
  {
    return unconnectedFactory.createSocket();
  }
  
  private Socket createSocket(InetSocketAddress remoteInetAddress, InetSocketAddress localInetAddress, int timeout)
    throws IOException
  {
    return SocketEventCreateUtil.createSocket(socketConnectListener, source, unconnectedFactory, remoteInetAddress, localInetAddress, timeout);
  }
  
  public Socket createSocket(String host, int port)
    throws IOException, UnknownHostException
  {
    InetSocketAddress remoteInetAddress = host != null ? new InetSocketAddress(host, port) : new InetSocketAddress(InetAddress.getByName(null), port);
    InetSocketAddress localInetAddress = new InetSocketAddress(0);
    return createSocket(remoteInetAddress, localInetAddress, 0);
  }
  
  public boolean equals(Object obj)
  {
    return (obj != null) && (obj.getClass().equals(ECFHttpClientProtocolSocketFactory.class));
  }
  
  public int hashCode()
  {
    return ECFHttpClientProtocolSocketFactory.class.hashCode();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.internal.provider.filetransfer.httpclient.ECFHttpClientProtocolSocketFactory
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.internal.provider.filetransfer.httpclient;

import java.io.IOException;
import java.net.Socket;
import org.eclipse.ecf.filetransfer.events.socketfactory.INonconnectedSocketFactory;

class ECFHttpClientSecureProtocolSocketFactory$1
  implements INonconnectedSocketFactory
{
  private final ISSLSocketFactoryModifier val$sslSocketFactoryModifier;
  
  ECFHttpClientSecureProtocolSocketFactory$1(ISSLSocketFactoryModifier paramISSLSocketFactoryModifier)
  {
    val$sslSocketFactoryModifier = paramISSLSocketFactoryModifier;
  }
  
  public Socket createSocket()
    throws IOException
  {
    return val$sslSocketFactoryModifier.getNonconnnectedSocketFactory().createSocket();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.internal.provider.filetransfer.httpclient.ECFHttpClientSecureProtocolSocketFactory.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.internal.provider.filetransfer.httpclient;

import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import javax.net.ssl.SSLSocketFactory;
import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
import org.eclipse.ecf.filetransfer.events.socket.ISocketEventSource;
import org.eclipse.ecf.filetransfer.events.socket.ISocketListener;
import org.eclipse.ecf.filetransfer.events.socketfactory.INonconnectedSocketFactory;

public final class ECFHttpClientSecureProtocolSocketFactory
  extends ECFHttpClientProtocolSocketFactory
  implements SecureProtocolSocketFactory
{
  private ISSLSocketFactoryModifier sslSocketFactoryModifier;
  
  public ECFHttpClientSecureProtocolSocketFactory(ISSLSocketFactoryModifier sslSocketFactoryModifier, ISocketEventSource source, ISocketListener socketConnectListener)
  {
    super(new INonconnectedSocketFactory()
    {
      public Socket createSocket()
        throws IOException
      {
        return getNonconnnectedSocketFactory().createSocket();
      }
    }, source, socketConnectListener);
    
    this.sslSocketFactoryModifier = sslSocketFactoryModifier;
  }
  
  public boolean equals(Object obj)
  {
    return (obj != null) && (obj.getClass().equals(ECFHttpClientSecureProtocolSocketFactory.class));
  }
  
  public int hashCode()
  {
    return ECFHttpClientSecureProtocolSocketFactory.class.hashCode();
  }
  
  public Socket createSocket(Socket socket, String host, int port, boolean autoClose)
    throws IOException, UnknownHostException
  {
    SSLSocketFactory sslSocketFactory = sslSocketFactoryModifier.getSSLSocketFactory();
    return sslSocketFactory.createSocket(socket, host, port, autoClose);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.internal.provider.filetransfer.httpclient.ECFHttpClientSecureProtocolSocketFactory
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.internal.provider.filetransfer.httpclient;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScheme;
import org.apache.commons.httpclient.auth.CredentialsNotAvailableException;
import org.apache.commons.httpclient.auth.CredentialsProvider;
import org.eclipse.ecf.core.util.Proxy;

public abstract class HttpClientProxyCredentialProvider
  implements CredentialsProvider
{
  private Collection provided;
  
  protected abstract Proxy getECFProxy();
  
  protected abstract Credentials getNTLMCredentials(Proxy paramProxy);
  
  public HttpClientProxyCredentialProvider()
  {
    provided = new HashSet();
  }
  
  private Object makeProvidedKey(AuthScheme scheme, String host, int port, boolean isProxyAuthenticating)
  {
    ArrayList list = new ArrayList(3);
    list.add(host);
    list.add(new Integer(port));
    list.add(Boolean.valueOf(isProxyAuthenticating));
    return list;
  }
  
  public Credentials getCredentials(AuthScheme scheme, String host, int port, boolean isProxyAuthenticating)
    throws CredentialsNotAvailableException
  {
    if (!isProxyAuthenticating) {
      return null;
    }
    Proxy proxy = getECFProxy();
    if (proxy == null) {
      return null;
    }
    Object provideKey = makeProvidedKey(scheme, host, port, isProxyAuthenticating);
    if (provided.contains(provideKey)) {
      return null;
    }
    provided.add(provideKey);
    if ("ntlm".equalsIgnoreCase(scheme.getSchemeName())) {
      return getNTLMCredentials(proxy);
    }
    if (("basic".equalsIgnoreCase(scheme.getSchemeName())) || 
      ("digest".equalsIgnoreCase(scheme.getSchemeName())))
    {
      String proxyUsername = proxy.getUsername();
      String proxyPassword = proxy.getPassword();
      if (proxyUsername != null)
      {
        Credentials credentials = new UsernamePasswordCredentials(proxyUsername, proxyPassword);
        return credentials;
      }
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.internal.provider.filetransfer.httpclient.HttpClientProxyCredentialProvider
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.internal.provider.filetransfer.httpclient;

import java.io.IOException;
import javax.net.ssl.SSLSocketFactory;
import org.eclipse.ecf.filetransfer.events.socketfactory.INonconnectedSocketFactory;

public abstract interface ISSLSocketFactoryModifier
{
  public abstract SSLSocketFactory getSSLSocketFactory()
    throws IOException;
  
  public abstract INonconnectedSocketFactory getNonconnnectedSocketFactory();
  
  public abstract void dispose();
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.internal.provider.filetransfer.httpclient.ISSLSocketFactoryModifier
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.internal.provider.filetransfer.httpclient;

import java.io.IOException;
import java.net.Socket;

public abstract interface ISocketConnectionCallback
{
  public abstract void onSocketCreated(Socket paramSocket);
  
  public abstract void onSocketConnected(Socket paramSocket);
  
  public abstract void onSocketConnectionFailed(Socket paramSocket, IOException paramIOException);
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.internal.provider.filetransfer.httpclient.ISocketConnectionCallback
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.internal.provider.filetransfer.httpclient;

import org.eclipse.osgi.util.NLS;

public class Messages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.ecf.internal.provider.filetransfer.httpclient.messages";
  public static String FileTransferNamespace_Http_Protocol;
  public static String FileTransferNamespace_Https_Protocol;
  public static String HttpClientRetrieveFileTransfer_CONNECTING_JOB_NAME;
  public static String HttpClientRetrieveFileTransfer_CONNECTING_TASK_NAME;
  public static String HttpClientRetrieveFileTransfer_Proxy_Auth_Required;
  public static String HttpClientRetrieveFileTransfer_Unauthorized;
  public static String HttpClientRetrieveFileTransfer_Username_Prefix;
  public static String HttpClientRetrieveFileTransfer_RESUME_START_POSITION_LESS_THAN_ZERO;
  public static String HttpClientRetrieveFileTransfer_ERROR_GENERAL_RESPONSE_CODE;
  public static String HttpClientRetrieveFileTransfer_EXCEPITION_INVALID_LAST_MODIFIED_FROM_SERVER;
  public static String HttpClientRetrieveFileTransfer_EXCEPTION_FILE_MODIFIED_SINCE_LAST_ACCESS;
  public static String HttpClientRetrieveFileTransfer_RESUME_ERROR_END_POSITION_LESS_THAN_START;
  public static String HttpClientRetrieveFileTransfer_EXCEPTION_COULD_NOT_CONNECT;
  public static String HttpClientRetrieveFileTransfer_INVALID_LAST_MODIFIED_TIME;
  public static String HttpClientRetrieveFileTransfer_INVALID_SERVER_RESPONSE_TO_PARTIAL_RANGE_REQUEST;
  public static String HttpClientRetrieveFileTransfer_RESUME_START_ERROR;
  
  static
  {
    NLS.initializeMessages("org.eclipse.ecf.internal.provider.filetransfer.httpclient.messages", Messages.class);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.internal.provider.filetransfer.httpclient.Messages
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.provider.filetransfer.httpclient;

import java.net.MalformedURLException;
import java.net.URL;
import org.apache.commons.httpclient.HttpClient;
import org.eclipse.core.runtime.Assert;
import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.identity.IIDFactory;
import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.core.security.IConnectContext;
import org.eclipse.ecf.core.util.Proxy;
import org.eclipse.ecf.filetransfer.IRemoteFileSystemListener;
import org.eclipse.ecf.filetransfer.IRemoteFileSystemRequest;
import org.eclipse.ecf.filetransfer.RemoteFileSystemException;
import org.eclipse.ecf.filetransfer.identity.IFileID;
import org.eclipse.ecf.filetransfer.service.IRemoteFileSystemBrowser;
import org.eclipse.ecf.provider.filetransfer.identity.FileTransferNamespace;
import org.eclipse.osgi.util.NLS;

class HttpClientBrowseFileTransferFactory$1
  implements IRemoteFileSystemBrowser
{
  private Proxy proxy;
  private IConnectContext connectContext;
  final HttpClientBrowseFileTransferFactory this$0;
  
  HttpClientBrowseFileTransferFactory$1(HttpClientBrowseFileTransferFactory paramHttpClientBrowseFileTransferFactory)
  {
    this$0 = paramHttpClientBrowseFileTransferFactory;
  }
  
  public Namespace getBrowseNamespace()
  {
    return IDFactory.getDefault().getNamespaceByName(FileTransferNamespace.PROTOCOL);
  }
  
  public IRemoteFileSystemRequest sendBrowseRequest(IFileID directoryOrFileId, IRemoteFileSystemListener listener)
    throws RemoteFileSystemException
  {
    Assert.isNotNull(directoryOrFileId);
    Assert.isNotNull(listener);
    try
    {
      url = directoryOrFileId.getURL();
    }
    catch (MalformedURLException e)
    {
      URL url;
      throw new RemoteFileSystemException(NLS.bind("Exception creating URL for {0}", directoryOrFileId));
    }
    URL url;
    HttpClientFileSystemBrowser browser = new HttpClientFileSystemBrowser(new HttpClient(), directoryOrFileId, listener, url, connectContext, proxy);
    return browser.sendBrowseRequest();
  }
  
  public void setConnectContextForAuthentication(IConnectContext connectContext)
  {
    this.connectContext = connectContext;
  }
  
  public void setProxy(Proxy proxy)
  {
    this.proxy = proxy;
  }
  
  public Object getAdapter(Class adapter)
  {
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientBrowseFileTransferFactory.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.provider.filetransfer.httpclient;

import java.net.MalformedURLException;
import java.net.URL;
import org.apache.commons.httpclient.HttpClient;
import org.eclipse.core.runtime.Assert;
import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.identity.IIDFactory;
import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.core.security.IConnectContext;
import org.eclipse.ecf.core.util.Proxy;
import org.eclipse.ecf.filetransfer.IRemoteFileSystemListener;
import org.eclipse.ecf.filetransfer.IRemoteFileSystemRequest;
import org.eclipse.ecf.filetransfer.RemoteFileSystemException;
import org.eclipse.ecf.filetransfer.identity.IFileID;
import org.eclipse.ecf.filetransfer.service.IRemoteFileSystemBrowser;
import org.eclipse.ecf.filetransfer.service.IRemoteFileSystemBrowserFactory;
import org.eclipse.ecf.provider.filetransfer.identity.FileTransferNamespace;
import org.eclipse.osgi.util.NLS;

public class HttpClientBrowseFileTransferFactory
  implements IRemoteFileSystemBrowserFactory
{
  public IRemoteFileSystemBrowser newInstance()
  {
    new IRemoteFileSystemBrowser()
    {
      private Proxy proxy;
      private IConnectContext connectContext;
      
      public Namespace getBrowseNamespace()
      {
        return IDFactory.getDefault().getNamespaceByName(FileTransferNamespace.PROTOCOL);
      }
      
      public IRemoteFileSystemRequest sendBrowseRequest(IFileID directoryOrFileId, IRemoteFileSystemListener listener)
        throws RemoteFileSystemException
      {
        Assert.isNotNull(directoryOrFileId);
        Assert.isNotNull(listener);
        try
        {
          url = directoryOrFileId.getURL();
        }
        catch (MalformedURLException e)
        {
          URL url;
          throw new RemoteFileSystemException(NLS.bind("Exception creating URL for {0}", directoryOrFileId));
        }
        URL url;
        HttpClientFileSystemBrowser browser = new HttpClientFileSystemBrowser(new HttpClient(), directoryOrFileId, listener, url, connectContext, proxy);
        return browser.sendBrowseRequest();
      }
      
      public void setConnectContextForAuthentication(IConnectContext connectContext)
      {
        this.connectContext = connectContext;
      }
      
      public void setProxy(Proxy proxy)
      {
        this.proxy = proxy;
      }
      
      public Object getAdapter(Class adapter)
      {
        return null;
      }
    };
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientBrowseFileTransferFactory
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.provider.filetransfer.httpclient;

import java.io.IOException;
import java.net.Socket;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import org.eclipse.ecf.core.util.StringUtils;
import org.eclipse.ecf.filetransfer.events.socketfactory.INonconnectedSocketFactory;
import org.eclipse.ecf.internal.provider.filetransfer.httpclient.ISSLSocketFactoryModifier;

public class HttpClientDefaultSSLSocketFactoryModifier
  implements ISSLSocketFactoryModifier, INonconnectedSocketFactory
{
  public static final String DEFAULT_SSL_PROTOCOL = "https.protocols";
  private SSLContext sslContext = null;
  private String defaultProtocolNames = System.getProperty("https.protocols");
  
  public SSLSocketFactory getSSLSocketFactory()
    throws IOException
  {
    if (sslContext == null) {
      try
      {
        sslContext = getSSLContext(defaultProtocolNames);
      }
      catch (Exception e)
      {
        IOException ioe = new IOException();
        ioe.initCause(e);
        throw ioe;
      }
    }
    return sslContext == null ? (SSLSocketFactory)SSLSocketFactory.getDefault() : sslContext.getSocketFactory();
  }
  
  public SSLContext getSSLContext(String protocols)
  {
    SSLContext rtvContext = null;
    if (protocols != null)
    {
      String[] protocolNames = StringUtils.split(protocols, ",");
      for (int i = 0; i < protocolNames.length; i++) {
        try
        {
          rtvContext = SSLContext.getInstance(protocolNames[i]);
          sslContext.init(null, new TrustManager[] { new HttpClientSslTrustManager() }, null);
        }
        catch (Exception localException) {}
      }
    }
    return rtvContext;
  }
  
  public Socket createSocket()
    throws IOException
  {
    return getSSLSocketFactory().createSocket();
  }
  
  public void dispose() {}
  
  public INonconnectedSocketFactory getNonconnnectedSocketFactory()
  {
    return this;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientDefaultSSLSocketFactoryModifier
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.provider.filetransfer.httpclient;

import org.eclipse.ecf.provider.filetransfer.events.socket.SocketEventSource;

class HttpClientFileSystemBrowser$1
  extends SocketEventSource
{
  final HttpClientFileSystemBrowser.HttpClientRemoteFileSystemRequest this$1;
  
  HttpClientFileSystemBrowser$1(HttpClientFileSystemBrowser.HttpClientRemoteFileSystemRequest paramHttpClientRemoteFileSystemRequest)
  {
    this$1 = paramHttpClientRemoteFileSystemRequest;
  }
  
  public Object getAdapter(Class adapter)
  {
    if (adapter == null) {
      return null;
    }
    if (adapter.isInstance(this)) {
      return this;
    }
    if (adapter.isInstance(this$1)) {
      return this$1;
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientFileSystemBrowser.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.provider.filetransfer.httpclient;

import org.apache.commons.httpclient.Credentials;
import org.eclipse.ecf.core.util.Proxy;
import org.eclipse.ecf.internal.provider.filetransfer.httpclient.HttpClientProxyCredentialProvider;

class HttpClientFileSystemBrowser$2
  extends HttpClientProxyCredentialProvider
{
  final HttpClientFileSystemBrowser this$0;
  
  HttpClientFileSystemBrowser$2(HttpClientFileSystemBrowser paramHttpClientFileSystemBrowser)
  {
    this$0 = paramHttpClientFileSystemBrowser;
  }
  
  protected Proxy getECFProxy()
  {
    return this$0.getProxy();
  }
  
  protected Credentials getNTLMCredentials(Proxy lp)
  {
    if (this$0.hasForceNTLMProxyOption()) {
      return HttpClientRetrieveFileTransfer.createNTLMCredentials(lp);
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientFileSystemBrowser.2
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.provider.filetransfer.httpclient;

import org.eclipse.ecf.provider.filetransfer.browse.AbstractFileSystemBrowser.RemoteFileSystemRequest;
import org.eclipse.ecf.provider.filetransfer.events.socket.SocketEventSource;

class HttpClientFileSystemBrowser$HttpClientRemoteFileSystemRequest
  extends AbstractFileSystemBrowser.RemoteFileSystemRequest
{
  protected SocketEventSource socketEventSource;
  final HttpClientFileSystemBrowser this$0;
  
  HttpClientFileSystemBrowser$HttpClientRemoteFileSystemRequest(HttpClientFileSystemBrowser paramHttpClientFileSystemBrowser)
  {
    super(paramHttpClientFileSystemBrowser);this$0 = paramHttpClientFileSystemBrowser;
    socketEventSource = new HttpClientFileSystemBrowser.1(this);
  }
  
  public Object getAdapter(Class adapter)
  {
    if (adapter == null) {
      return null;
    }
    return socketEventSource.getAdapter(adapter);
  }
  
  public void cancel()
  {
    this$0.cancel();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientFileSystemBrowser.HttpClientRemoteFileSystemRequest
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ecf.provider.filetransfer.httpclient;

import java.io.IOException;
import java.net.Socket;
import java.net.URL;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.auth.CredentialsProvider;
import org.apache.commons.httpclient.methods.HeadMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.httpclient.util.DateUtil;
import org.eclipse.core.runtime.Assert;
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.
1 2 3

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd