Revision 3952,
1.1 KB
checked in by alexandrecorreia, 13 years ago
(diff) |
Ticket #1710 - Adicao do codigo fonte java do componente jmessenger(jabberit_messenger)
|
-
Property svn:executable set to
*
|
Rev | Line | |
---|
[3952] | 1 | /** |
---|
| 2 | * @author Alexandre Correia - alexandrecorreia@celepar.pr.gov.br |
---|
| 3 | * @ ProxyName e ProxyPort |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | package nu.fw.jeti.util; |
---|
| 7 | |
---|
| 8 | import java.util.Iterator; |
---|
| 9 | import java.util.List; |
---|
| 10 | import java.net.InetSocketAddress; |
---|
| 11 | import java.net.Proxy; |
---|
| 12 | import java.net.ProxySelector; |
---|
| 13 | import java.net.URI; |
---|
| 14 | |
---|
| 15 | public class ProxyIM |
---|
| 16 | { |
---|
| 17 | private static String proxyServer; |
---|
| 18 | private static int proxyPort; |
---|
| 19 | |
---|
| 20 | public static void setProxy(String url) |
---|
| 21 | { |
---|
| 22 | try |
---|
| 23 | { |
---|
| 24 | System.setProperty("java.net.useSystemProxies","true"); |
---|
| 25 | List l = ProxySelector.getDefault().select(new URI(url)); |
---|
| 26 | |
---|
| 27 | for (Iterator iter = l.iterator(); iter.hasNext(); ) |
---|
| 28 | { |
---|
| 29 | Proxy proxy = (Proxy) iter.next(); |
---|
| 30 | InetSocketAddress addr = (InetSocketAddress)proxy.address(); |
---|
| 31 | |
---|
| 32 | if( addr == null ) |
---|
| 33 | { |
---|
| 34 | proxyServer = ""; |
---|
| 35 | proxyPort = 0; |
---|
| 36 | } |
---|
| 37 | else |
---|
| 38 | { |
---|
| 39 | proxyServer = addr.getHostName().toString(); |
---|
| 40 | proxyPort = addr.getPort(); |
---|
| 41 | } |
---|
| 42 | } |
---|
| 43 | } |
---|
| 44 | catch (Exception e) |
---|
| 45 | { |
---|
| 46 | e.printStackTrace(); |
---|
| 47 | } |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | public static String getProxyServer() |
---|
| 51 | { |
---|
| 52 | return proxyServer; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | public static int getProxyPort() |
---|
| 56 | { |
---|
| 57 | return proxyPort; |
---|
| 58 | } |
---|
| 59 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.