Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. URI baseUri = URI.create("https://my.company.com/");
  2. String username = "";
  3. String password = "";
  4.  
  5. Authenticator.setDefault(new Authenticator() {
  6.  
  7. @Override
  8. public PasswordAuthentication getPasswordAuthentication() {
  9. // only return our credentials for our URI
  10. if (baseUri.getHost().equals(getRequestingHost())) {
  11. return new PasswordAuthentication(username, password.toCharArray());
  12. }
  13. return null;
  14. }
  15. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement