private BasicAuthCache _getBasicAuthCache() {
    BasicAuthCache basicAuthCache = new BasicAuthCache();

    BasicScheme basicScheme = new BasicScheme();

    basicAuthCache.put(_httpHost, basicScheme);

    return basicAuthCache;
  }
  public void init() {
    /*
    loadLiferayProperties();

    hostname = liferayProperties.getProperty(FFPORTAL_SERVER_HOSTNAME);
    port = liferayProperties.getProperty(FFPORTAL_SERVER_PORT);
    companyId = liferayProperties.getProperty(FFPORTAL_REPOSITORY_COMPANYID);
    loginGroupId = liferayProperties.getProperty(FFPORTAL_USER_GROUP_ID);
    loginEmail = liferayProperties.getProperty(FFPORTAL_USER_EMAIL);
    loginPassword = liferayProperties.getProperty(FFPORTAL_USER_PASSWORD);
    */
    targetHost = new HttpHost(hostname, Integer.valueOf(port), "http");
    PoolingClientConnectionManager cxMgr =
        new PoolingClientConnectionManager(SchemeRegistryFactory.createDefault());
    cxMgr.setMaxTotal(100);
    cxMgr.setDefaultMaxPerRoute(20);
    httpclient = new DefaultHttpClient(cxMgr);

    httpclient
        .getCredentialsProvider()
        .setCredentials(
            new AuthScope(targetHost.getHostName(), targetHost.getPort()),
            new UsernamePasswordCredentials(loginEmail, loginPassword));

    // Create AuthCache instance
    this.authCache = new BasicAuthCache();
    // Generate BASIC scheme object and add it to the local
    // auth cache
    BasicScheme basicAuth = new BasicScheme();
    authCache.put(targetHost, basicAuth);
  }
Example #3
0
 public HTTPSession clearCredentialsCache() {
   BasicAuthCache ac =
       (BasicAuthCache) this.sessioncontext.getAttribute(HttpClientContext.AUTH_CACHE);
   if (ac != null) ac.clear();
   return this;
 }