CXF客户端授权问题

发布于 2024-10-10 07:35:29 字数 551 浏览 0 评论 0原文

我使用 JAXRSClientFactory.create 方法来创建代理,如下所示:

IMyService myService 
 = JAXRSClientFactory.create("http://myserviceurl/", IMyService.class, "login1", "pwd", null);

并且此代码工作正常。

之后,我需要将此服务与另一个凭据一起使用,并尝试使用另一个凭据创建相同的服务,如下所示:

IMyService myNewService 
 = JAXRSClientFactory.create("http://myserviceurl/", IMyService.class, "login2", "pwd", null);

此代码可以工作,但使用错误的凭据(使用第一个服务的凭据)。我没有找到任何方法来改变它(重置,或清除,或类似的东西)。

还有一个细节,这个问题只有摘要授权。有了基本的效果就很好。

有人可以帮我解决这个问题吗?

谢谢。

I use JAXRSClientFactory.create method to create proxy like this:

IMyService myService 
 = JAXRSClientFactory.create("http://myserviceurl/", IMyService.class, "login1", "pwd", null);

and this code work ok.

After that I need to use this service with another credentials and I try to create same service with another credentials like this:

IMyService myNewService 
 = JAXRSClientFactory.create("http://myserviceurl/", IMyService.class, "login2", "pwd", null);

this code work, but work with wrong credentials (with credentials from first service). I didn't found any way to change it (reset, or clear, or something like this).

And one more detail, this issue only with digest authorization. With basic it works well.

Could anybody help me with this issue.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

妄司 2024-10-17 07:35:29

摘要身份验证如何与 JAXRSClientFactory.create 一起使用?
根据API的描述,该方法用于获取具有基本身份验证的客户端。

How does digest auth work with JAXRSClientFactory.create?
According to the description of the API, the method is used in order to get a client with basic authentication.

白鸥掠海 2024-10-17 07:35:29

也许这样的事情应该有效:

Endpoint endpoint = WebClient.getConfig(client).getEndpoint();
AuthorizationPolicy policy = endpoint.getEndpointInfo().getExtensor(AuthorizationPolicy.class)
policy.setUserName("login2");

Maybe something like this should work :

Endpoint endpoint = WebClient.getConfig(client).getEndpoint();
AuthorizationPolicy policy = endpoint.getEndpointInfo().getExtensor(AuthorizationPolicy.class)
policy.setUserName("login2");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文