X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2FProxy.java;h=750b3eef6a37c874b69b485e8f30b9c41ca47946;hb=3519cb5c518d569235beaedfc3071cba45ec848d;hp=fa59c738439e40467aa62dfb28252799375b0375;hpb=5644a84eee241f6c831f06e0bbf29650f0b82cc2;p=fanfix.git diff --git a/src/be/nikiroo/utils/Proxy.java b/src/be/nikiroo/utils/Proxy.java deleted file mode 100755 index fa59c73..0000000 --- a/src/be/nikiroo/utils/Proxy.java +++ /dev/null @@ -1,92 +0,0 @@ -package be.nikiroo.utils; - -import java.net.Authenticator; -import java.net.PasswordAuthentication; - -/** - * Simple proxy helper to select a default internet proxy. - * - * @author niki - */ -public class Proxy { - /** - * Use the system proxy. - */ - static public void useSystemProxy() { - useSystemProxy(null, null); - } - - /** - * Use the system proxy with the given login/password, for authenticated - * proxies. - * - * @param user - * the user name or login - * @param password - * the password - */ - static public void useSystemProxy(String user, String password) { - System.setProperty("java.net.useSystemProxies", "true"); - auth(user, password); - } - - /** - * Use the give proxy. - * - * @param host - * the proxy host name or IP address - * @param port - * the port to use - */ - static public void useProxy(String host, int port) { - useProxy(host, port, null, null); - } - - /** - * Use the given proxy with the given login/password, for authenticated - * proxies. - * - * @param user - * the user name or login - * @param password - * the password - * @param host - * the proxy host name or IP address - * @param port - * the port to use - * @param user - * the user name or login - * @param password - * the password - */ - static public void useProxy(String host, int port, String user, - String password) { - System.setProperty("http.proxyHost", "proxy.stluc.ucl.ac.be"); - System.setProperty("http.proxyPort", "8080"); - auth(user, password); - } - - /** - * Select the default authenticator for proxy requests. - * - * @param user - * the user name or login - * @param password - * the password - */ - static private void auth(final String user, final String password) { - if (user != null && password != null) { - Authenticator proxy = new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - if (getRequestorType() == RequestorType.PROXY) { - return new PasswordAuthentication(user, - password.toCharArray()); - } - return null; - } - }; - Authenticator.setDefault(proxy); - } - } -}