classpath-inetlib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Classpath-inetlib] IMAPConnection(SocketFactory, String host, int port,


From: Daniel Harvey
Subject: [Classpath-inetlib] IMAPConnection(SocketFactory, String host, int port, ..)
Date: Sun, 18 Jul 2004 13:29:11 -0700

To allow the user to switch between IMAP/443 and
SSL-IMAP/993, I've added this constructor to gnu.inet.imap.IMAPConnection.

Note this is a different protocol than starttls().

I'd prefer if the recently added starttls code were changed to
take a SocketFactory instead of a TrustManager, to eliminate the
requirement of needing to find the TrustManager class at compile
time.

In my case, the sockets returned by the SocketFactory use my
custom TrustManager.  Thanks.


/**
   * Creates a new connection.
   * @param factory SocketFactory
   * @param host the name of the host to connect to
   * @param port the port to connect to
   */
  public IMAPConnection (SocketFactory factory, String host, int port,
                         int connectionTimeout, int timeout, boolean debug)
    throws UnknownHostException, IOException
    {
      this.debug = debug;
      // TODO connectionTimeout
      
      if (port < 0)
        {
          port = DEFAULT_PORT;
        }
      
      socket = factory.createSocket(host, port);
      if (timeout > 0)
        {
          socket.setSoTimeout (timeout);
        }
      
      InputStream in = socket.getInputStream ();
      in = new BufferedInputStream (in);
      this.in = new IMAPResponseTokenizer (in);
      OutputStream out = socket.getOutputStream ();
      out = new BufferedOutputStream (out);
      this.out = new CRLFOutputStream (out);
      
      asyncResponses = new ArrayList ();
      alerts = new ArrayList ();
    }
  
  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]