org.opennms.netmgt.capsd.plugins
Class HttpPlugin

java.lang.Object
  extended by org.opennms.netmgt.capsd.AbstractPlugin
      extended by org.opennms.netmgt.capsd.AbstractTcpPlugin
          extended by org.opennms.netmgt.capsd.plugins.HttpPlugin
All Implemented Interfaces:
Plugin
Direct Known Subclasses:
HttpsPlugin, NotesHttpPlugin

public class HttpPlugin
extends AbstractTcpPlugin

This class is designed to be used by the capabilities daemon to test for the existance of an HTTP server on remote interfaces. The class implements the Plugin interface that allows it to be used along with other plugins by the daemon. This plugin generates a HTTP GET request and checks the return code returned by the remote host to determine if it supports the protocol. The remote host's response will be deemed valid if the return code falls in the 100 to 599 range (inclusive). This is based on the following information from RFC 1945 (HTTP 1.0) HTTP 1.0 GET return codes: 1xx: Informational - Not used, future use 2xx: Success 3xx: Redirection 4xx: Client error 5xx: Server error

This plugin generates a HTTP GET request and checks the return code returned by the remote host to determine if it supports the protocol. The remote host's response will be deemed valid if the return code falls in the 100 to 599 range (inclusive). This is based on the following information from RFC 1945 (HTTP 1.0) HTTP 1.0 GET return codes: 1xx: Informational - Not used, future use 2xx: Success 3xx: Redirection 4xx: Client error 5xx: Server error

This plugin generates a HTTP GET request and checks the return code returned by the remote host to determine if it supports the protocol. The remote host's response will be deemed valid if the return code falls in the 100 to 599 range (inclusive). This is based on the following information from RFC 1945 (HTTP 1.0) HTTP 1.0 GET return codes: 1xx: Informational - Not used, future use 2xx: Success 3xx: Redirection 4xx: Client error 5xx: Server error

Version:
1.1.1.1
Author:
Mathew Brozowski, Sowmya , Weaver , OpenNMS

Field Summary
static boolean CHECK_RETURN_CODE
          Boolean indicating whether to check for a return code
static String DEFAULT_URL
          The query to send to the HTTP server
protected static String PROPERTY_NAME_MAX_RET_CODE
           
protected static String PROPERTY_NAME_PORT
           
protected static String PROPERTY_NAME_RESPONSE_TEXT
           
protected static String PROPERTY_NAME_RETURN_CODE
           
protected static String PROPERTY_NAME_URL
           
static String PROTOCOL_NAME
           
static String QUERY_STRING
          The query to send to the HTTP server
static String RESPONSE_STRING
          A string to look for in the response from the server
 
Constructor Summary
  HttpPlugin()
           
protected HttpPlugin(String protocolName, boolean checkReturnCode, String queryString, String responseString)
           
protected HttpPlugin(String protocolName, boolean checkReturnCode, String queryString, String responseString, int[] defaultPorts)
           
 
Method Summary
protected  boolean checkProtocol(Socket socket, ConnectionConfig config)
           
protected  boolean checkResponseBody(ConnectionConfig config, String response)
          Checks the response body as a substring or regular expression match according to the leading-tilde convention
protected  List<ConnectionConfig> getConnectionConfigList(Map<String,Object> qualifiers, InetAddress address)
           
 
Methods inherited from class org.opennms.netmgt.capsd.AbstractTcpPlugin
checkConnection, closeSocket, createConnectionConfig, getKeyedInteger, getKeyedIntegerArray, getPluginName, getProtocolName, isProtocolSupported, isProtocolSupported, populateConnectionConfig, preconnectCheck, saveConfig, saveKeyedInteger, setPluginName, wrapSocket
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_NAME_PORT

protected static final String PROPERTY_NAME_PORT
See Also:
Constant Field Values

PROPERTY_NAME_MAX_RET_CODE

protected static final String PROPERTY_NAME_MAX_RET_CODE
See Also:
Constant Field Values

PROPERTY_NAME_RETURN_CODE

protected static final String PROPERTY_NAME_RETURN_CODE
See Also:
Constant Field Values

PROPERTY_NAME_URL

protected static final String PROPERTY_NAME_URL
See Also:
Constant Field Values

PROPERTY_NAME_RESPONSE_TEXT

protected static final String PROPERTY_NAME_RESPONSE_TEXT
See Also:
Constant Field Values

CHECK_RETURN_CODE

public static final boolean CHECK_RETURN_CODE
Boolean indicating whether to check for a return code

See Also:
Constant Field Values

PROTOCOL_NAME

public static final String PROTOCOL_NAME
See Also:
Constant Field Values

QUERY_STRING

public static final String QUERY_STRING
The query to send to the HTTP server

See Also:
Constant Field Values

DEFAULT_URL

public static final String DEFAULT_URL
The query to send to the HTTP server

See Also:
Constant Field Values

RESPONSE_STRING

public static final String RESPONSE_STRING
A string to look for in the response from the server

See Also:
Constant Field Values
Constructor Detail

HttpPlugin

public HttpPlugin()
Parameters:
protocol -
defaultPort -
defaultTimeout -
defaultRetries -

HttpPlugin

protected HttpPlugin(String protocolName,
                     boolean checkReturnCode,
                     String queryString,
                     String responseString)

HttpPlugin

protected HttpPlugin(String protocolName,
                     boolean checkReturnCode,
                     String queryString,
                     String responseString,
                     int[] defaultPorts)
Method Detail

checkProtocol

protected boolean checkProtocol(Socket socket,
                                ConnectionConfig config)
                         throws IOException
Specified by:
checkProtocol in class AbstractTcpPlugin
Parameters:
sChannel -
isAServer -
Returns:
Throws:
IOException

getConnectionConfigList

protected List<ConnectionConfig> getConnectionConfigList(Map<String,Object> qualifiers,
                                                         InetAddress address)
Overrides:
getConnectionConfigList in class AbstractTcpPlugin

checkResponseBody

protected boolean checkResponseBody(ConnectionConfig config,
                                    String response)
Checks the response body as a substring or regular expression match according to the leading-tilde convention

Parameters:
config - ConnectionConfig object from which response-text property is extracted
response - Body of HTTP response to check
Returns:
Whether the response matches the response-text property


Copyright © 2009. All Rights Reserved.