Version 3

    Starting in JBoss AS 5.2 Beta, EAP 4.2 CP08 and EAP 4.3 CP06 there is a new SSLSocketFactory implementation available that can use a JaasSecurityDomain to configure SSL connections.

    This is useful if you need a custom SSLSocketFactory to use with LDAP, Remoting (for WebServices for example), etc or simply want to use a particular alias from a keystore (which would not be possible by using the "" property).


    LDAP Example:


    In conf/login-config.xml add the "java.naming.ldap.factory.socket" option to either LdapExtLoginModule  or LdapLoginModule in your security domain configuration:


    <application-policy name="mySecDomain">
        <login-module code="" flag="required">
          <module-option name="java.naming.provider.url">ldaps://localhost:636</module-option>
          <module-option name="java.naming.ldap.factory.socket></module-option>


    Add the "" system property at startup. This is the name of the JaasSecurityDomain:


    For Linux:

    Edit $JBOSS_HOME/bin/run.conf:



    For Windows:

    Edit $JBOSS_HOME/bin/run.bat:



    Remoting Connectors Example:


    Any Remoting connector can be set to specify the clients's socket factory that will be used for SSL communication, so if mutual SSL authentication is required, the client just needs to setup a JaasSecurityDomain bean and by connecting to the server it will automatically use that configuration for SSL. Here is an example for the connector used for EJB2:


    <mbean code="org.jboss.remoting.transport.Connector"
              display-name="Socket transport Connector">
          <attribute name="Configuration">
             <!-- Using the following <invoker> element instead of the InvokerLocator above because specific attributes needed. -->
             <!-- If wanted to use any of the parameters below, can just add them as parameters to the url above if wanted use the InvokerLocator attribute. -->
                <!-- Other than transport type and handler, none of these configurations are required (will just use defaults). -->
                <invoker transport="sslsocket">
                   <attribute name="dataType" isParam="true">invocation</attribute>
                   <attribute name="marshaller" isParam="true">org.jboss.invocation.unified.marshall.InvocationMarshaller</attribute>
                   <attribute name="unmarshaller" isParam="true">org.jboss.invocation.unified.marshall.InvocationUnMarshaller</attribute>
                   <!-- This will be port on which the marshall loader port runs on.  -->
                   <!-- <attribute name="loaderport" isParam="true">4447</attribute> -->
                   <!-- The following are specific to socket invoker -->
                   <!-- <attribute name="numAcceptThreads">1</attribute>-->
                   <!-- <attribute name="maxPoolSize">303</attribute>-->
                   <!-- <attribute name="clientMaxPoolSize" isParam="true">304</attribute>-->
                   <!-- <attribute name="timeout" isParam="true">60000</attribute> -->
                   <attribute name="serverBindAddress">${jboss.bind.address}</attribute>
                   <attribute name="serverBindPort">4446</attribute>
                   <!-- <attribute name="clientConnectAddress"></attribute> -->
                   <!-- <attribute name="clientConnectPort">7777</attribute> -->
                   <attribute name="enableTcpNoDelay" isParam="true">true</attribute>
                   <attribute name="serverSocketFactory">jboss.remoting:service=ServerSocketFactory,type=SSL</attribute>
                   <attribute name="useAllSocketFactoryParams" isParam="true">true</attribute>
                   <attribute name="socketFactoryClassName" isParam="true"></attribute>
                <!-- At least one handler is required by the connector.  If have more than one, must decalre -->
                <!-- different subsystem values.  Otherwise, all invocations will be routed to the only one -->
                <!-- that is declared. -->
                   <!-- can also specify handler by fully qualified classname -->
                   <handler subsystem="invoker">jboss:service=invoker,type=unified</handler>

    Note the addition of useAllSocketFactoryParams and socketFactoryClassName attributes.


    WebService Example:




    A JaasSecurityDomain Example:

    For EAP 4.x (MBean):
    <mbean code="" name=",domain=ldaps">
        <arg type="java.lang.String" value="ldaps"/>
      <attribute name="KeyStoreURL">localhost.keystore</attribute>
      <attribute name="KeyStoreAlias">ldaps</attribute>
      <attribute name="KeyStorePass">changeit</attribute>
      <attribute name="TrustStoreURL">localhost.truststore</attribute>
      <attribute name="TrustStorePass">changeit</attribute>


    For AS 5.x (JBoss Bean):
    <bean name="JaasSecurityDomain:ldaps" class="">
      <property name="keyStoreURL">localhost.keystore</property>
      <property name="keyStoreAlias">ldaps</property>
      <property name="keyStorePass">changeit</property>
      <property name="trustStoreURL">localhost.truststore</property>
      <property name="trustStorePass">changeit</property>
      <!-- introduce a JMX annotation to export this bean as an MBean -->


    Additional Info:

    If you require more than one SSLSocketFactory (with different JaasSecurityDomain configurations) you will need to extend JaasSecurityDomainSocketFactory so that each one uses a different system property:

    package my.package;
    public class MySocketFactory extends JaasSecurityDomainSocketFactory
        * Override to set a different system property name
       protected String getSystemPropertyName()
          return "";
        * Must have a static getDefault method
       public static SocketFactory getDefault()
          return new MySocketFactory();