KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > agent > client > ProxyInfo


1 package com.sslexplorer.agent.client;
2
3 /**
4  * Describes the location and authenitcation details of a single proxy
5  * server.
6  *
7  * @author Lee David Painter <a HREF="mailto: lee@3sp.com">&lt;lee@3sp.com&gt;</a>
8  */

9 public class ProxyInfo {
10     
11     // Private instance variables
12
private String JavaDoc protocol;
13     private String JavaDoc username;
14     private String JavaDoc password;
15     private String JavaDoc hostname;
16     private int port;
17     private String JavaDoc sourceIdent;
18     
19
20     /**
21      * Constructor.
22      *
23      * @param protocol
24      * @param username
25      * @param password
26      * @param hostname
27      * @param port
28      * @param sourceIdent
29      */

30     public ProxyInfo(String JavaDoc protocol, String JavaDoc username, String JavaDoc password, String JavaDoc hostname, int port, String JavaDoc sourceIdent) {
31         super();
32         this.protocol = protocol;
33         this.username = username;
34         this.password = password;
35         this.hostname = hostname;
36         this.port = port;
37         this.sourceIdent = sourceIdent;
38     }
39
40     /**
41      * Get the proxy server information as a URI. This includes the protocl,
42      * host, port, username and password.
43      *
44      * @return proxy server information as a URI
45      */

46     public String JavaDoc toUri() {
47         StringBuffer JavaDoc buf = new StringBuffer JavaDoc(getProtocol());
48         buf.append("://"); //$NON-NLS-1$
49
if(username != null && !username.equals("")) { //$NON-NLS-1$
50
buf.append(username);
51             if(password != null && !password.equals("")) { //$NON-NLS-1$
52
buf.append(":"); //$NON-NLS-1$
53
buf.append(password);
54             }
55             buf.append("@"); //$NON-NLS-1$
56
}
57         buf.append(hostname);
58         if(port != 0) {
59             buf.append(":"); //$NON-NLS-1$
60
buf.append(port);
61         }
62         return buf.toString();
63     }
64
65     /**
66      * Get to hostname or IP address of the proxy server
67      *
68      * @return hostname or IP address of the proxy server
69      */

70     public String JavaDoc getHostname() {
71         return hostname;
72     }
73
74     /**
75      * Get the password to use for proxy server authentication
76      *
77      * @return password to use for proxy server authentication
78      */

79     public String JavaDoc getPassword() {
80         return password;
81     }
82
83     /**
84      * Get the port on which the proxy server is running
85      *
86      * @return port on which the proxy server is running
87      */

88     public int getPort() {
89         return port;
90     }
91
92     /**
93      * Get the protocol on which the proxy server is running.
94      *
95      * @return protocol on which the proxy server is running.
96      */

97     public String JavaDoc getProtocol() {
98         return protocol;
99     }
100
101     /**
102      * Get the source ident
103      *
104      * CHECK Whats this?
105      *
106      * @return source ident
107      */

108     public String JavaDoc getSourceIdent() {
109         return sourceIdent;
110     }
111
112     /**
113      * Get the username to use for proxy server authentication
114      *
115      * @return username to use for proxy server authentication
116      */

117     public String JavaDoc getUsername() {
118         return username;
119     }
120 }
121
Popular Tags