Step 1 - Basic Library Obfuscation

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


In the first step we will obfuscate Mouse Gestures as a typical library, i.e. all public API methods should not be renamed. This guarantees that all applications, which are using the original Mouse Gestures jars, could use the obfuscated jars. It is a common situation when you are developing a library which is used in third party products.

Running RunAllatori.bat results in creating 3 files: obf-mousegestures-1.2.jar and obf-test.jar are obfuscated versions of the Mouse Gestures jars, log.xml is a 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 demo version of Allatori adds System.out's to the obfuscated application.

Let's look at the config.xml:

<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+"/>
        </class>
    </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, then 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