简体   繁体   English

如何在“ com.sun.jersey.api.client.Client”中添加身份验证过滤器\\标题?

[英]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: 我看到两个帖子:

1) post : 1) 发布

client.addFilter(new HTTPBasicAuthFilter(user, password));

2) post : 2) 发布

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.

相关问题 NoClassDefError com.sun.jersey.api.client.Client - NoClassDefError com.sun.jersey.api.client.Client com.sun.jersey.api.client.ClientHandlerException - com.sun.jersey.api.client.ClientHandlerException java.lang.NoClassDefFoundError: com/sun/jersey/api/client/Client - java.lang.NoClassDefFoundError: com/sun/jersey/api/client/Client 导入com.sun.jersey.api.client.ClientResponse的问题; - Issue with importing com.sun.jersey.api.client.ClientResponse; 获取com.sun.jersey.api.client.ClientHandlerException:生成Docusign API令牌 - Getting com.sun.jersey.api.client.ClientHandlerException: while generating Docusign API token 无法将JSON响应从com.sun.jersey.api.client.ClientResponse映射到POJO - Not able to map JSON response to POJO from com.sun.jersey.api.client.ClientResponse com.sun.jersey.api.client.ClientHandlerException:java.net.SocketException:连接重置 - com.sun.jersey.api.client.ClientHandlerException: java.net.SocketException: Connection reset com.sun.jersey.api.client.ClientHandlerException:java.net.ConnectException:连接被拒绝:在 Spring Boot 中连接 - com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect in Spring Boot com.sun.jersey.api.client.ClientHandlerException:Java类的消息正文阅读器 - com.sun.jersey.api.client.ClientHandlerException: A message body reader for Java class 如何模拟太阳球衣客户端的电话? - how to mock sun jersey client post calls?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM