Example usage for org.apache.http.auth AuthScope ANY_HOST

List of usage examples for org.apache.http.auth AuthScope ANY_HOST

Introduction

In this page you can find the example usage for org.apache.http.auth AuthScope ANY_HOST.

Prototype

String ANY_HOST

To view the source code for org.apache.http.auth AuthScope ANY_HOST.

Click Source Link

Document

The null value represents any host.

Usage

From source file:com.ibm.dataworks.DataLoadResource.java

/** 
 * Create an HTTP client object that is authenticated with the user and password
 * of the IBM DataWorks Service./*from  w w w.ja va  2s .  c  o m*/
 */
private HttpClient getAuthenticatedHttpClient() throws GeneralSecurityException {
    // NOTE: If you re-purpose this code for your own application you might want to have 
    // additional security mechanisms in place regarding certificate authentication.

    // build credentials object
    UsernamePasswordCredentials creds = new UsernamePasswordCredentials(vcapInfo.getUser(),
            vcapInfo.getPassword());
    CredentialsProvider credsProvider = new BasicCredentialsProvider();
    credsProvider.setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), creds);
    // For demo purposes only: always accept the certificate 
    TrustStrategy accepAllTrustStrategy = new TrustStrategy() {
        @Override
        public boolean isTrusted(X509Certificate[] certificate, String authType) {
            return true;
        }
    };
    SSLContextBuilder contextBuilder = new SSLContextBuilder();
    SSLContext context = contextBuilder.loadTrustMaterial(null, accepAllTrustStrategy).build();
    SSLConnectionSocketFactory scsf = new SSLConnectionSocketFactory(context, new AllowAllHostnameVerifier());

    HttpClient httpClient = HttpClientBuilder.create() //
            .setSSLSocketFactory(scsf) //
            .setDefaultCredentialsProvider(credsProvider) //
            .build();

    return httpClient;
}

From source file:com.gs.tools.doc.extractor.core.util.HttpUtility.java

public static DefaultHttpClient getLoginHttpsClient(String userName, String password) {
    try {// ww w  .  j  a v a  2 s  .c  o m
        KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
        trustStore.load(null, null);

        SSLSocketFactory sf = new DefaultSecureSocketFactory(trustStore);
        sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);

        HttpParams params = new BasicHttpParams();
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
        HttpConnectionParams.setConnectionTimeout(params, 300000);
        HttpConnectionParams.setSocketBufferSize(params, 10485760);
        HttpConnectionParams.setSoTimeout(params, 300000);

        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        registry.register(new Scheme("https", sf, 443));

        ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);

        DefaultHttpClient httpClient = new DefaultHttpClient(ccm, params);
        httpClient.getCredentialsProvider().setCredentials(
                new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM),
                new UsernamePasswordCredentials(userName, password));
        return httpClient;
    } catch (Exception e) {
        e.printStackTrace();
        return new DefaultHttpClient();
    }
}

From source file:com.mirth.connect.connectors.ws.WebServiceDispatcher.java

/**
 * Returns the URL for the passed in String. If the URL requires authentication, then the WSDL
 * is saved as a temp file and the URL for that file is returned.
 * /*from w ww.  j a  v a2 s . c om*/
 * @param wsdlUrl
 * @param username
 * @param password
 * @return
 * @throws Exception
 */
private URL getWsdlUrl(DispatchContainer dispatchContainer) throws Exception {
    URI uri = new URI(dispatchContainer.getCurrentWsdlUrl());

    // If the URL points to file, just return it
    if (!uri.getScheme().equalsIgnoreCase("file")) {
        BasicHttpClientConnectionManager httpClientConnectionManager = new BasicHttpClientConnectionManager(
                socketFactoryRegistry.build());
        httpClientConnectionManager.setSocketConfig(SocketConfig.custom().setSoTimeout(timeout).build());
        HttpClientBuilder clientBuilder = HttpClients.custom()
                .setConnectionManager(httpClientConnectionManager);
        HttpUtil.configureClientBuilder(clientBuilder);
        CloseableHttpClient client = clientBuilder.build();

        try {
            clients.add(client);
            HttpClientContext context = HttpClientContext.create();

            if (dispatchContainer.getCurrentUsername() != null
                    && dispatchContainer.getCurrentPassword() != null) {
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                AuthScope authScope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT,
                        AuthScope.ANY_REALM);
                Credentials credentials = new UsernamePasswordCredentials(
                        dispatchContainer.getCurrentUsername(), dispatchContainer.getCurrentPassword());
                credsProvider.setCredentials(authScope, credentials);
                AuthCache authCache = new BasicAuthCache();
                RegistryBuilder<AuthSchemeProvider> registryBuilder = RegistryBuilder
                        .<AuthSchemeProvider>create();
                registryBuilder.register(AuthSchemes.BASIC, new BasicSchemeFactory());

                context.setCredentialsProvider(credsProvider);
                context.setAuthSchemeRegistry(registryBuilder.build());
                context.setAuthCache(authCache);
            }

            RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(timeout)
                    .setSocketTimeout(timeout).setStaleConnectionCheckEnabled(true).build();
            context.setRequestConfig(requestConfig);

            return getWsdl(client, context, dispatchContainer, new HashMap<String, File>(),
                    dispatchContainer.getCurrentWsdlUrl()).toURI().toURL();
        } finally {
            HttpClientUtils.closeQuietly(client);
            clients.remove(client);
        }
    }

    return uri.toURL();
}

From source file:org.apache.abdera2.common.protocol.Session.java

public void usePreemptiveAuthentication(String target, String realm) throws URISyntaxException {
    AuthCache cache = (AuthCache) localContext.getAttribute(ClientContext.AUTH_CACHE);
    if (cache == null) {
        String host = AuthScope.ANY_HOST;
        int port = AuthScope.ANY_PORT;
        if (target != null) {
            URI uri = new URI(target);
            host = uri.getHost();//from  ww  w.j a  va 2s .  c  o  m
            port = uri.getPort();
        }
        BasicScheme basicAuth = new BasicScheme();
        HttpHost targetHost = new HttpHost(host, port, basicAuth.getSchemeName());
        cache = new BasicAuthCache();
        cache.put(targetHost, basicAuth);
        localContext.setAttribute(ClientContext.AUTH_CACHE, cache);
    }
}

From source file:com.soundcloud.playerapi.ApiWrapper.java

