Changeset 2093

Show
Ignore:
Timestamp:
03/10/07 03:42:01 (2 years ago)
Author:
merlimat
Message:

EclipseTracPlugin:

Install SSL certificate handler. Closes #1271

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • eclipsetracplugin/eclipse/trunk/mm.eclipse.trac/src/mm/eclipse/trac/perspective/PerspectiveFactory.java

    r2003 r2093  
    2121        IFolderLayout bottom = layout.createFolder( "bottom", IPageLayout.BOTTOM, 0.85f, 
    2222                                                    editorArea ); 
     23        bottom.addView( "mm.eclipse.trac.server.ServerView" ); 
    2324        bottom.addView( "mm.eclipse.trac.views.WikiPageHistory" ); 
    2425         
  • eclipsetracplugin/eclipse/trunk/mm.eclipse.trac/src/mm/eclipse/trac/xmlrpc/Trac.java

    r2016 r2093  
    22 
    33import java.net.URL; 
     4import java.security.cert.X509Certificate; 
     5 
     6import javax.net.ssl.HostnameVerifier; 
     7import javax.net.ssl.HttpsURLConnection; 
     8import javax.net.ssl.SSLContext; 
     9import javax.net.ssl.SSLSession; 
     10import javax.net.ssl.TrustManager; 
     11import javax.net.ssl.X509TrustManager; 
     12 
     13import mm.eclipse.trac.Log; 
    414 
    515import org.apache.xmlrpc.client.XmlRpcClient; 
     
    1424     
    1525    public Trac( URL url, String username, String password, boolean anonymous ) 
    16         throws Exception 
     26            throws Exception 
    1727    { 
     28        installSslCertificateHandler(); 
     29         
    1830        XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); 
    1931         
     
    2941            // will fail, without the system asking credentials with an 
    3042            // intrusive dialog. 
    31             if ( username.length() == 0 ) username = "xxxx"; 
     43            if ( username.length() == 0 ) 
     44                username = "xxxx"; 
    3245            config.setBasicUserName( username ); 
    3346             
    34             if ( password.length() == 0 ) password = "xxxx"; 
     47            if ( password.length() == 0 ) 
     48                password = "xxxx"; 
    3549            config.setBasicPassword( password ); 
    3650        } 
     
    6680    } 
    6781     
     82    private void installSslCertificateHandler() 
     83    { 
     84        // Create a trust manager that does not validate certificate chains 
     85         
     86        TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { 
     87            public X509Certificate[] getAcceptedIssuers() 
     88            { 
     89                return null; 
     90            } 
     91             
     92            public void checkClientTrusted( X509Certificate[] certs, String authType ) 
     93            { 
     94                // Trust always 
     95            } 
     96             
     97            public void checkServerTrusted( X509Certificate[] certs, String authType ) 
     98            { 
     99                // Trust always 
     100            } 
     101        } }; 
     102         
     103        // Install the all-trusting trust manager 
     104        try 
     105        { 
     106            SSLContext sc = SSLContext.getInstance( "SSL" ); 
     107             
     108            // Create empty HostnameVerifier 
     109            HostnameVerifier hv = new HostnameVerifier() { 
     110                public boolean verify( String arg0, SSLSession arg1 ) 
     111                { 
     112                    return true; 
     113                } 
     114            }; 
     115             
     116            sc.init( null, trustAllCerts, new java.security.SecureRandom() ); 
     117            HttpsURLConnection.setDefaultSSLSocketFactory( sc.getSocketFactory() ); 
     118            HttpsURLConnection.setDefaultHostnameVerifier( hv ); 
     119             
     120        } catch ( Exception e ) 
     121        { 
     122            Log.error( "Error installing SSL handler", e ); 
     123        } 
     124         
     125         
     126    } 
    68127}