net.sourceforge.rssowl.dao
Class ConnectionManager

java.lang.Object
  extended by net.sourceforge.rssowl.dao.ConnectionManager

public class ConnectionManager
extends java.lang.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.2.4
Author:
Benjamin Pasero

Field Summary
private  HttpClient client
           
(package private)  java.lang.String domain
           
(package private)  GetMethod getMethod
           
private static int HTTP_AUTH_REQUIRED
          Http Error Code: Authentication Required
private static int HTTP_ERRORS
          Begin of all Http Error Codes
private  java.io.InputStream inputStream
           
(package private)  java.lang.String password
           
private  boolean showLoginDialogIfRequired
           
(package private)  java.lang.String url
           
(package private)  java.lang.String userAgent
           
(package private)  java.lang.String username
           
 
Constructor Summary
ConnectionManager(java.lang.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
 java.io.InputStream getInputStream()
          Get the resulting InputStream
 java.lang.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(java.lang.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

HTTP_AUTH_REQUIRED

private static final int HTTP_AUTH_REQUIRED
Http Error Code: Authentication Required

See Also:
Constant Field Values

HTTP_ERRORS

private static final int HTTP_ERRORS
Begin of all Http Error Codes

See Also:
Constant Field Values

client

private HttpClient client

inputStream

private java.io.InputStream inputStream

showLoginDialogIfRequired

private boolean showLoginDialogIfRequired

domain

java.lang.String domain

getMethod

GetMethod getMethod

password

java.lang.String password

url

java.lang.String url

userAgent

java.lang.String userAgent

username

java.lang.String username
Constructor Detail

ConnectionManager

public ConnectionManager(java.lang.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 HttpException,
                    java.io.IOException
Connect to the given URL and handle Proxy and Authentification if required

Throws:
java.io.IOException - In case an error occurs
HttpException - In case an error occurs

connect

public void connect(boolean useProxy)
             throws HttpException,
                    java.io.IOException
Connect to the given URL and handle Proxy and Authentification if required

Parameters:
useProxy - Force usage of Proxy
Throws:
java.io.IOException - In case an error occurs
HttpException - In case an error occurs

getInputStream

public java.io.InputStream getInputStream()
Get the resulting InputStream

Returns:
InputStream The resulting InputStream from the connection

getStatusLine

public java.lang.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(java.lang.String userAgent)
Set the user agent to use in the response header

Parameters:
userAgent - The user agent to use

authenticate

private void authenticate()
                   throws 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:
URIException - In case the provided URL was not correct

initConnection

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

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

openConnection

private void openConnection()
                     throws HttpException,
                            java.io.IOException
Open the connection and retrieve the InputStream from the Server.

Throws:
java.io.IOException - If an error occurs
HttpException - If an error occurs

pipeConnection

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

Throws:
java.io.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