Chapter 7. Securing Your System
7.1. Securing Your JBoss Enterprise SOA Platform Installation
The JBoss Enterprise SOA Platform can be made secure, in the sense that you can configure the product so that services will only be executed if caller authentication succeeds and said caller possesses the correct permissions. The default security implementation is based on JAAS.
- through a gateway
- directly via the ServiceInvoker.
UsernameToken
or the BinarySecurityToken
from the SOAP header's security element.
7.2. Java Authentication and Authorization Service (JAAS)
7.3. JaasSecurityService
7.4. Secure Your System
Procedure 7.1. Task
vi SOA_ROOT/jboss-as/server/PROFILE/deployers/esb.deployer/jbossesb-properties.xml
.
- Scroll down to the section that contains properties name="security" and edit the settings to suit your system:
<properties name="security"> <property name="org.jboss.soa.esb.services.security.implementationClass" value="org.jboss.internal.soa.esb.services.security.JaasSecurityService"/> <property name="org.jboss.soa.esb.services.security.callbackHandler" value= "org.jboss.internal.soa.esb.services.security.UserPassCallbackHandler"/> <property name="org.jboss.soa.esb.services.security.sealAlgorithm" value="TripleDES"/> <property name="org.jboss.soa.esb.services.security.sealKeySize" value="168"/> <property name="org.jboss.soa.esb.services.security.contextTimeout" value="30000"/> <property name= "org.jboss.soa.esb.services.security.contextPropagatorImplemtationClass" value= "org.jboss.internal.soa.esb.services.security.JBossASContextPropagator"/> <property name="org.jboss.soa.esb.services.security.publicKeystore" value="/publicKeyStore"/> <property name="org.jboss.soa.esb.services.security.publicKeystorePassword" value="testKeystorePassword"/> <property name="org.jboss.soa.esb.services.security.publicKeyAlias" value="testAlias"/> <property name="org.jboss.soa.esb.services.security.publicKeyPassword" value="testPassword"/> <property name="org.jboss.soa.esb.services.security.publicKeyTransformation" value="RSA/ECB/PKCS1Padding"/> </properties>
- Save the file and exit.
- Open the log-in configuration file in your text editor:
vi SOA_ROOT/server/PROFILE/conf/login-config.xml
- Configure the JAAS log-in modules by editing the settings in this file. (You can use either a pre-configured option or create your own custom solution.)
- Save the file and exit.
7.5. Create an Encrypted Password File
Procedure 7.2. Task
- Go to the
conf
directory:cd SOA_ROOT/jboss-as/server/PROFILE/conf
- Execute this command:
java -cp ../../../lib/jbosssx.jar org.jboss.security.plugins.FilePassword welcometojboss 13 testpass esb.password
An encrypted password file is created.
7.6. Encryption Options
Option | Description |
---|---|
Salt |
This is the "salt" used to encrypt the password file. (In the example above, it is the
welcometojboss string .)
|
Iteration |
This is the number of iterations. (In the example above, it is the number
13 .)
|
Password File Name |
This is the name of the file where the encrypted password will be saved. In the example above, it is the
esb.password string.
|
testpass |
This is the test password.
|
7.7. Clear-Text Password
7.8. Password Mask
7.9. Masking Passwords
Passwords are secret authentication tokens that are used to limit access to resources to authorized parties only. For a JBoss services to access password-protected resources, the password must obviously be made available to it.
Important
7.10. Mask a Clear-Text Password
Important
jboss-keystore_pass.dat
file and repeat the procedure. Be aware that if you change the key store any masked passwords that were previously generated will no longer function.
Procedure 7.3. Task
- Generate a key pair using this command:
keytool -genkey -alias jboss -keyalg RSA -keysize 1024 -keystore password.keystore
and follow the prompts:keytool -genkey -alias jboss -keyalg RSA -keysize 1024 -keystore password.keystore Enter keystore password: Re-enter new password: What is your first and last name? [Unknown]: Bob Bobson What is the name of your organizational unit? [Unknown]: Corporate_IT What is the name of your organization? [Unknown]: XYZ What is the name of your City or Locality? [Unknown]: BRISBANE What is the name of your State or Province? [Unknown]: QLD What is the two-letter country code for this unit? [Unknown]: AU Is CN=Bob Bobson, OU=Corporate_IT, O=XYZ, L=BRISBANE, ST=QLD, C=AU correct? [no]: yes Enter key password for jboss (RETURN if same as keystore password):
Note
You must specify the same password for the key store and key pair. - Run
chown
to change ownership to the JBoss Application Server process owner, andchmod 600 password.keystore
to make sure only the file's owner can read it.Note
The process owner should not have console log-in access. In that case you will be performing these operations as another user. Creating masked passwords requires read access to the key store, so you may wish to complete configuration of masked passwords before restricting the key store file permissions. - Navigate to the
jboss-as/bin
directory:cd SOA_ROOT/jboss-as/bin
- Run the password tool, using the command
./password_tool.sh
on Red Hat Enterprise Linux systems, (orpassword_tool.bat
on Microsoft Windows-based systems.) - Select
0: Encrypt Keystore Password
by pressing 0, then Enter. - Enter the key store password you specified above.
- Enter a random string of characters to aid with encryption strength. This is the salt.
- Enter a whole number for the iterator count to aid with encryption strength.
- Select
5: Exit
to exit.Note
The password tool will exit with the message:Keystore is null. Cannot store.
This is normal. - Use the
chown
command to change ownership of thepassword/jboss_keystore_pass.dat
file to the process owner, andchmod 600 jboss-keystore_pass.dat
to ensure that only that owner can read the file. - Navigate to the
jboss-as/bin
directory:cd SOA_ROOT/jboss-as/bin
- Run the password tool, using the command
./password_tool.sh
on Red Hat Enterprise Linux systems (orpassword_tool.bat
on Microsoft Windows systems). - Select
1: Specify KeyStore
by pressing 1 then Enter. - Enter the path to the key store you created above. (You can specify an absolute path, or the path relative to
SOA_ROOT/jboss-as/bin
. This should beSOA_ROOT/jboss-as/bin/password.keystore
, unless you have changed the defaults.) - Enter the key alias. This should be "jboss" (unless you have performed an advanced installation and changed the defaults).
- Select
2: Create Password
by pressing 2, then Enter. You will be prompted for the security domain. Follow the prompts on screen./password_tool.sh ********************************** **** JBoss Password Tool******** ********************************** Error while trying to load data:Encrypted password file not located Maybe it does not exist and need to be created. 0: Encrypt Keystore Password 1:Specify KeyStore 2:Create Password 3: Remove a domain 4:Enquire Domain 5:Exit 1 Enter Keystore location including the file name password.keystore Enter Keystore alias jboss 0: Encrypt Keystore Password 1:Specify KeyStore 2:Create Password 3: Remove a domain 4:Enquire Domain 5:Exit 2 Enter security domain: default Enter passwd: passwordmask Password created for domain:default 0: Encrypt Keystore Password 1:Specify KeyStore 2:Create Password 3: Remove a domain 4:Enquire Domain 5:Exit
- Enter a name for the password mask. This is an arbitrary unique name that you will use to identify the password mask in configuration files.
- Enter the password that you wish to mask.
- Repeat the password mask creation process to create masks for all passwords you wish to mask.
- Exit the program by choosing
5: Exit
- Navigate to the
password
directory:cd SOA_ROOT/jboss-as/bin/password
7.11. Replace a Clear Text Password with its Password Mask
Prerequisites
- Pre-existing password masks
Procedure 7.4. Task
- Launch a text editor and replace each occurrence of a clear text password in the configuration files with an annotation referencing its mask.This is the general form of the annotation:
<annotation> @org.jboss.security.integration.password.Password(securityDomain=MASK_NAME, methodName=setPROPERTY_NAME) </annotation>
As a concrete example, the JBoss Messaging password is stored in the server profile'sdeploy/messaging/messaging-jboss-beans.xml
file. If you create a password mask named "messaging", then the before and after snippet of the configuration file will looks like this:<property name="suckerPassword"> CHANGE ME!! </property>
<annotation> @org.jboss.security.integration.password.Password(securityDomain=messaging, methodName=setSuckerPassword) </annotation>
7.12. Change the Default Password Mask Settings
SOA_ROOT/jboss-as/bin/password/password.keystore
, and the key alias "jboss". If you store the key pair used for password masking elsewhere, or under a different alias, you will need to update the server profiles with the new location or key alias.
Procedure 7.5. Task
- Open the security configuration file in a text editor:
vi SOA_ROOT/jboss-as/server/PROFILE/deploy/security/security-jboss-beans.xml
. - Edit the key store location and key alias. Here are some example settings:
<!-- Password Mask Management Bean--> <bean name="JBossSecurityPasswordMaskManagement" class="org.jboss.security.integration.password.PasswordMaskManagement" > <property name="keyStoreLocation">password/password.keystore</property> <property name="keyStoreAlias">jboss</property> <property name="passwordEncryptedFileName">password/jboss_password_enc.dat</property> <property name="keyStorePasswordEncryptedFileName">password/jboss_keystore_pass.dat</property> </bean>
- Save the file and exit.
7.13. Global Configuration File Security Settings
Property | Description | Required? |
---|---|---|
org.jboss.soa.esb.services.security.implementationClass |
This is the "concrete"SecurityService implementation that should be used. The default setting is
JaasSecurityService .
|
Yes
|
org.jboss.soa.esb.services.security.callbackHandler |
This is a default
CallbackHandler implementation, utilized when a JAAS-based SecurityService is employed. See “Customizing Security” for more information about the CallbackHandler property.
|
No
|
org.jboss.soa.esb.services.security.sealAlgorithm |
This is the algorithm to use when "sealing" the
SecurityContext .
|
No
|
org.jboss.soa.esb.services.security.sealKeySize |
This is the size of the secret/symmetric key used to encrypt/decrypt the
SecurityContext .
|
No
|
org.jboss.soa.esb.services.security.contextTimeout |
This is the amount of time (in milliseconds) for which a security context is valid. A global setting, this may be over-ridden on a per-service basis. To do so, specify the property of the same name that exists on the security element in the
jboss-esb.xml file.
|
No
|
org.jboss.soa.esb.services.security.contextPropagatorImplementationClass |
Use this to configure a global
SecurityContextPropagator . (For more details on the SecurityContextPropagator , please refer to the section on “Advanced Security Options”.)
|
No
|
org.jboss.soa.esb.services.security.publicKeystore |
This is the Keystore which holds the keys used to encrypt and decrypt that data which is external to the Enterprise Service Bus. The Keystore is used to encrypt the
AuthenticationRequest .
|
No
|
org.jboss.soa.esb.services.security.publicKeystorePassword |
This is the password for the public keystore.
|
No
|
org.jboss.soa.esb.services.security.publicKeyAlias |
This is the alias to use for the public key.
|
No
|
org.jboss.soa.esb.services.security.publicKeyPassword |
This is the password for the alias if one was specified upon creation.
|
No
|
org.jboss.soa.esb.services.security.publicKeyPassword |
This is a cipher transformation. It is in this format:
algorithm/mode/padding . If this is not specified, the "keys" algorithm will be used by default.
|
No
|
7.14. Key Pair
7.15. Keystore
SOA_ROOT/jboss-as/samples/quickstarts/security_cert/keystore
. Do not use this in a production environment. It is provided as an example only.
7.16. JBoss Rules and Security
Important
7.17. Enable Serialization on the Server
Procedure 7.6. Task
- Navigate to the SOA_ROOT directory:
cd SOA_ROOT
. - Run the
keytool
command and follow the prompts on screen:keytool -genkey -alias droolsKey -keyalg RSA -keystore MyDroolsPrivateKeyStore.keystore Enter keystore password: Re-enter new password: What is your first and last name? [Unknown]: Test User What is the name of your organizational unit? [Unknown]: HR What is the name of your organization? [Unknown]: Test Org What is the name of your City or Locality? [Unknown]: Brisbane What is the name of your State or Province? [Unknown]: QLD What is the two-letter country code for this unit? [Unknown]: AU Is CN=Test User, OU=HR, O=Test Org, L=Brisbane, ST=QLD, C=AU correct? [no]: yes Enter key password for droolsKey (RETURN if same as keystore password): Re-enter new password:
After answering all of the questions, a password-protected file namedMyDroolsPrivateKeyStore.keystore
is created. This keystore file has a private key called droolsKey with the password "drools". Store this file in a safe location in your environment, which will hereafter be referred to as thekeystoredir
.Important
The passwords above are examples only and should not be used in production. - Open the configuration file:
vi jboss-as/server/default/deploy/properties-service.xml
- Configure the JBoss Enterprise SOA Platform to use the JBoss Rules serialization feature by adding this snippet to
properties-service.xml
:<mbean code="org.jboss.varia.property.SystemPropertiesService" name="jboss:type=Service,name=SystemProperties"> <attribute name="Properties"> # Drools Security Serialization specific properties drools.serialization.sign=true drools.serialization.private.keyStoreURL=file://$keystoredir/MyDroolsPrivateKeyStore.keystore drools.serialization.private.keyStorePwd=drools drools.serialization.private.keyAlias=droolsKey drools.serialization.private.keyPwd=drools </attribute> </mbean>
- Set the drools.serialization.sign property to "true":
drools.serialization.sign=true
- drools.serialization.private.keyStoreURL=<RL> is the URL of the private keystore location.
- In the example above, replace
keystoredir
andMyDroolsKeyStore.keystore
with your keystore directory and the name of the keystore you created with the keytool - drools.serialization.private.keyStorePwd=<password> is the password to access the private keystore.
- drools.serialization.private.keyAlias=<key> is the key alias (identifier) of the private key.
- drools.serialization.private.keyPwd=<password> is the private key password.
- Save the file and exit.
- Restart the server instance.
Warning
If the system properties were not configured properly, you will see this error when you try to build a rules package:An error occurred building the package. Error signing object store: Key store with private key not configured. Please configure it properly before using signed serialization
7.18. Enable Serialization on the Client
Prerequisites
- Server serialization must already be enabled.
Procedure 7.7. Task
- Create a public key certificate from the private keystore. (You can access the keytool by running
keytool -genkey -alias droolsKey -keyalg RSA -keystore
.):keytool -export -alias droolsKey -file droolsKey.crt -keystore
MyDroolsPrivateKeyStore.keystore Enter keystore password: Certificate stored in file <droolsKey.crtU>
- Import the public key certificate into a public keystore. (This is where it will be used by your client applications):
keytool -import -alias droolsKey -file droolsKey.crt -keystore
MyPublicDroolsKeyStore.keystore Enter keystore password: Re-enter new password: Owner: CN=Test User, OU=Dev, O=XYZ Corporation, L=Brisbane, ST=QLD, C=AU Issuer: CN=Test User, OU=Dev, O=XYZ Corporation, L=Brisbane, ST=QLD, C=AU Serial number: 4ca0021b Valid from: Sun Sep 26 22:31:55 EDT 2010 until: Sat Dec 25 21:31:55 EST 2010 Certificate fingerprints: MD5: 31:1D:1B:98:59:CC:0E:3C:3F:57:01:C2:FE:F2:6D:C9 SHA1: 4C:26:52:CA:0A:92:CC:7A:86:04:50:53:80:94:2A:4F:82:6F:53:AD Signature algorithm name: SHA1withRSA Version: 3 Trust this certificate? [no]: yes Certificate was added to keystore
- Open the server configuration file:
vi grep drools jboss-as/server/default/deploy/properties-service.xml
- Replace keystoredir and MyPublicDroolsKeyStore.keystore with your keystore directory, and the name of the public keystore you created previously:
# Drools Client Properties for Security Serialization drools.serialization.public.keyStoreURL=file://$keystoredir/MyPublicDroolsKeyStore.keystore drools.serialization.public.keyStorePwd=drools
- Save the file and exit.
- Restart the JBoss Enterprise SOA Platform server.
- For Java client applications, set the system properties in your code like this:
// Set the client properties to deserialize the signed packages URL clientKeyStoreURL = getClass().getResource( "MyPublicDroolsKeyStore.keystore" ); System.setProperty( KeyStoreHelper.PROP_SIGN, "true" ); System.setProperty( KeyStoreHelper.PROP_PUB_KS_URL, clientKeyStoreURL.toExternalForm() ); System.setProperty( KeyStoreHelper.PROP_PUB_KS_PWD, "drools" ); ...
Alternatively, open therun.sh
shell script (vi SOA_ROOT/jboss-as/bin/run.sh
) script and edit the JAVA_OPTS section:# Serialization Security Settings JAVA_OPTS="-Ddrools.serialization.sign=true $JAVA_OPTS" JAVA_OPTS="-Ddrools.serialization.private.keyStoreURL=file://$keystoredir/MyDroolsKeyStore.keystore $JAVA_OPTS" JAVA_OPTS="-Ddrools.serialization.private.keyStorePwd=drools $JAVA_OPTS" JAVA_OPTS="-Ddrools.serialization.private.keyAlias=droolsKey $JAVA_OPTS" JAVA_OPTS="-Ddrools.serialization.private.keyPwd=drools $JAVA_OPTS" JAVA_OPTS="-Ddrools.serialization.public.keyStoreURL=file://$keystoredir/MyPublicDroolsKeyStore.keystore $JAVA_OPTS" JAVA_OPTS="-Ddrools.serialization.public.keyStorePwd=drools $JAVA_OPTS"
Replace the values shown above with ones specific to your environment, and then restart the server instance.
7.19. Disable Serialization Signing
- Open the configuration file:
vi SOA_ROOT/jboss-as/server/PROFILE/deploy/properties-service.xml
. - Remove the drools.serialization.sign property's value.
- Save the file and exit.An alternative way to do this task is to open the
run.sh
shell script (vi SOA_ROOT/jboss-as/bin/run.sh
) and edit it as follows:JAVA_OPTS="-Ddrools.serialization.sign=false $JAVA_OPTS"
- Restart the server instance.
- To turn signing off for Java client applications, remove the drools.serialization.sign property or add the following snippet to each application's code:
System.setProperty( KeyStoreHelper.PROP_SIGN, "false" );
7.20. Configure Security on a Per-Service Basis
- Open the global configuration file in a text editor:
vi SOA_ROOT/jboss-as/server/PROFILE/deployers/esb.deployer/jboss-esb.xml
. - Scroll down to the service you want to configure.
- Add a security element. This setting shows you how to do so:
<service category="Security" name="SimpleListenerSecured"> <security moduleName="messaging" runAs="adminRole" rolesAllowed="adminRole, normalUsers" callbackHandler="org.jboss.internal.soa.esb.services.security.UserPassCallbackHandler"> <property name="property1" value="value1"/> <property name="property2" value="value2"/> </security> ... </service>
- Save the file and exit.
7.21. Per-Service Security Properties
Property | Description | Required? |
---|---|---|
moduleName |
This is a module that exists in the
SOA_ROOT/jboss-as/server/PROFILE/conf/login-config.xml file.
| No |
runAs |
This is the runAs role.
| No |
rolesAllowed |
This is an comma-separated list of those roles that have been granted the ability to execute the service. This is used as a check that is performed after a caller has been authenticated, in order to verify that they are indeed belonging to one of the roles specified. The roles will have been assigned after a successful authentication by the underlying security mechanism.
| No |
callbackHandler |
This is the
CallbackHandler that will override that which was defined in the jbossesb-properties.xml file.
| No |
property |
These are optional properties that, once defined, will be made available to the
CallbackHandler implementation.
| No |
7.22. Override Global Security Settings
Procedure 7.8. Task
- Open the global configuration file in a text editor:
vi SOA_ROOT/jboss-as/server/PROFILE/deployers/esb.deployer/jbossesb-properties.xml
. - Configure the setting in question. Here is an example:
<security moduleName="messaging" runAs="adminRole" rolesAllowed="adminRole"> <property name="org.jboss.soa.esb.services.security.contextTimeout" value="50000"/> <property name= "org.jboss.soa.esb.services.security.contextPropagatorImplementationClass" value="org.xyz.CustomSecurityContextPropagator" /> </security>
- Save the file and exit.
7.23. Security Property Overrides
Property | Description | Required? |
---|---|---|
org.jboss.soa.esb.services.security.contextTimeout |
This property lets the service override the global security context time-out (milliseconds) that is specified in the
jbossesb-properties.xml file.
| No |
org.jboss.soa.esb.services.security.contextPropagatorImplementationClass |
This property lets the service to override the "global security context propagator" class implementation, that is specified in the
jbossesb-properties.xml file.
| No |
7.24. Security Context
7.25. Authentication Request
7.26. SecurityConfig
SecurityConfig
class grants access to the security configuration specified in the jboss-esb.xml
file. This class is made available to the Callback Handler.
7.27. Add an Authentication Class to a Message Object
Procedure 7.9. Task
- Execute this code:
byte[] encrypted = PublicCryptoUtil.INSTANCE.encrypt((Serializable) authRequest); message.getContext.setContext(SecurityService.AUTH_REQUEST, encrypted);
The authentication context is encrypted and then set within the message context. (It is later decrypted by the Enterprise Service Bus so that it can authenticate the request.)
7.28. security_basic Quick Start
SOA_ROOT/jboss-as/samples/quickstarts/security_basic
quick start demonstrates how to prepare the security on a message before you use the SecurityInvoker. The quick start also demonstrates how to configure the jbossesb-properties.xml
global configuration file for use by client services.
7.29. Set a Time Limit for the Security Context Globally
Procedure 7.10. Task
- Open the global configuration file in a text editor:
vi SOA_ROOT/jboss-as/server/PROFILE/deployers/esb.deployer/jbossesb-properties.xml
. - Scroll down to the section that contains security.contextTimeout. Set the time-out value (in milliseconds).
- Save the file and exit.
7.30. Set a Time Limit for the Security Context on a Per-Service Basis
Procedure 7.11. Task
- Open the service's configuration file in a text editor:
vi jboss-esb.xml
. - Scroll down to the section that contains Security Context. Set the time-out value (in milliseconds).
- Save the file and exit.