com.sun.mail.util
Class SocketFetcher

java.lang.Object
  extended by com.sun.mail.util.SocketFetcher

public class SocketFetcher
extends java.lang.Object

This class is used to get Sockets. Depending on the arguments passed it will either return a plain java.net.Socket or dynamically load the SocketFactory class specified in the classname param and return a socket created by that SocketFactory.


Method Summary
static java.net.Socket getSocket(java.lang.String host, int port, java.util.Properties props, java.lang.String prefix)
           
static java.net.Socket getSocket(java.lang.String host, int port, java.util.Properties props, java.lang.String prefix, boolean useSSL)
          This method returns a Socket.
static java.net.Socket startTLS(java.net.Socket socket)
          Start TLS on an existing socket.
static java.net.Socket startTLS(java.net.Socket socket, java.util.Properties props, java.lang.String prefix)
          Start TLS on an existing socket.
static java.net.Socket startTLS(java.net.Socket socket, java.lang.String host, java.util.Properties props, java.lang.String prefix)
          Start TLS on an existing socket.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSocket

public static java.net.Socket getSocket(java.lang.String host,
                                        int port,
                                        java.util.Properties props,
                                        java.lang.String prefix,
                                        boolean useSSL)
                                 throws java.io.IOException
This method returns a Socket. Properties control the use of socket factories and other socket characteristics. The properties used are:

If we're making an SSL connection, the ssl.socketFactory properties are used first, if set.

If the socketFactory property is set, the value is an instance of a SocketFactory class, not a string. The instance is used directly. If the socketFactory property is not set, the socketFactory.class property is considered. (Note that the SocketFactory property must be set using the put method, not the setProperty method.)

If the socketFactory.class property isn't set, the socket returned is an instance of java.net.Socket connected to the given host and port. If the socketFactory.class property is set, it is expected to contain a fully qualified classname of a javax.net.SocketFactory subclass. In this case, the class is dynamically instantiated and a socket created by that SocketFactory is returned.

If the socketFactory.fallback property is set to false, don't fall back to using regular sockets if the socket factory fails.

The socketFactory.port specifies a port to use when connecting through the socket factory. If unset, the port argument will be used.

If the connectiontimeout property is set, the timeout is passed to the socket connect method.

If the timeout property is set, it is used to set the socket timeout.

If the localaddress property is set, it's used as the local address to bind to. If the localport property is also set, it's used as the local port number to bind to.

Parameters:
host - The host to connect to
port - The port to connect to at the host
props - Properties object containing socket properties
prefix - Property name prefix, e.g., "mail.imap"
useSSL - use the SSL socket factory as the default
Throws:
java.io.IOException

getSocket

public static java.net.Socket getSocket(java.lang.String host,
                                        int port,
                                        java.util.Properties props,
                                        java.lang.String prefix)
                                 throws java.io.IOException
Throws:
java.io.IOException

startTLS

public static java.net.Socket startTLS(java.net.Socket socket)
                                throws java.io.IOException
Start TLS on an existing socket. Supports the "STARTTLS" command in many protocols. This version for compatibility with possible third party code that might've used this API even though it shouldn't.

Throws:
java.io.IOException

startTLS

public static java.net.Socket startTLS(java.net.Socket socket,
                                       java.util.Properties props,
                                       java.lang.String prefix)
                                throws java.io.IOException
Start TLS on an existing socket. Supports the "STARTTLS" command in many protocols. This version for compatibility with possible third party code that might've used this API even though it shouldn't.

Throws:
java.io.IOException

startTLS

public static java.net.Socket startTLS(java.net.Socket socket,
                                       java.lang.String host,
                                       java.util.Properties props,
                                       java.lang.String prefix)
                                throws java.io.IOException
Start TLS on an existing socket. Supports the "STARTTLS" command in many protocols.

Throws:
java.io.IOException