有没有可靠的方法来处理Android应用程序的Windows集成(NTLM)身份验证?

Jen*_*all 11 java authentication android ntlm web-services

正如标题所述,我们正在寻找一种方法来访问Windows集成(NTLM)身份验证背后的.NET 3.5 Web服务.

我们整整一周都在搜索互联网和本论坛,我们还没有找到解决这个问题的方法.

我们尝试过,DefaultHttpConnections,HttpPost,HttpGet等的不同变体.

但是,我们试图验证自己,我们遇到这些:

    SSLHandshakeException
Run Code Online (Sandbox Code Playgroud)

要么

   Authentication scheme ntlm not supported
   Authentication error: Unable to respond to any of these challenges: 
   ntlm=WWW-Authenticate: NTLM, negotiate=WWW-Authenticate: Negotiate
Run Code Online (Sandbox Code Playgroud)

IIS身份验证设置如下: 在此输入图像描述

我们尝试访问的页面是默认站点的子文件夹中的.aspx,我们没有优势,也不能将身份验证更改为默认站点.

我知道互联网中有很多其他人也有类似的问题.

此外,我们正在开发的应用程序不应该使用Web视图.

任何有关如何解决这个问题的建设性指示都将受到高度赞赏.提前致谢.




更新:我们现在已经更改了服务以执行基本身份验证和ntlm身份验证.

当我们将下面的代码运行到localhost测试服务器时,我们得到了正确的响应,localhost没有任何类型的身份验证机制.答复如下:

<soap:Body>
<FooResponse xmlns="uri:FlexAPI">
<FooResult>
<typeFooBar>
<FooNumber>4545</FooNumber>
<BarNumber>1</BarNumber>
</typeFooBar>
</FooResult>
</FooResponse>
</soap:Body>
Run Code Online (Sandbox Code Playgroud)

但是,当我们在经过身份验证的服务器上运行以下代码时,我们会得到此信息

org.xmlpull.v1.XmlPullParserException:expected:START_TAG { http://schemas.xmlsoap.org/soap/envelope/ } Envelope(位置:START_TAG @ 2:44 in java.io.InputStreamReader@4054b398)

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);



        request.addProperty("Foo", Bar.getText().toString());
        request.addProperty("Foo", Bar.getText().toString());
        request.addProperty("Foo", Bar() );
        request.addProperty("Foo", Bar.getText().toString());



        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);


        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);

        envelope.encodingStyle = "utf-8";
        envelope.implicitTypes = false;

        String myUrlz= "http://" + myUrl.getText().toString() +"/Foo/Bar.asmx"; 



        HttpTransportBasicAuth auth = new HttpTransportBasicAuth(myUrlz, "Foo", "Bar");

        auth.debug = true;
Run Code Online (Sandbox Code Playgroud)
try
{

auth.call(SOAP_ACTION, envelope); // Fails on this line. 
System.out.println("Dump" + auth.responseDump);


// all the other stuff.....


}
catch (FooException Bar)
{

                // ¯\_(?)_/¯

}
Run Code Online (Sandbox Code Playgroud)

所以基本上,我们在访问受保护的服务时接受html响应而不是xml.是的,除了身份验证部分之外,localhost服务和敏锐服务完全相同.

Cos*_*Key 1

简短的回答是否定的,Android 上的 NTLM 没有开箱即用的方法。

长的答案是,已经有人成功尝试使用 Apache HttpClient 组合您自己的解决方案。请参阅以下链接:

http://danhounshell.com/blog/android-using-ntlm-authentication-with-httpclient/ http://mrrask.wordpress.com/2009/08/21/android-authentication-via-ntlm/