How to secure properties before deployment in Anypoint Studio

secure properties
Developer Relations
10 min read

In the previous article, we learned how to configure an HTTPS endpoint in Anypoint Studio. In this tutorial, we are going to learn how to create a secure properties file. This properties file is where you will want to insert information such as private keys, client enforcement tokens, or other bits of information that you will want to reuse in multiple places in your project. When your Mule flows start to become long and robust, having all of your variables in a properties file will allow you to only change values in one place without having to modify every instance of that value throughout your project.

Create your file

Whenever you are storing global variables, unique tokens or keys, or login credentials, you should always store them in a file. Storing all of your variables in a single file will help keep your project organized, and if you ever need to make a change to an existing system or migrate the integration, you won’t have to make any manual modifications to your existing code.

To create a file, right-click on src/main/resources and click on New -> File and name the file Make sure you save the file in your src/main/resources folder.

screenshot1screenshot 2local properties

Now that you have successfully created the file, double click on your file to add a new entry. Every line on your file can be used for a unique property.

Add the properties:

After you have entered your private credentials into the file, the next step is to search Exchange for the Mule Secure Configuration Properties extension.

mule secure configuration

Once you import your Mule Secure Configuration Properties extension, go to the Global Configuration Elements screen. Click the Create button and add a new Global Property. For the name, type: secure.key and for the Value: WhateverKeyYouWant. For this example, we used MuleSoft as the key which is what we will use to encrypt the contents of our file.

secure key

Next, click the Create button again and create a Secure Properties Configuration. Under File, type the file name where your properties are stored. Under key, type: ${secure.key} which matches the value under the Global Property Configuration.

secure properties config mulesoft
Setting up the Salesforce Connector with secure credentials

Create your flow by dragging an HTTP Listener into the scene. Then important the Salesforce connector and add the Create component to the flow. Select the type to be: Lead and for the dataweave code:

anypoint studio

When you configure your Salesforce Connector configuration, enter your secure properties as follows:


These are the same values that you defined in your file. You can use this dollar sign and curly brace notation throughout your MuleSoft Anypoint Studio project in order to access variables from your file.

salesforce secure credentials
Encrypting your values

Next, open up your file with the Mule Properties Editor.

mule properties editor

In the table editor, double click on your Salesforce Username. Currently, your username is in plain text. We are going to need to encrypt these values using the Mule Properties Editor. Click the Encrypt button.

your email encrypted

Select the same algorithm that you selected when you created your Global Properties file, in the case blowfish. For the Key, make sure the key you enter matches the one you entered in your Global Property configuration. In the case of this tutorial, we entered: MuleSoft.

blow fish
How to deploy with your secure credentials

It’s important that before you deploy your application to CloudHub, that you add your secure.key value to your deployment properties. Currently, all of the contents of your file are encrypted. In order for your mule application to decrypt those credentials, you will need to pass the key you defined on deployment.

secure properties

Remember, this credential will be accessible to anyone who has access to your Anypoint Platform Account. If you want your properties hidden on CloudHub, you will need to update your mule-artifact.json in your mule application. To view instructions on how to do this, please visit the MuleSoft documentation located here.

Congratulations on securing your properties before Deployment

Nice job completing this tutorial and learning how to create a secure properties file that you can use to reference important variables in your Mule application. If you found this tutorial helpful, please give it a rating below.

Try Anypoint Platform for free

Start free trial

Already have an account? Sign in.

Related tutorials