/** @return The HttpClient instance used to make the calls */
public HttpClient getHttpClient() {
    if (httpClient == null) {
        final HttpParams params = getParams();
        HttpClientParams.setRedirecting(params, false);
        HttpProtocolParams.setUserAgent(params, getUserAgent());

        final SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", getSocketFactory(), 80));
        final SSLSocketFactory sslFactory = getSSLSocketFactory();
        registry.register(new Scheme("https", sslFactory, 443));
        httpClient = new DefaultHttpClient(new ThreadSafeClientConnManager(params, registry), params) {
            {/*from w w  w . j a v  a2 s  .  c om*/
                setKeepAliveStrategy(new ConnectionKeepAliveStrategy() {
                    @Override
                    public long getKeepAliveDuration(HttpResponse httpResponse, HttpContext httpContext) {
                        return KEEPALIVE_TIMEOUT;
                    }
                });

                getCredentialsProvider().setCredentials(
                        new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, CloudAPI.REALM, OAUTH_SCHEME),
                        OAuth2Scheme.EmptyCredentials.INSTANCE);

                getAuthSchemes().register(CloudAPI.OAUTH_SCHEME, new OAuth2Scheme.Factory(ApiWrapper.this));

                addResponseInterceptor(new HttpResponseInterceptor() {
                    @Override
                    public void process(HttpResponse response, HttpContext context)
                            throws HttpException, IOException {
                        if (response == null || response.getEntity() == null)
                            return;

                        HttpEntity entity = response.getEntity();
                        Header header = entity.getContentEncoding();
                        if (header != null) {
                            for (HeaderElement codec : header.getElements()) {
                                if (codec.getName().equalsIgnoreCase("gzip")) {
                                    response.setEntity(new GzipDecompressingEntity(entity));
                                    break;
                                }
                            }
                        }
                    }
                });
            }

            @Override
            protected HttpContext createHttpContext() {
                HttpContext ctxt = super.createHttpContext();
                ctxt.setAttribute(ClientContext.AUTH_SCHEME_PREF,
                        Arrays.asList(CloudAPI.OAUTH_SCHEME, "digest", "basic"));
                return ctxt;
            }

            @Override
            protected BasicHttpProcessor createHttpProcessor() {
                BasicHttpProcessor processor = super.createHttpProcessor();
                processor.addInterceptor(new OAuth2HttpRequestInterceptor());
                return processor;
            }

            // for testability only
            @Override
            protected RequestDirector createClientRequestDirector(HttpRequestExecutor requestExec,
                    ClientConnectionManager conman, ConnectionReuseStrategy reustrat,
                    ConnectionKeepAliveStrategy kastrat, HttpRoutePlanner rouplan, HttpProcessor httpProcessor,
                    HttpRequestRetryHandler retryHandler, RedirectHandler redirectHandler,
                    AuthenticationHandler targetAuthHandler, AuthenticationHandler proxyAuthHandler,
                    UserTokenHandler stateHandler, HttpParams params) {
                return getRequestDirector(requestExec, conman, reustrat, kastrat, rouplan, httpProcessor,
                        retryHandler, redirectHandler, targetAuthHandler, proxyAuthHandler, stateHandler,
                        params);
            }
        };
    }
    return httpClient;
}

From source file:uk.org.openeyes.oink.itest.adapters.ITProxyAdapter.java

@Test
public void testCreatePatient() throws Exception {

    Thread.sleep(10000);//from w  w w. j  ava 2 s .c  om

    OINKRequestMessage req = new OINKRequestMessage();
    req.setResourcePath("/Patient");
    req.setMethod(HttpMethod.POST);

    InputStream is = ITProxyAdapter.class.getResourceAsStream("/example-messages/fhir/patient2.json");
    Parser parser = new JsonParser();
    Patient p = (Patient) parser.parse(is);

    FhirBody body = new FhirBody(p);
    req.setBody(body);

    RabbitClient client = new RabbitClient(props.getProperty("rabbit.host"),
            Integer.parseInt(props.getProperty("rabbit.port")), props.getProperty("rabbit.vhost"),
            props.getProperty("rabbit.username"), props.getProperty("rabbit.password"));

    OINKResponseMessage resp = client.sendAndRecieve(req, props.getProperty("rabbit.routingKey"),
            props.getProperty("rabbit.defaultExchange"));

    assertEquals(201, resp.getStatus());

    String locationHeader = resp.getLocationHeader();
    assertNotNull(locationHeader);
    assertFalse(locationHeader.isEmpty());
    log.info("Posted to " + locationHeader);

    // Check exists on server
    // See if Patient exists
    DefaultHttpClient httpClient = new DefaultHttpClient();

    httpClient.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT),
            new UsernamePasswordCredentials("admin", "admin"));

    HttpGet httpGet = new HttpGet(locationHeader);
    httpGet.setHeader("Accept", "application/fhir+json");
    HttpResponse response1 = httpClient.execute(httpGet);
    assertEquals(200, response1.getStatusLine().getStatusCode());
}

From source file:com.imense.imenseANPRsdkProAUNZ.ImenseLicenseServer.java

