Android的Windows身份验证 [英] Android Windows authentication

查看:425
本文介绍了Android的Windows身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DefaultHttpHandler是德precated,HttpURLConnection类不支持NTLM和NTLM似乎是ASP.NET MCV网站的唯一很好的支持协议。那么,还剩下些什么呢?

DefaultHttpHandler is deprecated, HttpURLConnection does not support NTLM and NTLM seems to be the only well-supported protocol by ASP.NET MCV websites. So, what's left to do?

在我们的业务中,我们使用微软。我们登录使用微软,我们的网络邮件是微软做的,我们的平板电脑应用程序的Andr​​oid ...

In our business we use Microsoft. We log in using Microsoft, our webmail is done by Microsoft, and our tablet applications are Android...

目前我的工作,需要一个ASP.NET实体框架webinterface连接的项目。这webinterface托管在IIS,使用Windows身份验证配置,使用NTLM作为供应商。

Currently I'm working on a project that requires a connection to an ASP.NET entity framework webinterface. This webinterface is hosted on an IIS, configured with Windows Authentication, using NTLM as provider.

我做的应用程序有访问此webinterface。所以,我要求他们的用户名和密码的用户,要登录的webinterface。不过,Android根本不支持NTLM。我一直在四处寻找,但似乎这样的组合是相当罕见的。我想知道,我有哪些选择?

The app I'm making has to access this webinterface. So, I ask the users for their username and password, and want to log in on the webinterface. However, Android does not support NTLM at all. I've been looking around, but it seems like this combination is fairly rare. I'd like to know, what are my options?

允许我惹pretty任何东西。唯一requrement是,用户登录使用其Microsoft帐户,我们就没有使用过于价位Xamarin preFER。你会建议什么?

I am allowed to mess with pretty much anything. The only requrement is that users log in using their Microsoft account, and we'd prefer not using the overly-priced Xamarin. What would you reccomend?

推荐答案

好了,所以我做的第一件事就是导入的 JCIFS 库。它的一个罐子,你从该链接下载。

Okay so the first thing I did was to import the JCIFS library. Its a jar you download from that link.

我需要做的下一件事是导入JCIFSEngine类和NTLMSchemeFactory类到您的项目。

The next thing I needed to do was to import the JCIFSEngine class and NTLMSchemeFactory class into your project.

于是最后这个方法建立你了HTTPClient:

Then finally this method builds your 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以下行来改造:

My connections are done with Retrofit so I just attach this HTTPClient to retrofit using the following line:

retrofitAdapterBuilder.setClient(new ApacheClient(setupHttpClient(username, password)));

这为我工作至今偶虽然这是非常糟糕的是Android有对此没有本地支持。

This worked for me thus far even-though it is really bad that Android has no native support for this.

这篇关于Android的Windows身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