Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   */
  package org.jboss.remoting.security;
  
SSL socket factory whose configuration is customized.

Author(s):
John Mazzitelli
Version:
$Revision: 1099 $
 
 public class CustomSSLSocketFactory
    extends SSLSocketFactory
 {
    private SSLSocketFactory theDelegate;
    private SSLSocketBuilderMBean theBuilder;

   
Constructor for CustomSSLSocketFactory. The factory can be null - call setFactory(javax.net.ssl.SSLSocketFactory) to set it later.

Parameters:
factory the true factory this class delegates to
builder the class that built this custom factory - contains all the configuration for this factory
 
    public CustomSSLSocketFactorySSLSocketFactory factory,
                                   SSLSocketBuilder builder )
    {
       super();
         = builder;
        = factory;
    }
 
    public CustomSSLSocketFactory()
    {
 
    }

   
Sets the builder that created the factory.

Parameters:
sslSocketBuilder
 
    public void setSSLSocketBuilder(SSLSocketBuilderMBean sslSocketBuilder)
    {
       this. = sslSocketBuilder;
    }


   
Returns the builder that created this factory. You can obtain the configuration of this factory by examining the returned object's configuration.

Returns:
the builder
 
    {
       return ;
    }
   
   
Sets a new factory in this object - this is the factory that this object will use to create new sockets.

Parameters:
factory the new factory
Throws:
java.lang.IllegalArgumentException if factory is null
 
    public void setFactorySSLSocketFactory factory )
    {
       if ( factory == null )
       {
          throw new IllegalArgumentException"Factory cannot be null" );
       }
 
        = factory;
    }

   
 
    public Socket createSocketSocket  s,
                                String  host,
                                int     port,
                                boolean autoClose )
    throws IOException
    {
       SSLSocket sock = (SSLSocket.createSocketshostportautoClose );
       setSocketModessock );
       return sock;
    }

   
 
   public Socket createSocket()
   throws IOException
   {
      SSLSocket sock = (SSLSocket.createSocket();
      setSocketModessock );
      return sock;
   }

   
   public Socket createSocketInetAddress address,
                               int         port,
                               InetAddress localAddress,
                               int         localPort )
   throws IOException
   {
      SSLSocket sock = (SSLSocket.createSocketaddressportlocalAddresslocalPort );
      setSocketModessock );
      return sock;
   }

   
   public Socket createSocketInetAddress host,
                               int         port )
   throws IOException
   {
      SSLSocket sock = (SSLSocket.createSockethostport );
      setSocketModessock );
      return sock;
   }

   
   public Socket createSocketString      host,
                               int         port,
                               InetAddress localHost,
                               int         localPort )
   throws IOException,
          UnknownHostException
   {
      SSLSocket sock = (SSLSocket.createSockethostportlocalHostlocalPort );
      setSocketModessock );
      return sock;
   }

   
   public Socket createSocketString host,
                               int    port )
   throws IOException,
          UnknownHostException
   {
      SSLSocket sock = (SSLSocket.createSockethostport );
      setSocketModessock );
      return sock;
   }

   
   {
      return .getDefaultCipherSuites();
   }

   
   {
   }

   
   public boolean equalsObject obj )
   {
      return .equalsobj );
   }

   
   public int hashCode()
   {
      return .hashCode();
   }

   
   public String toString()
   {
      return .toString();
   }

   
Sets the socket modes according to the custom configuration.

Parameters:
sock the socket whose modes are to be set
   private void setSocketModesSSLSocket sock )
   {
      if (  != null )
      {
         if ( .isClientAuthModeWant() )
         {
            sock.setNeedClientAuthfalse );
            sock.setWantClientAuthtrue );
         }
         else if ( .isClientAuthModeNeed() )
         {
            sock.setWantClientAuthfalse );
            sock.setNeedClientAuthtrue );
         }
         else
         {
            sock.setWantClientAuthfalse );
            sock.setNeedClientAuthfalse );
         }
      }
      return;
   }
New to GrepCode? Check out our FAQ X