use of org.apache.commons.httpclient.MultiThreadedHttpConnectionManager in project cloudstack by apache.
the class UriUtils method getHttpClient.
/**
* Return HttpClient with connection timeout
*/
private static HttpClient getHttpClient() {
MultiThreadedHttpConnectionManager s_httpClientManager = new MultiThreadedHttpConnectionManager();
s_httpClientManager.getParams().setConnectionTimeout(5000);
return new HttpClient(s_httpClientManager);
}
use of org.apache.commons.httpclient.MultiThreadedHttpConnectionManager in project zaproxy by zaproxy.
the class HttpSender method createHttpClientViaProxy.
private HttpClient createHttpClientViaProxy() {
if (!param.isUseProxyChain()) {
return createHttpClient();
}
httpConnManagerProxy = new MultiThreadedHttpConnectionManager();
setCommonManagerParams(httpConnManagerProxy);
HttpClient clientProxy = new HttpClient(httpConnManagerProxy);
clientProxy.getHostConfiguration().setProxy(param.getProxyChainName(), param.getProxyChainPort());
setProxyAuth(clientProxy);
return clientProxy;
}
use of org.apache.commons.httpclient.MultiThreadedHttpConnectionManager in project zaproxy by zaproxy.
the class HttpSender method createHttpClient.
private HttpClient createHttpClient() {
httpConnManager = new MultiThreadedHttpConnectionManager();
setCommonManagerParams(httpConnManager);
return new HttpClient(httpConnManager);
}
use of org.apache.commons.httpclient.MultiThreadedHttpConnectionManager in project wso2-synapse by wso2.
the class NTLMMediator method mediate.
public boolean mediate(MessageContext messageContext) {
if (log.isDebugEnabled()) {
log.debug("[NTLMMediator] mediate method Invoked.");
}
// Creating a HTTP authenticator to cater the NTLM Authentication scheme
HttpTransportProperties.Authenticator authenticator = new HttpTransportProperties.Authenticator();
List<String> authScheme = new ArrayList<String>();
authScheme.add(HttpTransportProperties.Authenticator.NTLM);
authenticator.setAuthSchemes(authScheme);
// checks the attribute values are dynamic or not and set the dynamic values if available
String username = this.username;
if (dynamicUsername != null) {
username = dynamicUsername.evaluateValue(messageContext);
if (StringUtils.isEmpty(username)) {
log.warn("Evaluated value for " + this.username + " is empty");
}
}
String password = this.password;
if (dynamicPassword != null) {
password = dynamicPassword.evaluateValue(messageContext);
if (StringUtils.isEmpty(password)) {
log.warn("Evaluated value for " + this.password + " is empty");
}
}
String domain = this.domain;
if (dynamicDomain != null) {
domain = dynamicDomain.evaluateValue(messageContext);
if (StringUtils.isEmpty(domain)) {
log.warn("Evaluated value for " + this.domain + " is empty");
}
}
String host = this.host;
if (dynamicHost != null) {
host = dynamicHost.evaluateValue(messageContext);
if (StringUtils.isEmpty(host)) {
log.warn("Evaluated value for " + this.host + " is empty");
}
}
String ntlmVersion = this.ntlmVersion;
if (dynamicNtmlVersion != null) {
ntlmVersion = dynamicNtmlVersion.evaluateValue(messageContext);
if (StringUtils.isEmpty(ntlmVersion)) {
log.warn("Evaluated value for " + this.ntlmVersion + " is empty");
}
}
if (username != null) {
authenticator.setUsername(username);
} else {
if (log.isDebugEnabled()) {
log.debug("[NTLMMediator] Username not specified.");
}
}
if (password != null) {
authenticator.setPassword(resolveSecureVaultExpressions(password, messageContext));
} else {
if (log.isDebugEnabled()) {
log.debug("[NTLMMediator] Password not specified.");
}
}
if (host != null) {
authenticator.setHost(host);
} else {
if (log.isDebugEnabled()) {
log.debug("[NTLMMediator] Host not specified.");
}
}
if (domain != null) {
authenticator.setDomain(domain);
} else {
if (log.isDebugEnabled()) {
log.debug("[NTLMMediator] Domain not specified.");
}
}
if (ntlmVersion != null) {
if (log.isDebugEnabled()) {
log.debug("[NTLMMediator] NTLM version is: " + ntlmVersion);
}
} else {
if (log.isDebugEnabled()) {
log.debug("[NTLMMediator] NTLM version is not specified.");
}
}
// Set the newly created NTLM authenticator to the Axis2MessageContext
org.apache.axis2.context.MessageContext axis2MessageContext = ((Axis2MessageContext) messageContext).getAxis2MessageContext();
axis2MessageContext.getOptions().setProperty(HTTPConstants.AUTHENTICATE, authenticator);
// Read the MultiThreadedHttpConnectionManager from the cache and set it to the Axis2MessageContext
MultiThreadedHttpConnectionManager connectionManager;
String cacheKey = new StringBuilder().append(authenticator.getUsername()).append("@").append(authenticator.getDomain()).append(":").append(authenticator.getPassword()).toString();
if (connectionManagerCache.containsKey(cacheKey)) {
connectionManager = connectionManagerCache.get(cacheKey);
} else {
connectionManager = connectionManagerCache.put(cacheKey, new MultiThreadedHttpConnectionManager());
}
axis2MessageContext.getOptions().setProperty(HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER, connectionManager);
axis2MessageContext.getEnvelope().buildWithAttachments();
return true;
}
Aggregations