Date: 07/06/07 (Java Web) Keywords: java Java provides a super simple, yet hidden from plain view, way to do basic authentication of HttpURLConnection / URLConnection. Before making a connection add the following lines of code: final String login ="..."; final String password ="..."; Authenticator.setDefault(new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication (login, password.toCharArray()); [...] Source: http://blog.taragana.com/index.php/archive/java-tip-basic-authentication-with-httpurlconnection/
|