Step 1 - Basic Library Obfuscation

Files located in the tutorial/step1/files directory:
mousegestures-1.2.jarMouse Gestures library jar
test.jarJar with mouse gestures demo frame
RunAllatori.batRuns Allatori Obfuscator
MouseGesturesOriginal.batRuns original version of the Mouse Gestures
MouseGesturesObfuscated.batRuns obfuscated version of the Mouse Gestures
config.xmlAllatori configuration file
Clean.batDeletes generated files


In the first step we will obfuscate Mouse Gestures as a typical library - all public API methods should not be renamed. This guarantees that all applications that have used the original jars could use the obfuscated jars. This is a common situation when you develop a library that will be used in third party products.

Running RunAllatori.bat will result in creating 3 files: obf-mousegestures-1.2.jar and obf-test.jar are obfuscated versions of the Mouse Gestures jars, log.xml is log file created during obfuscation process.

Now you can run MouseGesturesOriginal.bat and MouseGesturesObfuscated.bat to test the original and obfuscated versions of the application. Note that obfuscated version displays System.out's that wouldn't be added by the registered version of the Allatori Obfuscator.

Let's look at the config.xml. Here it is:

<config>
    <jars>
        <jar in="test.jar" out="obf-test.jar"/>
        <jar in="mousegestures-1.2.jar" out="obf-mousegestures-1.2.jar"/>
    </jars>

    <keep-names>
        <class access="protected+"/>
        <field access="protected+"/>
        <method access="protected+"/>
    </keep-names>

    <property name="log-file" value="log.xml"/>
</config>

The jars section defines input and output jar files. If you use the same file name for in and out attributes than the jar will be overwritten with its obfuscated version.

The keep-names section defines class, method and field names that should not be renamed. As we obfuscate a library we expose all externally visible classes, fields and methods by setting access attribute to protected+. It means that everything with visibility 'protected' and higher ('public') will have their names unchanged.

log-file property defines the name of the log file. It can be removed from the configuration if you don't need a log of the obfuscation process. An example when log file is needed can be found in the Step 8.

Clean.bat removes obf-mousegestures-1.2.jar, obf-test.jar and log.xml files.

Step 2       Contents