15.3. EJB3 RMI + SSL Configuration
Procedure 15.4. Configure RMI + SSL for EJB3 Overview
- Generate encryption keys and certificate
- Configure a secure remote connector for RMI
- Annotate EJB3 beans to use the secure RMI connector
The file ejb3-connectors-jboss-beans.xml
in a JBoss Application Server profile deploy
directory contains JBoss Remoting connector definitions for EJB3 remote method invocation.
Example 15.2. Sample Secure EJB3 Connector
ejb3-connectors-jboss-beans.xml
file. Both beans are required to configure a secure connector for EJB3 using the key pair created in Procedure 15.1, “Generate a new key pair and add it to the key store "localhost.keystore" in the conf
directory.”.
keyPassword
property in the sample configuration is the key pair password specified when the key pair was created.
<bean name="EJB3SSLRemotingConnector" class="org.jboss.remoting.transport.Connector"> <property name="invokerLocator">sslsocket://${jboss.bind.address}:3843</property> <property name="serverConfiguration"> <inject bean="ServerConfiguration" /> </property> <property name="serverSocketFactory"> <inject bean="sslServerSocketFactory" /> </property> </bean> <bean name="sslServerSocketFactory" class="org.jboss.security.ssl.DomainServerSocketFactory"> <constructor> <parameter><inject bean="EJB3SSLDomain"/></parameter> </constructor> </bean> <bean name="EJB3SSLDomain" class="org.jboss.security.plugins.JaasSecurityDomain"> <constructor> <parameter>EJB3SSLDomain</parameter> </constructor> <property name="keyStoreURL">resource:localhost.keystore</property> <property name="keyStorePass">KEYSTORE_PASSWORD</property> </bean>
Note
localhost.keystore
) may contain multiple key pairs. The EJB connector will use the key pair with the defined keyAlias (ejb-ssl
).
All EJB3 beans use the unsecured RMI connector by default. To enable remote invocation of a bean via SSL, annotate the bean with @org.jboss.annotation.ejb.RemoteBinding
.
Example 15.3. EJB3 bean annotation to enable secure remote invocation
StatefulSSL
. The proxy implementing the remote interface, returned to a client when the bean is requested from JNDI, communicates with the server via SSL.
@RemoteBinding(clientBindUrl="sslsocket://0.0.0.0:3843", jndiBinding="StatefulSSL") @Remote(BusinessInterface.class) public class StatefulBean implements BusinessInterface { ... }
Note
You can enable both secure and insecure remote method invocation of the same EJB3 bean. Example 15.4, “EJB3 Bean annotation for secure and unsecured invocation” demonstrates the annotations to do this.
Example 15.4. EJB3 Bean annotation for secure and unsecured invocation
@RemoteBindings({ @RemoteBinding(clientBindUrl="sslsocket://0.0.0.0:3843", jndiBinding="StatefulSSL") @RemoteBinding(jndiBinding="StatefulNormal") }) @Remote(BusinessInterface.class) public class StatefulBean implements BusinessInterface { ... }
Note
0.0.0.0
, meaning "all interfaces". Change this to the value of the ${jboss.bind.address} system property.
StatefulNormal
from JNDI, the returned proxy implementing the remote interface communicates with the server via the unencrypted socket protocol; and if StatefulSSL
is requested, the returned proxy implementing the remote interface communicates with the server via SSL.