然后就找到了调用getLicense方法的jS类(名字很奇怪,因为是混淆过的原因,jS类反编译后的源码附在最后面了)
这个类中很明确地显示了License的获取方法。
首先是:jreble.lic文件,用winrar打开jrebel.jar就看到这个文件了。
从源码来看,UserLicense是用ObjectInputStream通过ReadObject得到了。
然后,属性license里面其实是一个Map,用ObjectInputStream从ByteArrayInputSteam中通过ReadObject得到。于是写了下面这样的测试代码
1package temp.jrebel;
2
3import java.io.BufferedInputStream;
4import java.io.BufferedOutputStream;
5import java.io.ByteArrayInputStream;
6import java.io.ByteArrayOutputStream;
7import java.io.File;
8import java.io.FileInputStream;
9import java.io.FileOutputStream;
10import java.io.IOException;
11import java.io.ObjectInputStream;
12import java.io.ObjectOutputStream;
13import java.util.Calendar;
14import java.util.GregorianCalendar;
15import java.util.Iterator;
16import java.util.Map;
17import junit.framework.Assert;
18import org.junit.Test;
19import com.zeroturnaround.licensing.UserLicense;
20
21public class ParseLicense {
22 @Test
23 public void parseLicenseFile() {
24 Object localObject1 = null;
25 try {
26 System.out.println("start to get lic file.");
27 File localFile2 = new File("d:\\temp\\jrebel.lic");
28 Assert.assertNotNull(localFile2);
29
30 System.out.println("start to get objectInputStream.");
31 localObject1 = new ObjectInputStream(new BufferedInputStream(
32 new FileInputStream(localFile2)));
33 Assert.assertNotNull(localObject1);
34
35 System.out.println("start to get userLicense.");
36 UserLicense localUserLicense1 = (UserLicense)((ObjectInputStream)localObject1).readObject();
37 Assert.assertNotNull(localUserLicense1);
38
39 System.out.println("start to get ObjectInputStream2.");
40 ObjectInputStream localObjectInputStream = new ObjectInputStream(new ByteArrayInputStream(localUserLicense1.getLicense()));
41 Assert.assertNotNull(localObjectInputStream);
42
43 System.out.println("start to get localMap.");
44 Map localMap = (Map)localObjectInputStream.readObject();
45 Assert.assertNotNull(localMap);
46
47 System.out.println("start tot output value.");
48 for ( Iterator<?> iter = localMap.keySet().iterator(); iter.hasNext(); ) {
49 String key = (String)iter.next();
50 System.out.println("key: " + key + ", value: " + localMap.get(key));
51 }
52
53 } catch (Exception e) {
54 e.printStackTrace();
55 Assert.fail("faile to parse license. ");
56 } finally {
57 if (localObject1 != null) {
58 try {
59 ((ObjectInputStream) localObject1).close();
60 } catch (IOException localIOException12) {
61 }
62 }
63 }
64
65 }
66}
67
68