任何人都可以向我解釋爲什麼基本身份驗證正在工作,摘要不起作用或無法正常顯示在服務器上的http頭中。澤西安全摘要與基本身份驗證
public String login(UserDTO user)
{
ClientConfig clientConfig = new DefaultClientConfig();
clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
Client client = Client.create(clientConfig);
// client.addFilter(new HTTPBasicAuthFilter(user.getUsername(), user.getPassword()));
client.addFilter(new HTTPDigestAuthFilter(user.getUsername(), user.getPassword()));
ClientResponse response = client.resource(url + "user/login").accept("application*json").type("application/json").get(ClientResponse.class);
System.out.println(response.toString());
return null;
}
如果我使用:
client.addFilter(new HTTPBasicAuthFilter(user.getUsername(), user.getPassword()));
我得到一個授權頭在服務器上:
USER LOGIN REQUEST
request:uri: /StambomenWebAPI/rest/user/login
method: GET
QueryString: null
Parameters:
Headers:
Name: accept Value: application*json
Name: content-type Value: application/json
Name: authorization Value: Basic QXhsOkxvbA==
Name: user-agent Value: Java/1.7.0_51
Name: host Value: localhost:8084
Name: connection Value: keep-alive
USER AND PASS[XXXXX, XXXXX]
但是當我使用
client.addFilter(new HTTPDigestAuthFilter(user.getUsername(), user.getPassword()));
我沒有得到一個授權標題字段...:s?
使用的球衣和Tomcat V7
我的問候和THX提前任何幫助