Reading Time: 3 minutes

Jasypt is an open source Java library which provides basic encryption capabilities using a high-level API. This library can be used with Mule to avoid clear text passwords for connectors and endpoints.First, download the latest Jasypt distribution, unpack it and copy icu4j and jasypt jars to MULE_HOME/lib/user directory.

latest report
Learn why we are the Leaders in API management and iPaaS

Then add the following snippet to your Mule config file:

Could not embed GitHub Gist 1016673: API rate limit exceeded for 87.250.177.137. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)

Next, you will need to encrypt your passwords using Jasypt command line tools. For example,  if your Mule application connects to the MySql database using password “dbpassword”, encrypt it using the following command:

Could not embed GitHub Gist 1303264: API rate limit exceeded for 87.250.177.137. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)

Where MyEncryptionPassword is your encryption key.  This command will produce the following output:

ka56rcI0bDpUWoAhy5Y+PrVvqu/wMCnL

Now create a properties file that will list your encrypted passwords and place it in your project src/main/resources directory, e.g. credentials.properties:

Could not embed GitHub Gist 1016697: API rate limit exceeded for 87.250.177.137. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)

Note the ENC() around our encrypted password, this is a que for Jasypt that it is dealing with an encrypted value.

Add the name of this file to the list of locations in the propertyConfigurer bean. Now you can use the property name in your data source configuration:

Could not embed GitHub Gist 1016705: API rate limit exceeded for 87.250.177.137. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)

Finally, create a system variable with the same name as the value of the passwordEnvName property in the first snippet, e.g. MULE_ENCRYPTION_PASSWORD and set its value to the encryption key used for the encrypting your password, e.g.:

Could not embed GitHub Gist 1303266: API rate limit exceeded for 87.250.177.137. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)

Thats it. You can now encrypt all passwords or any other values and Mule can read them and it starts up.