com.crashlytics.tools.android_2.1.0

eSpec.class);
  }
  
  public CookieOrigin getCookieOrigin()
  {
    return (CookieOrigin)getAttribute("http.cookie-origin", CookieOrigin.class);
  }
  
  private <T> Lookup<T> getLookup(String name, Class<T> clazz)
  {
    return (Lookup)getAttribute(name, Lookup.class);
  }
  
  public Lookup<CookieSpecProvider> getCookieSpecRegistry()
  {
    return getLookup("http.cookiespec-registry", CookieSpecProvider.class);
  }
  
  public void setCookieSpecRegistry(Lookup<CookieSpecProvider> lookup)
  {
    setAttribute("http.cookiespec-registry", lookup);
  }
  
  public Lookup<AuthSchemeProvider> getAuthSchemeRegistry()
  {
    return getLookup("http.authscheme-registry", AuthSchemeProvider.class);
  }
  
  public void setAuthSchemeRegistry(Lookup<AuthSchemeProvider> lookup)
  {
    setAttribute("http.authscheme-registry", lookup);
  }
  
  public CredentialsProvider getCredentialsProvider()
  {
    return (CredentialsProvider)getAttribute("http.auth.credentials-provider", CredentialsProvider.class);
  }
  
  public void setCredentialsProvider(CredentialsProvider credentialsProvider)
  {
    setAttribute("http.auth.credentials-provider", credentialsProvider);
  }
  
  public AuthCache getAuthCache()
  {
    return (AuthCache)getAttribute("http.auth.auth-cache", AuthCache.class);
  }
  
  public void setAuthCache(AuthCache authCache)
  {
    setAttribute("http.auth.auth-cache", authCache);
  }
  
  public AuthState getTargetAuthState()
  {
    return (AuthState)getAttribute("http.auth.target-scope", AuthState.class);
  }
  
  public AuthState getProxyAuthState()
  {
    return (AuthState)getAttribute("http.auth.proxy-scope", AuthState.class);
  }
  
  public <T> T getUserToken(Class<T> clazz)
  {
    return (T)getAttribute("http.user-token", clazz);
  }
  
  public Object getUserToken()
  {
    return getAttribute("http.user-token");
  }
  
  public void setUserToken(Object obj)
  {
    setAttribute("http.user-token", obj);
  }
  
  public RequestConfig getRequestConfig()
  {
    RequestConfig config = (RequestConfig)getAttribute("http.request-config", RequestConfig.class);
    return config != null ? config : RequestConfig.DEFAULT;
  }
  
  public void setRequestConfig(RequestConfig config)
  {
    setAttribute("http.request-config", config);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.client.protocol.HttpClientContext
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.client.protocol;

import java.io.IOException;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
import org.apache.http.annotation.Immutable;
import org.apache.http.protocol.HttpContext;

@Immutable
public class RequestAcceptEncoding
  implements HttpRequestInterceptor
{
  public void process(HttpRequest request, HttpContext context)
    throws HttpException, IOException
  {
    if (!request.containsHeader("Accept-Encoding")) {
      request.addHeader("Accept-Encoding", "gzip,deflate");
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.http.client.protocol.RequestAcceptEncoding
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.client.protocol;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.Header;
import org.apache.http.HttpException;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
import org.apache.http.RequestLine;
import org.apache.http.annotation.Immutable;
import org.apache.http.client.CookieStore;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.config.Lookup;
import org.apache.http.conn.routing.RouteInfo;
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.CookieOrigin;
import org.apache.http.cookie.CookieSpec;
import org.apache.http.cookie.CookieSpecProvider;
import org.apache.http.cookie.SetCookie2;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;
import org.apache.http.util.TextUtils;

@Immutable
public class RequestAddCookies
  implements HttpRequestInterceptor
{
  private final Log log = LogFactory.getLog(getClass());
  
  public void process(HttpRequest request, HttpContext context)
    throws HttpException, IOException
  {
    Args.notNull(request, "HTTP request");
    Args.notNull(context, "HTTP context");
    
    String method = request.getRequestLine().getMethod();
    if (method.equalsIgnoreCase("CONNECT")) {
      return;
    }
    HttpClientContext clientContext = HttpClientContext.adapt(context);
    
    CookieStore cookieStore = clientContext.getCookieStore();
    if (cookieStore == null)
    {
      log.debug("Cookie store not specified in HTTP context");
      return;
    }
    Lookup<CookieSpecProvider> registry = clientContext.getCookieSpecRegistry();
    if (registry == null)
    {
      log.debug("CookieSpec registry not specified in HTTP context");
      return;
    }
    HttpHost targetHost = clientContext.getTargetHost();
    if (targetHost == null)
    {
      log.debug("Target host not set in the context");
      return;
    }
    RouteInfo route = clientContext.getHttpRoute();
    if (route == null)
    {
      log.debug("Connection route not set in the context");
      return;
    }
    RequestConfig config = clientContext.getRequestConfig();
    String policy = config.getCookieSpec();
    if (policy == null) {
      policy = "best-match";
    }
    if (log.isDebugEnabled()) {
      log.debug("CookieSpec selected: " + policy);
    }
    URI requestURI = null;
    if ((request instanceof HttpUriRequest)) {
      requestURI = ((HttpUriRequest)request).getURI();
    } else {
      try
      {
        requestURI = new URI(request.getRequestLine().getUri());
      }
      catch (URISyntaxException ignore) {}
    }
    String path = requestURI != null ? requestURI.getPath() : null;
    String hostName = targetHost.getHostName();
    int port = targetHost.getPort();
    if (port < 0) {
      port = route.getTargetHost().getPort();
    }
    CookieOrigin cookieOrigin = new CookieOrigin(hostName, port >= 0 ? port : 0, !TextUtils.isEmpty(path) ? path : "/", route.isSecure());
    
    CookieSpecProvider provider = (CookieSpecProvider)registry.lookup(policy);
    if (provider == null) {
      throw new HttpException("Unsupported cookie policy: " + policy);
    }
    CookieSpec cookieSpec = provider.create(clientContext);
    
    List<Cookie> cookies = new ArrayList(cookieStore.getCookies());
    
    List<Cookie> matchedCookies = new ArrayList();
    Date now = new Date();
    for (Cookie cookie : cookies) {
      if (!cookie.isExpired(now))
      {
        if (cookieSpec.match(cookie, cookieOrigin))
        {
          if (log.isDebugEnabled()) {
            log.debug("Cookie " + cookie + " match " + cookieOrigin);
          }
          matchedCookies.add(cookie);
        }
      }
      else if (log.isDebugEnabled()) {
        log.debug("Cookie " + cookie + " expired");
      }
    }
    if (!matchedCookies.isEmpty())
    {
      List<Header> headers = cookieSpec.formatCookies(matchedCookies);
      for (Header header : headers) {
        request.addHeader(header);
      }
    }
    int ver = cookieSpec.getVersion();
    if (ver > 0)
    {
      boolean needVersionHeader = false;
      for (Cookie cookie : matchedCookies) {
        if ((ver != cookie.getVersion()) || (!(cookie instanceof SetCookie2))) {
          needVersionHeader = true;
        }
      }
      if (needVersionHeader)
      {
        Header header = cookieSpec.getVersionHeader();
        if (header != null) {
          request.addHeader(header);
        }
      }
    }
    context.setAttribute("http.cookie-spec", cookieSpec);
    context.setAttribute("http.cookie-origin", cookieOrigin);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.client.protocol.RequestAddCookies
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.client.protocol;

import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpException;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
import org.apache.http.annotation.Immutable;
import org.apache.http.auth.AuthProtocolState;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.AuthState;
import org.apache.http.auth.Credentials;
import org.apache.http.client.AuthCache;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.conn.routing.RouteInfo;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;

@Immutable
public class RequestAuthCache
  implements HttpRequestInterceptor
{
  private final Log log = LogFactory.getLog(getClass());
  
  public void process(HttpRequest request, HttpContext context)
    throws HttpException, IOException
  {
    Args.notNull(request, "HTTP request");
    Args.notNull(context, "HTTP context");
    
    HttpClientContext clientContext = HttpClientContext.adapt(context);
    
    AuthCache authCache = clientContext.getAuthCache();
    if (authCache == null)
    {
      log.debug("Auth cache not set in the context");
      return;
    }
    CredentialsProvider credsProvider = clientContext.getCredentialsProvider();
    if (credsProvider == null)
    {
      log.debug("Credentials provider not set in the context");
      return;
    }
    RouteInfo route = clientContext.getHttpRoute();
    HttpHost target = clientContext.getTargetHost();
    if (target.getPort() < 0) {
      target = new HttpHost(target.getHostName(), route.getTargetHost().getPort(), target.getSchemeName());
    }
    AuthState targetState = clientContext.getTargetAuthState();
    if ((targetState != null) && (targetState.getState() == AuthProtocolState.UNCHALLENGED))
    {
      AuthScheme authScheme = authCache.get(target);
      if (authScheme != null) {
        doPreemptiveAuth(target, authScheme, targetState, credsProvider);
      }
    }
    HttpHost proxy = route.getProxyHost();
    AuthState proxyState = clientContext.getProxyAuthState();
    if ((proxy != null) && (proxyState != null) && (proxyState.getState() == AuthProtocolState.UNCHALLENGED))
    {
      AuthScheme authScheme = authCache.get(proxy);
      if (authScheme != null) {
        doPreemptiveAuth(proxy, authScheme, proxyState, credsProvider);
      }
    }
  }
  
  private void doPreemptiveAuth(HttpHost host, AuthScheme authScheme, AuthState authState, CredentialsProvider credsProvider)
  {
    String schemeName = authScheme.getSchemeName();
    if (log.isDebugEnabled()) {
      log.debug("Re-using cached '" + schemeName + "' auth scheme for " + host);
    }
    AuthScope authScope = new AuthScope(host, AuthScope.ANY_REALM, schemeName);
    Credentials creds = credsProvider.getCredentials(authScope);
    if (creds != null)
    {
      if ("BASIC".equalsIgnoreCase(authScheme.getSchemeName())) {
        authState.setState(AuthProtocolState.CHALLENGED);
      } else {
        authState.setState(AuthProtocolState.SUCCESS);
      }
      authState.update(authScheme, creds);
    }
    else
    {
      log.debug("No credentials for preemptive authentication");
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.http.client.protocol.RequestAuthCache
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.client.protocol;

class RequestAuthenticationBase$1 {}

/* Location:
 * Qualified Name:     org.apache.http.client.protocol.RequestAuthenticationBase.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.client.protocol;

import java.util.Queue;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.Header;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
import org.apache.http.auth.AuthOption;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthState;
import org.apache.http.auth.AuthenticationException;
import org.apache.http.auth.ContextAwareAuthScheme;
import org.apache.http.auth.Credentials;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Asserts;

@Deprecated
abstract class RequestAuthenticationBase
  implements HttpRequestInterceptor
{
  final Log log = LogFactory.getLog(getClass());
  
  void process(AuthState authState, HttpRequest request, HttpContext context)
  {
    AuthScheme authScheme = authState.getAuthScheme();
    Credentials creds = authState.getCredentials();
    switch (authState.getState())
    {
    case FAILURE: 
      return;
    case SUCCESS: 
      ensureAuthScheme(authScheme);
      if (authScheme.isConnectionBased()) {
        return;
      }
      break;
    case CHALLENGED: 
      Queue<AuthOption> authOptions = authState.getAuthOptions();
      if (authOptions != null)
      {
        while (!authOptions.isEmpty())
        {
          AuthOption authOption = (AuthOption)authOptions.remove();
          authScheme = authOption.getAuthScheme();
          creds = authOption.getCredentials();
          authState.update(authScheme, creds);
          if (log.isDebugEnabled()) {
            log.debug("Generating response to an authentication challenge using " + authScheme.getSchemeName() + " scheme");
          }
          try
          {
            Header header = authenticate(authScheme, creds, request, context);
            request.addHeader(header);
          }
          catch (AuthenticationException ex)
          {
            if (log.isWarnEnabled()) {
              log.warn(authScheme + " authentication error: " + ex.getMessage());
            }
          }
        }
        return;
      }
      ensureAuthScheme(authScheme);
    }
    if (authScheme != null) {
      try
      {
        Header header = authenticate(authScheme, creds, request, context);
        request.addHeader(header);
      }
      catch (AuthenticationException ex)
      {
        if (log.isErrorEnabled()) {
          log.error(authScheme + " authentication error: " + ex.getMessage());
        }
      }
    }
  }
  
  private void ensureAuthScheme(AuthScheme authScheme)
  {
    Asserts.notNull(authScheme, "Auth scheme");
  }
  
  private Header authenticate(AuthScheme authScheme, Credentials creds, HttpRequest request, HttpContext context)
    throws AuthenticationException
  {
    Asserts.notNull(authScheme, "Auth scheme");
    if ((authScheme instanceof ContextAwareAuthScheme)) {
      return ((ContextAwareAuthScheme)authScheme).authenticate(creds, request, context);
    }
    return authScheme.authenticate(creds, request);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.client.protocol.RequestAuthenticationBase
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.client.protocol;

import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
import org.apache.http.RequestLine;
import org.apache.http.annotation.Immutable;
import org.apache.http.conn.routing.RouteInfo;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;

@Immutable
public class RequestClientConnControl
  implements HttpRequestInterceptor
{
  private final Log log = LogFactory.getLog(getClass());
  private static final String PROXY_CONN_DIRECTIVE = "Proxy-Connection";
  
  public void process(HttpRequest request, HttpContext context)
    throws HttpException, IOException
  {
    Args.notNull(request, "HTTP request");
    
    String method = request.getRequestLine().getMethod();
    if (method.equalsIgnoreCase("CONNECT"))
    {
      request.setHeader("Proxy-Connection", "Keep-Alive");
      return;
    }
    HttpClientContext clientContext = HttpClientContext.adapt(context);
    
    RouteInfo route = clientContext.getHttpRoute();
    if (route == null)
    {
      log.debug("Connection route not set in the context");
      return;
    }
    if (((route.getHopCount() == 1) || (route.isTunnelled())) && 
      (!request.containsHeader("Connection"))) {
      request.addHeader("Connection", "Keep-Alive");
    }
    if ((route.getHopCount() == 2) && (!route.isTunnelled()) && 
      (!request.containsHeader("Proxy-Connection"))) {
      request.addHeader("Proxy-Connection", "Keep-Alive");
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.http.client.protocol.RequestClientConnControl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.client.protocol;

import java.io.IOException;
import java.util.Collection;
import org.apache.http.Header;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
import org.apache.http.RequestLine;
import org.apache.http.annotation.Immutable;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;

@Immutable
public class RequestDefaultHeaders
  implements HttpRequestInterceptor
{
  private final Collection<? extends Header> defaultHeaders;
  
  public RequestDefaultHeaders(Collection<? extends Header> defaultHeaders)
  {
    this.defaultHeaders = defaultHeaders;
  }
  
  public RequestDefaultHeaders()
  {
    this(null);
  }
  
  public void process(HttpRequest request, HttpContext context)
    throws HttpException, IOException
  {
    Args.notNull(request, "HTTP request");
    
    String method = request.getRequestLine().getMethod();
    if (method.equalsIgnoreCase("CONNECT")) {
      return;
    }
    Collection<? extends Header> defHeaders = (Collection)request.getParams().getParameter("http.default-headers");
    if (defHeaders == null) {
      defHeaders = defaultHeaders;
    }
    if (defHeaders != null) {
      for (Header defHeader : defHeaders) {
        request.addHeader(defHeader);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.http.client.protocol.RequestDefaultHeaders
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.client.protocol;

import java.io.IOException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
import org.apache.http.HttpVersion;
import org.apache.http.ProtocolVersion;
import org.apache.http.RequestLine;
import org.apache.http.annotation.Immutable;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;

@Immutable
public class RequestExpectContinue
  implements HttpRequestInterceptor
{
  public void process(HttpRequest request, HttpContext context)
    throws HttpException, IOException
  {
    Args.notNull(request, "HTTP request");
    if ((!request.containsHeader("Expect")) && 
      ((request instanceof HttpEntityEnclosingRequest)))
    {
      ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
      HttpEntity entity = ((HttpEntityEnclosingRequest)request).getEntity();
      if ((entity != null) && (entity.getContentLength() != 0L) && (!ver.lessEquals(HttpVersion.HTTP_1_0)))
      {
        HttpClientContext clientContext = HttpClientContext.adapt(context);
        RequestConfig config = clientContext.getRequestConfig();
        if (config.isExpectContinueEnabled()) {
          request.addHeader("Expect", "100-continue");
        }
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.http.client.protocol.RequestExpectContinue
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.client.protocol;

import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.annotation.Immutable;
import org.apache.http.auth.AuthState;
import org.apache.http.conn.HttpRoutedConnection;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;

@Deprecated
@Immutable
public class RequestProxyAuthentication
  extends RequestAuthenticationBase
{
  public void process(HttpRequest request, HttpContext context)
    throws HttpException, IOException
  {
    Args.notNull(request, "HTTP request");
    Args.notNull(context, "HTTP context");
    if (request.containsHeader("Proxy-Authorization")) {
      return;
    }
    HttpRoutedConnection conn = (HttpRoutedConnection)context.getAttribute("http.connection");
    if (conn == null)
    {
      log.debug("HTTP connection not set in the context");
      return;
    }
    HttpRoute route = conn.getRoute();
    if (route.isTunnelled()) {
      return;
    }
    AuthState authState = (AuthState)context.getAttribute("http.auth.proxy-scope");
    if (authState == null)
    {
      log.debug("Proxy auth state not set in the context");
      return;
    }
    if (log.isDebugEnabled()) {
      log.debug("Proxy auth state: " + authState.getState());
    }
    process(authState, request, context);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.client.protocol.RequestProxyAuthentication
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.client.protocol;

import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.RequestLine;
import org.apache.http.annotation.Immutable;
import org.apache.http.auth.AuthState;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;

@Deprecated
@Immutable
public class RequestTargetAuthentication
  extends RequestAuthenticationBase
{
  public void process(HttpRequest request, HttpContext context)
    throws HttpException, IOException
  {
    Args.notNull(request, "HTTP request");
    Args.notNull(context, "HTTP context");
    
    String method = request.getRequestLine().getMethod();
    if (method.equalsIgnoreCase("CONNECT")) {
      return;
    }
    if (request.containsHeader("Authorization")) {
      return;
    }
    AuthState authState = (AuthState)context.getAttribute("http.auth.target-scope");
    if (authState == null)
    {
      log.debug("Target auth state not set in the context");
      return;
    }
    if (log.isDebugEnabled()) {
      log.debug("Target auth state: " + authState.getState());
    }
    process(authState, request, context);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.client.protocol.RequestTargetAuthentication
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.client.protocol;

class ResponseAuthCache$1 {}

/* Location:
 * Qualified Name:     org.apache.http.client.protocol.ResponseAuthCache.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.client.protocol;

import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpException;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.HttpResponseInterceptor;
import org.apache.http.annotation.Immutable;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthState;
import org.apache.http.client.AuthCache;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.impl.client.BasicAuthCache;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;

@Deprecated
@Immutable
public class ResponseAuthCache
  implements HttpResponseInterceptor
{
  private final Log log = LogFactory.getLog(getClass());
  
  public void process(HttpResponse response, HttpContext context)
    throws HttpException, IOException
  {
    Args.notNull(response, "HTTP request");
    Args.notNull(context, "HTTP context");
    AuthCache authCache = (AuthCache)context.getAttribute("http.auth.auth-cache");
    
    HttpHost target = (HttpHost)context.getAttribute("http.target_host");
    AuthState targetState = (AuthState)context.getAttribute("http.auth.target-scope");
    if ((target != null) && (targetState != null))
    {
      if (log.isDebugEnabled()) {
        log.debug("Target auth state: " + targetState.getState());
      }
      if (isCachable(targetState))
      {
        SchemeRegistry schemeRegistry = (SchemeRegistry)context.getAttribute("http.scheme-registry");
        if (target.getPort() < 0)
        {
          Scheme scheme = schemeRegistry.getScheme(target);
          target = new HttpHost(target.getHostName(), scheme.resolvePort(target.getPort()), target.getSchemeName());
        }
        if (authCache == null)
        {
          authCache = new BasicAuthCache();
          context.setAttribute("http.auth.auth-cache", authCache);
        }
        switch (targetState.getState())
        {
        case CHALLENGED: 
          cache(authCache, target, targetState.getAuthScheme());
          break;
        case FAILURE: 
          uncache(authCache, target, targetState.getAuthScheme());
        }
      }
    }
    HttpHost proxy = (HttpHost)context.getAttribute("http.proxy_host");
    AuthState proxyState = (AuthState)context.getAttribute("http.auth.proxy-scope");
    if ((proxy != null) && (proxyState != null))
    {
      if (log.isDebugEnabled()) {
        log.debug("Proxy auth state: " + proxyState.getState());
      }
      if (isCachable(proxyState))
      {
        if (authCache == null)
        {
          authCache = new BasicAuthCache();
          context.setAttribute("http.auth.auth-cache", authCache);
        }
        switch (proxyState.getState())
        {
        case CHALLENGED: 
          cache(authCache, proxy, proxyState.getAuthScheme());
          break;
        case FAILURE: 
          uncache(authCache, proxy, proxyState.getAuthScheme());
        }
      }
    }
  }
  
  private boolean isCachable(AuthState authState)
  {
    AuthScheme authScheme = authState.getAuthScheme();
    if ((authScheme == null) || (!authScheme.isComplete())) {
      return false;
    }
    String schemeName = authScheme.getSchemeName();
    return (schemeName.equalsIgnoreCase("Basic")) || (schemeName.equalsIgnoreCase("Digest"));
  }
  
  private void cache(AuthCache authCache, HttpHost host, AuthScheme authScheme)
  {
    if (log.isDebugEnabled()) {
      log.debug("Caching '" + authScheme.getSchemeName() + "' auth scheme for " + host);
    }
    authCache.put(host, authScheme);
  }
  
  private void uncache(AuthCache authCache, HttpHost host, AuthScheme authScheme)
  {
    if (log.isDebugEnabled()) {
      log.debug("Removing from cache '" + authScheme.getSchemeName() + "' auth scheme for " + host);
    }
    authCache.remove(host);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.client.protocol.ResponseAuthCache
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.client.protocol;

import java.io.IOException;
import java.util.Locale;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
import org.apache.http.HttpEntity;
import org.apache.http.HttpException;
import org.apache.http.HttpResponse;
import org.apache.http.HttpResponseInterceptor;
import org.apache.http.annotation.Immutable;
import org.apache.http.client.entity.DeflateDecompressingEntity;
import org.apache.http.client.entity.GzipDecompressingEntity;
import org.apache.http.protocol.HttpContext;

@Immutable
public class ResponseContentEncoding
  implements HttpResponseInterceptor
{
  public static final String UNCOMPRESSED = "http.client.response.uncompressed";
  
  public void process(HttpResponse response, HttpContext context)
    throws HttpException, IOException
  {
    HttpEntity entity = response.getEntity();
    if ((entity != null) && (entity.getContentLength() != 0L))
    {
      Header ceheader = entity.getContentEncoding();
      if (ceheader != null)
      {
        HeaderElement[] codecs = ceheader.getElements();
        boolean uncompressed = false;
        HeaderElement[] arr$ = codecs;int len$ = arr$.length;int i$ = 0;
        if (i$ < len$)
        {
          HeaderElement codec = arr$[i$];
          String codecname = codec.getName().toLowerCase(Locale.US);
          if (("gzip".equals(codecname)) || ("x-gzip".equals(codecname)))
          {
            response.setEntity(new GzipDecompressingEntity(response.getEntity()));
            uncompressed = true;
          }
          else if ("deflate".equals(codecname))
          {
            response.setEntity(new DeflateDecompressingEntity(response.getEntity()));
            uncompressed = true;
          }
          else
          {
            if ("identity".equals(codecname)) {
              return;
            }
            throw new HttpException("Unsupported Content-Coding: " + codec.getName());
          }
        }
        if (uncompressed)
        {
          response.removeHeaders("Content-Length");
          response.removeHeaders("Content-Encoding");
          response.removeHeaders("Content-MD5");
        }
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.http.client.protocol.ResponseContentEncoding
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.client.protocol;

import java.io.IOException;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.Header;
import org.apache.http.HeaderIterator;
import org.apache.http.HttpException;
import org.apache.http.HttpResponse;
import org.apache.http.HttpResponseInterceptor;
import org.apache.http.annotation.Immutable;
import org.apache.http.client.CookieStore;
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.CookieOrigin;
import org.apache.http.cookie.CookieSpec;
import org.apache.http.cookie.MalformedCookieException;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;

@Immutable
public class ResponseProcessCookies
  implements HttpResponseInterceptor
{
  private final Log log = LogFactory.getLog(getClass());
  
  public void process(HttpResponse response, HttpContext context)
    throws HttpException, IOException
  {
    Args.notNull(response, "HTTP request");
    Args.notNull(context, "HTTP context");
    
    HttpClientContext clientContext = HttpClientContext.adapt(context);
    
    CookieSpec cookieSpec = clientContext.getCookieSpec();
    if (cookieSpec == null)
    {
      log.debug("Cookie spec not specified in HTTP context");
      return;
    }
    CookieStore cookieStore = clientContext.getCookieStore();
    if (cookieStore == null)
    {
      log.debug("Cookie store not specified in HTTP context");
      return;
    }
    CookieOrigin cookieOrigin = clientContext.getCookieOrigin();
    if (cookieOrigin == null)
    {
      log.debug("Cookie origin not specified in HTTP context");
      return;
    }
    HeaderIterator it = response.headerIterator("Set-Cookie");
    processCookies(it, cookieSpec, cookieOrigin, cookieStore);
    if (cookieSpec.getVersion() > 0)
    {
      it = response.headerIterator("Set-Cookie2");
      processCookies(it, cookieSpec, cookieOrigin, cookieStore);
    }
  }
  
  private void processCookies(HeaderIterator iterator, CookieSpec cookieSpec, CookieOrigin cookieOrigin, CookieStore cookieStore)
  {
    while (iterator.hasNext())
    {
      Header header = iterator.nextHeader();
      try
      {
        List<Cookie> cookies = cookieSpec.parse(header, cookieOrigin);
        for (Cookie cookie : cookies) {
          try
          {
            cookieSpec.validate(cookie, cookieOrigin);
            cookieStore.addCookie(cookie);
            if (log.isDebugEnabled()) {
              log.debug("Cookie accepted: \"" + cookie + "\". ");
            }
          }
          catch (MalformedCookieException ex)
          {
            if (log.isWarnEnabled()) {
              log.warn("Cookie rejected: \"" + cookie + "\". " + ex.getMessage());
            }
          }
        }
      }
      catch (MalformedCookieException ex)
      {
        if (log.isWarnEnabled()) {
          log.warn("Invalid cookie header: \"" + header + "\". " + ex.getMessage());
        }
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.http.client.protocol.ResponseProcessCookies
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.client.utils;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.apache.http.annotation.Immutable;

@Immutable
public class CloneUtils
{
  public static <T> T cloneObject(T obj)
    throws CloneNotSupportedException
  {
    if (obj == null) {
      return null;
    }
    if ((obj instanceof Cloneable))
    {
      Class<?> clazz = obj.getClass();
      Method m;
      try
      {
        m = clazz.getMethod("clone", (Class[])null);
      }
      catch (NoSuchMethodException ex)
      {
        throw new NoSuchMethodError(ex.getMessage());
      }
      try
      {
        return (T)m.invoke(obj, (Object[])null);
      }
      catch (InvocationTargetException ex)
      {
        Throwable cause = ex.getCause();
        if ((cause instanceof CloneNotSupportedException)) {
          throw ((CloneNotSupportedException)cause);
        }
        throw new Error("Unexpected exception", cause);
      }
      catch (IllegalAccessException ex)
      {
        throw new IllegalAccessError(ex.getMessage());
      }
    }
    throw new CloneNotSupportedException();
  }
  
  public static Object clone(Object obj)
    throws CloneNotSupportedException
  {
    return cloneObject(obj);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.client.utils.CloneUtils
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.client.utils;

import java.lang.ref.SoftReference;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;

final class DateUtils$DateFormatHolder$1
  extends ThreadLocal<SoftReference<Map<String, SimpleDateFormat>>>
{
  protected SoftReference<Map<String, SimpleDateFormat>> initialValue()
  {
    return new SoftReference(new HashMap());
  }
}

/* Location:
 * Qualified Name:     org.apache.http.client.utils.DateUtils.DateFormatHolder.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.client.utils;

import java.lang.ref.SoftReference;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;

final class DateUtils$DateFormatHolder
{
  private static final ThreadLocal<SoftReference<Map<String, SimpleDateFormat>>> THREADLOCAL_FORMATS = new ThreadLocal()
  {
    protected SoftReference<Map<String, SimpleDateFormat>> initialValue()
    {
      return new SoftReference(new HashMap());
    }
  };
  
  public static SimpleDateFormat formatFor(String pattern)
  {
    SoftReference<Map<String, SimpleDateFormat>> ref = (SoftReference)THREADLOCAL_FORMATS.get();
    Map<String, SimpleDateFormat> formats = (Map)ref.get();
    if (formats == null)
    {
      formats = new HashMap();
      THREADLOCAL_FORMATS.set(new SoftReference(formats));
    }
    SimpleDateFormat format = (SimpleDateFormat)formats.get(pattern);
    if (format == null)
    {
      format = new SimpleDateFormat(pattern, Locale.US);
      format.setTimeZone(TimeZone.getTimeZone("GMT"));
      formats.put(pattern, format);
    }
    return format;
  }
  
  public static void clearThreadLocal()
  {
    THREADLOCAL_FORMATS.remove();
  }
}

/* Location:
 * Qualified Name:     org.apache.http.client.utils.DateUtils.DateFormatHolder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.client.utils;

import java.lang.ref.SoftReference;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import org.apache.http.annotation.Immutable;
import org.apache.http.util.Args;

@Immutable
public final class DateUtils
{
  public static final String PATTERN_RFC1123 = "EEE, dd MMM yyyy HH:mm:ss zzz";
  public static final String PATTERN_RFC1036 = "EEE, dd-MMM-yy HH:mm:ss zzz";
  public static final String PATTERN_ASCTIME = "EEE MMM d HH:mm:ss yyyy";
  private static final String[] DEFAULT_PATTERNS = { "EEE, dd MMM yyyy HH:mm:ss zzz", "EEE, dd-MMM-yy HH:mm:ss zzz", "EEE MMM d HH:mm:ss yyyy" };
  private static final Date DEFAULT_TWO_DIGIT_YEAR_START;
  public static final TimeZone GMT = TimeZone.getTimeZone("GMT");
  
  static
  {
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeZone(GMT);
    calendar.set(2000, 0, 1, 0, 0, 0);
    calendar.set(14, 0);
    DEFAULT_TWO_DIGIT_YEAR_START = calendar.getTime();
  }
  
  public static Date parseDate(String dateValue)
  {
    return parseDate(dateValue, null, null);
  }
  
  public static Date parseDate(String dateValue, String[] dateFormats)
  {
    return parseDate(dateValue, dateFormats, null);
  }
  
  public static Date parseDate(String dateValue, String[] dateFormats, Date startDate)
  {
    Args.notNull(dateValue, "Date value");
    String[] localDateFormats = dateFormats != null ? dateFormats : DEFAULT_PATTERNS;
    Date localStartDate = startDate != null ? startDate : DEFAULT_TWO_DIGIT_YEAR_START;
    String v = dateValue;
    if ((v.length() > 1) && (v.startsWith("'")) && (v.endsWith("'"))) {
      v = v.substring(1, v.length() - 1);
    }
    for (String dateFormat : localDateFormats)
    {
      SimpleDateFormat dateParser = DateFormatHolder.formatFor(dateFormat);
      dateParser.set2DigitYearStart(localStartDate);
      ParsePosition pos = new ParsePosition(0);
      Date result = dateParser.parse(v, pos);
      if (pos.getIndex() != 0) {
        return result;
      }
    }
    return null;
  }
  
  public static String formatDate(Date date)
  {
    return formatDate(date, "EEE, dd MMM yyyy HH:mm:ss zzz");
  }
  
  public static String formatDate(Date date, String pattern)
  {
    Args.notNull(date, "Date");
    Args.notNull(pattern, "Pattern");
    SimpleDateFormat formatter = DateFormatHolder.formatFor(pattern);
    return formatter.format(date);
  }
  
  public static void clearThreadLocal() {}
  
  static final class DateFormatHolder
  {
    private static final ThreadLocal<SoftReference<Map<String, SimpleDateFormat>>> THREADLOCAL_FORMATS = new ThreadLocal()
    {
      protected SoftReference<Map<String, SimpleDateFormat>> initialValue()
      {
        return new SoftReference(new HashMap());
      }
    };
    
    public static SimpleDateFormat formatFor(String pattern)
    {
      SoftReference<Map<String, SimpleDateFormat>> ref = (SoftReference)THREADLOCAL_FORMATS.get();
      Map<String, SimpleDateFormat> formats = (Map)ref.get();
      if (formats == null)
      {
        formats = new HashMap();
        THREADLOCAL_FORMATS.set(new SoftReference(formats));
      }
      SimpleDateFormat format = (SimpleDateFormat)formats.get(pattern);
      if (format == null)
      {
        format = new SimpleDateFormat(pattern, Locale.US);
        format.setTimeZone(TimeZone.getTimeZone("GMT"));
        formats.put(pattern, format);
      }
      return format;
    }
    
    public static void clearThreadLocal()
    {
      THREADLOCAL_FORMATS.remove
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