PreEmptive logo

Protecting Java Applications That Use Spring Framework Core

DashO protects applications that use Spring Framework Core. Spring can be configured using custom annotations or XML configuration files, and DashO supports both. However, applications that use custom annotations require additional handling.

If you use XML configuration files, the DashO Wizard will read them and automatically configure Renameable entry points for any Spring Bean classes it encounters. It will then rename the corresponding XML to match the new bean name assigned to the class. It will do the same for the bean’s properties. 

For example, here is a Spring bean called HelloWorld, which the DashO Wizard has automatically configured as a special Spring bean entry point:

EntryPoints

During the build, DashO renames the class to “a” and its “message” property to “a.” It also updates the Spring XML definitions to match:

In the above scenario, no additional DashO configuration was required after the initial setup wizard.

We can still apply obfuscation to the class files when configuring via annotations, but the Wizard will not automatically identify the Spring Beans. For example, if I run the DashO Wizard on the Spring annotated jar file without any other DashO configuration, I receive an error when running the obfuscated jar:

RuntimeError

This is because DashO’s Removal feature removed the call to getHelloWorld. After all, it was not called directly from the main method entry point. However, the getHelloWorld method has the @Bean Annotation, which returns the bean to be managed by Spring context. 

To prevent this, I added an exclude rule to the Removal exclusions for the getHelloWorld() method.

Finally, from the Removal tab, I need to confirm that “Visible Annotations” has not been checked. This ensures that the @Configuration and @Bean Spring annotations do not get Removed.

There are many ways to configure Spring, and I have presented just two simple examples. However, the main concept is the same for all the ways of doing it: DashO can automatically configure more features when you use Spring’s XML features, but even if you don’t, your projects can still be processed by configuring a few simple settings. 

You can download the example projects here.

If you have any feedback on this topic or other topics you would like us to discuss in the Support Corner, please contact us.

In This Article:

Try a Free Trial of PreEmptive Today!