// Path: src/main/java/org/kopi/ebics/interfaces/ContentFactory.java
// public interface ContentFactory extends Serializable {
// 
//   /**
//    * Returns a new data source of the data to be sent.
//    * The instance must ensure that the returned stream will
//    * deliver the identical data during the lifetime of this instance.
//    * Nevertheless how often the method will be called.
//    * @return a new data source of the data to be sent.
//    * @throws IOException
//    */
//   public InputStream getContent() throws IOException;
// }
// 
// Path: src/main/java/org/kopi/ebics/session/EbicsSession.java
// public class EbicsSession {
// 
//   /**
//    * Constructs a new ebics session
//    * @param user the ebics user
//    * @param the ebics client configuration
//    */
//   public EbicsSession(EbicsUser user, Configuration configuration) {
//     this.user = user;
//     this.configuration = configuration;
//     parameters = new HashMap<String, String>();
//   }
// 
//   /**
//    * Returns the banks encryption key.
//    * The key will be fetched automatically form the bank if needed.
//    * @return the banks encryption key.
//    * @throws IOException Communication error during key retrieval.
//    * @throws EbicsException Server error message generated during key retrieval.
//    */
//   public RSAPublicKey getBankE002Key() throws IOException, EbicsException {
//     return user.getPartner().getBank().getE002Key();
//   }
// 
//   /**
//    * Returns the banks authentication key.
//    * The key will be fetched automatically form the bank if needed.
//    * @return the banks authentication key.
//    * @throws IOException Communication error during key retrieval.
//    * @throws EbicsException Server error message generated during key retrieval.
//    */
//   public RSAPublicKey getBankX002Key() throws IOException, EbicsException {
//     return user.getPartner().getBank().getX002Key();
//   }
// 
//   /**
//    * Returns the bank id.
//    * @return the bank id.
//    * @throws EbicsException
//    */
//   public String getBankID() throws EbicsException {
//     return user.getPartner().getBank().getHostId();
//   }
// 
//   /**
//    * Return the session user.
//    * @return the session user.
//    */
//   public EbicsUser getUser() {
//     return user;
//   }
// 
//   /**
//    * Returns the client application configuration.
//    * @return the client application configuration.
//    */
//   public Configuration getConfiguration() {
//     return configuration;
//   }
// 
//   /**
//    * Sets the optional product identification that will be sent to the bank during each request.
//    * @param product Product description
//    */
//   public void setProduct(Product product) {
//     this.product = product;
//   }
// 
//   /**
//    * @return the product
//    */
//   public Product getProduct() {
//     return product;
//   }
// 
//   /**
//    * Adds a session parameter to use it in the transfer process.
//    * @param key the parameter key
//    * @param value the parameter value
//    */
//   public void addSessionParam(String key, String value) {
//     parameters.put(key, value);
//   }
// 
//   /**
//    * Retrieves a session parameter using its key.
//    * @param key the parameter key
//    * @return the session parameter
//    */
//   public String getSessionParam(String key) {
//     if (key == null) {
//       return null;
//     }
// 
//     return parameters.get(key);
//   }
// 
//   // --------------------------------------------------------------------
//   // DATA MEMBERS
//   // --------------------------------------------------------------------
// 
//   private EbicsUser				user;
//   private Configuration 			configuration;
//   private Product				product;
//   private Map<String, String>			parameters;
// }


import org.kopi.ebics.io.InputStreamContentFactory;
import org.kopi.ebics.session.EbicsSession;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.kopi.ebics.interfaces.ContentFactory;
	authscope = new AuthScope(proxyHost, proxyPort);
	httpClient.getState().setProxyCredentials(authscope, credentials);
      }
    }

    input = request.getContent();
    method = new PostMethod(session.getUser().getPartner().getBank().getURL().toString());
    method.getParams().setSoTimeout(30000);
    requestEntity = new InputStreamRequestEntity(input);
    method.setRequestEntity(requestEntity);
    method.setRequestHeader("Content-type", "text/xml; charset=ISO-8859-1");
    retCode = -1;
    retCode = httpClient.executeMethod(method);
    response = new InputStreamContentFactory(method.getResponseBodyAsStream());

    return retCode;
  }

  /**
   * Returns the content factory of the response body
   * @return the content factory of the response.
   */
  public ContentFactory getResponseBody() {
    return response;
  }

  //////////////////////////////////////////////////////////////////
  // DATA MEMBERS
  //////////////////////////////////////////////////////////////////

