Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package it.roaned.proxy;
- import java.net.Authenticator;
- import java.net.PasswordAuthentication;
- /**
- * copiata da:
- * http://blog.ashwani.co.in/blog/2013-07-29/access-sharepoint-webservices-from-java-behind-proxy/
- */
- public class SimpleAuthenticator extends Authenticator
- {
- private final static String proxyHost = "proxy.aubay.it";
- private String username;
- private final char[] password;
- public SimpleAuthenticator(String username,String password)
- {
- super();
- this.username = new String(username);
- this.password = password.toCharArray();
- }
- protected PasswordAuthentication getPasswordAuthentication()
- {
- String requestingHost = getRequestingHost();
- if (requestingHost == proxyHost){
- System.out.println("getPasswordAuthentication() request recieved from->" + requestingHost );
- return new PasswordAuthentication(username,password);
- }
- else{
- System.out.println("getPasswordAuthentication() request recieved from->" + requestingHost );
- return new PasswordAuthentication(username,password);
- }
- }
- }
- // Authenticator.setDefault(new SimpleAuthenticator("andrei.cebotari", "Htc__Aub92"));
- // log.info("Configuring Proxy settings");
- // System.getProperties().put("http.proxyHost","proxy.aubay.it");
- // System.getProperties().put("http.proxyPort","3128");
- // System.getProperties().put("https.proxyHost","proxy.aubay.it");
- // System.getProperties().put("https.proxyPort", "3128");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement