我如何让jcifs与apache轴很好地玩 [英] How can I get jcifs to play nicely with apache axis

查看:88
本文介绍了我如何让jcifs与apache轴很好地玩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将Apache Axis 1.4连接到使用NTLM身份验证来限制对其操作的访问的Web服务. 我期望使用Samba Jcifs处理NTLM握手.

I need to connect Apache Axis 1.4 to a Webservice that uses NTLM authentication to restrict access to its operations. I'm expecting to use Samba Jcifs to handle the NTLM handshake.

我找到了

http://hc.apache.org/httpcomponents-client/ntlm.html

这为我提供了如何通过jcifs连接HttpClient 4.0的绝妙指导.

which gives me fantastic directions for how to wire up HttpClient 4.0 with jcifs.

麻烦的是,Axis希望使用Http Client 3.0,并且两个API看起来非常不同.

Trouble is, Axis wants to use Http Client 3.0 and the two apis look very different.

我可以看到2种可能性

  1. 为Axis编写一个对象,使其可以插入HttpClient 4.
  2. 弄清楚如何通过Samba Jcifs连接HttpClient 3.0.

数字1.看起来不平凡,但可能 第二个.我在网络上找不到任何令人鼓舞的消息来描述如何做到这一点.

Number 1. looks non-trivial, but possible Number 2. I cannot find any encouraging messages on the web describing how to do this.

我的问题是:是否有人成功将samba jcifs与HttpClient 3.0连接? 是否有人已经创建了可与HttpClient 4一起使用的Axis HttpSender对象?

My question is: has anyone successfully connected samba jcifs with HttpClient 3.0 ? Has anyone already created an Axis HttpSender object that works with HttpClient 4 ?

有没有我没有考虑过的更好的选择?

Is there some better alternative that I have not considered?

推荐答案

最后有一个解决方案.

Apache Axis使用提供自己的NTLM实现的Apache HTTPClient. 但是,此实现尚不完整.它仅支持原始LM身份验证.
我需要连接的系统坚持使用最新的NTLM身份验证.

Apache Axis uses Apache HTTPClient which provides its own NTLM implementation.
However this implementation is incomplete; it only supports the primitive LM authentication.
The system I need to connect to insists upon the more recent NTLM authentication.

因此,当将Apache HTTP Client与NTLM一起使用时,我的Web服务无法通过身份验证.

Therefore my Webservice was failing to authenticate when using the Apache HTTP Client with NTLM.

实际上,这会进入无限循环,因为HTTPClient将永远不会停止尝试并且不会通过身份验证.

This actually then enters an infinite loop as the HTTPClient will never stop trying and failing to authenticate.

jcifs完全支持NTLM握手的所有3个版本.
我已经将org.apache.commons.httpclient.auth.NTLM复制粘贴到我自己的类中(为了打败继承而将其声明为最终")

jcifs fully supports all 3 versions of the NTLM handshake.
I have copy-and-pasted org.apache.commons.httpclient.auth.NTLM into my own class (it is declared as 'final' in order to defeat inheritance)

然后我覆盖了该方法

public String getType3Message(
        String user, String password, String host, String domain,
        byte[] nonce) throws AuthenticationException

构造jcifs.ntlmssp.Type3Message的实例 并使用此对象返回已正确生成NTML身份验证的Type3Message.

to construct an instance of jcifs.ntlmssp.Type3Message and use this object to return a Type3Message that has the NTML authentication correctly generated.

然后我需要创建自己的org.apache.commons.httpclient.auth.AuthScheme实例 利用这个新的NTLM实现.称呼 org.apache.commons.httpclient.auth.AuthPolicy.registerAuthScheme(AuthPolicy.NTLM, MyNewAuthScheme.class)

I then needed to create my own instance of org.apache.commons.httpclient.auth.AuthScheme to make use of this new NTLM implementation. call org.apache.commons.httpclient.auth.AuthPolicy.registerAuthScheme(AuthPolicy.NTLM, MyNewAuthScheme.class)

启动我的WS端点存根.

start up my WS endpoint stub.

它有效!!!

这篇关于我如何让jcifs与apache轴很好地玩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