Wrapping Mule4 — Secure Properties with TornadoFx
Tutorial on how to simplify your secure property creations with TornadoFx.
Join the DZone community and get the full member experience.
Join For FreeIn an earlier article, we discussed how to go about Securing your Mule 4 properties and your feedback was awesome. Everyone was comfortable using the command line, but many of you preferred a more modern point-and-click GUI approach where you didn't have to remember or reference magic incantations.
To that end, I created a GUI wrapper using TornadoFx, giving me the opportunity to learn and build a small but useful application. You'll still need to download the Mule 4 secure-properties-tool.jar dependency (linked in my previous article above). If you would like to download the GUI, you can get the Uber Jar (not the car-hailing company), or the code from my GitHub project page. The Uber Jar will need to be run from the same folder where you downloaded the mule jar as is shown in the code snippet below.
x
# Mule Secure properties Jar and TornadoFx Uber Jar
$ ls
secure-properties-tool.jar
SecureProps-0.0.1.jar
# run the jar
$ java -jar SecureProps-0.0.1.jar
When you run the Uber Jar, the SecureProps EncDec application will start up giving you the opportunity to encode or decode your secrets.

In the Secure Properties GUI select the crypto algorithm and cipher you wish to use.
The password you select is the same Mule will use to decode the properties at startup. Add your secret to the secret field and press Run to generate the encoding.
The default encoding is for insertion in a .properties file. To produce an encoding for a YAML file be sure to click on the checkbox before hitting the Run button.
You can always reverse the process by adding the encoding to the secret field. Just be sure not to include the ![] which wraps the encoding.
Light Backgrounder on TornadoFx
The TornadoFx is a GUI development framework created by Edvin Syse, as a lightweight JavaFx development framework developed in Kotlin.
Probably the main question most of you might have is: how long will it take to learn a new framework start doing building cool UI's using TornadoFx? The answer of course is it depends. It depends on whether you're just starting or have some background in JavaFx, JavaScript, Web development frameworks, and the like.
The good news is that TornadoFx extends on the basic concepts of other UI development frameworks, so if you've have some prior experience and an understanding of MVC patterns you should be in good shape.
To get you started, you can find the code for the Mule Secure properties app in my GitHub repository. The Uber jar is also there if you would just like to use it for securing your Mule 4 properties. While useful, it's still an immature version which doesn't validate any of the parameters you send to the Mule Jar. For example, it will be perfectly happy accepting a password length that's unacceptable to algorithms like AES which require 16 bytes and you might get results like this: "Invalid AES key length: 8 bytes". As long as you conform to the happy path it should work fine and acceptable for a non-production grade demo app.
Let's take a look at some code. To run your application, we'll wrap the JavaFx Stage adds the dimensions for our window, overrides the default application icon with one of our own, and passes our MainView class as our view entry point.
xxxxxxxxxx
class MyApp: App(MainView::class, Styles::class) {
override fun start(stage: Stage) {
with (stage) {
width = 500.0
height = 490.0
}
setStageIcon(Image("images/Favicon.png"))
super.start(stage)
}
}
The MainView and EncDecController fulfills the contractual obligations described by the MVC pattern. The controller runExec method executes's the Mule 4 Secure properties config jar, encoding or decoding our secret, using an asynchronous pattern so that our UI view thread doesn't block. It takes a string as an argument, which we entered manually to the jar when we first reviewed the Mule jar in our last article.
In the MainView.kt you'll find most of our UI controls and layout styles. Though, you will probably want to consolidate and centralize most of your layout definitions in a file like the Styles.kt, which is similar in nature to a styles.css. For a better understanding of how Layouts and Controls work in TornadoFx you'll probably want to review Edvin's TornadoFx guide. To make you even more productive, Edvin has created a TornadoFx plugin for IntelliJ Idea.
To bootstrap your knowledge even faster you might want to consider taking a Udemy course like Paulo Dichone's TornadoFx course.
Whether you're inspired to create your own TornadoFx application or just use one, like this one, I hope you found this an interesting read and that the links help to get you up to speed quickly. As always, I look forward to your feedback and thoughts on improvements.
Opinions expressed by DZone contributors are their own.
Trending
-
Generics in Java and Their Implementation
-
Demystifying SPF Record Limitations
-
Azure Virtual Machines
-
How to LINQ Between Java and SQL With JPAStreamer
Comments