|  |  |  | @ -6,6 +6,7 @@ | 
			
		
	
		
			
				
					|  |  |  |  |  */ | 
			
		
	
		
			
				
					|  |  |  |  | package net.java.sip.communicator.impl.protocol.jabber; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | import java.io.*; | 
			
		
	
		
			
				
					|  |  |  |  | import java.math.*; | 
			
		
	
		
			
				
					|  |  |  |  | import java.net.*; | 
			
		
	
		
			
				
					|  |  |  |  | import java.security.*; | 
			
		
	
	
		
			
				
					|  |  |  | @ -42,6 +43,7 @@ | 
			
		
	
		
			
				
					|  |  |  |  | import org.jivesoftware.smack.packet.*; | 
			
		
	
		
			
				
					|  |  |  |  | import org.jivesoftware.smack.provider.*; | 
			
		
	
		
			
				
					|  |  |  |  | import org.jivesoftware.smack.util.StringUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import org.jivesoftware.smack.util.TLSUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import org.jivesoftware.smackx.*; | 
			
		
	
		
			
				
					|  |  |  |  | import org.jivesoftware.smackx.packet.*; | 
			
		
	
		
			
				
					|  |  |  |  | import org.osgi.framework.*; | 
			
		
	
	
		
			
				
					|  |  |  | @ -1165,6 +1167,8 @@ private ConnectState connectAndLogin( | 
			
		
	
		
			
				
					|  |  |  |  |             tlsRequired ? ConnectionConfiguration.SecurityMode.required : | 
			
		
	
		
			
				
					|  |  |  |  |                 ConnectionConfiguration.SecurityMode.enabled); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         TLSUtils.setTLSOnly(confConn); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         if(connection != null) | 
			
		
	
		
			
				
					|  |  |  |  |         { | 
			
		
	
		
			
				
					|  |  |  |  |             logger.error("Connection is not null and isConnected:" | 
			
		
	
	
		
			
				
					|  |  |  | @ -1211,7 +1215,7 @@ private ConnectState connectAndLogin( | 
			
		
	
		
			
				
					|  |  |  |  |                     logger.debug(buff.toString()); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 connection.setCustomSslContext(sslContext); | 
			
		
	
		
			
				
					|  |  |  |  |                 confConn.setCustomSSLContext(sslContext); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             else if (tlsRequired) | 
			
		
	
		
			
				
					|  |  |  |  |                 throw new XMPPException( | 
			
		
	
	
		
			
				
					|  |  |  | @ -3016,4 +3020,87 @@ public SSLSocket getSSLSocket() | 
			
		
	
		
			
				
					|  |  |  |  |         return result; | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * A {@link SSLSocketFactory} which uses an existing {@link SSLSocketFactory} to delegate its operations to and overrides the | 
			
		
	
		
			
				
					|  |  |  |  |      * {@link javax.net.ssl.SSLSocket#getEnabledProtocols() enabled protocols} to the protocols that were passed to its | 
			
		
	
		
			
				
					|  |  |  |  |      * {@link #ProtocolOverridingSSLSocketFactory(javax.net.ssl.SSLSocketFactory, String[]) constructor} | 
			
		
	
		
			
				
					|  |  |  |  |      * | 
			
		
	
		
			
				
					|  |  |  |  |      * @author Jaikiran Pai | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     public class ProtocolOverridingSSLSocketFactory extends SSLSocketFactory { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         private final SSLSocketFactory underlyingSSLSocketFactory; | 
			
		
	
		
			
				
					|  |  |  |  |         private final String[] enabledProtocols; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         public ProtocolOverridingSSLSocketFactory(final SSLSocketFactory delegate, final String[] enabledProtocols) { | 
			
		
	
		
			
				
					|  |  |  |  |             this.underlyingSSLSocketFactory = delegate; | 
			
		
	
		
			
				
					|  |  |  |  |             this.enabledProtocols = enabledProtocols; | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         @Override | 
			
		
	
		
			
				
					|  |  |  |  |         public String[] getDefaultCipherSuites() { | 
			
		
	
		
			
				
					|  |  |  |  |             return underlyingSSLSocketFactory.getDefaultCipherSuites(); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         @Override | 
			
		
	
		
			
				
					|  |  |  |  |         public String[] getSupportedCipherSuites() { | 
			
		
	
		
			
				
					|  |  |  |  |             return underlyingSSLSocketFactory.getSupportedCipherSuites(); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         @Override | 
			
		
	
		
			
				
					|  |  |  |  |         public Socket createSocket(final Socket socket, final String host, final int port, final boolean autoClose) throws IOException { | 
			
		
	
		
			
				
					|  |  |  |  |             final Socket underlyingSocket = underlyingSSLSocketFactory.createSocket(socket, host, port, autoClose); | 
			
		
	
		
			
				
					|  |  |  |  |             return overrideProtocol(underlyingSocket); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         @Override | 
			
		
	
		
			
				
					|  |  |  |  |         public Socket createSocket(final String host, final int port) throws IOException, UnknownHostException { | 
			
		
	
		
			
				
					|  |  |  |  |             final Socket underlyingSocket = underlyingSSLSocketFactory.createSocket(host, port); | 
			
		
	
		
			
				
					|  |  |  |  |             return overrideProtocol(underlyingSocket); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         @Override | 
			
		
	
		
			
				
					|  |  |  |  |         public Socket createSocket(final String host, final int port, final InetAddress localAddress, final int localPort) throws IOException, UnknownHostException { | 
			
		
	
		
			
				
					|  |  |  |  |             final Socket underlyingSocket = underlyingSSLSocketFactory.createSocket(host, port, localAddress, localPort); | 
			
		
	
		
			
				
					|  |  |  |  |             return overrideProtocol(underlyingSocket); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         @Override | 
			
		
	
		
			
				
					|  |  |  |  |         public Socket createSocket(final InetAddress host, final int port) throws IOException { | 
			
		
	
		
			
				
					|  |  |  |  |             final Socket underlyingSocket = underlyingSSLSocketFactory.createSocket(host, port); | 
			
		
	
		
			
				
					|  |  |  |  |             return overrideProtocol(underlyingSocket); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         @Override | 
			
		
	
		
			
				
					|  |  |  |  |         public Socket createSocket(final InetAddress host, final int port, final InetAddress localAddress, final int localPort) throws | 
			
		
	
		
			
				
					|  |  |  |  |             IOException | 
			
		
	
		
			
				
					|  |  |  |  |         { | 
			
		
	
		
			
				
					|  |  |  |  |             final Socket underlyingSocket = underlyingSSLSocketFactory.createSocket(host, port, localAddress, localPort); | 
			
		
	
		
			
				
					|  |  |  |  |             return overrideProtocol(underlyingSocket); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         /** | 
			
		
	
		
			
				
					|  |  |  |  |          * Set the {@link javax.net.ssl.SSLSocket#getEnabledProtocols() enabled protocols} to {@link #enabledProtocols} if the <code>socket</code> is a | 
			
		
	
		
			
				
					|  |  |  |  |          * {@link SSLSocket} | 
			
		
	
		
			
				
					|  |  |  |  |          * | 
			
		
	
		
			
				
					|  |  |  |  |          * @param socket The Socket | 
			
		
	
		
			
				
					|  |  |  |  |          * @return | 
			
		
	
		
			
				
					|  |  |  |  |          */ | 
			
		
	
		
			
				
					|  |  |  |  |         private Socket overrideProtocol(final Socket socket) { | 
			
		
	
		
			
				
					|  |  |  |  |             if (socket instanceof SSLSocket) { | 
			
		
	
		
			
				
					|  |  |  |  |                 if (enabledProtocols != null && enabledProtocols.length > 0) { | 
			
		
	
		
			
				
					|  |  |  |  | //                    System.err.println("oooooooooooo "
 | 
			
		
	
		
			
				
					|  |  |  |  | //                        + );
 | 
			
		
	
		
			
				
					|  |  |  |  |                     for(String s : ((SSLSocket) socket).getEnabledProtocols()) | 
			
		
	
		
			
				
					|  |  |  |  |                         System.err.println("ooo " + s); | 
			
		
	
		
			
				
					|  |  |  |  | //                    ((SSLSocket) socket).setEnabledProtocols(enabledProtocols);
 | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             return socket; | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
	
		
			
				
					|  |  |  | 
 |