|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.foxsmart.ic.net.DefaultHttpProtocolHandler
public class DefaultHttpProtocolHandler
The DefaultHttpProtocolHandler class handles the HTTP communication with the router.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.foxsmart.ic.net.ProtocolHandler |
|---|
ProtocolHandler.Protocol |
| Field Summary | |
|---|---|
static java.lang.String |
COMMAND_PART_SEPARATOR
Command part separator. |
static int |
DEFAULT_HTTP_PORT
The default telnet socket port. |
protected java.lang.Integer |
defaultProtocolTimeout
|
static java.lang.String |
ESCAPE_PREFIX
Escape prefix. |
protected org.apache.commons.logging.Log |
log
|
static java.lang.String |
PASSWORD_MASK
|
static java.lang.String |
PREFIX_CONFIGURE
The "configure" prefix. |
static java.lang.String |
PREFIX_EXEC
The "exec" prefix. |
| Fields inherited from interface com.foxsmart.ic.net.ProtocolHandler |
|---|
CR, DEFAULT_PROTOCOL_TIMEOUT_SECONDS |
| Constructor Summary | |
|---|---|
DefaultHttpProtocolHandler()
Default Constructor. |
|
| Method Summary | |
|---|---|
void |
connect(java.lang.String hostname,
java.lang.Integer port,
java.lang.String username,
java.lang.String password,
java.lang.Integer timeout)
Connects to the router using HTTP. |
void |
disconnect()
This method sets the usernameUsed and passwordUsed flags to false. |
boolean |
getAvailable()
Default implementation returns true. |
protected java.lang.String |
getBaseUrl()
Gets the base URL for connecting to the router using HTTP. |
protected java.lang.String |
getBaseUrl(java.lang.String hostname,
java.lang.Integer port)
Gets the base URL for connecting to the router using HTTP with the specified hostname and port number. |
java.lang.Integer |
getDefaultProtocolTimeout()
Gets the default operation timeout value. |
boolean |
getPasswordUsed()
Gets whether the password was used for authentication. |
ProtocolHandler.Protocol |
getProtocol()
Returns the HTTP protocol. |
boolean |
getUsernameUsed()
Gets whether the username was used for authentication. |
boolean |
isConnected()
Returns true if the client is currently connected to a server. |
protected java.lang.String |
prepareCommandPart(java.lang.String commandPart)
|
java.lang.String |
sendCommandWithResults(java.lang.String command)
Sends a command and returns the results. |
java.lang.String |
sendConfigCommandWithResults(java.lang.String command,
boolean parent)
Sends a configuration command and returns the results. |
void |
setDefaultProtocolTimeout(java.lang.Integer timeout)
Modifies the default operation protocol timeout value. |
void |
setPasswordUsed(boolean passwordUsed)
Sets whether the password was used for authentication. |
void |
setUsernameUsed(boolean usernameUsed)
Sets whether the username was used for authentication. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String PREFIX_EXEC
public static final java.lang.String PREFIX_CONFIGURE
public static final java.lang.String COMMAND_PART_SEPARATOR
public static final java.lang.String ESCAPE_PREFIX
protected org.apache.commons.logging.Log log
public static final int DEFAULT_HTTP_PORT
protected java.lang.Integer defaultProtocolTimeout
public static final java.lang.String PASSWORD_MASK
| Constructor Detail |
|---|
public DefaultHttpProtocolHandler()
| Method Detail |
|---|
public ProtocolHandler.Protocol getProtocol()
getProtocol in interface ProtocolHandler
public void connect(java.lang.String hostname,
java.lang.Integer port,
java.lang.String username,
java.lang.String password,
java.lang.Integer timeout)
throws java.lang.Exception
connect in interface HttpProtocolHandlerhostname - The name of the remote host.port - The port to connect to on the remote host. If null is passed in, a default port will be used.username - The username to connect with. Null should be passed in if no username is required.password - The password to connect with. Null should be passed in if no password is required.timeout - The timeout in seconds. If null is passed in, a default timeout will be used.
AuthenticationFailedException - when a successful connection could not be made
java.io.IOException - if the URL stream could not be opened to the URL
java.net.UnknownServiceException - if the URL protocol does not support input
ThreadTimeoutException - if a timeout occurred while connecting to the router.
java.net.UnknownHostException - If the hostname cannot be resolved.
java.lang.Exception - if any other problems were encountered.Note that the
timeout is not used.
public java.lang.String sendCommandWithResults(java.lang.String command)
throws java.lang.Exception
sendCommandWithResults in interface HttpProtocolHandlercommand - The command to send to the device.
java.lang.Exception - if any problems were encountered.
public java.lang.String sendConfigCommandWithResults(java.lang.String command,
boolean parent)
throws java.lang.Exception
sendConfigCommandWithResults in interface HttpProtocolHandlercommand - The command to send to the device.parent - True if the configuration command is a parent element or false if not.
java.lang.Exception - if any problems were encountered.protected java.lang.String getBaseUrl()
protected java.lang.String getBaseUrl(java.lang.String hostname,
java.lang.Integer port)
hostname - the hostnameport - the port number.
public boolean isConnected()
isConnected in interface HttpProtocolHandlerpublic void setDefaultProtocolTimeout(java.lang.Integer timeout)
setDefaultProtocolTimeout in interface HttpProtocolHandlersetDefaultProtocolTimeout in interface ProtocolHandlertimeout - The default timeout value in seconds to wait for the data to be returned. If null is passed, no
timeout will be used. Beware that if an expected match string is not found or if the device doesn't respond, the
expect method will not return.public java.lang.Integer getDefaultProtocolTimeout()
getDefaultProtocolTimeout in interface HttpProtocolHandlergetDefaultProtocolTimeout in interface ProtocolHandlerpublic void setUsernameUsed(boolean usernameUsed)
setUsernameUsed in interface HttpProtocolHandlerusernameUsed - True if the username was used or false if not.public boolean getUsernameUsed()
getUsernameUsed in interface HttpProtocolHandlerpublic void setPasswordUsed(boolean passwordUsed)
setPasswordUsed in interface HttpProtocolHandlerpasswordUsed - True if the password was used or false if not.public boolean getPasswordUsed()
getPasswordUsed in interface HttpProtocolHandler
public void disconnect()
throws java.io.IOException
disconnect in interface HttpProtocolHandlerjava.io.IOException - If there is an error closing the socket.public boolean getAvailable()
getAvailable in interface ProtocolHandlerpublic java.lang.String toString()
toString in class java.lang.Objectprotected java.lang.String prepareCommandPart(java.lang.String commandPart)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||