as part of development of android application business, have communicate through proxy authentication server.
here's code wrote:
final httpurlconnection connection = (httpurlconnection) new url(url).openconnection(new proxy(proxy.type.http, new inetsocketaddress(proxy_name, proxy_port))); authenticator.setdefault(new ntlmauthenticator(proxy_username, proxy_password)); connection.setconnecttimeout(5000); connection.setrequestproperty("content-type", "text/xml; charset=utf-8"); connection.setdoinput(true); connection.setdooutput(true); final int retcode = connection.getresponsecode(); system.out.println("return code : " + retcode);
with class
private class ntlmauthenticator extends authenticator { private final string username; private final string password; public ntlmauthenticator(final string username, final string password) { super(); this.username = username; this.password = password; } @override public passwordauthentication getpasswordauthentication() { system.out.println("get password auth"); return (new passwordauthentication(username, password.tochararray())); } }
unfortunately, still response code equal 407 , i've realized never spent in method getpasswordauthentication
the same program works java program not android.
my version of android 4.4.4 , have seen used okhttp queries. debugging , entering code of android, i've realized object contained okhttp proxy configuration not authenticator.
could me ?
thank you
Comments
Post a Comment