使用Spring security AuthenticationProvider
实现自定义身份验证后,它运行良好,但是当我实现JAX-RS客户端时:
Client client = ClientBuilder.newClient();
final String URI = "http://localhost:8383/";
String username = "haikel";
String password = "blockchainGED2014!";
Form mapForm = new Form();
mapForm.param("username", username).param("password", password);
Invocation.Builder builder = client.target(URI)
.path("login")
.request();
Response response = builder.post(Entity.entity(mapForm, MediaType.APPLICATION_FORM_URLENCODED_TYPE));
System.out.println(response.getStatus());
System.out.println(response.getCookies());
它返回200并且正文中的login.html
页面没有cookie我用cURL测试了这个调用:
curl -v -X POST 'http://localhost:8383/login' -d'username=haikel&password=blockchainGED2014!'
它也有效
我用MultivaluedMap
更改了表单并在构建器中添加了参数
Invocation.Builder builder = client.target(URI)
.queryParam("username", username)
.queryParam("password", password)
.path("login")
.request();
但是它显示了相同的结果200没有cookie和身体login.html
。
请帮忙!谢谢