@Override
protected Boolean doInBackground(Void... arg0) {

    try {/*from   w w w  . j a  v a2 s  .  com*/

        int[] uid_success = { 0 };
        //generate unique device ID
        String device_uid = ImenseOCRTask.getUniqueDeviceID(androidAppContext, uid_success);

        if (device_uid == null || device_uid.length() < VALID_UID_LENGTH) {
            throw new Exception("Invalid UID");
        }

        // Instantiate the custom HttpClient
        DefaultHttpClient client = new MyHttpClient(androidAppContext.getApplicationContext());

        //see http://hc.apache.org/httpcomponents-client/httpclient/xref/index.html
        CredentialsProvider credsProvider = new BasicCredentialsProvider();
        credsProvider.setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT),
                new UsernamePasswordCredentials(ImenseLicenseServerLogin, ImenseLicenseServerPassword));
        client.setCredentialsProvider(credsProvider);

        HttpGet httpget = new HttpGet(ImenseLicenseServerURL + device_uid);

        // Execute the GET call and obtain the response
        HttpResponse httpresponse = client.execute(httpget);
        HttpEntity resEntity = httpresponse.getEntity();

        //System.out.println("Response Status: <"+httpresponse.getStatusLine()+">");
        if (resEntity != null) {
            String resS = EntityUtils.toString(resEntity);
            resS = resS.trim();

            if (resS.length() == VALID_KEY_LENGTH && !resS.startsWith("Error:")) {
                //this should be a valid key!
                licensekey = resS;
            } else {
                if (resS.startsWith("Error:")) {
                    serverResponseMessage = resS; //human readable error message
                }
            }
        }
        if (resEntity != null) {
            resEntity.consumeContent();
        }

        // When HttpClient instance is no longer needed,
        // shut down the connection manager to ensure
        // immediate deallocation of all system resources
        client.getConnectionManager().shutdown();

    } catch (Exception ex) {
        ex.printStackTrace();
    }

    if (licensekey != null && licensekey.length() == VALID_KEY_LENGTH) {
        //verify license key

        int verificationResponse = ImenseOCRTask.verifyLicenseKey(androidAppContext, licensekey);

        //"verificationResponse" may take on the following values:
        //0: license key invalid or expired
        //1: license key valid for more than 14 days
        //>1: license key valid for "verificationResponse-1" number of days

        if (verificationResponse < 1) {
            licensekey = null;
            return false;
        }

        return true;
    } //if (licensekey != null && licensekey.length()==VALID_KEY_LENGTH) {

    return false;
}

From source file:com.mnxfst.testing.activities.http.AbstractHTTPRequestActivity.java

/**
 * @see com.mnxfst.testing.activities.TSPlanActivity#initialize(com.mnxfst.testing.plan.config.TSPlanConfigOption)
 *//*w  w  w.j  ava2 s . c om*/
