This tool embed watermark phrase into Java class file. However, this technique is very fragile. The man who know class file structure or modifying class file tool can break the watermark very easy. Additionally, optimizer or obfuscator may remove watermark.
Thus, I believe that you wish practical watermarking tool, use jmark.
Sorry, api documents are only Japanese.
I describe that how embedding watermark below.
First, swt search attribute_info which named WATERMARK.
If swt cannot found it, then it add Constant_Utf8 entry into Constantpool which value is WATERMARK.
Second, swt encrypt data by given key, and create attribute_info which body is encryption data.
Then, insert attribute_info into class file, and dump one.
By the way, this attribute_info's tag is -1 because this tool use
org.apache.bcel.classfile.Unknown class in BCEL.
First, swt search attribute_info which named WATERMARK.
If swt cannot found one, that class file has no watermark phrase.
So swt will be exit.
swt extract byte array from attribute_info, and decrypt one by given key, and
display decrypt data to standard output.
attribute_info structure is below.
watermark_attribute_info{
u2 attribute_name_index;
u4 attribute_length;
u1 info[attribute_length];
}
License is GNU GPL(GNU General Public License).
link about GPL
from GPL FAQ.
Q. In an object-oriented language such as Java, if I use a class that is GPL'ed without modifying, and subclass it, in what way does the GPL affect the larger program?
A. Subclassing is creating a derivative work. Therefore, the terms of the GPL affect the whole program where you create a subclass of a GPL'ed class.
Java 2 SDK 1.4 or higher. If you use lower than version 1.4, then you must install JCE.
swt.Below explanation is very very simple, and I do not explain more detail. You must understand this explanation which is minimal.
If you do not accept above things, use Java 2 SKD 1.4 or higher.
First, you download jce
and extract one.
Second, copy jce1.x.x/lib/*.jar to $JAVA_HOME/jre/lib/ext.
Add below one line to $JAVA_HOME/jre/lib/security/java.security.
security.provider.3=com.sun.crypto.provider.SunJCE
above 3 is small number with no overlapping.
Now complete installing.
untar swt-x.x.x.tar.gz.
$ gzip -cd swt-x.x.x.tar.gz | tar xvf -
Then, it apear swt-x.x.x directory.
use script on swt-x.x.x/bin directory.
<code>swt</code><code>addProvider</code>
I create Apache Ant Task that enable embedding watermark. This task cannot extract watermark phrase.
Example
<taskdef name="watermark"
classname="com.oikaze.tama.swt.WatermarkTask"
classpathref="project.class.path"
/>
<mkdir dir="${watermark.test}" />
<watermark destdir="${watermark.test}"
data="Copyright(C) by Haruaki TAMADA"
key="watermark test key"
basedir="${build.bin}">
<include name="**/*.class" />
<exclude name="**/*Test.class" />
</watermark>
Attributes
| Attribute | Description | Required |
|---|---|---|
data |
watermark data. | Yes |
baseDir |
search class file base directory | No. Default value is project basedir |
destDir |
output directory | Yes |
key |
encryption key | Yes |
algorithm |
encryption algorithm. Default value is "PBEWithMD5AndDES" |
No |
provider |
JCE provider name. Default value is SunJCE |
No |
iteration |
iteration count of PBE. Default value is 20 | No |
lastModifiedCheck |
Check the last modified time of target class file. This task do not output if destination file is newer. | No |
| Contents |
|---|
| Link |
| Contents |
| Link |