You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Saminda Abeyruwan <sa...@gmail.com> on 2007/01/03 12:51:53 UTC
Fwd: NTLM with Axis2 1.1
HI Jonathan,
We've committed the changes to the Axis2 branch/trunk. Please take a
checkout and build as mentioned in prior mail. Please be kind enough to let
us know the status with the new fix.
To get the NTLM auth working with host/port not given, you should have aim
for a client as follow,
=============================================
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.client.Options;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.transport.http.HttpTransportProperties;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMAbstractFactory;
public class NTLMAuthTest {
public static void main(String[] args) {
try {
ServiceClient serviceClient = new ServiceClient();
/*
commons httpclint support NTML cred with following,
1. Need Host - > (optional)If Host is not given, the property
org.apache.commons.httpclient.auth.AuthScope.ANY_HOST will be used.
2. Need Port -> (optional)If not given AuthScope.ANY_PORT will
be used
3. Need Username - > (Must)
4. Need Password -> (Must)
5. Need domain - > (Must) This should be given according to
http://jakarta.apache.org/commons/httpclient/authentication.html#NTLM
6. Need Realm ->(optional) If not given
AuthScope.ANY_REALMwill be used
*/
HttpTransportProperties.Authenticator
auth = new
HttpTransportProperties.Authenticator();
auth.setDomain("domain"); // must
auth.setUsername("username"); // must
auth.setPassword("password"); //must
// auth.setAllowedRetry(true);
Options options = new Options();
serviceClient.setOptions(options);
serviceClient.getOptions()
.setProperty(
org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,
auth);
options.setTo(new EndpointReference("
http://wso2.org/webservices));
OMElement ele = OMAbstractFactory.getOMFactory
().createOMElement("ele","","");
serviceClient.sendReceive(ele);
} catch (AxisFault axisFault) {
axisFault
.printStackTrace();
}
}
}
==============================================
Thank you
Saminda
---------- Forwarded message ----------
From: Saminda Abeyruwan <sa...@gmail.com>
Date: Jan 3, 2007 2:20 PM
Subject: Re: NTLM with Axis2 1.1
To: Jonathan McCracken <jo...@nexicon.ca>
Hi Jonathan,
Thanks for using Axis2.
We found a bug in NTLM handling. I've created a JIRA on behalf you
https://issues.apache.org/jira/browse/AXIS2-1929
I've fixed the bug in Axis2 branch as well as trunk.
You can find the branch in,
https://svn.apache.org/repos/asf/webservices/axis2/branches/java/1_1
use maven clean release -Dmaven.test.skip=true -o to build the jars offline
Copy the axis2-XX-1.1.1-SNAPSHOT jars to your working classpath and run the
sample again.
Due to a Test failure in branch I couldn't commit the code as yet. Will buzz
you once the code being committed.
Please be kind enough to test it and publish the results.
Thank you
Saminda
On 1/3/07, Jonathan McCracken < jon@nexicon.ca > wrote:
>
> Hello Samindaa,
>
> First off thank you for contributing to Axis2, and I hope you have the
> time to respond to my question regarding getting NTLM working for my
> Client Stub in 1.1 release.
>
> I've looked through all the articles I can find and have turned up
> with the same error. I'm using the following code to modify my stub:
>
> public AdminWebServiceStub() throws org.apache.axis2.AxisFault {
>
> populateAxisService();
> populateFaults();
>
> ConfigurationContext configurationContext = null;
>
> _serviceClient = new
> org.apache.axis2.client.ServiceClient(configurationContext,_service);
>
> configurationContext =
> _serviceClient.getServiceContext().getConfigurationContext();
>
> //setup NTLM auth
> HttpTransportProperties.Authenticator
> auth = new
> HttpTransportProperties.Authenticator();
> auth.setDomain("domain");
> auth.setUsername("username");
> auth.setPassword("password");
> //do not set HOST or PORT...although I've tried this and both return
> same error //auth.setHost("url");
> //auth.setPort(83));
>
> //NTLMScheme ntlmAuthScheme = new NTLMScheme();
> //ArrayList authSchemes = new ArrayList();
> //authSchemes.add(ntlmAuthScheme);
> //auth.setAuthSchemes(authSchemes);
>
> //set NTLM auth
> _serviceClient.getOptions().setProperty(
> org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,
> auth);
>
> //set webservice end-point
> _serviceClient.getOptions().setTo(new
> org.apache.axis2.addressing.EndpointReference("url"));
>
> //Set the soap version
> _serviceClient.getOptions().setSoapVersionURI(
> org.apache.axiom.soap.SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI );
> }
>
> /////////////END CODE
>
>
> The error I get is as follows:
>
> Jan 2, 2007 3:07:15 PM
> org.apache.commons.httpclient.HttpMethodDirector
> processWWWAuthChallenge
> WARNING: Unable to respond to any of these challenges:
> {negotiate=Negotiate}
>
> org.apache.axis2.AxisFault: HTTP Transport error : '401' -
> 'Unauthorized'; nested exception is:
> org.apache.axis2.AxisFault: HTTP Transport error : '401' -
> 'Unauthorized'; nested exception is:
> org.apache.axis2.AxisFault: HTTP Transport error : '401' -
> 'Unauthorized'; nested exception is:
> org.apache.axis2.AxisFault: HTTP Transport error : '401' -
> 'Unauthorized'
> at
> org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(
> CommonsHTTPTransportSender.java:225)
> at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:670)
> at org.apache.axis2.description.OutInAxisOperationClient.send (
> OutInAxisOperation.java:365)
> at org.apache.axis2.description.OutInAxisOperationClient.execute(
> OutInAxisOperation.java:295)
> at
> com.transcanada.safex.externalAccess.tedsProxy.AdminWebServiceStub.GetUser(
> AdminWebServiceStub.java:622)
> at com.transcanada.safex.junit.TestTedsBindingStub.testGetUser(
> TestTedsBindingStub.java:31)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:25)
> at com.intellij.rt.execution.junit2.JUnitStarter.main (
> JUnitStarter.java:31)
> Caused by: org.apache.axis2.AxisFault: HTTP Transport error : '401' -
> 'Unauthorized'; nested exception is:
> org.apache.axis2.AxisFault: HTTP Transport error : '401' -
> 'Unauthorized'
> at
> org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons
> (CommonsHTTPTransportSender.java:340)
> at
> org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(
> CommonsHTTPTransportSender.java :205)
> ... 23 more
> Caused by: org.apache.axis2.AxisFault: HTTP Transport error : '401' -
> 'Unauthorized'
> at org.apache.axis2.transport.http.SOAPOverHTTPSender.send(
> SOAPOverHTTPSender.java :144)
> at
> org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons
> (CommonsHTTPTransportSender.java:334)
> ... 24 more
>
>
> /////////END STACK TRACE
>
>
> I'm not sure what I'm doing wrong, as far as I can tell my client has
> the correct HTTPTransportProperties at runtime (i've debugged this one
> a few times). I've also checked the credentials and they work, but the
> error seems to be related to not being able to respond to the NTLM
> Negotiate challenge?
>
> Any help/ideas would be greatly appreciated.
>
>
> Thanks,
>
> Jonathan
>
--
Saminda Abeyruwan
Software Engineer
WSO2 Inc. - www.wso2.org
--
Saminda Abeyruwan
Software Engineer
WSO2 Inc. - www.wso2.org