Since 23 sdk Android class were excluded classes:
org.apache.http.auth.AuthScheme;
org.apache.http.auth.AuthSchemeFactory;
org.apache.http.impl.auth.NTLMScheme;
org.apache.http.impl.auth.NTLMEngine;
org.apache.http.impl.auth.NTLMEngineException;
As it is now authorized in AD, with login and password through a retrofit? There OKHttpklient can be through headers?
1) add package org.apache.httpcomponents:httpclient:4.5 to build.gradle (app)
//noinspection DuplicatePlatformClasses
implementation '**org.apache.httpcomponents:httpclient:4.5**'
2) Add package org.apache.http.impl.auth to your project (folder in /java)
3) Create public class in added org.apache.http.impl.auth package
public class PublicNTLMEngineImpl implements NTLMEngine {
// with content of http://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.5.2/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
}
4) use Giohji's NTLMAuthenticator with instance of new PublicNTLMEngineImpl
OkHttpClient httpClient = new OkHttpClient.Builder()
.connectTimeout(30, TimeUnit.SECONDS)
.writeTimeout(10, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.authenticator(new NTLMAuthenticator(username, password, domainOrComputerName))
.build();
5) source code: http://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.5.2/httpclient/src/main/java/org/apache/http/impl/auth/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With