| Modifier and Type | Field and Description |
|---|---|
| private static MailLogger |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private static void | checkServerIdentity(String
name of the server expected server, SSLSocket SSLSocket connected to the server sslSocket)Check the server from the Socket connection against the server name(s) as expressed in the server certificate (RFC 2595 check). |
| private static IOException | |
| private static void | configureSSLSocket(Socket socket, String host, Properties props, String prefix, SocketFactory sf)
Configure the SSL options for the socket (if it's an SSL socket), based on the mail. |
| private static Socket | createSocket(InetAddress localaddr, int localport, String host, int port, int cto, int to, Properties props, String prefix, SocketFactory sf, boolean useSSL)
Create a socket with the given local address and connected to the given host and port. |
| private static ClassLoader | |
| public static Socket | Returns: the SocketThe host to connect to host, int The port to connect to at the host port, Properties Properties object containing socket properties props, String Property name prefix, e.g., "mail.imap" prefix, boolean use the SSL socket factory as the default useSSL)This method returns a Socket. |
| public static Socket | |
| private static SocketFactory | |
| private static boolean | |
| private static boolean | Returns: true if it matchesname of the server expected server, X509Certificate X509Certificate to get the subject's name from cert)Do any of the names in the cert match the server name? |
| private static boolean | matchServer(String
name of the server expected server, String name from the server's certificate name)Does the server we're expecting to connect to match the given name from the server's certificate? |
| private static void | |
| public static Socket | |
| public static Socket | Returns: the wrapped Socketthe existing socket socket, Properties the properties props, String the property prefix prefix)
Deprecated
Start TLS on an existing socket.
|
| public static Socket | Returns: the wrapped Socketthe existing socket socket, String the host the socket is connected to host, Properties the properties props, String the property prefix prefix)Start TLS on an existing socket. |
| private static String[] | stringArray(String s)
Parse a string into whitespace separated tokens and return the tokens in an array. |
| logger | back to summary |
|---|---|
| private static MailLogger logger | |
| SocketFetcher | back to summary |
|---|---|
| private SocketFetcher() | |
| checkServerIdentity | back to summary |
|---|---|
| private static void checkServerIdentity(String server, SSLSocket sslSocket) throws IOException Check the server from the Socket connection against the server name(s) as expressed in the server certificate (RFC 2595 check).
| |
| cleanupAndThrow | back to summary |
|---|---|
| private static IOException cleanupAndThrow(Socket socket, IOException ife) | |
| configureSSLSocket | back to summary |
|---|---|
| private static void configureSSLSocket(Socket socket, String host, Properties props, String prefix, SocketFactory sf) throws IOException Configure the SSL options for the socket (if it's an SSL socket),
based on the mail. | |
| createSocket | back to summary |
|---|---|
| private static Socket createSocket(InetAddress localaddr, int localport, String host, int port, int cto, int to, Properties props, String prefix, SocketFactory sf, boolean useSSL) throws IOException Create a socket with the given local address and connected to the given host and port. Use the specified connection timeout and read timeout. If a socket factory is specified, use it. Otherwise, use the SSLSocketFactory if useSSL is true. | |
| getContextClassLoader | back to summary |
|---|---|
| private static ClassLoader getContextClassLoader() Convenience method to get our context class loader. Assert any privileges we might have and then call the Thread.getContextClassLoader method. | |
| getSocket | back to summary |
|---|---|
| public static Socket getSocket(String host, int port, Properties props, String prefix, boolean useSSL) throws 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
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. If the usesocketchannels property is set, and we create the Socket ourself, and the selection of other properties allows, create a SocketChannel and get the Socket from it. This allows us to later retrieve the SocketChannel from the Socket and use it with Select.
| |
| getSocket | back to summary |
|---|---|
| public static Socket getSocket(String host, int port, Properties props, String prefix) throws IOException | |
| getSocketFactory | back to summary |
|---|---|
| private static SocketFactory getSocketFactory(String sfClass) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException Return a socket factory of the specified class. | |
| isRecoverable | back to summary |
|---|---|
| private static boolean isRecoverable(Throwable t) | |
| matchCert | back to summary |
|---|---|
| private static boolean matchCert(String server, X509Certificate cert) Do any of the names in the cert match the server name?
| |
| matchServer | back to summary |
|---|---|
| private static boolean matchServer(String server, String name) Does the server we're expecting to connect to match the given name from the server's certificate? | |
| proxyConnect | back to summary |
|---|---|
| private static void proxyConnect(Socket socket, String proxyHost, int proxyPort, String proxyUser, String proxyPassword, String host, int port, int cto) throws IOException Use the HTTP CONNECT protocol to connect to a site through an HTTP proxy server. Protocol is roughly: CONNECT | |
| startTLS | back to summary |
|---|---|
| public static Socket startTLS(Socket socket) throws IOException
Deprecated
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.
| |
| startTLS | back to summary |
|---|---|
| public static Socket startTLS(Socket socket, Properties props, String prefix) throws IOException
Deprecated
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.
| |
| startTLS | back to summary |
|---|---|
| public static Socket startTLS(Socket socket, String host, Properties props, String prefix) throws IOException Start TLS on an existing socket. Supports the "STARTTLS" command in many protocols.
| |
| stringArray | back to summary |
|---|---|
| private static String[] stringArray(String s) Parse a string into whitespace separated tokens and return the tokens in an array. | |