X

Easy Access to WSO2's Online Resources During COVID-19 Lockdown.   Read More

How to configure Axis2 to support Basic, NTLM and Proxy authentication?

Archived Content
This article is provided for historical perspective only, and may not reflect current conditions. Please refer to relevant product page for more up-to-date product information and resources.
  • By Saminda Abeyruwan
  • 12 Jun, 2006

Configuration for Proxy Authentication It has to be noted that Proxy Authentication via httpclient is available only with HTTP 1.0 version. Configuration for Proxy Authentication is available at deployment time (axis2.xml) or runtime.

1. Proxy Authentication at Deployment time In Axis2.xml, user will be able to find the following entry:



<transportSender name="http"
class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
<parameter name="PROTOCOL"
locked="false">HTTP/1.1</parameter>
<parameter name="Transfer-Encoding"
locked="false">chunked</parameter>
</transportSender>

To enable proxy authentication:

<transportSender name="http"
class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
<parameter name="PROTOCOL"
locked="false">HTTP/1.0</parameter>
<parameter name="PROXY" proxy_host="proxy_host_name"
proxy_port="proxy_host_port"
locked="true>userName:domain:passWord</parameter>
</transportSender>

2. Proxy Authenticaion at Runtime.



In client or stub:

HttpTransportProperties.ProxyProperties proxyProperties = new
HttpTransportProperties().new ProxyProperties();

proxyProperties.setProxyHostName("axis2");
proxyProperties.setProxyPort(9762);
proxyproperties.setDomain("axis2/anon");
proxyproperties.setPassWord("passwd");
proxyproperties.setUserName("usernm");

//in order to makesure that we use HTTP 1.0
options.setProperty(MessageContextConstants.HTTP_PROTOCOL_VERSION,
HTTPConstants.HEADER_PROTOCOL_10);

options.setProperty(org.apache.axis2.transport.http.HTTPConstants.PROXY,
proxyProperties);

Basic and NTLM Authentication Axis2 uses commons-httpclient's preemptive authentication scheme to support Basic and NTLM Authentication.

1. To Enable Basic Authentication

HttpTransportProperties.BasicAuthentication basicAuthentication =
new HttpTransportProperties().new BasicAuthentication();

basicAuthentication.setUsername("axis2");
basicAuthentication.setPassword("axis2");
options.setProperty(

org.apache.axis2.transport.http.HTTPConstants.BASIC_AUTHENTICATION,
basicAuthentication);

2. To Enable NTLM Authentication

HttpTransportProperties.NTLMAuthentication ntlmAuthentication =
new HttpTransportProperties().new NTLMAuthentication();

ntlmAuthentication.setUsername("axis2");
ntlmAuthentication.setPassword("axis2");
ntlmAuthentication.setHost("axis2");
ntlmAuthentication.setPort(9443);
ntlmAuthentication.setRealm("someRealm");

options.setProperty(

org.apache.axis2.transport.http.HTTPConstants.NTLM_AUTHENTICATION,
ntlmAuthentication);