DZone
Integration Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Integration Zone > Configure, Secure, and Access Mule Application Properties

Configure, Secure, and Access Mule Application Properties

This article will help you to use Mule application properties in a secure way. Here's how to create and access Mule properties.

Karan Gupta user avatar by
Karan Gupta
·
Mar. 25, 22 · Integration Zone · Tutorial
Like (3)
Save
Tweet
2.13K Views

Join the DZone community and get the full member experience.

Join For Free

In this article, you will see a different way in which we can configure and secure Mule application properties.

Creating and Accessing Mule Properties

Let's start with directly configuring the properties in the connector. Here we are simply hardcoding the value in the configuration section. Let's see this in a Database connector configuration as an example.

Database Config

Setting Values Without Properties File

This is not the right way to do it as the data will be different for different environments (DEV, QA, and PROD). To avoid this we will create a properties file and get data from there.

Properties files can be created in two ways: .yaml and .properties. We will see it in both ways.

The .yaml file follows a parent-child structure, so we need to take care of indentation while defining the properties. Let's see it with an example.

We will create a .yaml file in the Mule project inside src/main/resources. Screenshot of .yaml file

*.yaml File

To make use of this .yaml file, we need to create configuration properties in the Global element and set the configuration file path. Once this is done we can use ${dbConnection.<<name>>} to set the properties variable in connection configuration.

Configuration properties screenshot

Configuration Properties

Screenshot of Database Config


Note: To make this dynamic, i.e. to pick data of dev when code is deployed in dev or QA when code is deployed in QA, define an argument env and pass it as a runtime variable, eg. -Denv=dev.Configuration properties

Get Properties File Based on env

If you want to use .properties file you need to define data as below in the configuration file. To refer to these properties, we will use the same pattern ${dbConnection.<<name>>} as we did for .yaml file.

*.properties File

Till now, we were defining property files within our mule project, but what if you need to refer to properties files kept at different file locations. Let us see how we can achieve this. 

For this, we need to create global properties and set the path where our file is kept as below.Global property

Setting Up Property File Path

Now create a configuration property and use this path to fetch the properties file. Once this is done, the rest of the process is the same as how to use those properties as shown above.Configuration properties screenshot

Another way to access the properties is by using the p function. For this, enable the fx function and then use #[Mule::p('<property name')] syntax to access the properties. Accessing other properties

Securing Mule Properties

As seen above, we are using plain text for a password value which is not ideal. Now we will see how we can encrypt the password and use it in a secure way.

For this, first download secure-properties-tool.jar which we will be used to encrypt/decrypt any data that we want to consume in a secure manner.

Once done, we need to go to the required download path and open the command prompt in that location. Below is the syntax to do encrypt or decrypt text strings.

 
java -cp secure-properties-tool.jar com.mulesoft.tools.SecurePropertiesTool \
<method> \
<operation> \
<algorithm> \
<mode> \
<key> \
<value> \
--use-random-iv [optional]

We will now encrypt our password using the above syntax. We are using the AES algorithm to encrypt the password. Here is the list of supported algorithm and modes .Encrypting password

To configure secure properties it needs to be enclosed in ![] , and to access it, the syntax is ${secure::<propertyName>} as shown below.

Storing Secure Properties


Accessing Secure Properties

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Top ALM Tools and Solutions Providers
  • Understanding Kubernetes Resource Types
  • MongoDB vs. DynamoDB Head-to-Head: Which Should You Choose?
  • How to Build a Simple CLI With Oclif

Comments

Integration Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo