org.edg.security.httpclient
Class HTTPJavaClient

java.lang.Object
  |
  +--org.edg.security.httpclient.HTTPJavaClient

public class HTTPJavaClient
extends java.lang.Object

Class implementing a client API to send HTTP requests to a web server. The API library is based on the functionality originally implemented by jwget (the Java port of wget). It can send http(s) GET, POST, HEAD, PUT, DELETE to a destination URL, with a wide range of optional data. It offers SSL and Globus Grid Proxy integration.

Author:
Gian Luca Volpato

Constructor Summary
HTTPJavaClient()
           
 
Method Summary
 GenericResponse connectURL(java.lang.String method, java.lang.String url, java.util.Properties addHeaders, PostBody body, java.util.Properties options)
          Sends a generic HTTP request to the destination file specified by the URL.
 GenericResponse getURL(java.lang.String url, java.util.Properties options)
          Sends GET request to the destination file specified by the URL.
 void init(java.util.Properties initConfig)
          Initializes the security context of the HTTPJavaClient by setting configuration parameters as Log4j configuration file, proxy server, username/password, SSL certificate and key location, grid-proxy file location, authorization role and authorization policy.
 GenericResponse postURL(java.lang.String url, PostBody body, java.util.Properties options)
          Sends POST request, with POST data, to the destination file specified by the URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTTPJavaClient

public HTTPJavaClient()
Method Detail

init

public void init(java.util.Properties initConfig)
Initializes the security context of the HTTPJavaClient by setting configuration parameters as Log4j configuration file, proxy server, username/password, SSL certificate and key location, grid-proxy file location, authorization role and authorization policy.

Parameters:
initConfig - collection of initialization parameters for the security context.

getURL

public GenericResponse getURL(java.lang.String url,
                              java.util.Properties options)
Sends GET request to the destination file specified by the URL. The method can receive additional parameters to be included in the request (timeout, userAgent,keepAlive, cache, saveHeaders).

Parameters:
url - absolute path of the destination file.
options - collection of optional parameters.
Returns:
HTTP response with result code, headers and body.
Throws:
java.lang.RuntimeException - if the destination URL is null.

postURL

public GenericResponse postURL(java.lang.String url,
                               PostBody body,
                               java.util.Properties options)
Sends POST request, with POST data, to the destination file specified by the URL. The method must receive the body data to be included in the request and can also include other optional parameters (timeout, userAgent, keepAlive, cache, saveHeaders).

Parameters:
url - absolute path of the destination file.
body - data to be POSTed.
options - collection of optional parameters.
Returns:
HTTP response with result code, headers and body.
Throws:
java.lang.RuntimeException - if destination URL or body are null.

connectURL

public GenericResponse connectURL(java.lang.String method,
                                  java.lang.String url,
                                  java.util.Properties addHeaders,
                                  PostBody body,
                                  java.util.Properties options)
Sends a generic HTTP request to the destination file specified by the URL. The method can receive and handle a large variety of optional parameters, such as additional request headers and body data.

Parameters:
method - connection method to be used.
url - absolute path of the destination file.
addHeaders - collection of additional headers.
body - data to be saved in the server host (only for POST and PUT operations).
options - collection of optional parameters.
Returns:
HTTP response with result code, headers and body.
Throws:
java.lang.RuntimeException - if connection method or destination URL are null.