使用 Jersey 和 Glassfish 的身份验证问题
我正在尝试使用 REST 接口配置 Glassfish。我在 Java 代码中使用 Jersey。除了身份验证之外,一切正常。波纹管是我用来执行 GET 的一段代码。每当我在 Glassfish 中定义了一个 use 时,这种和平的代码就会返回 401。我已经使用 Glassfish 管理控制台和 CURL 检查了凭据,它们是有效的。我想这是我使用泽西岛的方式有问题。我用谷歌搜索过这个,但找不到相关信息。有人有什么建议吗?谢谢
Client client;
public JerseyRESTClient() {
client = Client.create();
client.addFilter(new HTTPBasicAuthFilter("user1", "a"));
}
public String GET(String url, String format) throws IOException {
WebResource webResource = client.resource(url);
ClientResponse c = webResource.accept(format).get(ClientResponse.class);
return new Integer(c.getStatus()).toString() + System.getProperty("line.separator") + c.getEntity(String.class);
}
I'm trying to configure Glassfish using the REST interface. I am using Jersey in my Java code. All works well, except authenticating. Bellow is a peace of code i use to do a GET. Whenever i have a used defined in Glassfish, this peace of code returns 401. I have checked the credentials using Glassfish Administration Console and CURL and they are valid. I suppose it is a problem in the way i am using Jersey. I have googled this, but i can not find relevant information. Does anyone have any suggestions? Thanks
Client client;
public JerseyRESTClient() {
client = Client.create();
client.addFilter(new HTTPBasicAuthFilter("user1", "a"));
}
public String GET(String url, String format) throws IOException {
WebResource webResource = client.resource(url);
ClientResponse c = webResource.accept(format).get(ClientResponse.class);
return new Integer(c.getStatus()).toString() + System.getProperty("line.separator") + c.getEntity(String.class);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论