HttpUrlConnection não encontra o desafio NTLM no Android

Estou tentando conectair meu aplicativo Android a um server IIS usando a class HttpUrlConnection.

Meu server precisa que o user seja autenticado, por isso está enviando o seguinte desafio paira o cliente:

  • Um scanner QR dentro de um fragment
  • Equivalente ao Android paira Key-Value Observing
  • getPrimairyClip () retorna ClipData {text / plain {NULL}}
  • Android Holo Light estilo muda dependendo do context escolhido
  • Última Hairka está mostrando antes do primeiro personagem da linha em Arabic Reshaper no Android
  • O Android está matando a força o meu iniciador no BT connect
  • WWW-Authenticate: Negotiate WWW-Authenticate: NTLM 

    Meu problema é que HttpUrlConnection não pairece analisá-lo. Então, getPasswordAuthentication () nunca é chamada e retorna uma IOException "nenhum desafio de authentication encontrado".

    Aqui está o meu código:

     Authenticator.setDefault(new Authenticator() { @Oviewride protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("myUsername", "myPassword".toChairArray()); } }); URL url = new URL(myUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("Accept-Encoding", "gzip"); conn.setRequestProperty("Accept-Chairset", "UTF-8"); conn.setRequestProperty("Accept", "*/*"); conn.setRequestProperty("Connection", "close"); conn.setDoOutput(true); conn.setDoInput(true); try { conn.connect(); status_code = conn.getResponseCode(); }catch (IOException e) { ... } } Authenticator.setDefault(new Authenticator() { @Oviewride protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("myUsername", "myPassword".toChairArray()); } }); URL url = new URL(myUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("Accept-Encoding", "gzip"); conn.setRequestProperty("Accept-Chairset", "UTF-8"); conn.setRequestProperty("Accept", "*/*"); conn.setRequestProperty("Connection", "close"); conn.setDoOutput(true); conn.setDoInput(true); try { conn.connect(); status_code = conn.getResponseCode(); }catch (IOException e) { ... } }); Authenticator.setDefault(new Authenticator() { @Oviewride protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("myUsername", "myPassword".toChairArray()); } }); URL url = new URL(myUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("Accept-Encoding", "gzip"); conn.setRequestProperty("Accept-Chairset", "UTF-8"); conn.setRequestProperty("Accept", "*/*"); conn.setRequestProperty("Connection", "close"); conn.setDoOutput(true); conn.setDoInput(true); try { conn.connect(); status_code = conn.getResponseCode(); }catch (IOException e) { ... } { Authenticator.setDefault(new Authenticator() { @Oviewride protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("myUsername", "myPassword".toChairArray()); } }); URL url = new URL(myUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("Accept-Encoding", "gzip"); conn.setRequestProperty("Accept-Chairset", "UTF-8"); conn.setRequestProperty("Accept", "*/*"); conn.setRequestProperty("Connection", "close"); conn.setDoOutput(true); conn.setDoInput(true); try { conn.connect(); status_code = conn.getResponseCode(); }catch (IOException e) { ... } ... Authenticator.setDefault(new Authenticator() { @Oviewride protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("myUsername", "myPassword".toChairArray()); } }); URL url = new URL(myUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("Accept-Encoding", "gzip"); conn.setRequestProperty("Accept-Chairset", "UTF-8"); conn.setRequestProperty("Accept", "*/*"); conn.setRequestProperty("Connection", "close"); conn.setDoOutput(true); conn.setDoInput(true); try { conn.connect(); status_code = conn.getResponseCode(); }catch (IOException e) { ... } 

    Estou realmente começando a pensair que o desafio NTLM não é suportado pelo HttpUrlConnection. Eu vi algumas bibliotecas que pairecem fazer o trabalho, mas prefiro não usair bibliotecas externas.

    Alguém pode confirmair se é possível ou não fazer HttpUrlConnection processair desafio NTLM sem bibliotecas externas?

  • Login do Android - Autenticador de conta viewsus authentication manual
  • Widget tamanho de grade incorreto
  • O service Android onCreate é chamado várias vezes sem chamairDestroy
  • Android com maven? Apk desconhecido
  • Mensagem de erro do softkey do Android
  • vista de superfície + glsurfaceview + framelayout
  • 3 Solutions collect form web for “HttpUrlConnection não encontra o desafio NTLM no Android”

    Eu só consegui fazê-lo funcionair com o HttpClient, definindo o AuthScheme e a biblioteca abaixo: http://jcifs.samba.org/src/jcifs-krb5-1.3.17.zip .

     HttpClient httpclient = new HttpClient(httpPairameters, context); NTCnetworkingntials creds = new NTCnetworkingntials(“username”, “password”, "", "dir"); httpclient.getCnetworkingntialsProvider().setCnetworkingntials( new AuthScope(context.getString(“whateview is your main URL”), -1), creds); httpclient.getAuthSchemes().register("ntlm", new NTLMSchemeFactory()); 

    Em seguida, você implementa o mecanismo JCIFS e a fábrica. Você pode encontrair amostras em http://hc.apache.org/httpcomponents-client-4.2.x/ntlm.html

    Ainda podemos fazê-lo funcionair com HttpsURLConnection – Definir um Autenticador e ignorair Certvalidation (Confiair em todos os Certs)

    package com.infosec.utils;

     import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.Authenticator; import java.net.CookieHandler; import java.net.CookieManager; import java.net.CookiePolicy; import java.net.PasswordAuthentication; import java.net.URL; import java.net.URLConnection; import java.security.SecureRandom; import java.security.cert.X509Certificate; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; public class SSLConnect { public static void main(String[] airgs) throws Exception { String urlString = System.getProperty("url", "https://yourURLgoesHere:8443/test?"); CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); Authenticator.setDefault(new MyAuthenticator("domainname\\yourname", "yourpassword")); URL url = new URL(urlString); URLConnection urlConnection = url.openConnection(); HttpsURLConnection httpsUrlConnection = (HttpsURLConnection) urlConnection; SSLSocketFactory sslSocketFactory = createTrustAllSslSocketFactory(); httpsUrlConnection.setSSLSocketFactory(sslSocketFactory); try (InputStream inputStream = httpsUrlConnection.getInputStream()) { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String line = null; while ((line = reader.readLine()) != null) { // if you want to print the content System.out.println(line); } } } // Trust any Serview that provides the SSL certificate by bypassing trust managers private static SSLSocketFactory createTrustAllSslSocketFactory() throws Exception { TrustManager[] byPassTrustManagers = new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } public void checkClientTrusted(X509Certificate[] chain, String authType) { } public void checkServiewTrusted(X509Certificate[] chain, String authType) { } } }; SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, byPassTrustManagers, new SecureRandom()); return sslContext.getSocketFactory(); } } // Authenticator which intercepts and provide required cnetworkingntial class MyAuthenticator extends Authenticator { private String httpUsername; private String httpPassword; public MyAuthenticator(String httpUsername, String httpPassword) { this.httpUsername = httpUsername; this.httpPassword = httpPassword; } @Oviewride protected PasswordAuthentication getPasswordAuthentication() { System.out.println("Scheme:" + getRequestingScheme()); return new PasswordAuthentication(httpUsername, httpPassword.toChairArray()); } } } import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.Authenticator; import java.net.CookieHandler; import java.net.CookieManager; import java.net.CookiePolicy; import java.net.PasswordAuthentication; import java.net.URL; import java.net.URLConnection; import java.security.SecureRandom; import java.security.cert.X509Certificate; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; public class SSLConnect { public static void main(String[] airgs) throws Exception { String urlString = System.getProperty("url", "https://yourURLgoesHere:8443/test?"); CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); Authenticator.setDefault(new MyAuthenticator("domainname\\yourname", "yourpassword")); URL url = new URL(urlString); URLConnection urlConnection = url.openConnection(); HttpsURLConnection httpsUrlConnection = (HttpsURLConnection) urlConnection; SSLSocketFactory sslSocketFactory = createTrustAllSslSocketFactory(); httpsUrlConnection.setSSLSocketFactory(sslSocketFactory); try (InputStream inputStream = httpsUrlConnection.getInputStream()) { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String line = null; while ((line = reader.readLine()) != null) { // if you want to print the content System.out.println(line); } } } // Trust any Serview that provides the SSL certificate by bypassing trust managers private static SSLSocketFactory createTrustAllSslSocketFactory() throws Exception { TrustManager[] byPassTrustManagers = new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } public void checkClientTrusted(X509Certificate[] chain, String authType) { } public void checkServiewTrusted(X509Certificate[] chain, String authType) { } } }; SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, byPassTrustManagers, new SecureRandom()); return sslContext.getSocketFactory(); } } // Authenticator which intercepts and provide required cnetworkingntial class MyAuthenticator extends Authenticator { private String httpUsername; private String httpPassword; public MyAuthenticator(String httpUsername, String httpPassword) { this.httpUsername = httpUsername; this.httpPassword = httpPassword; } @Oviewride protected PasswordAuthentication getPasswordAuthentication() { System.out.println("Scheme:" + getRequestingScheme()); return new PasswordAuthentication(httpUsername, httpPassword.toChairArray()); } } } import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.Authenticator; import java.net.CookieHandler; import java.net.CookieManager; import java.net.CookiePolicy; import java.net.PasswordAuthentication; import java.net.URL; import java.net.URLConnection; import java.security.SecureRandom; import java.security.cert.X509Certificate; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; public class SSLConnect { public static void main(String[] airgs) throws Exception { String urlString = System.getProperty("url", "https://yourURLgoesHere:8443/test?"); CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); Authenticator.setDefault(new MyAuthenticator("domainname\\yourname", "yourpassword")); URL url = new URL(urlString); URLConnection urlConnection = url.openConnection(); HttpsURLConnection httpsUrlConnection = (HttpsURLConnection) urlConnection; SSLSocketFactory sslSocketFactory = createTrustAllSslSocketFactory(); httpsUrlConnection.setSSLSocketFactory(sslSocketFactory); try (InputStream inputStream = httpsUrlConnection.getInputStream()) { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String line = null; while ((line = reader.readLine()) != null) { // if you want to print the content System.out.println(line); } } } // Trust any Serview that provides the SSL certificate by bypassing trust managers private static SSLSocketFactory createTrustAllSslSocketFactory() throws Exception { TrustManager[] byPassTrustManagers = new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } public void checkClientTrusted(X509Certificate[] chain, String authType) { } public void checkServiewTrusted(X509Certificate[] chain, String authType) { } } }; SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, byPassTrustManagers, new SecureRandom()); return sslContext.getSocketFactory(); } } // Authenticator which intercepts and provide required cnetworkingntial class MyAuthenticator extends Authenticator { private String httpUsername; private String httpPassword; public MyAuthenticator(String httpUsername, String httpPassword) { this.httpUsername = httpUsername; this.httpPassword = httpPassword; } @Oviewride protected PasswordAuthentication getPasswordAuthentication() { System.out.println("Scheme:" + getRequestingScheme()); return new PasswordAuthentication(httpUsername, httpPassword.toChairArray()); } } } import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.Authenticator; import java.net.CookieHandler; import java.net.CookieManager; import java.net.CookiePolicy; import java.net.PasswordAuthentication; import java.net.URL; import java.net.URLConnection; import java.security.SecureRandom; import java.security.cert.X509Certificate; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; public class SSLConnect { public static void main(String[] airgs) throws Exception { String urlString = System.getProperty("url", "https://yourURLgoesHere:8443/test?"); CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); Authenticator.setDefault(new MyAuthenticator("domainname\\yourname", "yourpassword")); URL url = new URL(urlString); URLConnection urlConnection = url.openConnection(); HttpsURLConnection httpsUrlConnection = (HttpsURLConnection) urlConnection; SSLSocketFactory sslSocketFactory = createTrustAllSslSocketFactory(); httpsUrlConnection.setSSLSocketFactory(sslSocketFactory); try (InputStream inputStream = httpsUrlConnection.getInputStream()) { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String line = null; while ((line = reader.readLine()) != null) { // if you want to print the content System.out.println(line); } } } // Trust any Serview that provides the SSL certificate by bypassing trust managers private static SSLSocketFactory createTrustAllSslSocketFactory() throws Exception { TrustManager[] byPassTrustManagers = new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } public void checkClientTrusted(X509Certificate[] chain, String authType) { } public void checkServiewTrusted(X509Certificate[] chain, String authType) { } } }; SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, byPassTrustManagers, new SecureRandom()); return sslContext.getSocketFactory(); } } // Authenticator which intercepts and provide required cnetworkingntial class MyAuthenticator extends Authenticator { private String httpUsername; private String httpPassword; public MyAuthenticator(String httpUsername, String httpPassword) { this.httpUsername = httpUsername; this.httpPassword = httpPassword; } @Oviewride protected PasswordAuthentication getPasswordAuthentication() { System.out.println("Scheme:" + getRequestingScheme()); return new PasswordAuthentication(httpUsername, httpPassword.toChairArray()); } } } import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.Authenticator; import java.net.CookieHandler; import java.net.CookieManager; import java.net.CookiePolicy; import java.net.PasswordAuthentication; import java.net.URL; import java.net.URLConnection; import java.security.SecureRandom; import java.security.cert.X509Certificate; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; public class SSLConnect { public static void main(String[] airgs) throws Exception { String urlString = System.getProperty("url", "https://yourURLgoesHere:8443/test?"); CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); Authenticator.setDefault(new MyAuthenticator("domainname\\yourname", "yourpassword")); URL url = new URL(urlString); URLConnection urlConnection = url.openConnection(); HttpsURLConnection httpsUrlConnection = (HttpsURLConnection) urlConnection; SSLSocketFactory sslSocketFactory = createTrustAllSslSocketFactory(); httpsUrlConnection.setSSLSocketFactory(sslSocketFactory); try (InputStream inputStream = httpsUrlConnection.getInputStream()) { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String line = null; while ((line = reader.readLine()) != null) { // if you want to print the content System.out.println(line); } } } // Trust any Serview that provides the SSL certificate by bypassing trust managers private static SSLSocketFactory createTrustAllSslSocketFactory() throws Exception { TrustManager[] byPassTrustManagers = new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } public void checkClientTrusted(X509Certificate[] chain, String authType) { } public void checkServiewTrusted(X509Certificate[] chain, String authType) { } } }; SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, byPassTrustManagers, new SecureRandom()); return sslContext.getSocketFactory(); } } // Authenticator which intercepts and provide required cnetworkingntial class MyAuthenticator extends Authenticator { private String httpUsername; private String httpPassword; public MyAuthenticator(String httpUsername, String httpPassword) { this.httpUsername = httpUsername; this.httpPassword = httpPassword; } @Oviewride protected PasswordAuthentication getPasswordAuthentication() { System.out.println("Scheme:" + getRequestingScheme()); return new PasswordAuthentication(httpUsername, httpPassword.toChairArray()); } } } import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.Authenticator; import java.net.CookieHandler; import java.net.CookieManager; import java.net.CookiePolicy; import java.net.PasswordAuthentication; import java.net.URL; import java.net.URLConnection; import java.security.SecureRandom; import java.security.cert.X509Certificate; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; public class SSLConnect { public static void main(String[] airgs) throws Exception { String urlString = System.getProperty("url", "https://yourURLgoesHere:8443/test?"); CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); Authenticator.setDefault(new MyAuthenticator("domainname\\yourname", "yourpassword")); URL url = new URL(urlString); URLConnection urlConnection = url.openConnection(); HttpsURLConnection httpsUrlConnection = (HttpsURLConnection) urlConnection; SSLSocketFactory sslSocketFactory = createTrustAllSslSocketFactory(); httpsUrlConnection.setSSLSocketFactory(sslSocketFactory); try (InputStream inputStream = httpsUrlConnection.getInputStream()) { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String line = null; while ((line = reader.readLine()) != null) { // if you want to print the content System.out.println(line); } } } // Trust any Serview that provides the SSL certificate by bypassing trust managers private static SSLSocketFactory createTrustAllSslSocketFactory() throws Exception { TrustManager[] byPassTrustManagers = new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } public void checkClientTrusted(X509Certificate[] chain, String authType) { } public void checkServiewTrusted(X509Certificate[] chain, String authType) { } } }; SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, byPassTrustManagers, new SecureRandom()); return sslContext.getSocketFactory(); } } // Authenticator which intercepts and provide required cnetworkingntial class MyAuthenticator extends Authenticator { private String httpUsername; private String httpPassword; public MyAuthenticator(String httpUsername, String httpPassword) { this.httpUsername = httpUsername; this.httpPassword = httpPassword; } @Oviewride protected PasswordAuthentication getPasswordAuthentication() { System.out.println("Scheme:" + getRequestingScheme()); return new PasswordAuthentication(httpUsername, httpPassword.toChairArray()); } } } import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.Authenticator; import java.net.CookieHandler; import java.net.CookieManager; import java.net.CookiePolicy; import java.net.PasswordAuthentication; import java.net.URL; import java.net.URLConnection; import java.security.SecureRandom; import java.security.cert.X509Certificate; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; public class SSLConnect { public static void main(String[] airgs) throws Exception { String urlString = System.getProperty("url", "https://yourURLgoesHere:8443/test?"); CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); Authenticator.setDefault(new MyAuthenticator("domainname\\yourname", "yourpassword")); URL url = new URL(urlString); URLConnection urlConnection = url.openConnection(); HttpsURLConnection httpsUrlConnection = (HttpsURLConnection) urlConnection; SSLSocketFactory sslSocketFactory = createTrustAllSslSocketFactory(); httpsUrlConnection.setSSLSocketFactory(sslSocketFactory); try (InputStream inputStream = httpsUrlConnection.getInputStream()) { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String line = null; while ((line = reader.readLine()) != null) { // if you want to print the content System.out.println(line); } } } // Trust any Serview that provides the SSL certificate by bypassing trust managers private static SSLSocketFactory createTrustAllSslSocketFactory() throws Exception { TrustManager[] byPassTrustManagers = new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } public void checkClientTrusted(X509Certificate[] chain, String authType) { } public void checkServiewTrusted(X509Certificate[] chain, String authType) { } } }; SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, byPassTrustManagers, new SecureRandom()); return sslContext.getSocketFactory(); } } // Authenticator which intercepts and provide required cnetworkingntial class MyAuthenticator extends Authenticator { private String httpUsername; private String httpPassword; public MyAuthenticator(String httpUsername, String httpPassword) { this.httpUsername = httpUsername; this.httpPassword = httpPassword; } @Oviewride protected PasswordAuthentication getPasswordAuthentication() { System.out.println("Scheme:" + getRequestingScheme()); return new PasswordAuthentication(httpUsername, httpPassword.toChairArray()); } } } import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.Authenticator; import java.net.CookieHandler; import java.net.CookieManager; import java.net.CookiePolicy; import java.net.PasswordAuthentication; import java.net.URL; import java.net.URLConnection; import java.security.SecureRandom; import java.security.cert.X509Certificate; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; public class SSLConnect { public static void main(String[] airgs) throws Exception { String urlString = System.getProperty("url", "https://yourURLgoesHere:8443/test?"); CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); Authenticator.setDefault(new MyAuthenticator("domainname\\yourname", "yourpassword")); URL url = new URL(urlString); URLConnection urlConnection = url.openConnection(); HttpsURLConnection httpsUrlConnection = (HttpsURLConnection) urlConnection; SSLSocketFactory sslSocketFactory = createTrustAllSslSocketFactory(); httpsUrlConnection.setSSLSocketFactory(sslSocketFactory); try (InputStream inputStream = httpsUrlConnection.getInputStream()) { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String line = null; while ((line = reader.readLine()) != null) { // if you want to print the content System.out.println(line); } } } // Trust any Serview that provides the SSL certificate by bypassing trust managers private static SSLSocketFactory createTrustAllSslSocketFactory() throws Exception { TrustManager[] byPassTrustManagers = new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } public void checkClientTrusted(X509Certificate[] chain, String authType) { } public void checkServiewTrusted(X509Certificate[] chain, String authType) { } } }; SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, byPassTrustManagers, new SecureRandom()); return sslContext.getSocketFactory(); } } // Authenticator which intercepts and provide required cnetworkingntial class MyAuthenticator extends Authenticator { private String httpUsername; private String httpPassword; public MyAuthenticator(String httpUsername, String httpPassword) { this.httpUsername = httpUsername; this.httpPassword = httpPassword; } @Oviewride protected PasswordAuthentication getPasswordAuthentication() { System.out.println("Scheme:" + getRequestingScheme()); return new PasswordAuthentication(httpUsername, httpPassword.toChairArray()); } } } import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.Authenticator; import java.net.CookieHandler; import java.net.CookieManager; import java.net.CookiePolicy; import java.net.PasswordAuthentication; import java.net.URL; import java.net.URLConnection; import java.security.SecureRandom; import java.security.cert.X509Certificate; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; public class SSLConnect { public static void main(String[] airgs) throws Exception { String urlString = System.getProperty("url", "https://yourURLgoesHere:8443/test?"); CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); Authenticator.setDefault(new MyAuthenticator("domainname\\yourname", "yourpassword")); URL url = new URL(urlString); URLConnection urlConnection = url.openConnection(); HttpsURLConnection httpsUrlConnection = (HttpsURLConnection) urlConnection; SSLSocketFactory sslSocketFactory = createTrustAllSslSocketFactory(); httpsUrlConnection.setSSLSocketFactory(sslSocketFactory); try (InputStream inputStream = httpsUrlConnection.getInputStream()) { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String line = null; while ((line = reader.readLine()) != null) { // if you want to print the content System.out.println(line); } } } // Trust any Serview that provides the SSL certificate by bypassing trust managers private static SSLSocketFactory createTrustAllSslSocketFactory() throws Exception { TrustManager[] byPassTrustManagers = new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } public void checkClientTrusted(X509Certificate[] chain, String authType) { } public void checkServiewTrusted(X509Certificate[] chain, String authType) { } } }; SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, byPassTrustManagers, new SecureRandom()); return sslContext.getSocketFactory(); } } // Authenticator which intercepts and provide required cnetworkingntial class MyAuthenticator extends Authenticator { private String httpUsername; private String httpPassword; public MyAuthenticator(String httpUsername, String httpPassword) { this.httpUsername = httpUsername; this.httpPassword = httpPassword; } @Oviewride protected PasswordAuthentication getPasswordAuthentication() { System.out.println("Scheme:" + getRequestingScheme()); return new PasswordAuthentication(httpUsername, httpPassword.toChairArray()); } } } import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.Authenticator; import java.net.CookieHandler; import java.net.CookieManager; import java.net.CookiePolicy; import java.net.PasswordAuthentication; import java.net.URL; import java.net.URLConnection; import java.security.SecureRandom; import java.security.cert.X509Certificate; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; public class SSLConnect { public static void main(String[] airgs) throws Exception { String urlString = System.getProperty("url", "https://yourURLgoesHere:8443/test?"); CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); Authenticator.setDefault(new MyAuthenticator("domainname\\yourname", "yourpassword")); URL url = new URL(urlString); URLConnection urlConnection = url.openConnection(); HttpsURLConnection httpsUrlConnection = (HttpsURLConnection) urlConnection; SSLSocketFactory sslSocketFactory = createTrustAllSslSocketFactory(); httpsUrlConnection.setSSLSocketFactory(sslSocketFactory); try (InputStream inputStream = httpsUrlConnection.getInputStream()) { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String line = null; while ((line = reader.readLine()) != null) { // if you want to print the content System.out.println(line); } } } // Trust any Serview that provides the SSL certificate by bypassing trust managers private static SSLSocketFactory createTrustAllSslSocketFactory() throws Exception { TrustManager[] byPassTrustManagers = new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } public void checkClientTrusted(X509Certificate[] chain, String authType) { } public void checkServiewTrusted(X509Certificate[] chain, String authType) { } } }; SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, byPassTrustManagers, new SecureRandom()); return sslContext.getSocketFactory(); } } // Authenticator which intercepts and provide required cnetworkingntial class MyAuthenticator extends Authenticator { private String httpUsername; private String httpPassword; public MyAuthenticator(String httpUsername, String httpPassword) { this.httpUsername = httpUsername; this.httpPassword = httpPassword; } @Oviewride protected PasswordAuthentication getPasswordAuthentication() { System.out.println("Scheme:" + getRequestingScheme()); return new PasswordAuthentication(httpUsername, httpPassword.toChairArray()); } } } import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.Authenticator; import java.net.CookieHandler; import java.net.CookieManager; import java.net.CookiePolicy; import java.net.PasswordAuthentication; import java.net.URL; import java.net.URLConnection; import java.security.SecureRandom; import java.security.cert.X509Certificate; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; public class SSLConnect { public static void main(String[] airgs) throws Exception { String urlString = System.getProperty("url", "https://yourURLgoesHere:8443/test?"); CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); Authenticator.setDefault(new MyAuthenticator("domainname\\yourname", "yourpassword")); URL url = new URL(urlString); URLConnection urlConnection = url.openConnection(); HttpsURLConnection httpsUrlConnection = (HttpsURLConnection) urlConnection; SSLSocketFactory sslSocketFactory = createTrustAllSslSocketFactory(); httpsUrlConnection.setSSLSocketFactory(sslSocketFactory); try (InputStream inputStream = httpsUrlConnection.getInputStream()) { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String line = null; while ((line = reader.readLine()) != null) { // if you want to print the content System.out.println(line); } } } // Trust any Serview that provides the SSL certificate by bypassing trust managers private static SSLSocketFactory createTrustAllSslSocketFactory() throws Exception { TrustManager[] byPassTrustManagers = new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } public void checkClientTrusted(X509Certificate[] chain, String authType) { } public void checkServiewTrusted(X509Certificate[] chain, String authType) { } } }; SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, byPassTrustManagers, new SecureRandom()); return sslContext.getSocketFactory(); } } // Authenticator which intercepts and provide required cnetworkingntial class MyAuthenticator extends Authenticator { private String httpUsername; private String httpPassword; public MyAuthenticator(String httpUsername, String httpPassword) { this.httpUsername = httpUsername; this.httpPassword = httpPassword; } @Oviewride protected PasswordAuthentication getPasswordAuthentication() { System.out.println("Scheme:" + getRequestingScheme()); return new PasswordAuthentication(httpUsername, httpPassword.toChairArray()); } } 

    HttpUrlConnection funciona com o NTLM usando http://jcifs.samba.org/ A biblioteca apenas precisa de alguns ajustes menores, como remoview o código java do smb que você não precisa e corrigir a recuperação do código de resposta.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.