だから私はUnauthorized error
httpクライアントで承認した後に取得しています。アクセスしようとしている Web サイトにはNTLM
認証があります。誰かがこの問題を手伝ってくれれば幸いです。
public class ClientAuthentication {
public static void main(String[] args) throws Exception {
DefaultHttpClient httpclient = new DefaultHttpClient();
try {
httpclient.getCredentialsProvider().setCredentials(
new AuthScope("website", 80),
new UsernamePasswordCredentials("username", "password"));
HttpGet httpget = new HttpGet("http://cdg5.intranet.bell.ca/BlackFoot/Ont/");
System.out.println("executing request" + httpget.getRequestLine());
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
if (entity != null) {
System.out.println("Response content length: " + entity.getContentLength());
}
EntityUtils.consume(entity);
} finally {
// When HttpClient instance is no longer needed,
// shut down the connection manager to ensure
// immediate deallocation of all system resources
httpclient.getConnectionManager().shutdown();
}
}
}
そして、これが私が得た結果です
「実行リクエストGET http://cdg5.intranet.bell.ca/BlackFoot/Ont/ HTTP/1.1
HTTP/1.1 401 Unauthorized Response コンテンツの長さ: 1656"