-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpoc_verify.java
More file actions
72 lines (66 loc) · 4.09 KB
/
Copy pathpoc_verify.java
File metadata and controls
72 lines (66 loc) · 4.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package poc_lisence3j;
import javax0.license3j.License;
import javax0.license3j.io.IOFormat;
import javax0.license3j.io.LicenseReader;
import java.io.IOException;
import java.util.Date;
import static org.apache.log4j.helpers.LogLog.error;
import static sun.misc.Version.println;
public class poc_verify {
public static void main(String[] args) {
License license = new License();
try {
license= new LicenseReader("license.base64")
.read(IOFormat.BASE64);
} catch (IOException e) {
error("Error reading license file " + e);
}
// encode the public key into your application
// (you can copy paste this from License3jRepl after key generation, see later)
byte [] digest = new byte[] {
(byte)0x81,
(byte)0x54, (byte)0xE0, (byte)0x7C, (byte)0x8D, (byte)0x27, (byte)0x68, (byte)0x12, (byte)0x07,
(byte)0x39, (byte)0x4E, (byte)0xA4, (byte)0x9A, (byte)0x47, (byte)0x7D, (byte)0x57, (byte)0x45,
(byte)0xDF, (byte)0xB0, (byte)0xAB, (byte)0x6C, (byte)0xD1, (byte)0x08, (byte)0x77, (byte)0x1D,
(byte)0xD8, (byte)0x21, (byte)0x2D, (byte)0x38, (byte)0x99, (byte)0xD2, (byte)0x6D, (byte)0x18,
(byte)0x25, (byte)0x9B, (byte)0x23, (byte)0x51, (byte)0x7A, (byte)0xC2, (byte)0xA8, (byte)0xCB,
(byte)0x92, (byte)0x88, (byte)0x1F, (byte)0x3C, (byte)0x8C, (byte)0x7F, (byte)0x4C, (byte)0x8B,
(byte)0x96, (byte)0x92, (byte)0xB1, (byte)0x7B, (byte)0xE3, (byte)0xBD, (byte)0x51, (byte)0x59,
(byte)0x05, (byte)0xDB, (byte)0xFE, (byte)0x6F, (byte)0x8F, (byte)0x47, (byte)0x30,
};
byte [] key = new byte[] {
(byte)0x52,
(byte)0x53, (byte)0x41, (byte)0x00, (byte)0x30, (byte)0x81, (byte)0x9F, (byte)0x30, (byte)0x0D,
(byte)0x06, (byte)0x09, (byte)0x2A, (byte)0x86, (byte)0x48, (byte)0x86, (byte)0xF7, (byte)0x0D,
(byte)0x01, (byte)0x01, (byte)0x01, (byte)0x05, (byte)0x00, (byte)0x03, (byte)0x81, (byte)0x8D,
(byte)0x00, (byte)0x30, (byte)0x81, (byte)0x89, (byte)0x02, (byte)0x81, (byte)0x81, (byte)0x00,
(byte)0x9A, (byte)0x40, (byte)0x9E, (byte)0x4B, (byte)0x8B, (byte)0x52, (byte)0x2C, (byte)0x49,
(byte)0xDB, (byte)0xD0, (byte)0x9D, (byte)0xA5, (byte)0x6E, (byte)0xFB, (byte)0xF7, (byte)0x76,
(byte)0xF2, (byte)0x07, (byte)0x4E, (byte)0xAA, (byte)0x16, (byte)0x10, (byte)0x00, (byte)0x0B,
(byte)0xA2, (byte)0x99, (byte)0x52, (byte)0xBE, (byte)0x5F, (byte)0xE7, (byte)0x00, (byte)0x05,
(byte)0x02, (byte)0x32, (byte)0x43, (byte)0x42, (byte)0xEB, (byte)0x3E, (byte)0xE1, (byte)0xF8,
(byte)0x4A, (byte)0xD7, (byte)0x01, (byte)0x05, (byte)0xD2, (byte)0xC8, (byte)0xDE, (byte)0x46,
(byte)0x69, (byte)0x3B, (byte)0x85, (byte)0x16, (byte)0xC8, (byte)0x30, (byte)0x3B, (byte)0x88,
(byte)0x85, (byte)0xC0, (byte)0xBB, (byte)0xC7, (byte)0x60, (byte)0x9F, (byte)0x4F, (byte)0x9C,
(byte)0x89, (byte)0xA9, (byte)0xC7, (byte)0xFB, (byte)0x2D, (byte)0xB5, (byte)0xF9, (byte)0x98,
(byte)0xCF, (byte)0x52, (byte)0x36, (byte)0xA9, (byte)0xF7, (byte)0x63, (byte)0x82, (byte)0x3A,
(byte)0xF7, (byte)0x38, (byte)0x8B, (byte)0xA7, (byte)0xB7, (byte)0x97, (byte)0x6A, (byte)0x05,
(byte)0x84, (byte)0xDD, (byte)0x18, (byte)0x2C, (byte)0x9A, (byte)0x39, (byte)0x83, (byte)0x3A,
(byte)0xAB, (byte)0xA4, (byte)0x83, (byte)0x26, (byte)0xBE, (byte)0xF6, (byte)0xE7, (byte)0x58,
(byte)0xDC, (byte)0x2E, (byte)0xE5, (byte)0xB2, (byte)0xD4, (byte)0x43, (byte)0x72, (byte)0xA9,
(byte)0xC6, (byte)0xE7, (byte)0x16, (byte)0xDC, (byte)0xA5, (byte)0x71, (byte)0x11, (byte)0x9B,
(byte)0x70, (byte)0x1D, (byte)0xA2, (byte)0x8E, (byte)0xEE, (byte)0x9E, (byte)0x78, (byte)0x2D,
(byte)0x02, (byte)0x03, (byte)0x01, (byte)0x00, (byte)0x01,
};
// check that the license is signed properly
if( !license.isOK(key) ){
// if not signed, stop the application
error("Lisence not signed");
return;
}
// get a feature and from the feature type specific data, like date, int, long, String...
System.out.println("Validated!");
int user_no = license.get("ownerno").getInt();
System.out.println("Extracted feature user number:" + user_no );
}
}