geronimo-mail_2.1/geronimo-mail_2.1_provider/src/main/java/org/apache/geronimo/mail/util/MailConnection.java [575:626]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    protected void getConnectedTLSSocket() throws MessagingException {
     	// it worked, now switch the socket into TLS mode
     	try {

            // we use the same target and port as the current connection.
            serverHost = socket.getInetAddress().getHostName();
            serverPort = socket.getPort();

            // the socket factory can be specified via a session property.  By default, we use
            // the native SSL factory.
            if(createSocketFromConfiguredFactoryInstance(true, true)) {
                debugOut("TLS socket factory configured as instance"); 
            } else if(createSocketFromFactory(true, true)) {
                debugOut("TLS socket factory configured as class"); 
            } else {
                debugOut("TLS socket factory from SSLContext"); 
                createSSLSocketFromSSLContext(true);
            }

            // If this is an instance of SSLSocket (very common), try setting the protocol.
            // If this is some other class because of a factory override, we'll just have to
            // accept that things will work.
            if (socket instanceof SSLSocket) {
                String[] suites = getFromWhitespaceSeparatedProperty(MAIL_SSL_CIPHERSUITES);
                if (suites == null) {
                    // use all supported ciphers as no custom ciphers were specified
                    suites = ((SSLSocket)socket).getSupportedCipherSuites();
                    debugOut("No custom ciphers are specified, using all supported ciphers of the given SSLSocket: " + Arrays.toString(suites));
                }
                ((SSLSocket)socket).setEnabledCipherSuites(suites);
                String[] protocols = getFromWhitespaceSeparatedProperty(MAIL_SSL_PROTOCOLS);
                if(protocols != null) {
                    ((SSLSocket)socket).setEnabledProtocols(protocols);
                } else {
                    // no custom protocols were specified; use it as is.
                    debugOut("No custom protocols specified, using the enabled protocols of the given SSLSocket: " + Arrays.toString(((SSLSocket) socket).getEnabledProtocols()));
                }
                ((SSLSocket)socket).setUseClientMode(true);
                debugOut("Initiating STARTTLS handshake");
                ((SSLSocket)socket).startHandshake();
            } else {
                throw new IOException("Socket is not an instance of SSLSocket, maybe wrong configured ssl factory?");
            }

            getConnectionStreams();
            debugOut("TLS connection established"); 
     	}
        catch (Exception e) {
            debugOut("Failure attempting to convert connection to TLS", e);
     	    throw new MessagingException("Unable to convert connection to TLS", e);
     	}
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



geronimo-javamail_1.6/geronimo-javamail_1.6_provider/src/main/java/org/apache/geronimo/javamail/util/MailConnection.java [575:626]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    protected void getConnectedTLSSocket() throws MessagingException {
     	// it worked, now switch the socket into TLS mode
     	try {

            // we use the same target and port as the current connection.
            serverHost = socket.getInetAddress().getHostName();
            serverPort = socket.getPort();

            // the socket factory can be specified via a session property.  By default, we use
            // the native SSL factory.
            if(createSocketFromConfiguredFactoryInstance(true, true)) {
                debugOut("TLS socket factory configured as instance"); 
            } else if(createSocketFromFactory(true, true)) {
                debugOut("TLS socket factory configured as class"); 
            } else {
                debugOut("TLS socket factory from SSLContext"); 
                createSSLSocketFromSSLContext(true);
            }

            // If this is an instance of SSLSocket (very common), try setting the protocol.
            // If this is some other class because of a factory override, we'll just have to
            // accept that things will work.
            if (socket instanceof SSLSocket) {
                String[] suites = getFromWhitespaceSeparatedProperty(MAIL_SSL_CIPHERSUITES);
                if (suites == null) {
                    // use all supported ciphers as no custom ciphers were specified
                    suites = ((SSLSocket)socket).getSupportedCipherSuites();
                    debugOut("No custom ciphers are specified, using all supported ciphers of the given SSLSocket: " + Arrays.toString(suites));
                }
                ((SSLSocket)socket).setEnabledCipherSuites(suites);
                String[] protocols = getFromWhitespaceSeparatedProperty(MAIL_SSL_PROTOCOLS);
                if(protocols != null) {
                    ((SSLSocket)socket).setEnabledProtocols(protocols);
                } else {
                    // no custom protocols were specified; use it as is.
                    debugOut("No custom protocols specified, using the enabled protocols of the given SSLSocket: " + Arrays.toString(((SSLSocket) socket).getEnabledProtocols()));
                }
                ((SSLSocket)socket).setUseClientMode(true);
                debugOut("Initiating STARTTLS handshake");
                ((SSLSocket)socket).startHandshake();
            } else {
                throw new IOException("Socket is not an instance of SSLSocket, maybe wrong configured ssl factory?");
            }

            getConnectionStreams();
            debugOut("TLS connection established"); 
     	}
        catch (Exception e) {
            debugOut("Failure attempting to convert connection to TLS", e);
     	    throw new MessagingException("Unable to convert connection to TLS", e);
     	}
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



