source: branches/2.2/jabberit_messenger/java_source/src/nu/fw/jeti/backend/LoginInfo.java @ 3102

Revision 3102, 5.7 KB checked in by amuller, 14 years ago (diff)

Ticket #986 - Efetuado merge para o Branch 2.2( atualizacao do modulo)

  • Property svn:executable set to *
Line 
1/*
2 *      Jeti, a Java Jabber client, Copyright (C) 2003 E.S. de Boer 
3 *
4 *  This program is free software; you can redistribute it and/or modify
5 *  it under the terms of the GNU General Public License as published by
6 *  the Free Software Foundation; either version 2 of the License, or
7 *  (at your option) any later version.
8 *
9 *  This program is distributed in the hope that it will be useful,
10 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
11 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 *      GNU General Public License for more details.
13 *
14 *  You should have received a copy of the GNU General Public License
15 *  along with this program; if not, write to the Free Software
16 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 *
18 *      For questions, comments etc,
19 *      use the website at http://jeti.jabberstudio.org
20 *  or mail me at eric@jeti.tk
21 */
22
23package nu.fw.jeti.backend;
24
25import java.net.ProxySelector;
26import java.net.URL;
27
28import com.sun.java.browser.net.ProxyInfo;
29import com.sun.java.browser.net.ProxyService;
30
31import nu.fw.jeti.util.Utils;
32
33
34/**
35 * @author E.S. de Boer
36 */
37
38public class LoginInfo
39{
40        public final static int NO_PROXY=0;
41        public final static int SOCKS_PROXY=1;
42        public final static int HTTP_PROXY=2;
43        public final static int HTTP_BIND=3;
44               
45        private String server;
46    private String host;
47        private int port;
48        private String username;
49        private String resource;
50        private String password;
51        private boolean ssl=false;
52        private int proxyType=NO_PROXY;
53        private String proxyServer;
54        private String proxyPort;
55        private String proxyUsername;
56        private String proxyPassword;
57        private int priority;
58
59        //applet
60    public LoginInfo(String server, String host, String username,String password,
61                String resource,int port,boolean ssl,int priority)
62    {
63        if(username!=null && username.indexOf("@")!=-1 )
64        {
65                this.host = server;
66                int atPos = username.indexOf('@');
67                this.username = username.substring(0,atPos);
68                this.server = username.substring(atPos+1,username.length());
69        }
70        else
71        {
72                this.server = server;
73            this.host = host;
74                this.username = username;
75        }
76
77        this.ssl = ssl;
78                this.password = password;
79                if(password != null && password.equals("")) this.password =null;
80                this.resource = resource;
81                if(resource != null && resource.equals("")) this.resource ="Jeti";
82                this.port = port;
83                if(port==0)port=5222;
84                this.priority = priority;
85    }
86
87    public LoginInfo(String server, String host, String username,
88                     String password, String resource,int port, boolean ssl,int priority,
89                     int proxy, String proxyServer, String proxyUsername,
90                     String proxyPassword, String proxyPort )
91    {
92        this(server,host,username,password,resource,port,ssl,priority);
93                this.proxyType = proxy;
94                this.proxyServer = proxyServer;
95                this.proxyPort = proxyPort;
96                this.proxyUsername = proxyUsername ;
97                this.proxyPassword = proxyPassword;
98    }
99
100    public LoginInfo(String server, String host, String username, String password, String resource,
101                                 int port, boolean ssl, String proxyServer, String proxyPort)
102    {
103        this.server = server;
104        this.host = host;
105        this.username = username;
106        this.password = password;
107        this.resource = resource;
108        this.port = port;
109        this.ssl = ssl;
110        this.proxyServer = proxyServer;
111        this.proxyPort = proxyPort;
112    }
113   
114        /**
115         * Returns the port.
116         * @return String
117         */
118        public int getPort()
119        {
120                return port;
121        }
122
123        /**
124         * Returns the resource.
125         * @return String
126         */
127        public String getResource()
128        {
129                return resource;
130        }
131
132        /**
133         * Returns the server.
134         * @return String
135         */
136        public String getServer()
137        {
138                return server;
139        }
140
141        /**
142     * Returns the host to connect to.
143     * @return String
144     */
145    public String getHost()
146    {
147        return host;
148    }
149
150    /**
151         * Returns the ssl.
152         * @return boolean
153         */
154        public boolean isSSl() {
155                return ssl;
156        }
157       
158        public int getPriority()
159        {
160                return priority;
161        }
162
163        /**
164         * Returns the username.
165         * @return String
166         */
167        public String getUsername() {
168                return username;
169        }
170
171        /**
172         * Returns the password.
173         * @return String
174         */
175        public String getPassword()
176        {
177                return password;
178        }
179
180        /**
181         * Sets the password.
182         * @param password The password to set
183         */
184        public void setPassword(String password)
185        {
186                this.password = password;
187        }
188
189        public void setProxyPassword(String proxyPassword)
190        {
191                this.proxyPassword = proxyPassword;
192        }
193       
194        /**
195         * Returns the proxyPassword.
196         * @return String
197         */
198        public String getProxyPassword()
199        {
200                return proxyPassword;
201        }
202
203        /**
204         * Returns the proxyPort.
205         * @return int
206         */
207        public String getProxyPort()
208        {
209                return proxyPort;
210        }
211
212        /**
213         * Returns the proxyServer.
214         * @return String
215         */
216        public String getProxyServer()
217        {
218                return proxyServer;
219        }
220
221        /**
222         * Set the proxyUsername;
223         *
224         */
225       
226        public void setProxyUsername(String proxyUsername)
227        {
228                this.proxyUsername = proxyUsername;
229        }
230       
231        /**
232         * Returns the proxyUsername.
233         * @return String
234         */
235        public String getProxyUsername()
236        {
237                return proxyUsername;
238        }
239       
240        /**
241         * returns the type of proxy used
242         * @return proxy type
243         */
244        public int getProxyType()
245        {
246                return proxyType;
247        }
248
249        /**
250         * returns the used proxy
251         * @param proxy the proxy type to test
252         * @return true if the proxy is used
253         */
254        public boolean useProxy(int proxy)
255        {
256                return proxyType == proxy;
257        }
258       
259        public boolean isHTTPProxy()
260        {
261                //System.out.println( "( " + proxyType + "==" + LoginInfo.HTTP_PROXY + " ) = " + useProxy(LoginInfo.HTTP_PROXY));
262               
263                if( useProxy(LoginInfo.HTTP_PROXY) )
264                        return true;
265                else
266                        return false;
267        }
268}
269/*
270 * Overrides for emacs
271 * Local variables:
272 * tab-width: 4
273 * End:
274 */
Note: See TracBrowser for help on using the repository browser.