-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathtestLicense.java
More file actions
71 lines (54 loc) · 2.14 KB
/
Copy pathtestLicense.java
File metadata and controls
71 lines (54 loc) · 2.14 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
package common;
/*
* Date: 11-8-11
*/
import gudusoft.gsqlparser.EDbVendor;
//import gudusoft.gsqlparser.crypto.*;
import gudusoft.gsqlparser.TGSqlParser;
import junit.framework.TestCase;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class testLicense extends TestCase {
public void test1(){
TGSqlParser sqlparser = new TGSqlParser(EDbVendor.dbvoracle);
sqlparser.sqltext = "SELECT * from dual;";
int i = sqlparser.parse();
assertTrue(sqlparser.parse() == 0);
// if (i == 0){
// System.out.println("username: "+sqlparser.getUserName());
// System.out.println("machineid: "+sqlparser.getMachineId());
// }else{
// System.out.println("error message:"+sqlparser.getErrormessage());
// }
}
public void test2(){
//HardwareBinder hb = new HardwareBinder();
// hb.setUseHwAddress();
// System.out.print("license system not test for machine id:"+hb.getMachineIdString());
//assertTrue(hb.getMachineIdString().equalsIgnoreCase("516c1e52-cc5b-37ef-81c8-08d8fc2dee9e"));
}
public void testMd5hash(){
boolean ignoreMachineId = false;
byte[] bytesOfMessage=null;
String username = "james wang";
String machineid = "516c1e52-cc5b-37ef-81c8-08d8fc2dee9e";
String teststr = "I love sql pretty printer, yeah!"+username.toLowerCase();
if(!ignoreMachineId){
teststr += machineid.toLowerCase();
}
try {
bytesOfMessage = teststr.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
MessageDigest md = null;
try {
md = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
byte[] digest = md.digest(bytesOfMessage);
//System.out.println(HardwareBinder.getHex(digest));
}
}