使用Java对Microsoft IIS服务器进行身份验证?

时间:2014-01-10 00:05:24

标签: java http iis

我想对使用Microsoft IIS使用Java获取数据的网站进行身份验证(我有权限)。但我是Java的新手,我不知道Microsoft IIS是如何工作的。

我尝试使用HttpURLConnection发送GET请求来获取标头,我得到了这个:

Key : null ,Value : [HTTP/1.1 401 Unauthorized]
Key : WWW-Authenticate ,Value : [NTLM, Negotiate]
Key : Vary ,Value : [Accept-Encoding]
Key : Date ,Value : [Thu, 09 Jan 2014 18:46:24 GMT]
Key : Content-Length ,Value : [1293]
Key : Content-Type ,Value : [text/html]
Key : X-Powered-By ,Value : [ASP.NET, UrlRewriter.NET 2.0.0]
Key : Server ,Value : [Microsoft-IIS/7.5]

我正在使用它来设置身份验证信息:

Authenticator.setDefault(new Authenticator() {
    protected PasswordAuthentication getPasswordAuthentication() {          
        return new PasswordAuthentication("user", "pass".toCharArray());
    }
});

0 个答案:

没有答案