[英]how to add authentication filter\header to `com.sun.jersey.api.client.Client`?
how can I add authentication filter\\header to 如何将身份验证过滤器\\标头添加到
com.sun.jersey.api.client.Client
? com.sun.jersey.api.client.Client
?
I'm using jersey-bundle-1.18.2
我正在使用jersey-bundle-1.18.2
i saw two posts: 我看到两个帖子:
client.addFilter(new HTTPBasicAuthFilter(user, password));
client.setUsernamePassword("testClient", "secret");
but non of them apply to the above Client
class. 但它们都不适用于上述Client
类。
These method don't exist in this type. 这些方法在这种类型中不存在。
I tried to execute addFilter
after a builder method that returns Webresource
我尝试在返回Webresource
生成器方法之后执行addFilter
So I changed: 所以我改变了:
client.addFilter(new HTTPBasicAuthFilter(RT_USERNAME, RT_PASSWORD);
ClientResponse clientResponse = client
.resource(resource)
.queryParam("confirm", "true")
.queryParam("id", alertId)
.addFilter(new HTTPBasicAuthFilter(RT_USERNAME, RT_PASSWORD)...
to 至
client.addFilter(new HTTPBasicAuthFilter(RT_USERNAME, RT_PASSWORD);
ClientResponse clientResponse = client
.resource(resource)
.queryParam("confirm", "true")
.queryParam("id", alertId)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.