Android Authentication scheme ntlm not supported

前端 未结 4 2044
别那么骄傲
别那么骄傲 2021-02-10 16:31

I am using asynhttpClient for basic authentication

http://loopj.com/android-async-http/

that is looj lib..

below is my code:

usernameRandomPassw

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-10 16:57

    here is the answer through code:

    add below code to your android file

                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, "", "")
                );
    
                HttpUriRequest httpget = new HttpGet(your_URL);
                HttpResponse response = httpclient.execute(httpget);
                String responseBody = EntityUtils.toString(response.getEntity());
                Log.i(tag,"responseBody =>>>>>>>>>>"+responseBody);
    

    now download lib and java file from

    https://github.com/masconsult/android-ntlm

    and copy jcifs-1.3.17.jar to your lib folder and JCIFSEngine and NTLMSchemeFactory to your package. (you can change package if you want..)

    Thats it your app is ready to run.

    More useful Links:

    http://www.developergarden.com/en/marketplace/components/details/cmp/android-ntlm-authentication/

提交回复
热议问题