List of usage examples for java.net Authenticator requestPasswordAuthentication
public static PasswordAuthentication requestPasswordAuthentication(InetAddress addr, int port, String protocol, String prompt, String scheme)
From source file:org.droidparts.http.worker.HttpURLConnectionWorker.java
private void setupBasicAuth() { if (passAuth != null) { Authenticator.setDefault(new FixedAuthenticator(passAuth)); if (!AuthScope.ANY.equals(authScope)) { InetAddress host = null; if (authScope.getHost() != null) { try { host = InetAddress.getByName(authScope.getHost()); } catch (UnknownHostException e) { L.e("Failed to setup basic auth."); L.d(e);//from w ww . j av a 2 s. c o m Authenticator.setDefault(null); return; } } int port = (authScope.getPort() == AuthScope.ANY_PORT) ? 0 : authScope.getPort(); Authenticator.requestPasswordAuthentication(host, port, null, authScope.getRealm(), authScope.getScheme()); } } }