好的,我做的第一件事就是导入JCIFS库。它是您从该链接下载的一个jar文件。
我需要做的下一件事是将JCIFSEngine类和NTLMSchemeFactory类导入到您的项目中。
于是最后这个方法建立你了HTTPClient:
//I know it is deprecated but there is no other way to implement NTLM thus far.
private static DefaultHttpClient setupHttpClient (String username, String password) {
DefaultHttpClient httpclient = new DefaultHttpClient();
// register ntlm auth scheme
httpclient.getAuthSchemes().register("ntlm", new NTLMSchemeFactory());
httpclient.getCredentialsProvider().setCredentials(
// Limit the credentials only to the specified domain and port
new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT),
// Specify credentials, most of the time only user/pass is needed
new NTCredentials(username, password, "", "")
);
return httpclient;
}
我的连接与改造完成,所以我只是将这个附加了HTTPClient使用以下行来改造:
retrofitAdapterBuilder.setClient(new ApacheClient(setupHttpClient(username, password)));
因此,这个工作对我来说甚至远不止 - 尽管Android对此没有本地支持是非常糟糕的。
IMO,你可以阅读[我的答案在这里](http://stackoverflow.com/questions/31466653/how-to-use-security-authentication-authorization-in-as-web-api/31471027#31471027) – BNK
查看JCIFS jar。用它来启动和运行我们的NTLM。如果你需要帮助,我会发布我是如何在这里做到的! – Smashing
@Smashing我见过JCIFS几次,但据我所知只与DefaultHttpHandler。我会更多地考虑一下,但是如果你能够提供一个关于如何使用HttpURLConnection的例子,那会很棒。 –