Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
   * JBoss, Home of Professional Open Source
   * Copyright 2005, JBoss Inc., and individual contributors as indicated
   * by the @authors tag. See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.remoting.security;
  
  import  org.jboss.logging.Logger;
  
  import java.io.File;
  import java.net.URL;
  import java.util.Map;

A class that contains code that remoting factories need to build customized server and client SSL sockets.

Author(s):
John Mazzitelli
Tom Elrod
Version:
$Revision: 5689 $
  
  public class SSLSocketBuilder implements SSLSocketBuilderMBeanCloneable
  {
   
Constant defining the config property used to define the SSL provider to use.
  
     public static final String REMOTING_SSL_PROVIDER_NAME = "org.jboss.remoting.sslProviderName";

   
Constant defining the config property used to define the SSL socket protocol to use.
  
     public static final String REMOTING_SSL_PROTOCOL = "org.jboss.remoting.sslProtocol";

   
If the protocol isn't specified, this will be the default. Value is "TLS".
  
     public static final String DEFAULT_SSL_PROTOCOL = "TLS";

   
Constant defining the config property used to define if the sockets will be in client or server mode.
  
     public static final String REMOTING_SOCKET_USE_CLIENT_MODE = "org.jboss.remoting.socket.useClientMode";

   
Constant defining the config property used to define if the server sockets will be in client or server mode.
  
     public static final String REMOTING_SERVER_SOCKET_USE_CLIENT_MODE = "org.jboss.remoting.serversocket.useClientMode";

   
Constant defining the config property used to define if sockets need or want client authentication. This configuration option is only useful for sockets in the server mode. The value of such a property is one of the CLIENT_AUTH_MODE_XXX constants.
 
    public static final String REMOTING_CLIENT_AUTH_MODE = "org.jboss.remoting.clientAuthMode";

   
Client auth mode that indicates client authentication will not be peformed.
 
    public static final String CLIENT_AUTH_MODE_NONE = "none";

   
Client auth mode that indicates that we want client authentication but it isn't required.
 
    public static final String CLIENT_AUTH_MODE_WANT = "want";

   
Client auth mode that indicates that client authentication is required.
 
    public static final String CLIENT_AUTH_MODE_NEED = "need";

   
Constant defining the config property used to define if a client should attempt to authenticate a server certificate as one it trusts. The value of such a property is a boolean.
 
    public static final String REMOTING_SERVER_AUTH_MODE = "org.jboss.remoting.serverAuthMode";

   
Constant defining the config property used to define where JBoss/Remoting will look for the keystore file. This can be relative to the thread's classloader or can be an absolute path on the file system or can be a URL.
 
    public static final String REMOTING_KEY_STORE_FILE_PATH = "org.jboss.remoting.keyStore";

   
Constant defining the config property that defines the keystore's type.
 
    public static final String REMOTING_KEY_STORE_TYPE = "org.jboss.remoting.keyStoreType";

   
Constant defining the config property that defines the key management algorithm used by the keystore.
 
    public static final String REMOTING_KEY_STORE_ALGORITHM = "org.jboss.remoting.keyStoreAlgorithm";

   
Constant defining the config property that defines the password of the keystore.
 
    public static final String REMOTING_KEY_STORE_PASSWORD = "org.jboss.remoting.keyStorePassword";

   
Constant defining the config property that indicates the client's alias as found in the keystore.
 
    public static final String REMOTING_KEY_ALIAS = "org.jboss.remoting.keyAlias";

   
Constant defining the config property that indicates the key password for the keys in the key store.
 
    public static final String REMOTING_KEY_PASSWORD = "org.jboss.remoting.keyPassword";

   
Constant that defines the standard system property that the javax.net.ssl classes look for when locating the keystore file.
 
    public static final String STANDARD_KEY_STORE_FILE_PATH = "javax.net.ssl.keyStore";

   
Constant that defines the standard system property that the javax.net.ssl classes look for when needing to know what type the keystore file is.
 
    public static final String STANDARD_KEY_STORE_TYPE = "javax.net.ssl.keyStoreType";

   
Constant that defines the standard system property that the javax.net.ssl classes look for when needing the keystore password.
 
    public static final String STANDARD_KEY_STORE_PASSWORD = "javax.net.ssl.keyStorePassword";

   
Default key/trust store type if one not set as bean property, via config, or via system property. Value is 'JKS'.
 
    public static final String DEFAULT_KEY_STORE_TYPE = "JKS";

   
Default key/trust store algorithm if one net set as bean property or via config. Value is 'SunX509'.
 
    public static final String DEFAULT_KEY_STORE_ALGORITHM = "SunX509";

   
Constant defining the config property used to define where JBoss/Remoting will look for the truststore file. This can be relative to the thread's classloader or can be an absolute path on the file system.
 
    public static final String REMOTING_TRUST_STORE_FILE_PATH = "org.jboss.remoting.trustStore";

   
Constant defining the config property that defines the truststore's type.
 
    public static final String REMOTING_TRUST_STORE_TYPE = "org.jboss.remoting.trustStoreType";

   
Constant defining the config property that defines the key management algorithm used by the truststore.
 
    public static final String REMOTING_TRUST_STORE_ALGORITHM = "org.jboss.remoting.trustStoreAlgorithm";

   
Constant defining the config property that defines the password of the keystore.
 
    public static final String REMOTING_TRUST_STORE_PASSWORD = "org.jboss.remoting.trustStorePassword";

   
Constant that defines the standard system property that the javax.net.ssl classes look for when locating the truststore file.
 
    public static final String STANDARD_TRUST_STORE_FILE_PATH = "javax.net.ssl.trustStore";

   
Constant that defines the standard system property that the javax.net.ssl classes look for when needing to know what type the truststore file is.
 
    public static final String STANDARD_TRUST_STORE_TYPE = "javax.net.ssl.trustStoreType";

   
Constant that defines the standard system property that the javax.net.ssl classes look for when needing the truststore password.
 
    public static final String STANDARD_TRUST_STORE_PASSWORD = "javax.net.ssl.trustStorePassword";

   
System property key to define the fully qualified class name of default socket factory to use when not using custom config.
 
    public static final String REMOTING_DEFAULT_SOCKET_FACTORY_CLASS = "org.jboss.remoting.defaultSocketFactory";
    
    public static final String NONE_STORE = "NONE";
 
    private SSLContext sslContextServerSocketFactory = null// context that builds the server socket factories
    private SSLContext sslContextSocketFactory = null// context that builds the socket factories
    private Provider provider = null;
    private String providerName = null;
    private String secureSocketProtocol = null;
 
    private KeyManager[] keyManagers = null;
    private TrustManager[] trustManagers = null;
    private SecureRandom secureRandom = null;
 
    private URL    keyStoreFilePath = null;
    private String keyStoreType = null;
    private String keyStoreAlgorithm = null;
    private String keyStorePassword = null;
    private String keyAlias = null;
    private String keyPassword = null;
 
    private URL    trustStoreFilePath = null;
    private String trustStoreType = null;
    private String trustStoreAlgorithm = null;
    private String trustStorePassword = null;
 
    private Map config = null;
    private Boolean socketUseClientMode = null;
    private Boolean serverSocketUseClientMode = null;
    private String clientAuthMode = null;
    private Boolean serverAuthMode = null;
 
    private boolean useSSLServerSocketFactory = true;
    private boolean useSSLSocketFactory = true;
 
    private static final Logger log = Logger.getLogger(SSLSocketBuilder.class);
    
    private static URL NONE_STORE_URL;
    
    static
    {
       try
       {
           = new URL("file:NONE");
       } catch (MalformedURLException e)
       {
          .info("unexpected URL exception"e);
       }
    }

   
Constructor for SSLSocketBuilder that does not have any configuration so it falls back to all defaults.
 
    public SSLSocketBuilder()
    {
       this(null);
    }

   
Constructor for SSLSocketBuilder that allows the caller to override the default settings for the various SSL configuration properties.

Parameters:
config configuration with properties defining things like where the keystore and truststore files are, their types, etc.
 
    public SSLSocketBuilder(Map config)
    {
       this. = config;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setUseSSLServerSocketFactory(boolean)
 
    public void setUseSSLServerSocketFactory(boolean shouldUse)
    {
       this. = shouldUse;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.getUseSSLServerSocketFactory()
 
    public boolean getUseSSLServerSocketFactory()
    {
       return ;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setUseSSLSocketFactory(boolean)
 
    public void setUseSSLSocketFactory(boolean shouldUse)
    {
       this. = shouldUse;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.getUseSSLSocketFactory()
 
    public boolean getUseSSLSocketFactory()
    {
       return ;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.createSSLServerSocketFactory()
 
    {
       return createSSLServerSocketFactorynull );
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.createSSLServerSocketFactory(org.jboss.remoting.security.CustomSSLServerSocketFactory)
 
    {
       ServerSocketFactory ssf = null;
 
       ifgetUseSSLServerSocketFactory() )
       {
          ssf = SSLServerSocketFactory.getDefault();
       }
       else
       {
          if (wrapper == null)
          {
             wrapper = new CustomSSLServerSocketFactory(nullthis);
          }
 
          ssf = createCustomServerSocketFactory(wrapper);
       }
 
       return ssf;
    }

   
This creates a fully custom SSL server socket factory using this object's configuration.

Parameters:
wrapper the wrapper where the created factory will be stored
Returns:
the SSLServerSocketFactory
Throws:
IOException
 
    {
       if ( == null)
       {
       }
 
 
       wrapper.setFactory((SSLServerSocketFactoryssf);
 
       return wrapper;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.createSSLSocketFactory()
 
    {
       return createSSLSocketFactory(null);
    }


   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.createSSLSocketFactory(org.jboss.remoting.security.CustomSSLSocketFactory)
 
    {
       SocketFactory sf = null;
 
       if (getUseSSLSocketFactory())
       {
          String defaultFactoryName = getSystemProperty();
          
          if (defaultFactoryName != null)
          {
             try
             {
                final Class sfClass = ClassLoaderUtility.loadClass(defaultFactoryNameSSLSocketBuilder.class);
                Method m = getMethod(sfClass"getDefault"null);
                
                if (m == null)
                {
                   throw new RuntimeException(
                         "Could not create the socket factory "
                         + defaultFactoryName
                         + " because the class "
                         + sfClass
                         + " doesn't provide the getDefault method.");
                }
                sf = (SocketFactorym.invoke(nullnull);
             }
             catch (Exception ex)
             {
                throw new RuntimeException(
                      "Could not create the socket factory "
                      + defaultFactoryNameex);
             }
          }
          if (sf == null)
          {
             sf = SSLSocketFactory.getDefault();
          }
       }
       else
       {
          if (wrapper == null)
          {
             wrapper = new CustomSSLSocketFactory(nullthis);
          }
 
          sf = createCustomSocketFactory(wrapper);
       }
 
       return sf;
    }

   
This creates a fully custom SSL socket factory using this object's configuration.

Parameters:
wrapper the wrapper where the created factory will be stored
Returns:
the wrapper with the new factory stored in it
Throws:
IOException
 
    {
       if ( == null)
       {
          createSocketFactorySSLContext();
       }
 
 
       wrapper.setFactory((SSLSocketFactorysf);
 
       return wrapper;
    }


   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.getServerSocketFactorySSLContext()
 
    {
       return ;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.getSocketFactorySSLContext()
 
    {
       return ;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.getSecureSocketProtocol()
 
    {
       if ( == null)
       {
          if( != null)
          {
          }
          if ( == null)
          {
              = ;
          }
       }
 
       return ;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setSecureSocketProtocol(String)
 
    public void setSecureSocketProtocol(String protocol)
    {
       if(protocol != null && protocol.length() > 0)
       {
          this. = protocol;
       }
       else
       {
          throw new IllegalArgumentException("Can not set remoting socket factory with null protocol");
       }
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.getProvider()
 
    public Provider getProvider()
    {
       return ;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setProvider(java.security.Provider)
 
    public void setProvider(Provider provider)
    {
       this. = provider;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.getProviderName()
 
    public String getProviderName()
    {
       if ( == null)
       {
          if( != null)
          {
              = (String.get();
          }
       }
       return ;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setProviderName(java.lang.String)
 
    public void setProviderName(String providerName)
    {
       this. = providerName;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.getSecureRandom()
 
    public SecureRandom getSecureRandom()
    {
       if( != null)
       {
          return ;
       }
 
        = new SecureRandom();
 
       return ;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setSecureRandom(java.security.SecureRandom)
 
    public void setSecureRandom(SecureRandom secureRandom)
    {
       this. = secureRandom;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.getKeyStoreURL()
 
    public String getKeyStoreURL()
    {
       URL keyStore = getKeyStore();
       if(keyStore != null)
       {
          return keyStore.toString();
       }
       else
       {
          return null;
       }
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.getKeyStore()
 
    public URL getKeyStore()
    {
       if( != null)
       {
          return ;
       }
 
       if( != null)
       {
          String path = (String.get();
          if(path != null && path.length() > 0)
          {
             setKeyStoreURLpath );
          }
       }
 
       if( == null)
       {
          if(path != null && path.length() > 0)
          {
             setKeyStoreURLpath );
          }
       }
 
       return ;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setKeyStoreURL(java.lang.String)
 
    public void setKeyStoreURL(String keyStoreFilePath)
    {
       try
       {
          this. = validateStoreURL(keyStoreFilePath);
       }
       catch (IOException e)
       {
          throw new RuntimeException"Cannot validate the store URL: " + keyStoreFilePath , e );
       }
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setKeyStore(java.net.URL)
 
    public void setKeyStore(URL keyStore)
    {
       this. = keyStore;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.getKeyStoreType()
 
    public String getKeyStoreType()
    {
       if( != null)
       {
          return ;
       }
 
       if( != null)
       {
          String type = (String).get();
          if(type != null && type.length() > 0)
          {
              = type;
          }
       }
 
       if( == null)
       {
          if( == null)
          {
              = ;
          }
       }
 
       return ;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setKeyStoreType(java.lang.String)
 
    public void setKeyStoreType(String keyStoreType)
    {
       this. = keyStoreType;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.getKeyStoreAlgorithm()
 
    public String getKeyStoreAlgorithm()
    {
       if( != null)
       {
          return ;
       }
 
       if( != null)
       {
          String alg = (String).get();
          if(alg != null && alg.length() > 0)
          {
              = alg;
          }
       }
 
       if( == null)
       {
       }
 
       return ;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setKeyStoreAlgorithm(java.lang.String)
 
    public void setKeyStoreAlgorithm(String algorithm)
    {
       this. = algorithm;
    }

   
Returns the password used to gain access to the keystore.

Returns:
keystore password
 
    public String getKeyStorePassword()
    {
       if( != null)
       {
          return ;
       }
 
       if( != null)
       {
          String passwd = (String).get();
          if(passwd != null && passwd.length() > 0)
          {
              = passwd;
          }
       }
 
       if( == null)
       {
       }
 
       return ;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setKeyStorePassword(java.lang.String)
 
    public void setKeyStorePassword(String keyStorePassword)
    {
       this. = keyStorePassword;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.getTrustStoreURL()
 
    public String getTrustStoreURL()
    {
       URL trustStore = getTrustStore();
       if(trustStore != null)
       {
          return trustStore.toString();
       }
       else
       {
          return null;
       }
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.getTrustStore()
 
    public URL getTrustStore()
    {
       if( != null)
       {
          return ;
       }
 
       if( != null)
       {
          String path = (String).get();
          if(path != null && path.length() > 0)
          {
             setTrustStoreURLpath );
          }
       }
 
       if( == null)
       {
          if(path != null && path.length() > 0)
          {
             setTrustStoreURLpath );
          }
       }
 
       return ;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setTrustStore(java.net.URL)
 
    public void setTrustStore(URL trustStore)
    {
       this. = trustStore;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setTrustStoreURL(java.lang.String)
 
    public void setTrustStoreURL(String trustStoreFilePath)
    {
       try
       {
          this. = validateStoreURL(trustStoreFilePath);
       }
       catch (IOException e)
       {
          throw new RuntimeException"Cannot validate the store URL: " + trustStoreFilePath , e );
       }
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.getTrustStoreType()
 
    public String getTrustStoreType()
    {
       if( != null)
       {
          return ;
       }
 
       if( != null)
       {
          String type = (String).get();
          if(type != null && type.length() > 0)
          {
              = type;
          }
       }
 
       if( == null)
       {
          if( == null)
          {
              = getKeyStoreType();
          }
       }
 
       return ;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setTrustStoreType(java.lang.String)
 
    public void setTrustStoreType(String trustStoreType)
    {
       this. = trustStoreType;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.getTrustStoreAlgorithm()
 
    {
       if( != null)
       {
          return ;
       }
 
       if( != null)
       {
          String alg = (String).get();
          if(alg != null && alg.length() > 0)
          {
              = alg;
          }
       }
 
       if( == null)
       {
           = getKeyStoreAlgorithm();
       }
 
       return ;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setTrustStoreAlgorithm(java.lang.String)
 
    public void setTrustStoreAlgorithm(String algorithm)
    {
       this. = algorithm;
    }

   
Returns the password used to gain access to the truststore.

Returns:
truststore password
 
    public String getTrustStorePassword()
    {
       if( != null)
       {
          return ;
       }
 
       if( != null)
       {
          String passwd = (String).get();
          if(passwd != null && passwd.length() > 0)
          {
              = passwd;
          }
       }
 
       if( == null)
       {
          if( == null)
          {
              = getKeyStorePassword();
          }
       }
 
       return ;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setTrustStorePassword(java.lang.String)
 
    public void setTrustStorePassword(String trustStorePassword)
    {
       this. = trustStorePassword;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.getKeyAlias()
 
    public String getKeyAlias()
    {
       if( != null)
       {
          return ;
       }
       if( != null)
       {
           = (String).get();
       }
       return ;
    }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setKeyAlias(java.lang.String)
 
    public void setKeyAlias(String alias)
    {
       this. = alias;
    }

   
Returns the password to use for the keys within the key store. If this value is not set, this will return null but when this value is needed by this class, the value for the key store password will be used instead.

Returns:
key password
 
    public String getKeyPassword()
    {
       if( != null)
       {
          return ;
      }
      if( != null)
      {
         String passwd = (String).get();
         if(passwd != null && passwd.length() > 0)
         {
             = passwd;
         }
      }
      return ;
   }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setKeyPassword(java.lang.String)
   public void setKeyPassword(String keyPassword)
   {
      this. = keyPassword;
   }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.isSocketUseClientMode()
   public boolean isSocketUseClientMode( )
   {
      if ( == null)
      {
         if ( != null && .containsKey())
         {
         }
         else
         {
             = .;
         }
      }
      return .booleanValue();
   }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.isServerSocketUseClientMode()
   public boolean isServerSocketUseClientMode( )
   {
      if ( == null)
      {
         {
         }
         else
         {
             = .;
         }
      }
   }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setSocketUseClientMode(boolean)
   public void setSocketUseClientModeboolean useClientMode )
   {
      this. = Boolean.valueOf(useClientMode);
   }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setServerSocketUseClientMode(boolean)
   public void setServerSocketUseClientModeboolean useClientMode )
   {
      this. = Boolean.valueOf(useClientMode);
   }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.isClientAuthModeNone()
   public boolean isClientAuthModeNone()
   {
   }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.isClientAuthModeWant()
   public boolean isClientAuthModeWant()
   {
   }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.isClientAuthModeNeed()
   public boolean isClientAuthModeNeed()
   {
   }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.getClientAuthMode()
   public String getClientAuthMode()
   {
      if ( == null)
      {
         if ( != null && .containsKey())
         {
         }
         else
         {
             = ;
         }
      }
      return ;
   }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setClientAuthMode(java.lang.String)
   public void setClientAuthMode(String mode)
   {
      if (  mode == null ||
            (!mode.equalsIgnoreCase()
             && !mode.equalsIgnoreCase()
             && !mode.equalsIgnoreCase()))
      {
         .warn("Client authentication mode is invalid [" + mode + "]; falling back to NEED mode");
      }
      else
      {
          = mode;
      }
      return;
   }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.isServerAuthMode()
   public boolean isServerAuthMode()
   {
      if ( == null)
      {
         if ( != null && .containsKey())
         {
             = Boolean.valueOf( (String.get() );
         }
         else
         {
             = .;
         }
      }
      return .booleanValue();
   }

   

See also:
org.jboss.remoting.security.SSLSocketBuilderMBean.setServerAuthMode(boolean)
   public void setServerAuthMode(boolean mode)
   {
       = Boolean.valueOf(mode);
   }

   
Creates (but does not initialize) the SSL context used by this object to create server socket factories. The provider/protocol is used to determine what SSL context to use. Call initializeServerSocketFactorySSLContext() if you want to create and initialize in one method call. If the server socket factory SSL context was already created, this will create a new one and remove the old one.

Throws:
IOException
         throws IOException
   {
      try
      {
         if(getProvider() != null)
         {
         }
         else if(getProviderName() != null)
         {
         }
         else
         {
             = SSLContext.getInstance(getSecureSocketProtocol());
         }
      }
      catch(Exception e)
      {
         IOException ioe = new IOException("Error creating server socket factory SSL context: " + e.getMessage());
         ioe.setStackTrace(e.getStackTrace());
         throw ioe;
      }
      return;
   }

   
Creates (but does not initialize) the SSL context used by this object to create socket factories. The provider/protocol is used to determine what SSL context to use. Call initializeSocketFactorySSLContext() if you want to create and initialize in one method call. If the socket factory SSL context was already created, this will create a new one and remove the old one.

Throws:
IOException
   protected void createSocketFactorySSLContext()
   throws IOException
   {
      try
      {
         if(getProvider() != null)
         {
             = SSLContext.getInstance(getSecureSocketProtocol(), getProvider());
         }
         else if(getProviderName() != null)
         {
         }
         else
         {
             = SSLContext.getInstance(getSecureSocketProtocol());
         }
      }
      catch(Exception e)
      {
         IOException ioe = new IOException("Error creating socket factory SSL context: " + e.getMessage());
         ioe.setStackTrace(e.getStackTrace());
         throw ioe;
      }
      return;
   }

   
Initializes the SSL context used by this object that will create the server socket factories. If the SSL context is not yet created, this method will also create it. The provider/protocol is used to determine what SSL context to use. Key and trust managers are loaded and a secure random object is created and the SSL context for the protocol/provider is initialized with them.

Throws:
IOException
         throws IOException
   {
      try
      {
         if ( == null)
         {
            createServerSocketFactorySSLContext();
         }
         try
         {
             = loadKeyManagers();
         }
         catch (NullStoreURLException e)
         {
            if (isServerSocketUseClientMode())
            {
                = null;
               .debug("Could not find keytore url.  " + e.getMessage());
            }
            else
            {
               // because this ssl context will create server socket factories, will throw if can not find keystore
               IOException ioe = new IOException("Can not find keystore url.");
               ioe.initCause(e);
               throw ioe;
            }
         }
         try
         {
            boolean isClientMode = isServerSocketUseClientMode();
             = loadTrustManagers(isClientMode);
         }
         catch (NullStoreURLException e)
         {
             = null;
            .debug("Could not find truststore url.  " + e.getMessage());
         }
          = getSecureRandom();
      }
      catch(Exception e)
      {
         IOException ioe = new IOException("Error initializing server socket factory SSL context: " + e.getMessage());
         ioe.setStackTrace(e.getStackTrace());
         throw ioe;
      }
      return;
   }

   
Initializes the SSL context used by this object that will create the socket factories. If the SSL context is not yet created, this method will also create it. The provider/protocol is used to determine what SSL context to use. Key and trust managers are loaded and a secure random object is created and the SSL context for the protocol/provider is initialized with them.

Throws:
IOException
   protected void initializeSocketFactorySSLContext()
   throws IOException
   {
      try
      {
         if ( == null)
         {
            createSocketFactorySSLContext();
         }
         try
         {
             = loadKeyManagers();
         }
         catch (NullStoreURLException e)
         {
            if (isSocketUseClientMode())
            {
               // this is allowable since would be the normal scenario
                = null;
               .debug("Could not find keystore url.  " + e.getMessage());
            }
            else
            {
               IOException ioe = new IOException("Can not find keystore url.");
               ioe.initCause(e);
               throw ioe;
            }
         }
         try
         {
            boolean isClientMode = isSocketUseClientMode();
             = loadTrustManagers(isClientMode);
         }
         catch (NullStoreURLException e)
         {
            // If the keyManagers is not null, could possibly be using in client mode
            // so want to allow it.  Otherwise, need to throw exception as will not be able
            // to use in client mode or not
            if( != null)
            {
                = null;
               .debug("Could not find truststore url.  " + e.getMessage());
            }
            else
            {
               IOException ioe = new IOException("Can not find truststore url.");
               ioe.initCause(e);
               throw ioe;
            }
         }
          = getSecureRandom();
      }
      catch(Exception e)
      {
         IOException ioe = new IOException("Error initializing socket factory SSL context: " + e.getMessage());
         ioe.setStackTrace(e.getStackTrace());
         throw ioe;
      }
      return;
   }

   
Loads the trust managers based on this object's truststore.

Returns:
array of trust managers that should be loaded in this object's SSL context
Throws:
NoSuchProviderException
NoSuchAlgorithmException
IOException
CertificateException
KeyStoreException
NullStoreURLException
   protected TrustManager[] loadTrustManagers(boolean isClientMode)
   {
      if(isClientMode && !isServerAuthMode())
      {
         // we are in client mode and do not want to perform server cert authentication
         // return a trust manager that trusts all certs
          = new TrustManager[] {
               new X509TrustManager() {
                  public void checkClientTrustedX509Certificate[] chainString authType ) {}
                  public void checkServerTrustedX509Certificate[] chainString authType ) {}
                  public X509Certificate[] getAcceptedIssuers()  { return null; }
               }};
      }
      else
      {
         String tsType = getTrustStoreType();
         String tsPasswd = getTrustStorePassword();
         URL tsPathURL = getTrustStore();
         String tsAlg = getTrustStoreAlgorithm();
         TrustManagerFactory trustMgrFactory;
         KeyStore trustStore = loadKeyStore(tsTypetsPathURLtsPasswd);
         if (getProvider() != null)
         {
            trustMgrFactory = TrustManagerFactory.getInstance(tsAlggetProvider());
         }
         else if (getProviderName() != null)
         {
            trustMgrFactory = TrustManagerFactory.getInstance(tsAlggetProviderName());
         }
         else
         {
            trustMgrFactory = TrustManagerFactory.getInstance(tsAlg);
         }