// Path: src/main/java/org/kopi/ebics/interfaces/ContentFactory.java
// public interface ContentFactory extends Serializable {
// 
//   /**
//    * Returns a new data source of the data to be sent.
//    * The instance must ensure that the returned stream will
//    * deliver the identical data during the lifetime of this instance.
//    * Nevertheless how often the method will be called.
//    * @return a new data source of the data to be sent.
//    * @throws IOException
//    */
//   public InputStream getContent() throws IOException;
// }
// 
// Path: src/main/java/org/kopi/ebics/session/EbicsSession.java
// public class EbicsSession {
// 
//   /**
//    * Constructs a new ebics session
//    * @param user the ebics user
//    * @param the ebics client configuration
//    */
//   public EbicsSession(EbicsUser user, Configuration configuration) {
//     this.user = user;
//     this.configuration = configuration;
//     parameters = new HashMap<String, String>();
//   }
// 
//   /**
//    * Returns the banks encryption key.
//    * The key will be fetched automatically form the bank if needed.
//    * @return the banks encryption key.
//    * @throws IOException Communication error during key retrieval.
//    * @throws EbicsException Server error message generated during key retrieval.
//    */
//   public RSAPublicKey getBankE002Key() throws IOException, EbicsException {
//     return user.getPartner().getBank().getE002Key();
//   }
// 
//   /**
//    * Returns the banks authentication key.
//    * The key will be fetched automatically form the bank if needed.
//    * @return the banks authentication key.
//    * @throws IOException Communication error during key retrieval.
//    * @throws EbicsException Server error message generated during key retrieval.
//    */
//   public RSAPublicKey getBankX002Key() throws IOException, EbicsException {
//     return user.getPartner().getBank().getX002Key();
//   }
// 
//   /**
//    * Returns the bank id.
//    * @return the bank id.
//    * @throws EbicsException
//    */
//   public String getBankID() throws EbicsException {
//     return user.getPartner().getBank().getHostId();
//   }
// 
//   /**
//    * Return the session user.
//    * @return the session user.
//    */
//   public EbicsUser getUser() {
//     return user;
//   }
// 
//   /**
//    * Returns the client application configuration.
//    * @return the client application configuration.
//    */
//   public Configuration getConfiguration() {
//     return configuration;
//   }
// 
//   /**
//    * Sets the optional product identification that will be sent to the bank during each request.
//    * @param product Product description
//    */
//   public void setProduct(Product product) {
//     this.product = product;
//   }
// 
//   /**
//    * @return the product
//    */
//   public Product getProduct() {
//     return product;
//   }
// 
//   /**
//    * Adds a session parameter to use it in the transfer process.
//    * @param key the parameter key
//    * @param value the parameter value
//    */
//   public void addSessionParam(String key, String value) {
//     parameters.put(key, value);
//   }
// 
//   /**
//    * Retrieves a session parameter using its key.
//    * @param key the parameter key
//    * @return the session parameter
//    */
//   public String getSessionParam(String key) {
//     if (key == null) {
//       return null;
//     }
// 
//     return parameters.get(key);
//   }
// 
//   // --------------------------------------------------------------------
//   // DATA MEMBERS
//   // --------------------------------------------------------------------
// 
//   private EbicsUser				user;
//   private Configuration 			configuration;
//   private Product				product;
//   private Map<String, String>			parameters;
// }


// Path: src/main/java/org/kopi/ebics/client/HttpRequestSender.java
import org.kopi.ebics.io.InputStreamContentFactory;
import org.kopi.ebics.session.EbicsSession;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.kopi.ebics.interfaces.ContentFactory;

	authscope = new AuthScope(proxyHost, proxyPort);
	httpClient.getState().setProxyCredentials(authscope, credentials);
      }
    }

    input = request.getContent();
    method = new PostMethod(session.getUser().getPartner().getBank().getURL().toString());
    method.getParams().setSoTimeout(30000);
    requestEntity = new InputStreamRequestEntity(input);
    method.setRequestEntity(requestEntity);
    method.setRequestHeader("Content-type", "text/xml; charset=ISO-8859-1");
    retCode = -1;
    retCode = httpClient.executeMethod(method);
    response = new InputStreamContentFactory(method.getResponseBodyAsStream());

    return retCode;
  }

  /**
   * Returns the content factory of the response body
   * @return the content factory of the response.
   */
  public ContentFactory getResponseBody() {
    return response;
  }

  //////////////////////////////////////////////////////////////////
  // DATA MEMBERS
  //////////////////////////////////////////////////////////////////

  private EbicsSession				session;