如何将身份验证过滤器\标头添加到
com.sun.jersey.api.client.Client
?
我正在使用jersey-bundle-1.18.2
我看了两篇帖子:
1)post:
client.addFilter(new HTTPBasicAuthFilter(user, password));
2)post:
client.setUsernamePassword("testClient", "secret");
但不适用于上述Client
类。
这种方法不存在于此类型中。
答案 0 :(得分:0)
我尝试在返回addFilter
Webresource
所以我改变了:
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)...
到
client.addFilter(new HTTPBasicAuthFilter(RT_USERNAME, RT_PASSWORD);
ClientResponse clientResponse = client
.resource(resource)
.queryParam("confirm", "true")
.queryParam("id", alertId)