Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *  Licensed to the Apache Software Foundation (ASF) under one
   *  or more contributor license agreements.  See the NOTICE file
   *  distributed with this work for additional information
   *  regarding copyright ownership.  The ASF licenses this file
   *  to you under the Apache License, Version 2.0 (the
   *  "License"); you may not use this file except in compliance
   *  with the License.  You may obtain a copy of the License at
   *  
  *    http://www.apache.org/licenses/LICENSE-2.0
  *  
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
  *  under the License. 
  *  
  */
 
 package org.apache.directory.studio.connection.core.io.jndi;
 
 
 
A SSLSocketFactory that accepts every certificate without validation.

Author(s):
Apache Directory Project
 
 public class DummySSLSocketFactory extends SSLSocketFactory
 {

    
The default instance.
 
     private static SSLSocketFactory instance;


    
Gets the default instance. Note: This method is invoked from the JNDI framework when creating a ldaps:// connection.

Returns:
the default instance
 
     public static SSLSocketFactory getDefault()
     {
         if (  == null )
         {
              = new DummySSLSocketFactory();
         }
         return ;
     }

    
The delegate.
 
     private SSLSocketFactory delegate;


    
Creates a new instance of DummySSLSocketFactory. Note: This method is invoked from the JNDI (Apache Harmony) when creating a ldaps:// connection. Must be public!
 
     public DummySSLSocketFactory()
     {
         try
         {
             TrustManager tm = new X509TrustManager()
             {
                 public X509Certificate[] getAcceptedIssuers()
                 {
                     return new X509Certificate[0];
                 }
 
 
                 public void checkClientTrustedX509Certificate[] arg0String arg1 ) throws CertificateException
                 {
                 }
 
 
                 public void checkServerTrustedX509Certificate[] arg0String arg1 ) throws CertificateException
                 {
                 }
             };
             TrustManager[] tma =
                 { tm };
            SSLContext sc = SSLContext.getInstance"TLS" ); //$NON-NLS-1$
            sc.initnulltmanew SecureRandom() );
             = sc.getSocketFactory();
        }
        catch ( Exception e )
        {
            e.printStackTrace();
        }
    }


    
    public String[] getDefaultCipherSuites()
    {
        return .getDefaultCipherSuites();
    }


    
    public String[] getSupportedCipherSuites()
    {
        return .getSupportedCipherSuites();
    }


    
    public Socket createSocketSocket sString hostint portboolean autoClose ) throws IOException
    {
        try
        {
            return .createSocketshostportautoClose );
        }
        catch ( IOException e )
        {
            e.printStackTrace();
            throw e;
        }
    }


    
    public Socket createSocketString hostint port ) throws IOExceptionUnknownHostException
    {
        try
        {
            return .createSockethostport );
        }
        catch ( IOException e )
        {
            e.printStackTrace();
            throw e;
        }
    }


    
    public Socket createSocketInetAddress hostint port ) throws IOException
    {
        try
        {
            return .createSockethostport );
        }
        catch ( IOException e )
        {
            e.printStackTrace();
            throw e;
        }
    }


    
    public Socket createSocketString hostint portInetAddress localHostint localPort ) throws IOException,
        UnknownHostException
    {
        try
        {
            return .createSockethostportlocalHostlocalPort );
        }
        catch ( IOException e )
        {
            e.printStackTrace();
            throw e;
        }
    }


    
    public Socket createSocketInetAddress addressint portInetAddress localhAddressint localPort )
        throws IOException
    {
        try
        {
            return .createSocketaddressportlocalhAddresslocalPort );
        }
        catch ( IOException e )
        {
            e.printStackTrace();
            throw e;
        }
    }
New to GrepCode? Check out our FAQ X