开发者

Authentication problem using Jersey and Glassfish

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);     开发者_Python百科   
    return new Integer(c.getStatus()).toString() + System.getProperty("line.separator") + c.getEntity(String.class);        
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