code: protected void prepareConnection(HttpURLConnection con, int contentLength)
  			throws IOException {
  
  		super.prepareConnection(con, contentLength);
  
  		Authentication auth = getAuthenticationToken();
  
  		if ((auth != null) && (auth.getName() != null)
  				&& (auth.getCredentials() != null)) {
  			String base64 = auth.getName() + ":"
  					+ auth.getCredentials().toString();
  			con.setRequestProperty("Authorization", "Basic "
  					+ new String(Base64.encodeBase64(base64.getBytes())));
  
  			if (logger.isDebugEnabled()) {
  				logger.debug("HttpInvocation now presenting via BASIC authentication with token:: "
  						+ auth);
  			}
  		} else {
  			if (logger.isDebugEnabled()) {
  				logger.debug("Unable to set BASIC authentication header as Authentication token is invalid: "
  						+ auth);
  			}
  		}
  
  		doPrepareConnection(con, contentLength);
  	}
docs: Called every time a HTTP invocation is made.
  <p>
  Simply allows the parent to setup the connection, and then adds an
  <code>Authorization</code> HTTP header property that will be used for
  BASIC authentication. Following that a call to
  {@link #doPrepareConnection} is made to allow subclasses to apply any
  additional configuration desired to the connection prior to invoking the
  request.
  <p>
  The previously saved authentication token is used to obtain the principal
  and credentials. If the saved token is null, then the "Authorization"
  header will not be added to the request.
  
  @param con
  the HTTP connection to prepare
  @param contentLength
  the length of the content to send
  
  @throws IOException
  if thrown by HttpURLConnection methods