我正在使用JCIFS库找到here在我的Android应用程序中使用NTLM身份验证。当它刚刚访问某个站点并解析了一个xml时,该应用程序工作正常,但现在我添加了NTLM auth它没有似乎工作。任何人都可以从这段代码中看出httpclient和输入流之间的问题是什么?
DefaultHttpClient client = new DefaultHttpClient();
client.getAuthSchemes().register("ntlm", new NTLMSchemeFactory());
client.getCredentialsProvider().setCredentials(new AuthScope("http://www.musowls.org",80),
new NTCredentials(username, password, null, "musschool"));
HttpGet request = new HttpGet("http://www.musowls.org/assignments/assignmentsbystudentxml.aspx");
HttpResponse resp = client.execute(request);
HttpEntity entity = resp.getEntity();
InputStream inputStream = entity.getContent();
答案 0 :(得分:0)
尝试以下代码,它可能对您有帮助。
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getAuthSchemes().register("ntlm", new NTLMSchemeFactory());
NTCredentials creds = new NTCredentials("user_name", "password", "", "http://www.musowls.org/");
httpclient.getCredentialsProvider().setCredentials(AuthScope.ANY, creds);
HttpConnectionParams.setConnectionTimeout(httpclient.getParams(), 5000);
HttpPost httppost = new HttpPost("http://www.musowls.org/assignments/assignmentsbystudentxml.aspx");
httppost.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
HttpResponse response = httpclient.execute(httppost); // ERROR HAPPENS HERE
responseXML = EntityUtils.toString(response.getEntity());
Log.d("Responce", responseXML);
答案 1 :(得分:0)
1)从这里下载JCIFS:http://jcifs.samba.org/
2)按照此处的说明操作:http://hc.apache.org/httpcomponents-client-ga/ntlm.html
答案 2 :(得分:0)