|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--hamsam.net.ProxyInfo
Defines the type of connections to be used for each protocol. An object that implements this interface is used by Hamsam library to determine what type of connections are to be used for each protocol.
Field Summary | |
static int |
DIRECT
Connection type indicating a direct connection to the Internet. |
static int |
HTTP
Connection type indicating a connection through HTTP proxy to the Internet. |
static int |
SOCKS4
Connection type indicating a connection through Socks Version 4 proxy to the Internet. |
static int |
SOCKS5
Connection type indicating a connection through Socks Version 5 proxy to the Internet. |
Constructor Summary | |
ProxyInfo()
Construct a proxy information object indicating direct connection to the Internet. |
|
ProxyInfo(int type,
java.lang.String serverName,
int serverPort)
Construct a proxy information object indicating the type of proxy to be used, the proxy server's host name, and proxy server's listening port number. |
Method Summary | |
Connection |
getConnection(java.lang.String hostname,
int port)
Creates a connection through the proxy set in this ProxyInfo object. |
java.lang.String |
getPassword()
Returns the password to be used for proxy authentication. |
int |
getProxyType()
Returns the type of proxy to be used as indicated by this object. |
java.lang.String |
getServerName()
Returns the host name of the proxy server to be used. |
int |
getServerPort()
Returns the TCP/IP port at which the proxy server is listening. |
java.lang.String |
getUsername()
Returns the username to be used for proxy authentication. |
void |
setPassword(java.lang.String password)
Set the password to be used for proxy authentication. |
void |
setUsername(java.lang.String username)
Set the username to be used for proxy authentication. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DIRECT
public static final int SOCKS4
public static final int SOCKS5
public static final int HTTP
Constructor Detail |
public ProxyInfo()
public ProxyInfo(int type, java.lang.String serverName, int serverPort) throws IllegalArgumentException
You may use SOCKS4, SOCKS5, or HTTP as the proxy types. If you specify
the proxy type as DIRECT, an
IllegalArgumentException
will be thrown.
type
- The proxy server type.serverName
- The host name of the proxy server.serverPort
- The TCP/IP port number in which the proxy is listening.
IllegalArgumentException
- If type
is DIRECT
.Method Detail |
public void setUsername(java.lang.String username) throws IllegalStateException
Socks version 5 and HTTP proxies optionally use authentication through a username-password mechanism. This method sets the username for such authentication.
If the proxy type is other than SOCKS5
or HTTP
,
this method throws an
IllegalStateException
.
username
- The username to be used for proxy authentication.
IllegalStateException
- If the proxy type is neither Socks version 5
nor HTTP.public void setPassword(java.lang.String password) throws IllegalStateException
Socks version 5 and HTTP proxies optionally use authentication through a username-password mechanism. This method sets the password for such authentication.
If the proxy type is other than SOCKS5
or HTTP
,
this method throws an
IllegalStateException
.
password
- The password to be used for proxy authentication.
IllegalStateException
- If the proxy type is neither Socks version 5
nor HTTP.public int getProxyType()
This method returns the proxy type set at the time of constructing this object.
public java.lang.String getServerName()
If this object specifies a direct connection to the Internet,
this method will return null
.
null
if there is no proxy servers.public int getServerPort()
If there is no proxy server, this will return -1.
public java.lang.String getUsername() throws IllegalStateException
If the type of the proxy is neither Socks version 5 nor HTTP,
an
IllegalStateException
will be thrown.
null
if the proxy does not require authentication.
IllegalStateException
- If the proxy type is neither Socks version 5
nor HTTP.public java.lang.String getPassword() throws IllegalStateException
If the type of the proxy is neither Socks version 5 nor HTTP, an IllegalStateException will be thrown.
null
if the proxy does not require authentication.
IllegalStateException
- If the proxy type is neither Socks version 5
nor HTTP.public Connection getConnection(java.lang.String hostname, int port) throws java.net.UnknownHostException, java.io.IOException, IllegalStateException
hostname
- the host to connect to.port
- the TCP/IP ports number to connect to.
java.net.UnknownHostException
- if the proxy server or the host is unknown.
java.io.IOException
- if an I/O error occured while connecting.
IllegalStateException
- if this ProxyInfo is not initialized properly.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |