Creating Time-Limited (Trial) Java Applications with Stringer Java Obfuscator

Using 2.1.5 (and higher) version of Stringer Java Obfuscator you might easilly create time-limited/trial versions of your applications/libraries. This approach also works for subscriptions.

How does it work?


A new parameter has been added in 2.1.5 version of Stringer Java Obfuscator - trialExpirationTime. Its value points to the end of working period of an application. By default, the value is to be set in seconds (unix time/Epoch), but you could use a date pattern via trialExpirationTimePattern parameter (syntax is similar to SimpleDateFormat class).

Here is an example of using the option in CLI:

    java -jar stringer.jar -configFile mycfg.xml -trialExpirationTimestamp 1462359651 original.jar trial.jar

Example for Ant:

        <stringer srcFile="${dist}/HelloWorld.jar"
                  destFile="${dist}/HelloWorld.jar"
                  verbose="true"
                  checkCaller="true"
                  resourceEncryption="true"
                  integrityProtection="true"
                  optimize="true"
                  trialExpirationTimestamp="${trial.period.ts}"
                  trialExpirationTimestampPattern="yyyyMMdd"
        >

Example for Maven:

          <plugin>            
                <groupId>com.licel</groupId>
                <artifactId>stringer-maven-plugin</artifactId>
                <version>2.1.5</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>stringer</goal>
                        </goals>
                        <configuration>  
                            <verbose>true</verbose>
                            <checkCaller>true</checkCaller>
                            <resourceEncryption>true</resourceEncryption>   
                            <includes>
                                <include>test/**</include>
                            </includes>
                            <excludes>
                                <exclude>exclude/**</exclude>
                            </excludes>
                            <trialExpirationTimestamp>${trial.period.ts}</trialExpirationTimestamp>
                            <trialExpirationTimestampPattern>yyyyMMdd</trialExpirationTimestampPattern>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Notes:

  1. In order to check that the expiration time is set correctly, please find a line in verbose log that looks like: trialExpirationTimestamp: 1462359651(05/04/2016 @ 11:00am (UTC))

  2. Stringer Java Obfuscator should be set to protect your application with use of String Encryption (at least). We strongly recommend to use Integrity Protection, as well.

  3. Using Maven/Ant you might easilly generate a needed timestamp, and then use it to protect your applications, thus you have right trial/subscription versions for your customers.

Here is a task for Ant:

<tstamp> 
    <format property="trial.period.ts" pattern="yyyyMMdd" offset="+1" unit="month"/>
</tstamp>

This task creates trial.period.ts property with the value of +1 month from the current date.

For Maven you could use nl.fizzit.maven.plugins:maven-tstamp-plugin:

<plugin>
  <groupId>nl.fizzit.maven.plugins</groupId>
  <artifactId>maven-tstamp-plugin</artifactId>
  <version>1.0</version>
    <executions>
      <execution>
        <goals>
          <goal>export</goal>
        </goals>
        <configuration>
          <formats>
            <format>
              <property>trial.period.ts</property>
              <pattern>yyyyMMdd</pattern>
              <offset>+1</offset>
              <unit>month</unit>
            </format>
          </formats>
        </configuration>
      </execution>
    </executions>
</plugin>

Do not forget that those tasks should be performed before calling Stringer Java Obfuscator.

In the next part we will tell you how to make a zero-cost licensing mechanism with use of Stringer Java Obfuscator and a few dozens of lines of Java code.

Stay tuned!