Protect Tomcat Web App

Video Tutorial

Protect Tomcat App

Get Started

If you haven't read the get started article, please read it first, it described the basic structure and concepts of Protector4J.

GUI Tool

Execute protector4j-ui[.exe] in the folder of Protector4J, you will see the interface below

Login

If you have got the license, you can click the login button on the top-right corner and type your account information. Although, without the license, you can still try this tool too.

Choose app type

Click the "Tomcat Application" button on the app types page.

Choose war/jar files to protect

Choose the war/jar files to protect, you can add single or multi war/jar files here.

Options

Protect all classes

if this option is selected, all the classes will be encrypted during the task

Protect the specified classes

If this option is selected, you can choose which classes to encrypt in the next step

Protect inner jars

If this option is checked, the classes in the inner jars will be encrypted too.

Choose classes to protect

If you selected "Protect the specified classes" in the previous step, you will see this page. On this page, you can choose the classes that you want to be encrypted.

Output options

On this page, you can specify the Java version, the Tomcat version, the output folder and target platforms. After this is done, click the "Next" button on the bottom, it will start the encryption process.

Encryption process

It will take some time to finish the encryption process. After it is done, you can check the result in the output folder.

Check the result

After the encryption process complete, please go to the output folder to check the result. There is a tomcat folder with the web apps and the custom java runtime in it.

Run the encrypted app

Please go to the tomcat's bin directory, and use the startup.sh or startup.bat shell script to launch it.

On Linux and macOS

./startup.sh

On Windows

startup.bat

Every encryption task will request a new and unique key. The files that are been encrypted in different task can not be used together.

Create Windows Service

If you need to create the windows service, please refer here

CLI Tool

The configuration of task file

It needs to specify a task file as an argument to the command-line tool.

Please find the task.tomcat.yml in the task-templates directory, copy and modify a new one.

email: ''
password: ''
jarsPath: []
protectAll: false
protectInnerJars: false
classesToProtect: []
outputFolder: ''
tempFolder: ''
javaVersion: ''
tomcatVersion: ''
includeJavaFX: false
targetPlatforms: []

The account information

If you have purchased this tool, you would have got your account information including the email address and the password for the license. Please type them in the appropriate fields, the value of the password field should be the md5 value of the password, not the password itself. or you can leave the email and the password fields empty, just have a try.

email: account-email
password: md5-of-password

Specify the jars and the classes need to be encrypted.

jarsPath

The jarsPath field is an array, which you could specify one or multi jar/war files that need to be processed in the encryption work.

jarsPath: [jar-path1,jar-path2,...]

or

jarsPath:
- jar-path1
- jar-path2

protectAll

If this value is true, all the classes in the jar will be encrypted.

protectInnerJars

If this value is true, the classes in the inner jars will be encrypted too.

classesToProtect

In this field, you can specify the classes that need to be encrypted. it can be a full class name, or wildcard case ones

if the classes are in the WEB-INF/classes folder, please add WEB-INF.classes prefix for each item

classesToProtect: [WEB-INF.classes.vlinx.test.TestClass1, WEB-INF.classes.vlinx.test.pack1.*, WEB-INF.classes.vlinx.test.pack1.**]

or

classesToProtect:
- WEB-INF.classes.vlinx.test.TestClass1
- WEB-INF.classes.vlinx.test.pack1.*
- WEB-INF.classes.vlinx.test.pack1.**

* means all the classes in the package, but exclude the classes in the sub package

** means all the classes in the package including the classes in the sub package.

If the protectAll is true, this field will be ignored.

javaVersion

The java versions supported now are Java 8 and Java 11, you can type "java-8" for Java 8 and type "java-11" for Java 11

tomcatVersion

The tomcat versions supported now are Tomcat 8.5 and Tomcat 9.0. You can type "tomcat-8.5" for Tomcat 8.5, "tomcat-9" for Tomcat 9.0

tempFolder

The temp folder for the files generated during the encryption process, after the task completed, the files in the temp folder will be cleaned.

outputFolder

The encrypted app and the custom Java runtime will be placed into the output folder.

includeJavaFX

Whether include the JavaFX framework

targetPlatforms

This field is an array, the available values are [linux64, win64, mac, linux32, win32], you can set one or multi target platforms according to the requirement.

On windows, currently only supports win64 and win32 as the target platforms.

targetPlatforms: [linux64, win64, mac, linux32, win32]

or

targetPlatforms:
- linux64
- win64
- mac
- linux32
- win32

Execute the encryption process

Go the folder of Protector4J and execute the command below to run the encryption process

On Linux or macOS

./protector4j -t tomcat -f path-of-task-file

On Windows

protector4j -t tomcat -f path-of-task-file

-t task type

-f task file

You can execute protector4j --help to see the detail arguments.

Check the result

After the encryption process complete, please go to the output folder to check the result. There is a tomcat folder with the web apps and the custom java runtime in it.

Run the encrypted app

Please go to the tomcat's bin directory, and use the startup.sh or startup.bat to launch it.

For Linux and macOS

./startup.sh

For Windows

startup.bat

Every encryption task will request a new and unique key. The files that are been encrypted in different task can not be used together.

Create Windows Service

If you need to create the windows service, please refer here

Create Windows Service

Create service

There is a "create-service.bat" script in tomcat/bin folder, if you need to create the windows service, just cd to the tomcat/bin folder then execute

create-service.bat your-service-name

Please execute this script as Administrator, it will create a Windows service then start it

Delete service

If you need to delete the service, cd to tomcat/bin folder too, then execute

delete-service.bat your-service-name

this script should run with Administrator too