Example usage for org.apache.commons.httpclient.params HostParams getParameter

List of usage examples for org.apache.commons.httpclient.params HostParams getParameter

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.params HostParams getParameter.

Prototype

public Object getParameter(String paramString) 

Source Link

Usage

From source file:org.globus.axis.transport.commons.CommonsHttpConnectionManager.java

private ExtendedHttpConnection getNewConnection(HostConfiguration hostConfiguration) {
    ExtendedHttpConnection httpConnection = new ExtendedHttpConnection(hostConfiguration, this.staleChecking);
    httpConnection.setHttpConnectionManager(this);
    HttpConnectionParams connectionParams = httpConnection.getParams();
    connectionParams.setDefaults(this.params);

    if (this.hostConfigurationParams != null) {
        HostParams hostParams = hostConfiguration.getParams();
        for (int i = 0; i < this.hostConfigurationParams.length; i++) {
            String key = this.hostConfigurationParams[i];
            Object value = hostParams.getParameter(key);
            if (value != null) {
                connectionParams.setParameter(key, value);
            }//from w  w w  .j  av  a2  s .co m
        }
    }

    if (logger.isDebugEnabled()) {
        logger.debug("got new connection: " + httpConnection);
    }

    return httpConnection;
}

From source file:org.jetbrains.tfsIntegration.webservice.WebServiceHelper.java

private static void setCredentials(final @NotNull HttpClient httpClient, final @NotNull Credentials credentials,
        final @NotNull URI serverUri) {
    if (credentials.getType() == Credentials.Type.Alternate) {
        HostParams parameters = httpClient.getHostConfiguration().getParams();
        Collection<Header> headers = (Collection<Header>) parameters.getParameter(HostParams.DEFAULT_HEADERS);

        if (headers == null) {
            headers = new ArrayList<Header>();
            parameters.setParameter(HostParams.DEFAULT_HEADERS, headers);
        }/*ww  w.ja va2  s.co  m*/

        Header authHeader = ContainerUtil.find(headers, new Condition<Header>() {
            @Override
            public boolean value(Header header) {
                return header.getName().equals(HTTPConstants.HEADER_AUTHORIZATION);
            }
        });

        if (authHeader == null) {
            authHeader = new Header(HTTPConstants.HEADER_AUTHORIZATION, "");
            headers.add(authHeader);
        }

        authHeader.setValue(BasicScheme.authenticate(
                new UsernamePasswordCredentials(credentials.getUserName(), credentials.getPassword()),
                "UTF-8"));
    } else {
        final NTCredentials ntCreds = new NTCredentials(credentials.getUserName(), credentials.getPassword(),
                serverUri.getHost(), credentials.getDomain());
        httpClient.getState().setCredentials(AuthScope.ANY, ntCreds);
        httpClient.getParams().setBooleanParameter(USE_NATIVE_CREDENTIALS,
                credentials.getType() == Credentials.Type.NtlmNative);
    }
}