Encrypted password in datasource for JBoss7

1) Replace user-name and password with security-domain in datasource configuration:

JBOSS_HOME/standalone/configuration/standalone.xml
...
<subsystem xmlns="urn:jboss:domain:datasources:1.0">
  <datasources>
    ...
    <datasource jta="true" jndi-name="java:/xdsDS" pool-name="xds_pool" enabled="true" use-java-context="true" use-ccm="true">
       ...
       <security>
          <!-- <user-name>pacs</user-name> -->
          <!-- <password>xxx</password> -->
          <security-domain>encrypted-ds</security-domain>
       </security>
    ...
    </datasource>
    ...
  </datasources>
...

2) Encrypt password:

unix
export CLASSPATH=${JBOSS_HOME}/modules/org/picketbox/main/picketbox-4.0.7.Final.jar:${JBOSS_HOME}/modules/org/jboss/logging/main/jboss-logging-3.1.0.CR2.jar
java  org.picketbox.datasource.security.SecureIdentityLoginModule <password>
windows
set CLASSPATH=%JBOSS_HOME%\modules\org\picketbox\main\picketbox-4.0.7.Final.jar;%JBOSS_HOME%\modules\org\jboss\logging\main\jboss-logging-3.1.0.CR2.jar
java  org.picketbox.datasource.security.SecureIdentityLoginModule <password>

3) Add security-domain in JBOSS_HOME/standalone/configuration/standalone.xml using encrypted password of step 2:

JBOSS_HOME/standalone/configuration/standalone.xml
   ...
   <subsystem xmlns="urn:jboss:domain:security:1.1">
      <security-domains>
      ...
         <security-domain name="encrypted-ds" cache-type="default">
            <authentication>
               <login-module code="org.picketbox.datasource.security.SecureIdentityLoginModule"       flag="required">
                  <module-option name="username" value="pacs"/>
                  <module-option name="password" value="16e0af412f44e943"/>
               </login-module>
            </authentication>
         </security-domain>
      </security-domains>
   </subsystem>
   ...