如何配置 HttpClient 进行基本身份验证?
我发现这个序列设置基本身份验证 这里:
HttpClient client = new HttpClient();
client.getState().setCredentials(
new AuthScope("www.domain.com", 443, "realm"),
new UsernamePasswordCredentials("username", "password") );
如何使用 spring 配置来实现这一点? 背后的原因是,我需要为 spring-integration HttpOutboundGateway 启用身份验证。 我在这个主题上找到的唯一信息是这个
- 问题是:如何进行spring配置?
- 其次,如何将 HttpClient 注入到 spring-integration 中?
I found this sequence to set up basic authentication here:
HttpClient client = new HttpClient();
client.getState().setCredentials(
new AuthScope("www.domain.com", 443, "realm"),
new UsernamePasswordCredentials("username", "password") );
How can this be achived by using spring configuration?
The reason behind is, I need to enable authentication for a spring-integration HttpOutboundGateway.
The only piece of information I found on this topic is this
- The question is: How to do the spring-configuration?
- And second how can I inject the HttpClient into spring-integration?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,可能是这样的:(注意,没有测试任何内容 - 这只是一系列随机的想法:))
Well, it could be something like that: (note, nothing is tested - thats just a series of random thoughts :) )
创建一个
FactoryBean
您自己的类,它返回具有您喜欢的配置的 HttpClient 实例。Create a
FactoryBean
class of your own which returns HttpClient instances with the configuration you like.