By default, the JAAS login modules store passwords in plaintext format. Although you can (and should) protect such data by setting file permissions appropriately, you can provide additional protection to passwords by storing them in an obscured format (using a message digest algorithm).
Fuse ESB Enterprise provides a set of options for enabling password encryption, which can be combined with any of the JAAS login modules (except for the public key login module, where it is not needed).
![]() | Important |
|---|---|
Although message digest algorithms are not easy to crack, they are not invulnerable to attack (for example, see the Wikipedia article on cryptographic hash functions). Always use file permissions to protect files containing passwords, in addition to using password encryption. |
Password encryption for JAAS login modules can optionally be enabled by setting the following login module properties:
encryption.enabledSet to
true, to enable password encryption.encryption.nameName of the encryption service, which has been registered as an OSGi service.
encryption.prefixPrefix for encrypted passwords.
encryption.suffixSuffix for encrypted passwords.
encryption.algorithmSpecifies the name of the encryption algorithm—for example,
MD5orSHA-1. You can specify one of the following encryption algorithms:MD2MD5SHA-1SHA-256SHA-384SHA-512
encryption.encodingEncrypted passwords encoding:
hexadecimalorbase64.encryption.providerName(Jasypt only)Name of the
java.security.Providerinstance that is to provide the digest algorithm.encryption.providerClassName(Jasypt only)Class name of the security provider that is to provide the digest algorithm
encryption.iterations(Jasypt only)Number of times to apply the hash function recursively.
encryption.saltSizeBytes(Jasypt only)Size of the salt used to compute the digest.
encryption.saltGeneratorClassName(Jasypt only)Class name of the salt generator.
role.policySpecifies the policy for identifying role principals. Can have the values,
prefixorgroup.role.discriminatorSpecifies the discriminator value to be used by the role policy.
An encryption service can be defined by inheriting from the
org.apache.karaf.jaas.modules.EncryptionService interface and exporting an
instance of the encryption service as an OSGi service. Two alternative implementations of
the encryption service are provided:
The basic encryption service is installed in the standalone container by default and you
can reference it by setting the encryption.name property to the value,
basic. In the basic encryption service, the message digest algorithms are
provided by the SUN security provider (the default security provider in the Oracle JDK).
The Jasypt encryption service can be installed in the standalone container by installing
the jasypt-encryption feature. For example, you can install Jasypt encryption
by entering the following console command:
karaf@root> features:install jasypt-encryption
This command installs the requisite Jasypt bundles and exports Jasypt encryption as an
OSGi service, so that it is available for use by JAAS login modules. To access the Jasypt
encryption service, set the encryption.name property to the value,
jasypt.
For more information about Jasypt encryption, see the Jasypt documentation.
Assuming that you have already installed the jasypt-encryption feature, you
could deploy a properties login module with Jasypt encryption using the following Blueprint
configuration:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:jaas="http://karaf.apache.org/xmlns/jaas/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">
<type-converters>
<bean class="org.apache.karaf.jaas.modules.properties.PropertiesConverter"/>
</type-converters>
<!-- Allow usage of System properties, especially the karaf.base property -->
<ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]"/>
<jaas:config name="karaf" rank="2">
<jaas:module className="org.apache.karaf.jaas.modules.properties.PropertiesLoginModule"
flags="required">
users = $[karaf.base]/etc/users.properties
encryption.enabled = true
encryption.name = jasypt
encryption.algorithm = SHA-256
encryption.encoding = base64
encryption.iterations = 100000
encryption.saltSizeBytes = 16
</jaas:module>
</jaas:config>
<!-- The Backing Engine Factory Service for the PropertiesLoginModule -->
<service interface="org.apache.karaf.jaas.modules.BackingEngineFactory">
<bean class="org.apache.karaf.jaas.modules.properties.PropertiesBackingEngineFactory"/>
</service>
</blueprint>





![[Important]](imagesdb/important.gif)


