net.sourceforge.rssowl.dao
Class ConnectionManager

java.lang.Object
  extended bynet.sourceforge.rssowl.dao.ConnectionManager

public class ConnectionManager
extends Object

The ConnectionManager establishes a connection to the given URL and handles Proxy and Authentification. As result, the InputStream is returned. Since the ConnectionManager will be instantiated out of parallel running Threads, it is important to check if the current executing Thread was not yet stopped.

Version:
1.1.3
Author:
Benjamin Pasero

Field Summary
private  org.apache.commons.httpclient.HttpClient client
           
(package private)  String domain
           
(package private)  org.apache.commons.httpclient.methods.GetMethod getMethod
           
private  InputStream inputStream
           
(package private)  String password
           
private  boolean showLoginDialogIfRequired
           
(package private)  String url
           
(package private)  String userAgent
           
(package private)  String username
           
 
Constructor Summary
ConnectionManager(String url)
          Instantiate a new ConnectionManager to establish a connection to the given URL
 
Method Summary
private  void authenticate()
          The connection requires authentification.
 void closeConnection()
          Closes the connection
 void connect()
          Connect to the given URL and handle Proxy and Authentification if required
 void connect(boolean useProxy)
          Connect to the given URL and handle Proxy and Authentification if required
 InputStream getInputStream()
          Get the resulting InputStream
 String getStatusLine()
          Get the statusline that the server has sent as a response to the connection
private  void initConnection()
          Initialize the connection with creating a HttpClient object and a GET method object with the given URL
static void initSSLProtocol()
          This will allow to use any SSL certificate without validation.
private  void openConnection()
          Open the connection and retrieve the InputStream from the Server.
private  void pipeConnection()
          Try to pipe the resulting InputStream into a GZipInputStream
private  boolean proceed()
          Checks wether the current running Thread was not yet stopped.
private  void setHeaders()
          Set default headers to the connection
 void setShowLoginDialogIfRequired(boolean showLoginDialogIfRequired)
          Set wether to show the LoginDialog in case authentification is required
 void setUserAgent(String userAgent)
          Set the user agent to use in the response header
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

client

private org.apache.commons.httpclient.HttpClient client

inputStream

private InputStream inputStream

showLoginDialogIfRequired

private boolean showLoginDialogIfRequired

domain

String domain

getMethod

org.apache.commons.httpclient.methods.GetMethod getMethod

password

String password

url

String url

userAgent

String userAgent

username

String username
Constructor Detail

ConnectionManager

public ConnectionManager(String url)
Instantiate a new ConnectionManager to establish a connection to the given URL

Parameters:
url - The URL to connect to
Method Detail

initSSLProtocol

public static void initSSLProtocol()
This will allow to use any SSL certificate without validation. Allows to use the HTTPS protocol with the HttpClient.


closeConnection

public void closeConnection()
Closes the connection


connect

public void connect()
             throws org.apache.commons.httpclient.HttpException,
                    IOException
Connect to the given URL and handle Proxy and Authentification if required

Throws:
IOException - In case an error occurs
org.apache.commons.httpclient.HttpException - In case an error occurs

connect

public void connect(boolean useProxy)
             throws org.apache.commons.httpclient.HttpException,
                    IOException
Connect to the given URL and handle Proxy and Authentification if required

Parameters:
useProxy - Force usage of Proxy
Throws:
IOException - In case an error occurs
org.apache.commons.httpclient.HttpException - In case an error occurs

getInputStream

public InputStream getInputStream()
Get the resulting InputStream

Returns:
InputStream The resulting InputStream from the connection

getStatusLine

public String getStatusLine()
Get the statusline that the server has sent as a response to the connection

Returns:
String The responded statusline to the connect

setShowLoginDialogIfRequired

public void setShowLoginDialogIfRequired(boolean showLoginDialogIfRequired)
Set wether to show the LoginDialog in case authentification is required

Parameters:
showLoginDialogIfRequired - If TRUE, show the LoginDialog if required

setUserAgent

public void setUserAgent(String userAgent)
Set the user agent to use in the response header

Parameters:
userAgent - The user agent to use

authenticate

private void authenticate()
                   throws org.apache.commons.httpclient.URIException
The connection requires authentification. Open the LoginDialog in case username and password are not stored in the CryptoManager. Use the credentials to authenticate to the Server. Supported authentification methods are Base, Digest and NTLM

Throws:
org.apache.commons.httpclient.URIException - In case the provided URL was not correct

initConnection

private void initConnection()
                     throws IOException
Initialize the connection with creating a HttpClient object and a GET method object with the given URL

Throws:
IOException - In case of an error while creating the GET-Method.

openConnection

private void openConnection()
                     throws org.apache.commons.httpclient.HttpException,
                            IOException
Open the connection and retrieve the InputStream from the Server.

Throws:
IOException - If an error occurs
org.apache.commons.httpclient.HttpException - If an error occurs

pipeConnection

private void pipeConnection()
                     throws IOException
Try to pipe the resulting InputStream into a GZipInputStream

Throws:
IOException - If an error occurs

proceed

private boolean proceed()
Checks wether the current running Thread was not yet stopped.

Returns:
boolean TRUE in case the execution may proceed

setHeaders

private void setHeaders()
Set default headers to the connection



RSSOwl - RSS / RDF / Atom Newsreader

SourceForge.net Logo