org.ferris.net
Class BasicAuthenticationUrlConnection

java.lang.Object
  extended by org.ferris.net.BasicAuthenticationUrlConnection

public class BasicAuthenticationUrlConnection
extends Object

Opens a URLConnection and uses the given credentials to pass a username and password along for doing HTTP basic authentication.

Author:
Mike Remijan

Constructor Summary
BasicAuthenticationUrlConnection(URL url, String username, String clearTextPassword)
          Establishes a connection which can be read from the InputStream from this object.
 
Method Summary
 void close()
          Sets all properties to null and closes the InputStream
 InputStream getInputStream()
          Get the InputStream from the URLConnection.
 URLConnection getUrlConnection()
          Get the URLConnection object created by this class's constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicAuthenticationUrlConnection

public BasicAuthenticationUrlConnection(URL url,
                                        String username,
                                        String clearTextPassword)
                                 throws IOException
Establishes a connection which can be read from the InputStream from this object. The username and password are Base64 encoded before sending them out so don't worry about a clear text password being sent over the network. Make sure you call close() when you're done.

Parameters:
url - - The URL.
username - - The basic authentication username
clearTextPassword - - The basic authentication clear text password. This (along with the username) will be Base64 encoded before sending it out so don't worry about a clear text password being sent over the network.
Throws:
IOException - Thrown if opening the connection to the URL fails.
Method Detail

getUrlConnection

public URLConnection getUrlConnection()
Get the URLConnection object created by this class's constructor.


getInputStream

public InputStream getInputStream()
Get the InputStream from the URLConnection. Make sure you remember to call close()!!

See Also:
getUrlConnection(), close()

close

public void close()
Sets all properties to null and closes the InputStream



Copyright © Jun 11, 2009-2011 The Ferris Foundation. All Rights Reserved.