6.5. Datasource Security

6.5.1. About Datasource Security

Datasource security refers to encrypting or obscuring passwords for datasource connections. These passwords can be stored in plain text in configuration files, however this represents a security risk.
The preferred solution for datasource security is the use of either security domains or password vaults. Examples of each are included below. For more information, refer to the Security Architecture and other JBoss EAP security documentation.

Example 6.13. Security Domain Example

 <security-domain name="DsRealm" cache-type="default">  
    <login-module code="ConfiguredIdentity" flag="required">  
      <module-option name="userName" value="sa"/>  
      <module-option name="principal" value="sa"/>  
      <module-option name="password" value="sa"/>  
The DsRealm domain is referenced by a datasource like so:
  <datasource jndi-name="java:jboss/datasources/securityDs"
      <new-connection-sql>select current_user()</new-connection-sql>


If a security domain will be used with multiple datasources, then caching should be disabled on the security domain. This can be accomplished by setting the value of the cache-type attribute to none or by removing the attribute altogether. However, if caching is desired, then a separate security domain should be used for each datasource.

Example 6.14. Password Vault Example