/* * Jeti, a Java Jabber client, Copyright (C) 2003 E.S. de Boer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * For questions, comments etc, * use the website at http://jeti.jabberstudio.org * or mail me at eric@jeti.tk */ package nu.fw.jeti.backend; import java.net.ProxySelector; import java.net.URL; import com.sun.java.browser.net.ProxyInfo; import com.sun.java.browser.net.ProxyService; import nu.fw.jeti.util.Utils; /** * @author E.S. de Boer */ public class LoginInfo { public final static int NO_PROXY=0; public final static int SOCKS_PROXY=1; public final static int HTTP_PROXY=2; public final static int HTTP_BIND=3; private String server; private String host; private int port; private String username; private String resource; private String password; private boolean ssl=false; private int proxyType=NO_PROXY; private String proxyServer; private String proxyPort; private String proxyUsername; private String proxyPassword; private int priority; //applet public LoginInfo(String server, String host, String username,String password, String resource,int port,boolean ssl,int priority) { if(username!=null && username.indexOf("@")!=-1 ) { this.host = server; int atPos = username.indexOf('@'); this.username = username.substring(0,atPos); this.server = username.substring(atPos+1,username.length()); } else { this.server = server; this.host = host; this.username = username; } this.ssl = ssl; this.password = password; if(password != null && password.equals("")) this.password =null; this.resource = resource; if(resource != null && resource.equals("")) this.resource ="Jeti"; this.port = port; if(port==0)port=5222; this.priority = priority; } public LoginInfo(String server, String host, String username, String password, String resource,int port, boolean ssl,int priority, int proxy, String proxyServer, String proxyUsername, String proxyPassword, String proxyPort ) { this(server,host,username,password,resource,port,ssl,priority); this.proxyType = proxy; this.proxyServer = proxyServer; this.proxyPort = proxyPort; this.proxyUsername = proxyUsername ; this.proxyPassword = proxyPassword; } public LoginInfo(String server, String host, String username, String password, String resource, int port, boolean ssl, String proxyServer, String proxyPort) { this.server = server; this.host = host; this.username = username; this.password = password; this.resource = resource; this.port = port; this.ssl = ssl; this.proxyServer = proxyServer; this.proxyPort = proxyPort; } /** * Returns the port. * @return String */ public int getPort() { return port; } /** * Returns the resource. * @return String */ public String getResource() { return resource; } /** * Returns the server. * @return String */ public String getServer() { return server; } /** * Returns the host to connect to. * @return String */ public String getHost() { return host; } /** * Returns the ssl. * @return boolean */ public boolean isSSl() { return ssl; } public int getPriority() { return priority; } /** * Returns the username. * @return String */ public String getUsername() { return username; } /** * Returns the password. * @return String */ public String getPassword() { return password; } /** * Sets the password. * @param password The password to set */ public void setPassword(String password) { this.password = password; } public void setProxyPassword(String proxyPassword) { this.proxyPassword = proxyPassword; } /** * Returns the proxyPassword. * @return String */ public String getProxyPassword() { return proxyPassword; } /** * Returns the proxyPort. * @return int */ public String getProxyPort() { return proxyPort; } /** * Returns the proxyServer. * @return String */ public String getProxyServer() { return proxyServer; } /** * Set the proxyUsername; * */ public void setProxyUsername(String proxyUsername) { this.proxyUsername = proxyUsername; } /** * Returns the proxyUsername. * @return String */ public String getProxyUsername() { return proxyUsername; } /** * returns the type of proxy used * @return proxy type */ public int getProxyType() { return proxyType; } /** * returns the used proxy * @param proxy the proxy type to test * @return true if the proxy is used */ public boolean useProxy(int proxy) { return proxyType == proxy; } public boolean isHTTPProxy() { //System.out.println( "( " + proxyType + "==" + LoginInfo.HTTP_PROXY + " ) = " + useProxy(LoginInfo.HTTP_PROXY)); if( useProxy(LoginInfo.HTTP_PROXY) ) return true; else return false; } } /* * Overrides for emacs * Local variables: * tab-width: 4 * End: */