public void initialize(TSPlanConfigOption cfg) throws TSPlanActivityExecutionException {

    if (cfg == null)
        throw new TSPlanActivityExecutionException("Failed to initialize activity '" + this.getClass().getName()
                + "' due to missing configuration options");

    /////////////////////////////////////////////////////////////////////////////////////////
    // fetch scheme, host, port and path

    this.scheme = (String) cfg.getOption(CFG_OPT_SCHEME);
    if (this.scheme == null || this.scheme.isEmpty())
        throw new TSPlanActivityExecutionException(
                "Required config option '" + CFG_OPT_SCHEME + "' missing for activity '" + getName() + "'");

    this.host = (String) cfg.getOption(CFG_OPT_HOST);
    if (this.host == null || this.host.isEmpty())
        throw new TSPlanActivityExecutionException(
                "Requied config option '" + CFG_OPT_HOST + "' missing for activity '" + getName() + "'");

    String portStr = (String) cfg.getOption(CFG_OPT_PORT);
    if (portStr != null && !portStr.isEmpty()) {
        try {
            this.port = Integer.parseInt(portStr.trim());
        } catch (NumberFormatException e) {
            throw new TSPlanActivityExecutionException(
                    "Failed to parse expected numerical value for config option '" + CFG_OPT_PORT
                            + "' for activity '" + getName() + "'");
        }
    }

    // fetch username and password
    this.basicAuthUsername = (String) cfg.getOption(CFG_OPT_BASIC_AUTH_USERNAME);
    this.basicAuthPassword = (String) cfg.getOption(CFG_OPT_BASIC_AUTH_PASSWORD);
    this.basicAuthHostScope = (String) cfg.getOption(CFG_OPT_BASIC_AUTH_HOST_SCOPE);

    String authPortScopeStr = (String) cfg.getOption(CFG_OPT_BASIC_AUTH_PORT_SCOPE);
    if (authPortScopeStr != null && !authPortScopeStr.trim().isEmpty()) {
        try {
            this.basicAuthPortScope = Integer.parseInt(authPortScopeStr.trim());
        } catch (NumberFormatException e) {
            throw new TSPlanActivityExecutionException(
                    "Failed to parse expected numerical value for config option '"
                            + CFG_OPT_BASIC_AUTH_PORT_SCOPE + "' for activity '" + getName() + "'");
        }
    }

    if (this.port <= 0)
        this.port = 80;

    this.path = (String) cfg.getOption(CFG_OPT_PATH);
    if (this.path == null || this.path.isEmpty())
        this.path = "/";

    String maxConnStr = (String) cfg.getOption(CFG_OPT_MAX_CONNECTIONS);
    if (maxConnStr != null && !maxConnStr.isEmpty()) {
        try {
            this.maxConnections = Integer.parseInt(maxConnStr);
        } catch (NumberFormatException e) {
            throw new TSPlanActivityExecutionException(
                    "Failed to parse expected numerical value for config option '" + CFG_OPT_MAX_CONNECTIONS
                            + "' for activity '" + getName() + "'");
        }
    }

    // initialize http host and context
    this.httpHost = new HttpHost(this.host, this.port);

    // URI builder
    try {

        // query parameters
        List<NameValuePair> qParams = new ArrayList<NameValuePair>();
        for (String key : cfg.getOptions().keySet()) {
            if (key.startsWith(REQUEST_PARAM_OPTION_PREFIX)) {
                String value = (String) cfg.getOption(key);
                String requestParameterName = key.substring(REQUEST_PARAM_OPTION_PREFIX.length(), key.length());
                qParams.add(new BasicNameValuePair(requestParameterName, value));

                if (logger.isDebugEnabled())
                    logger.debug("activity[name=" + getName() + ", id=" + getId() + ", requestParameter="
                            + requestParameterName + ", value=" + value + "]");
            }
        }

        this.destinationURI = URIUtils.createURI(this.scheme, this.host, this.port, this.path,
                URLEncodedUtils.format(qParams, this.contentChartset), null);

        // TODO handle post values

    } catch (URISyntaxException e) {
        throw new TSPlanActivityExecutionException("Failed to initialize uri for [scheme=" + this.scheme
                + ", host=" + this.host + ", port=" + this.port + ", path=" + this.path + "]");
    }

    httpRequestContext.setAttribute(ExecutionContext.HTTP_CONNECTION, clientConnection);
    httpRequestContext.setAttribute(ExecutionContext.HTTP_TARGET_HOST, httpHost);

    if (logger.isDebugEnabled())
        logger.debug("activity[name=" + getName() + ", id=" + getId() + ", maxConnections=" + maxConnections
                + ", scheme=" + scheme + ", host=" + host + ", port=" + port + ", path=" + path + "]");

    /////////////////////////////////////////////////////////////////////////////////////////

    /////////////////////////////////////////////////////////////////////////////////////////
    // protocol settings

    this.userAgent = (String) cfg.getOption(CFG_OPT_USER_AGENT);
    if (this.userAgent == null || this.userAgent.isEmpty())
        this.userAgent = "ptest-server";

    String protocolVersion = (String) cfg.getOption(CFG_OPT_HTTP_PROTOCOL_VERSION);
    if (protocolVersion != null && !protocolVersion.isEmpty()) {
        if (protocolVersion.equalsIgnoreCase("0.9"))
            this.httpVersion = HttpVersion.HTTP_0_9;
        else if (protocolVersion.equalsIgnoreCase("1.0"))
            this.httpVersion = HttpVersion.HTTP_1_0;
        else if (protocolVersion.equalsIgnoreCase("1.1"))
            this.httpVersion = HttpVersion.HTTP_1_1;
        else
            throw new TSPlanActivityExecutionException("Failed to parse http protocol version '"
                    + protocolVersion + "'. Valid value: 0.9, 1.0 and 1.1");
    }

    this.contentChartset = (String) cfg.getOption(CFG_OPT_CONTENT_CHARSET);
    if (this.contentChartset == null || this.contentChartset.isEmpty())
        this.contentChartset = "UTF-8";

    String expectContStr = (String) cfg.getOption(CFG_OPT_EXPECT_CONTINUE);
    if (expectContStr != null && !expectContStr.isEmpty()) {
        this.expectContinue = Boolean.parseBoolean(expectContStr.trim());
    }

    HttpProtocolParams.setUserAgent(httpParameters, userAgent);
    HttpProtocolParams.setVersion(httpParameters, httpVersion);
    HttpProtocolParams.setContentCharset(httpParameters, contentChartset);
    HttpProtocolParams.setUseExpectContinue(httpParameters, expectContinue);

    String httpProcStr = (String) cfg.getOption(CFG_OPT_HTTP_REQUEST_PROCESSORS);
    if (httpProcStr != null && !httpProcStr.isEmpty()) {
        List<HttpRequestInterceptor> interceptors = new ArrayList<HttpRequestInterceptor>();
        String[] procClasses = httpProcStr.split(",");
        if (procClasses != null && procClasses.length > 0) {
            for (int i = 0; i < procClasses.length; i++) {
                try {
                    Class<?> clazz = Class.forName(procClasses[i]);
                    interceptors.add((HttpRequestInterceptor) clazz.newInstance());

                    if (logger.isDebugEnabled())
                        logger.debug("activity[name=" + getName() + ", id=" + getId()
                                + ", httpRequestInterceptor=" + procClasses[i] + "]");
                } catch (Exception e) {
                    throw new TSPlanActivityExecutionException("Failed to instantiate http interceptor '"
                            + procClasses[i] + "' for activity '" + getName() + "'. Error: " + e.getMessage());
                }
            }
        }

        this.httpRequestResponseProcessor = new ImmutableHttpProcessor(
                (HttpRequestInterceptor[]) interceptors.toArray(EMPTY_HTTP_REQUEST_INTERCEPTOR_ARRAY));
        this.hasRequestResponseProcessors = true;
    }

    this.method = (String) cfg.getOption(CFG_OPT_METHOD);
    if (method == null || method.isEmpty())
        this.method = "GET";
    if (!method.equalsIgnoreCase("get") && !method.equalsIgnoreCase("post"))
        throw new TSPlanActivityExecutionException(
                "Invalid method '" + method + "' found for activity '" + getName() + "'");

    if (logger.isDebugEnabled())
        logger.debug("activity[name=" + getName() + ", id=" + getId() + ", method=" + method + ", user-agent="
                + userAgent + ", httpVersion=" + httpVersion + ", contentCharset=" + contentChartset
                + ", expectContinue=" + expectContinue + "]");

    /////////////////////////////////////////////////////////////////////////////////////////

    /////////////////////////////////////////////////////////////////////////////////////////
    // fetch proxy settings

    this.proxyUrl = (String) cfg.getOption(CFG_OPT_PROXY_URL);

    String proxyPortStr = (String) cfg.getOption(CFG_OPT_PROXY_PORT);
    if (proxyPortStr != null && !proxyPortStr.isEmpty()) {
        try {
            this.proxyPort = Integer.parseInt(proxyPortStr.trim());
        } catch (NumberFormatException e) {
            throw new TSPlanActivityExecutionException(
                    "Failed to parse expected numerical value for config option '" + CFG_OPT_PROXY_PORT
                            + "' for activity '" + getName() + "'");
        }
    }

    this.proxyUser = (String) cfg.getOption(CFG_OPT_PROXY_USER);
    this.proxyPassword = (String) cfg.getOption(CFG_OPT_PROXY_PASSWORD);

    if (proxyUrl != null && !proxyUrl.isEmpty()) {

        if (proxyPort > 0)
            this.proxyHost = new HttpHost(proxyUrl, proxyPort);
        else
            this.proxyHost = new HttpHost(proxyUrl);
    }

    if (logger.isDebugEnabled())
        logger.debug("activity[name=" + getName() + ", id=" + getId() + ", proxyUrl=" + proxyUrl
                + ", proxyPort=" + proxyPort + ", proxyUser=" + proxyUser + "]");

    /////////////////////////////////////////////////////////////////////////////////////////

    //      /////////////////////////////////////////////////////////////////////////////////////////
    //      // fetch request parameters
    //
    //      // unfortunately we must step through the whole set of keys ... 
    //      for(String key : cfg.getOptions().keySet()) {
    //         if(key.startsWith(REQUEST_PARAM_OPTION_PREFIX)) {
    //            String value = (String)cfg.getOption(key);
    //            String requestParameterName = key.substring(REQUEST_PARAM_OPTION_PREFIX.length(), key.length());            
    //            httpParameters.setParameter(requestParameterName, value);            
    //            if(logger.isDebugEnabled())
    //               logger.debug("activity[name="+getName()+", id="+getId()+", requestParameter="+requestParameterName+", value="+value+"]");
    //         }
    //      }
    //
    //      /////////////////////////////////////////////////////////////////////////////////////////

    /////////////////////////////////////////////////////////////////////////////////////////
    // configure scheme registry and initialize http client

    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
    schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));

    if (logger.isDebugEnabled())
        logger.debug("activity[name=" + getName() + ", id=" + getId() + ", registeredSchemes={http, https}]");

    ThreadSafeClientConnManager threadSafeClientConnectionManager = new ThreadSafeClientConnManager(
            schemeRegistry);
    threadSafeClientConnectionManager.setMaxTotal(maxConnections);
    threadSafeClientConnectionManager.setDefaultMaxPerRoute(maxConnections);
    this.httpClient = new DefaultHttpClient(threadSafeClientConnectionManager);

    if (this.basicAuthUsername != null && !this.basicAuthUsername.trim().isEmpty()
            && this.basicAuthPassword != null && !this.basicAuthPassword.trim().isEmpty()) {
        UsernamePasswordCredentials creds = new UsernamePasswordCredentials(this.basicAuthUsername,
                this.basicAuthPassword);
        AuthScope authScope = null;
        if (basicAuthHostScope != null && !basicAuthHostScope.isEmpty() && basicAuthPortScope > 0) {
            authScope = new AuthScope(basicAuthHostScope, basicAuthPortScope);
        } else {
            authScope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT);
        }

        this.httpClient.getCredentialsProvider().setCredentials(authScope, creds);

        if (logger.isDebugEnabled())
            logger.debug("activity[name=" + getName() + ", id=" + getId() + ", credentials=("
                    + creds.getUserName() + ", " + creds.getPassword() + "), authScope=(" + authScope.getHost()
                    + ":" + authScope.getPort() + ")]");
    }

    if (logger.isDebugEnabled())
        logger.debug("activity[name=" + getName() + ", id=" + getId()
                + ", threadSafeClientConnectionManager=initialized]");

}