Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static class MyAuthenticator extends Authenticator {
- public PasswordAuthentication getPasswordAuthentication() {
- System.out.println("trying to authenticate");
- return new PasswordAuthentication("user", "password".toCharArray());
- }
- }
- Authenticator.setDefault(new MyAuthenticator())
- String encoding = Base64.encode("user:password".getBytes());
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setRequestMethod("GET");
- connection.setDoOutput(true);
- connection.setRequestProperty ("Authorization", "Basic " + encoding);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement