com.crashlytics.tools.android_2.1.0

.conn.routing.RouteInfo.LayerType
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.routing;

public enum RouteInfo$TunnelType
{
  PLAIN,  TUNNELLED;
  
  private RouteInfo$TunnelType() {}
}

/* Location:
 * Qualified Name:     org.apache.http.conn.routing.RouteInfo.TunnelType
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.routing;

import java.net.InetAddress;
import org.apache.http.HttpHost;

public abstract interface RouteInfo
{
  public abstract HttpHost getTargetHost();
  
  public abstract InetAddress getLocalAddress();
  
  public abstract int getHopCount();
  
  public abstract HttpHost getHopTarget(int paramInt);
  
  public abstract HttpHost getProxyHost();
  
  public abstract TunnelType getTunnelType();
  
  public abstract boolean isTunnelled();
  
  public abstract LayerType getLayerType();
  
  public abstract boolean isLayered();
  
  public abstract boolean isSecure();
  
  public static enum TunnelType
  {
    PLAIN,  TUNNELLED;
    
    private TunnelType() {}
  }
  
  public static enum LayerType
  {
    PLAIN,  LAYERED;
    
    private LayerType() {}
  }
}

/* Location:
 * Qualified Name:     org.apache.http.conn.routing.RouteInfo
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.routing;

import java.net.InetAddress;
import org.apache.http.HttpHost;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.util.Args;
import org.apache.http.util.Asserts;
import org.apache.http.util.LangUtils;

@NotThreadSafe
public final class RouteTracker
  implements RouteInfo, Cloneable
{
  private final HttpHost targetHost;
  private final InetAddress localAddress;
  private boolean connected;
  private HttpHost[] proxyChain;
  private RouteInfo.TunnelType tunnelled;
  private RouteInfo.LayerType layered;
  private boolean secure;
  
  public RouteTracker(HttpHost target, InetAddress local)
  {
    Args.notNull(target, "Target host");
    targetHost = target;
    localAddress = local;
    tunnelled = RouteInfo.TunnelType.PLAIN;
    layered = RouteInfo.LayerType.PLAIN;
  }
  
  public void reset()
  {
    connected = false;
    proxyChain = null;
    tunnelled = RouteInfo.TunnelType.PLAIN;
    layered = RouteInfo.LayerType.PLAIN;
    secure = false;
  }
  
  public RouteTracker(HttpRoute route)
  {
    this(route.getTargetHost(), route.getLocalAddress());
  }
  
  public final void connectTarget(boolean secure)
  {
    Asserts.check(!connected, "Already connected");
    connected = true;
    this.secure = secure;
  }
  
  public final void connectProxy(HttpHost proxy, boolean secure)
  {
    Args.notNull(proxy, "Proxy host");
    Asserts.check(!connected, "Already connected");
    connected = true;
    proxyChain = new HttpHost[] { proxy };
    this.secure = secure;
  }
  
  public final void tunnelTarget(boolean secure)
  {
    Asserts.check(connected, "No tunnel unless connected");
    Asserts.notNull(proxyChain, "No tunnel without proxy");
    tunnelled = RouteInfo.TunnelType.TUNNELLED;
    this.secure = secure;
  }
  
  public final void tunnelProxy(HttpHost proxy, boolean secure)
  {
    Args.notNull(proxy, "Proxy host");
    Asserts.check(connected, "No tunnel unless connected");
    Asserts.notNull(proxyChain, "No tunnel without proxy");
    
    HttpHost[] proxies = new HttpHost[proxyChain.length + 1];
    System.arraycopy(proxyChain, 0, proxies, 0, proxyChain.length);
    
    proxies[(proxies.length - 1)] = proxy;
    
    proxyChain = proxies;
    this.secure = secure;
  }
  
  public final void layerProtocol(boolean secure)
  {
    Asserts.check(connected, "No layered protocol unless connected");
    layered = RouteInfo.LayerType.LAYERED;
    this.secure = secure;
  }
  
  public final HttpHost getTargetHost()
  {
    return targetHost;
  }
  
  public final InetAddress getLocalAddress()
  {
    return localAddress;
  }
  
  public final int getHopCount()
  {
    int hops = 0;
    if (connected) {
      if (proxyChain == null) {
        hops = 1;
      } else {
        hops = proxyChain.length + 1;
      }
    }
    return hops;
  }
  
  public final HttpHost getHopTarget(int hop)
  {
    Args.notNegative(hop, "Hop index");
    int hopcount = getHopCount();
    Args.check(hop < hopcount, "Hop index exceeds tracked route length");
    HttpHost result = null;
    if (hop < hopcount - 1) {
      result = proxyChain[hop];
    } else {
      result = targetHost;
    }
    return result;
  }
  
  public final HttpHost getProxyHost()
  {
    return proxyChain == null ? null : proxyChain[0];
  }
  
  public final boolean isConnected()
  {
    return connected;
  }
  
  public final RouteInfo.TunnelType getTunnelType()
  {
    return tunnelled;
  }
  
  public final boolean isTunnelled()
  {
    return tunnelled == RouteInfo.TunnelType.TUNNELLED;
  }
  
  public final RouteInfo.LayerType getLayerType()
  {
    return layered;
  }
  
  public final boolean isLayered()
  {
    return layered == RouteInfo.LayerType.LAYERED;
  }
  
  public final boolean isSecure()
  {
    return secure;
  }
  
  public final HttpRoute toRoute()
  {
    return !connected ? null : new HttpRoute(targetHost, localAddress, proxyChain, secure, tunnelled, layered);
  }
  
  public final boolean equals(Object o)
  {
    if (o == this) {
      return true;
    }
    if (!(o instanceof RouteTracker)) {
      return false;
    }
    RouteTracker that = (RouteTracker)o;
    return (connected == connected) && (secure == secure) && (tunnelled == tunnelled) && (layered == layered) && (LangUtils.equals(targetHost, targetHost)) && (LangUtils.equals(localAddress, localAddress)) && (LangUtils.equals(proxyChain, proxyChain));
  }
  
  public final int hashCode()
  {
    int hash = 17;
    hash = LangUtils.hashCode(hash, targetHost);
    hash = LangUtils.hashCode(hash, localAddress);
    if (proxyChain != null) {
      for (HttpHost element : proxyChain) {
        hash = LangUtils.hashCode(hash, element);
      }
    }
    hash = LangUtils.hashCode(hash, connected);
    hash = LangUtils.hashCode(hash, secure);
    hash = LangUtils.hashCode(hash, tunnelled);
    hash = LangUtils.hashCode(hash, layered);
    return hash;
  }
  
  public final String toString()
  {
    StringBuilder cab = new StringBuilder(50 + getHopCount() * 30);
    
    cab.append("RouteTracker[");
    if (localAddress != null)
    {
      cab.append(localAddress);
      cab.append("->");
    }
    cab.append('{');
    if (connected) {
      cab.append('c');
    }
    if (tunnelled == RouteInfo.TunnelType.TUNNELLED) {
      cab.append('t');
    }
    if (layered == RouteInfo.LayerType.LAYERED) {
      cab.append('l');
    }
    if (secure) {
      cab.append('s');
    }
    cab.append("}->");
    if (proxyChain != null) {
      for (HttpHost element : proxyChain)
      {
        cab.append(element);
        cab.append("->");
      }
    }
    cab.append(targetHost);
    cab.append(']');
    
    return cab.toString();
  }
  
  public Object clone()
    throws CloneNotSupportedException
  {
    return super.clone();
  }
}

/* Location:
 * Qualified Name:     org.apache.http.conn.routing.RouteTracker
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.scheme;

import java.io.IOException;
import java.net.InetAddress;

@Deprecated
public abstract interface HostNameResolver
{
  public abstract InetAddress resolve(String paramString)
    throws IOException;
}

/* Location:
 * Qualified Name:     org.apache.http.conn.scheme.HostNameResolver
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.scheme;

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

@Deprecated
public abstract interface LayeredSchemeSocketFactory
  extends SchemeSocketFactory
{
  public abstract Socket createLayeredSocket(Socket paramSocket, String paramString, int paramInt, boolean paramBoolean)
    throws IOException, UnknownHostException;
}

/* Location:
 * Qualified Name:     org.apache.http.conn.scheme.LayeredSchemeSocketFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.scheme;

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

@Deprecated
public abstract interface LayeredSocketFactory
  extends SocketFactory
{
  public abstract Socket createSocket(Socket paramSocket, String paramString, int paramInt, boolean paramBoolean)
    throws IOException, UnknownHostException;
}

/* Location:
 * Qualified Name:     org.apache.http.conn.scheme.LayeredSocketFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.scheme;

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

@Deprecated
class LayeredSocketFactoryAdaptor
  extends SocketFactoryAdaptor
  implements LayeredSocketFactory
{
  private final LayeredSchemeSocketFactory factory;
  
  LayeredSocketFactoryAdaptor(LayeredSchemeSocketFactory factory)
  {
    super(factory);
    this.factory = factory;
  }
  
  public Socket createSocket(Socket socket, String host, int port, boolean autoClose)
    throws IOException, UnknownHostException
  {
    return factory.createLayeredSocket(socket, host, port, autoClose);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.conn.scheme.LayeredSocketFactoryAdaptor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.scheme;

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 org.apache.http.annotation.Immutable;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.util.Args;

@Deprecated
@Immutable
public class PlainSocketFactory
  implements SocketFactory, SchemeSocketFactory
{
  private final HostNameResolver nameResolver;
  
  public static PlainSocketFactory getSocketFactory()
  {
    return new PlainSocketFactory();
  }
  
  @Deprecated
  public PlainSocketFactory(HostNameResolver nameResolver)
  {
    this.nameResolver = nameResolver;
  }
  
  public PlainSocketFactory()
  {
    nameResolver = null;
  }
  
  public Socket createSocket(HttpParams params)
  {
    return new Socket();
  }
  
  public Socket createSocket()
  {
    return new Socket();
  }
  
  public Socket connectSocket(Socket socket, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpParams params)
    throws IOException, ConnectTimeoutException
  {
    Args.notNull(remoteAddress, "Remote address");
    Args.notNull(params, "HTTP parameters");
    Socket sock = socket;
    if (sock == null) {
      sock = createSocket();
    }
    if (localAddress != null)
    {
      sock.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params));
      sock.bind(localAddress);
    }
    int connTimeout = HttpConnectionParams.getConnectionTimeout(params);
    int soTimeout = HttpConnectionParams.getSoTimeout(params);
    try
    {
      sock.setSoTimeout(soTimeout);
      sock.connect(remoteAddress, connTimeout);
    }
    catch (SocketTimeoutException ex)
    {
      throw new ConnectTimeoutException("Connect to " + remoteAddress + " timed out");
    }
    return sock;
  }
  
  public final boolean isSecure(Socket sock)
  {
    return false;
  }
  
  @Deprecated
  public Socket connectSocket(Socket socket, String host, int port, InetAddress localAddress, int localPort, HttpParams params)
    throws IOException, UnknownHostException, ConnectTimeoutException
  {
    InetSocketAddress local = null;
    if ((localAddress != null) || (localPort > 0)) {
      local = new InetSocketAddress(localAddress, localPort > 0 ? localPort : 0);
    }
    InetAddress remoteAddress;
    InetAddress remoteAddress;
    if (nameResolver != null) {
      remoteAddress = nameResolver.resolve(host);
    } else {
      remoteAddress = InetAddress.getByName(host);
    }
    InetSocketAddress remote = new InetSocketAddress(remoteAddress, port);
    return connectSocket(socket, remote, local, params);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.conn.scheme.PlainSocketFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.scheme;

import java.util.Locale;
import org.apache.http.annotation.Immutable;
import org.apache.http.util.Args;
import org.apache.http.util.LangUtils;

@Deprecated
@Immutable
public final class Scheme
{
  private final String name;
  private final SchemeSocketFactory socketFactory;
  private final int defaultPort;
  private final boolean layered;
  private String stringRep;
  
  public Scheme(String name, int port, SchemeSocketFactory factory)
  {
    Args.notNull(name, "Scheme name");
    Args.check((port > 0) && (port <= 65535), "Port is invalid");
    Args.notNull(factory, "Socket factory");
    this.name = name.toLowerCase(Locale.ENGLISH);
    defaultPort = port;
    if ((factory instanceof SchemeLayeredSocketFactory))
    {
      layered = true;
      socketFactory = factory;
    }
    else if ((factory instanceof LayeredSchemeSocketFactory))
    {
      layered = true;
      socketFactory = new SchemeLayeredSocketFactoryAdaptor2((LayeredSchemeSocketFactory)factory);
    }
    else
    {
      layered = false;
      socketFactory = factory;
    }
  }
  
  @Deprecated
  public Scheme(String name, SocketFactory factory, int port)
  {
    Args.notNull(name, "Scheme name");
    Args.notNull(factory, "Socket factory");
    Args.check((port > 0) && (port <= 65535), "Port is invalid");
    
    this.name = name.toLowerCase(Locale.ENGLISH);
    if ((factory instanceof LayeredSocketFactory))
    {
      socketFactory = new SchemeLayeredSocketFactoryAdaptor((LayeredSocketFactory)factory);
      
      layered = true;
    }
    else
    {
      socketFactory = new SchemeSocketFactoryAdaptor(factory);
      layered = false;
    }
    defaultPort = port;
  }
  
  public final int getDefaultPort()
  {
    return defaultPort;
  }
  
  @Deprecated
  public final SocketFactory getSocketFactory()
  {
    if ((socketFactory instanceof SchemeSocketFactoryAdaptor)) {
      return ((SchemeSocketFactoryAdaptor)socketFactory).getFactory();
    }
    if (layered) {
      return new LayeredSocketFactoryAdaptor((LayeredSchemeSocketFactory)socketFactory);
    }
    return new SocketFactoryAdaptor(socketFactory);
  }
  
  public final SchemeSocketFactory getSchemeSocketFactory()
  {
    return socketFactory;
  }
  
  public final String getName()
  {
    return name;
  }
  
  public final boolean isLayered()
  {
    return layered;
  }
  
  public final int resolvePort(int port)
  {
    return port <= 0 ? defaultPort : port;
  }
  
  public final String toString()
  {
    if (stringRep == null)
    {
      StringBuilder buffer = new StringBuilder();
      buffer.append(name);
      buffer.append(':');
      buffer.append(Integer.toString(defaultPort));
      stringRep = buffer.toString();
    }
    return stringRep;
  }
  
  public final boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if ((obj instanceof Scheme))
    {
      Scheme that = (Scheme)obj;
      return (name.equals(name)) && (defaultPort == defaultPort) && (layered == layered);
    }
    return false;
  }
  
  public int hashCode()
  {
    int hash = 17;
    hash = LangUtils.hashCode(hash, defaultPort);
    hash = LangUtils.hashCode(hash, name);
    hash = LangUtils.hashCode(hash, layered);
    return hash;
  }
}

/* Location:
 * Qualified Name:     org.apache.http.conn.scheme.Scheme
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.scheme;

import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import org.apache.http.params.HttpParams;

@Deprecated
public abstract interface SchemeLayeredSocketFactory
  extends SchemeSocketFactory
{
  public abstract Socket createLayeredSocket(Socket paramSocket, String paramString, int paramInt, HttpParams paramHttpParams)
    throws IOException, UnknownHostException;
}

/* Location:
 * Qualified Name:     org.apache.http.conn.scheme.SchemeLayeredSocketFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.scheme;

import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import org.apache.http.params.HttpParams;

@Deprecated
class SchemeLayeredSocketFactoryAdaptor
  extends SchemeSocketFactoryAdaptor
  implements SchemeLayeredSocketFactory
{
  private final LayeredSocketFactory factory;
  
  SchemeLayeredSocketFactoryAdaptor(LayeredSocketFactory factory)
  {
    super(factory);
    this.factory = factory;
  }
  
  public Socket createLayeredSocket(Socket socket, String target, int port, HttpParams params)
    throws IOException, UnknownHostException
  {
    return factory.createSocket(socket, target, port, true);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.conn.scheme.SchemeLayeredSocketFactoryAdaptor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.scheme;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.params.HttpParams;

@Deprecated
class SchemeLayeredSocketFactoryAdaptor2
  implements SchemeLayeredSocketFactory
{
  private final LayeredSchemeSocketFactory factory;
  
  SchemeLayeredSocketFactoryAdaptor2(LayeredSchemeSocketFactory factory)
  {
    this.factory = factory;
  }
  
  public Socket createSocket(HttpParams params)
    throws IOException
  {
    return factory.createSocket(params);
  }
  
  public Socket connectSocket(Socket sock, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpParams params)
    throws IOException, UnknownHostException, ConnectTimeoutException
  {
    return factory.connectSocket(sock, remoteAddress, localAddress, params);
  }
  
  public boolean isSecure(Socket sock)
    throws IllegalArgumentException
  {
    return factory.isSecure(sock);
  }
  
  public Socket createLayeredSocket(Socket socket, String target, int port, HttpParams params)
    throws IOException, UnknownHostException
  {
    return factory.createLayeredSocket(socket, target, port, true);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.conn.scheme.SchemeLayeredSocketFactoryAdaptor2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.scheme;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.http.HttpHost;
import org.apache.http.annotation.ThreadSafe;
import org.apache.http.util.Args;

@Deprecated
@ThreadSafe
public final class SchemeRegistry
{
  private final ConcurrentHashMap<String, Scheme> registeredSchemes;
  
  public SchemeRegistry()
  {
    registeredSchemes = new ConcurrentHashMap();
  }
  
  public final Scheme getScheme(String name)
  {
    Scheme found = get(name);
    if (found == null) {
      throw new IllegalStateException("Scheme '" + name + "' not registered.");
    }
    return found;
  }
  
  public final Scheme getScheme(HttpHost host)
  {
    Args.notNull(host, "Host");
    return getScheme(host.getSchemeName());
  }
  
  public final Scheme get(String name)
  {
    Args.notNull(name, "Scheme name");
    
    Scheme found = (Scheme)registeredSchemes.get(name);
    return found;
  }
  
  public final Scheme register(Scheme sch)
  {
    Args.notNull(sch, "Scheme");
    Scheme old = (Scheme)registeredSchemes.put(sch.getName(), sch);
    return old;
  }
  
  public final Scheme unregister(String name)
  {
    Args.notNull(name, "Scheme name");
    
    Scheme gone = (Scheme)registeredSchemes.remove(name);
    return gone;
  }
  
  public final List<String> getSchemeNames()
  {
    return new ArrayList(registeredSchemes.keySet());
  }
  
  public void setItems(Map<String, Scheme> map)
  {
    if (map == null) {
      return;
    }
    registeredSchemes.clear();
    registeredSchemes.putAll(map);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.conn.scheme.SchemeRegistry
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.scheme;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.params.HttpParams;

@Deprecated
public abstract interface SchemeSocketFactory
{
  public abstract Socket createSocket(HttpParams paramHttpParams)
    throws IOException;
  
  public abstract Socket connectSocket(Socket paramSocket, InetSocketAddress paramInetSocketAddress1, InetSocketAddress paramInetSocketAddress2, HttpParams paramHttpParams)
    throws IOException, UnknownHostException, ConnectTimeoutException;
  
  public abstract boolean isSecure(Socket paramSocket)
    throws IllegalArgumentException;
}

/* Location:
 * Qualified Name:     org.apache.http.conn.scheme.SchemeSocketFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.scheme;

import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.params.HttpParams;

@Deprecated
class SchemeSocketFactoryAdaptor
  implements SchemeSocketFactory
{
  private final SocketFactory factory;
  
  SchemeSocketFactoryAdaptor(SocketFactory factory)
  {
    this.factory = factory;
  }
  
  public Socket connectSocket(Socket sock, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpParams params)
    throws IOException, UnknownHostException, ConnectTimeoutException
  {
    String host = remoteAddress.getHostName();
    int port = remoteAddress.getPort();
    InetAddress local = null;
    int localPort = 0;
    if (localAddress != null)
    {
      local = localAddress.getAddress();
      localPort = localAddress.getPort();
    }
    return factory.connectSocket(sock, host, port, local, localPort, params);
  }
  
  public Socket createSocket(HttpParams params)
    throws IOException
  {
    return factory.createSocket();
  }
  
  public boolean isSecure(Socket sock)
    throws IllegalArgumentException
  {
    return factory.isSecure(sock);
  }
  
  public SocketFactory getFactory()
  {
    return factory;
  }
  
  public boolean equals(Object obj)
  {
    if (obj == null) {
      return false;
    }
    if (this == obj) {
      return true;
    }
    if ((obj instanceof SchemeSocketFactoryAdaptor)) {
      return factory.equals(factory);
    }
    return factory.equals(obj);
  }
  
  public int hashCode()
  {
    return factory.hashCode();
  }
}

/* Location:
 * Qualified Name:     org.apache.http.conn.scheme.SchemeSocketFactoryAdaptor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.scheme;

import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.params.HttpParams;

@Deprecated
public abstract interface SocketFactory
{
  public abstract Socket createSocket()
    throws IOException;
  
  public abstract Socket connectSocket(Socket paramSocket, String paramString, int paramInt1, InetAddress paramInetAddress, int paramInt2, HttpParams paramHttpParams)
    throws IOException, UnknownHostException, ConnectTimeoutException;
  
  public abstract boolean isSecure(Socket paramSocket)
    throws IllegalArgumentException;
}

/* Location:
 * Qualified Name:     org.apache.http.conn.scheme.SocketFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.scheme;

import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;

@Deprecated
class SocketFactoryAdaptor
  implements SocketFactory
{
  private final SchemeSocketFactory factory;
  
  SocketFactoryAdaptor(SchemeSocketFactory factory)
  {
    this.factory = factory;
  }
  
  public Socket createSocket()
    throws IOException
  {
    HttpParams params = new BasicHttpParams();
    return factory.createSocket(params);
  }
  
  public Socket connectSocket(Socket socket, String host, int port, InetAddress localAddress, int localPort, HttpParams params)
    throws IOException, UnknownHostException, ConnectTimeoutException
  {
    InetSocketAddress local = null;
    if ((localAddress != null) || (localPort > 0)) {
      local = new InetSocketAddress(localAddress, localPort > 0 ? localPort : 0);
    }
    InetAddress remoteAddress = InetAddress.getByName(host);
    InetSocketAddress remote = new InetSocketAddress(remoteAddress, port);
    return factory.connectSocket(socket, remote, local, params);
  }
  
  public boolean isSecure(Socket socket)
    throws IllegalArgumentException
  {
    return factory.isSecure(socket);
  }
  
  public SchemeSocketFactory getFactory()
  {
    return factory;
  }
  
  public boolean equals(Object obj)
  {
    if (obj == null) {
      return false;
    }
    if (this == obj) {
      return true;
    }
    if ((obj instanceof SocketFactoryAdaptor)) {
      return factory.equals(factory);
    }
    return factory.equals(obj);
  }
  
  public int hashCode()
  {
    return factory.hashCode();
  }
}

/* Location:
 * Qualified Name:     org.apache.http.conn.scheme.SocketFactoryAdaptor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.socket;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import org.apache.http.HttpHost;
import org.apache.http.protocol.HttpContext;

public abstract interface ConnectionSocketFactory
{
  public abstract Socket createSocket(HttpContext paramHttpContext)
    throws IOException;
  
  public abstract Socket connectSocket(int paramInt, Socket paramSocket, HttpHost paramHttpHost, InetSocketAddress paramInetSocketAddress1, InetSocketAddress paramInetSocketAddress2, HttpContext paramHttpContext)
    throws IOException;
}

/* Location:
 * Qualified Name:     org.apache.http.conn.socket.ConnectionSocketFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.socket;

import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import org.apache.http.protocol.HttpContext;

public abstract interface LayeredConnectionSocketFactory
  extends ConnectionSocketFactory
{
  public abstract Socket createLayeredSocket(Socket paramSocket, String paramString, int paramInt, HttpContext paramHttpContext)
    throws IOException, UnknownHostException;
}

/* Location:
 * Qualified Name:     org.apache.http.conn.socket.LayeredConnectionSocketFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.socket;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import org.apache.http.HttpHost;
import org.apache.http.annotation.Immutable;
import org.apache.http.protocol.HttpContext;

@Immutable
public class PlainConnectionSocketFactory
  implements ConnectionSocketFactory
{
  public static final PlainConnectionSocketFactory INSTANCE = new PlainConnectionSocketFactory();
  
  public static PlainConnectionSocketFactory getSocketFactory()
  {
    return INSTANCE;
  }
  
  public Socket createSocket(HttpContext context)
    throws IOException
  {
    return new Socket();
  }
  
  public Socket connectSocket(int connectTimeout, Socket socket, HttpHost host, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpContext context)
    throws IOException
  {
    Socket sock = socket != null ? socket : createSocket(context);
    if (localAddress != null) {
      sock.bind(localAddress);
    }
    try
    {
      sock.connect(remoteAddress, connectTimeout);
    }
    catch (IOException ex)
    {
      try
      {
        sock.close();
      }
      catch (IOException ignore) {}
      throw ex;
    }
    return sock;
  }
}

/* Location:
 * Qualified Name:     org.apache.http.conn.socket.PlainConnectionSocketFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.ssl;

import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.cert.Certificate;
import java.security.cert.CertificateParsingException;
import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.StringTokenizer;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
import javax.security.auth.x500.X500Principal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.annotation.Immutable;
import org.apache.http.conn.util.InetAddressUtils;

@Immutable
public abstract class AbstractVerifier
  implements X509HostnameVerifier
{
  private static final String[] BAD_COUNTRY_2LDS = { "ac", "co", "com", "ed", "edu", "go", "gouv", "gov", "info", "lg", "ne", "net", "or", "org" };
  
  static
  {
    Arrays.sort(BAD_COUNTRY_2LDS);
  }
  
  private final Log log = LogFactory.getLog(getClass());
  
  public final void verify(String host, SSLSocket ssl)
    throws IOException
  {
    if (host == null) {
      throw new NullPointerException("host to verify is null");
    }
    SSLSession session = ssl.getSession();
    if (session == null)
    {
      InputStream in = ssl.getInputStream();
      in.available();
      
      session = ssl.getSession();
      if (session == null)
      {
        ssl.startHandshake();
        
        session = ssl.getSession();
      }
    }
    Certificate[] certs = session.getPeerCertificates();
    X509Certificate x509 = (X509Certificate)certs[0];
    verify(host, x509);
  }
  
  public final boolean verify(String host, SSLSession session)
  {
    try
    {
      Certificate[] certs = session.getPeerCertificates();
      X509Certificate x509 = (X509Certificate)certs[0];
      verify(host, x509);
      return true;
    }
    catch (SSLException e) {}
    return false;
  }
  
  public final void verify(String host, X509Certificate cert)
    throws SSLException
  {
    String[] cns = getCNs(cert);
    String[] subjectAlts = getSubjectAlts(cert, host);
    verify(host, cns, subjectAlts);
  }
  
  public final void verify(String host, String[] cns, String[] subjectAlts, boolean strictWithSubDomains)
    throws SSLException
  {
    LinkedList<String> names = new LinkedList();
    if ((cns != null) && (cns.length > 0) && (cns[0] != null)) {
      names.add(cns[0]);
    }
    if (subjectAlts != null) {
      for (String subjectAlt : subjectAlts) {
        if (subjectAlt != null) {
          names.add(subjectAlt);
        }
      }
    }
    if (names.isEmpty())
    {
      String msg = "Certificate for <" + host + "> doesn't contain CN or DNS subjectAlt";
      throw new SSLException(msg);
    }
    StringBuilder buf = new StringBuilder();
    
    String hostName = normaliseIPv6Address(host.trim().toLowerCase(Locale.US));
    boolean match = false;
    for (Iterator<String> it = names.iterator(); it.hasNext();)
    {
      String cn = (String)it.next();
      cn = cn.toLowerCase(Locale.US);
      
      buf.append(" <");
      buf.append(cn);
      buf.append('>');
      if (it.hasNext()) {
        buf.append(" OR");
      }
      String[] parts = cn.split("\\.");
      boolean doWildcard = (parts.length >= 3) && (parts[0].endsWith("*")) && (acceptableCountryWildcard(cn)) && (!isIPAddress(host));
      if (doWildcard)
      {
        String firstpart = parts[0];
        if (firstpart.length() > 1)
        {
          String prefix = firstpart.substring(0, firstpart.length() - 1);
          String suffix = cn.substring(firstpart.length());
          String hostSuffix = hostName.substring(prefix.length());
          match = (hostName.startsWith(prefix)) && (hostSuffix.endsWith(suffix));
        }
        else
        {
          match = hostName.endsWith(cn.substring(1));
        }
        if ((match) && (strictWithSubDomains)) {
          match = countDots(hostName) == countDots(cn);
        }
      }
      else
      {
        match = hostName.equals(normaliseIPv6Address(cn));
      }
      if (match) {
        break;
      }
    }
    if (!match) {
      throw new SSLException("hostname in certificate didn't match: <" + host + "> !=" + buf);
    }
  }
  
  public static boolean acceptableCountryWildcard(String cn)
  {
    String[] parts = cn.split("\\.");
    if ((parts.length != 3) || (parts[2].length() != 2)) {
      return true;
    }
    return Arrays.binarySearch(BAD_COUNTRY_2LDS, parts[1]) < 0;
  }
  
  public static String[] getCNs(X509Certificate cert)
  {
    LinkedList<String> cnList = new LinkedList();
    
    String subjectPrincipal = cert.getSubjectX500Principal().toString();
    StringTokenizer st = new StringTokenizer(subjectPrincipal, ",+");
    while (st.hasMoreTokens())
    {
      String tok = st.nextToken().trim();
      if ((tok.length() > 3) && 
        (tok.substring(0, 3).equalsIgnoreCase("CN="))) {
        cnList.add(tok.substring(3));
      }
    }
    if (!cnList.isEmpty())
    {
      String[] cns = new String[cnList.size()];
      cnList.toArray(cns);
      return cns;
    }
    return null;
  }
  
  private static String[] getSubjectAlts(X509Certificate cert, String hostname)
  {
    int subjectType;
    int subjectType;
    if (isIPAddress(hostname)) {
      subjectType = 7;
    } else {
      subjectType = 2;
    }
    LinkedList<String> subjectAltList = new LinkedList();
    Collection<List<?>> c = null;
    try
    {
      c = cert.getSubjectAlternativeNames();
    }
    catch (CertificateParsingException cpe) {}
    if (c != null) {
      for (List<?> aC : c)
      {
        List<?> list = aC;
        int type = ((Integer)list.get(0)).intValue();
        if (type == subjectType)
        {
          String s = (String)list.get(1);
          subjectAltList.add(s);
        }
      }
    }
    if (!subjectAltList.isEmpty())
    {
      String[] subjectAlts = new String[subjectAltList.size()];
      subjectAltList.toArray(subjectAlts);
      return subjectAlts;
    }
    return null;
  }
  
  public static String[] getDNSSubjectAlts(X509Certificate cert)
  {
    return getSubjectAlts(cert, null);
  }
  
  public static int countDots(String s)
  {
    int count = 0;
    for (int i = 0; i < s.length(); i++) {
      if (s.charAt(i) == '.') {
        count++;
      }
    }
    return count;
  }
  
  private static boolean isIPAddress(String hostname)
  {
    return (hostname != null) && ((InetAddressUtils.isIPv4Address(hostname)) || (InetAddressUtils.isIPv6Address(hostname)));
  }
  
  private String normaliseIPv6Address(String hostname)
  {
    if ((hostname == null) || (!InetAddressUtils.isIPv6Address(hostname))) {
      return hostname;
    }
    try
    {
      InetAddress inetAddress = InetAddress.getByName(hostname);
      return inetAddress.getHostAddress();
    }
    catch (UnknownHostException uhe)
    {
      log.error("Unexpected error converting " + hostname, uhe);
    }
    return hostname;
  }
}

/* Location:
 * Qualified Name:     org.apache.http.conn.ssl.AbstractVerifier
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.ssl;

import org.apache.http.annotation.Immutable;

@Immutable
public class AllowAllHostnameVerifier
  extends AbstractVerifier
{
  public final void verify(String host, String[] cns, String[] subjectAlts) {}
  
  public final String toString()
  {
    return "ALLOW_ALL";
  }
}

/* Location:
 * Qualified Name:     org.apache.http.conn.ssl.AllowAllHostnameVerifier
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.ssl;

import javax.net.ssl.SSLException;
import org.apache.http.annotation.Immutable;

@Immutable
public class BrowserCompatHostnameVerifier
  extends AbstractVerifier
{
  public final void verify(String host, String[] cns, String[] subjectAlts)
    throws SSLException
  {
    verify(host, cns, subjectAlts, false);
  }
  
  public final String toString()
  {
    return "BROWSER_COMPATIBLE";
  }
}

/* Location:
 * Qualified Name:     org.apache.http.conn.ssl.BrowserCompatHostnameVerifier
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.ssl;

import java.security.cert.X509Certificate;
import java.util.Arrays;
import org.apache.http.util.Args;

public final class PrivateKeyDetails
{
  private final String type;
  private final X509Certificate[] certChain;
  
  public PrivateKeyDetails(String type, X509Certificate[] certChain)
  {
    this.type = ((String)Args.notNull(type, "Private key type"));
    this.certChain = certChain;
  }
  
  public String getType()
  {
    return type;
  }
  
  public X509Certificate[] getCertChain()
  {
    return certChain;
  }
  
  public String toString()
  {
    return type + ':' + Arrays.toString(certChain);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.conn.ssl.PrivateKeyDetails
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.ssl;

import java.net.Socket;
import java.util.Map;

public abstract interface PrivateKeyStrategy
{
  public abstract String chooseAlias(Map<String, PrivateKeyDetails> paramMap, Socket paramSocket);
}

/* Location:
 * Qualified Name:     org.apache.http.conn.ssl.PrivateKeyStrategy
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.conn.ssl;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import org.apache.http.HttpHost;
import org.apache.http.annotation.ThreadSafe;
import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;
import org.apache.http.util.TextUtils;

@ThreadSafe
public class SSLConnectionSocketFactory
  implements LayeredConnectionSocketFactory
{
  public static final String TLS = "TLS";
  public static final String SSL = "SSL";
  public static final String SSLV2 = "SSLv2";
  public static final X509HostnameVerifier ALLOW_ALL_HOSTNAME_VERIFIER = new AllowAllHostnameVerifier();
  public static final X509HostnameVerifier BROWSER_COMPATIBLE_HOSTNAME_VERIFIER = new BrowserCompatHostnameVerifier();
  public static final X509HostnameVerifier STRICT_HOSTNAME_VERIFIER = new StrictHostnameVerifier();
  private final SSLSocketFactory socketfactory;
  private final X509HostnameVerifier hostnameVerifier;
  private final String[] supportedProtocols;
  private final String[] supportedCipherSuites;
  
  public static SSLConnectionSocketFactory getSocketFactory()
    throws SSLInitializationException
  {
    return new SSLConnectionSocketFactory(SSLContexts.createDefault(), BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
  }
  
  private static String[] split(String s)
  {
    if (TextUtils.isBlank(s)) {
      return null;
    }
    return s.split(" *, *");
  }
  
  public static SSLConnect
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109

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-2019. Infinite Loop Ltd