diff --git a/build.gradle b/build.gradle index e0f799c..c7866ef 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ plugins { id 'java' + id 'java-library' id 'application' } @@ -25,19 +26,19 @@ sourceSets { } dependencies { - implementation project(":common") - implementation project(":mockjava") + api project(":common") + api project(":mockjava") implementation 'org.apache.commons:commons-lang3:3.0' implementation 'com.atlassian.commonmark:commonmark:0.17.0' implementation 'com.idealista:format-preserving-encryption:1.0.0' - implementation 'com.squareup.okhttp3:okhttp:4.9.1' - implementation 'com.sun.mail:javax.mail:1.6.2' implementation 'org.apache.commons:commons-math3:3.6.1' implementation 'org.codehaus.groovy:groovy-all:3.0.8' - implementation 'org.jsoup:jsoup:1.14.2' - implementation 'org.apache.httpcomponents:httpclient:4.5.13' - implementation fileTree(dir: 'lib', include: '*.jar') implementation 'io.grpc:grpc-all:1.41.0' + implementation 'org.jsoup:jsoup:1.14.2' + implementation 'com.sun.mail:javax.mail:1.6.2' + implementation 'com.squareup.okhttp3:okhttp:4.9.1' + api fileTree(dir: 'lib', include: '*.jar') + testImplementation 'junit:junit:4.13.2' } diff --git a/lib/doipsdk-v1.0.5.jar b/lib/doipsdk-v1.0.5.jar new file mode 100644 index 0000000..55d2aa1 Binary files /dev/null and b/lib/doipsdk-v1.0.5.jar differ diff --git a/src/main/debugger/org/bdware/sc/debugger/DebugMain.java b/src/main/debugger/org/bdware/sc/debugger/DebugMain.java index 563381e..1739885 100644 --- a/src/main/debugger/org/bdware/sc/debugger/DebugMain.java +++ b/src/main/debugger/org/bdware/sc/debugger/DebugMain.java @@ -32,9 +32,10 @@ public class DebugMain { ContractProcess.instance.handler.setDBInfo(wrap("", config.dbPath), printCallback); ContractProcess.instance.handler.registerMangerPort(wrap("", Integer.valueOf(config.cPort)), printCallback); ContractProcess.instance.handler.setContractBundle(wrap("", config.contract), printCallback); - String urlFormat = ("http://%s/SCIDE/SCManager?action=reconnectAll&owner=%s"); + String urlFormat = ("http://%s/SCIDE/SCManager?action=reconnectPort&owner=%s&port=%d"); - String url = String.format(urlFormat, config.agentHttpAddr, config.pubKey); + String url = String.format(urlFormat, config.agentHttpAddr, + config.pubKey, ContractProcess.instance.server.mainPort.get()); Map resp = HttpUtil.httpGet(url); String data = (String) resp.get("response"); LOGGER.info(JsonUtil.toPrettyJson(JsonUtil.parseStringAsJsonObject(data))); diff --git a/src/main/java/org/bdware/sc/ContractProcess.java b/src/main/java/org/bdware/sc/ContractProcess.java index 38eda38..c0173e9 100644 --- a/src/main/java/org/bdware/sc/ContractProcess.java +++ b/src/main/java/org/bdware/sc/ContractProcess.java @@ -22,7 +22,6 @@ import org.bdware.sc.ContractResult.Status; import org.bdware.sc.bean.*; import org.bdware.sc.boundry.JavaScriptEntry; import org.bdware.sc.boundry.Resources; -import org.bdware.sc.boundry.utils.FileUtil; import org.bdware.sc.boundry.utils.RocksDBUtil; import org.bdware.sc.boundry.utils.UtilRegistry; import org.bdware.sc.compiler.YJSCompiler; @@ -35,6 +34,7 @@ import org.bdware.sc.handler.ContractHandler; import org.bdware.sc.index.TimeSerialIndex; import org.bdware.sc.node.*; import org.bdware.sc.trace.ProgramPointCounter; +import org.bdware.sc.util.FileUtil; import org.bdware.sc.util.HashUtil; import org.bdware.sc.util.JsonUtil; import org.objectweb.asm.ClassReader; @@ -522,7 +522,7 @@ public class ContractProcess { LOGGER.debug("result: " + retStr); return retStr; } else { - contract.setScript(FileUtil.getContent(zipPath)); + contract.setScript(FileUtil.getFileContent(zipPath)); return setContract(contract); } diff --git a/src/main/java/org/bdware/sc/blockdb/Constants.java b/src/main/java/org/bdware/sc/blockdb/Constants.java deleted file mode 100644 index 90f6abb..0000000 --- a/src/main/java/org/bdware/sc/blockdb/Constants.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.bdware.sc.blockdb; - -public class Constants { - public static final int ELASTIC_DB = 0; -} diff --git a/src/main/java/org/bdware/sc/blockdb/DBRepository.java b/src/main/java/org/bdware/sc/blockdb/DBRepository.java deleted file mode 100644 index 221e0d8..0000000 --- a/src/main/java/org/bdware/sc/blockdb/DBRepository.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.bdware.sc.blockdb; - -import org.bdware.sc.commParser.BDLedger.Transaction; - -import java.util.Map; - -public interface DBRepository { - public String Get(Map condition);//get hash of transaction - public boolean Put(Transaction trans);//put transaction into databases - public boolean Delete(String hash);//delete transaction - public boolean Create_DB();//createDB - public boolean Open_DB(); //OpenDB -} \ No newline at end of file diff --git a/src/main/java/org/bdware/sc/blockdb/DBUtil.java b/src/main/java/org/bdware/sc/blockdb/DBUtil.java deleted file mode 100644 index 7cca7ca..0000000 --- a/src/main/java/org/bdware/sc/blockdb/DBUtil.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.bdware.sc.blockdb; - -public class DBUtil { - private static DBRepository instance = null; - - public static DBRepository getInstance(int type) { - if (null == instance && type == Constants.ELASTIC_DB) { - instance = new ElasticDBUtil(); - } - return instance; - } -} diff --git a/src/main/java/org/bdware/sc/blockdb/ElasticDBUtil.java b/src/main/java/org/bdware/sc/blockdb/ElasticDBUtil.java deleted file mode 100644 index bf82f54..0000000 --- a/src/main/java/org/bdware/sc/blockdb/ElasticDBUtil.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.bdware.sc.blockdb; - -import okhttp3.*; -import org.bdware.sc.commParser.BDLedger.Transaction; -import org.bdware.sc.util.JsonUtil; - -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class ElasticDBUtil implements DBRepository { - public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); - public OkHttpClient client = new OkHttpClient(); - public List transactions = new ArrayList<>(); - public int bulk = 10000; - - @Override - public String Get(Map condition) { - // TODO Auto-generated method stub - Map map = new HashMap<>(); - Map map1 = new HashMap<>(); - Map map2 = new HashMap<>(); - map2.put("data", condition.get("data") + "*"); - map1.put("wildcard", map2); - map.put("query", map1); - String json = JsonUtil.toJson(map); - RequestBody requestbody = FormBody.create(json, JSON); - Request request = new Request.Builder().url("http://127.0.0.1:9200/transaction/_doc/_search").post(requestbody).build(); - try { - Response resp = client.newCall(request).execute(); - System.out.print(resp.body().string()); - resp.body().close(); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return json; - } - - @Override - public boolean Put(Transaction trans) { - // TODO Auto-generated method stub - transactions.add(trans); - if (transactions.size() == bulk) { - StringBuilder sb = new StringBuilder(); - try { - for (int i = 0; i < bulk; i++) { - sb - .append("{\"index\":{}}\n{\"data\":\"") - .append(new String(transactions.get(i).data, StandardCharsets.UTF_8)) - .append("\",") - .append("\"hash\":") - .append("\"") - .append(new String(transactions.get(i).hash, StandardCharsets.UTF_8)) - .append("\"") - .append("}") - .append("\n"); - } - //System.out.println(sb.toString()); - RequestBody requestbody = FormBody.create(sb.toString(), JSON); - Request request = new Request.Builder().url("http://127.0.0.1:9200/transaction/_doc/_bulk").post(requestbody).build(); - Response res1 = client.newCall(request).execute(); - boolean res = res1.isSuccessful(); - res1.body().close(); - System.out.println(res); - transactions.clear(); - return res; - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - return false; - } - - @Override - public boolean Delete(String hash) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean Create_DB() { - // TODO Auto-generated method stub - RequestBody body = RequestBody.create("", JSON); - Request request = new Request.Builder().url("http://127.0.0.1:9200/transaction/").put(body).build(); - try { - Response response = client.newCall(request).execute(); - boolean res = response.isSuccessful(); - response.body().close(); - return res; - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return false; - } - - @Override - public boolean Open_DB() { - // TODO Auto-generated method stub - return false; - } -} diff --git a/src/main/java/org/bdware/sc/blockdb/MongoDBUtil.java b/src/main/java/org/bdware/sc/blockdb/MongoDBUtil.java deleted file mode 100644 index eaf752c..0000000 --- a/src/main/java/org/bdware/sc/blockdb/MongoDBUtil.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.bdware.sc.blockdb; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -public class MongoDBUtil { - public static Object connect(String url, int port, String dbName, String usrName, String pwd) { - try { - Class serverAddr = Class.forName("com.mongodb.ServerAddress"); - Constructor cons = serverAddr.getConstructor(String.class, Integer.TYPE); - Object serverAddress = cons.newInstance(url, port); - List addrs = new ArrayList<>(); - addrs.add(serverAddress); - Method createeScramSha1 = - Class.forName("com.mongodb.MongoCredential") - .getDeclaredMethod( - "createScramSha1Credential", - String.class, - String.class, - char[].class); - Object credential = createeScramSha1.invoke(null, usrName, dbName, pwd.toCharArray()); - List credentials = new ArrayList<>(); - credentials.add(credential); - Constructor mongoClient = - Class.forName("com.mongodb.MongoClient").getConstructor(List.class, List.class); - Object client = mongoClient.newInstance(addrs, credentials); - // 通过连接认证获取MongoDB连接 - return client; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } -} diff --git a/src/main/java/org/bdware/sc/blockdb/RocksDBUtil.java b/src/main/java/org/bdware/sc/blockdb/RocksDBUtil.java deleted file mode 100644 index 9740a7b..0000000 --- a/src/main/java/org/bdware/sc/blockdb/RocksDBUtil.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.bdware.sc.blockdb; - -import org.bdware.sc.commParser.BDLedger.Transaction; -import org.rocksdb.Options; -import org.rocksdb.RocksDB; -import org.rocksdb.RocksDBException; - -import java.io.File; -import java.util.Map; - -public class RocksDBUtil implements DBRepository{ - private static RocksDB rocksdb; - static { - RocksDB.loadLibrary(); - } - - public static RocksDB loadDB(String path, String readOnly) { - try { - Options options = new Options(); - options.setCreateIfMissing(true); - RocksDB rocksDB; - File lockFile = new File(path,"LOCK"); - lockFile.delete(); - if (readOnly != null && readOnly.equals("true")) { - rocksDB = RocksDB.openReadOnly(options, path); - } else - rocksDB = RocksDB.open(options, path); - rocksdb = rocksDB; - return rocksDB; - - } catch (RocksDBException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return null; - } - - @Override - public String Get(Map condition) { - // TODO Auto-generated method stub - if(condition.containsKey("start")&&condition.containsKey("end")) { - int start = (int)condition.get("start"); - int end = (int)condition.get("end"); - } - return null; - } - - @Override - public boolean Put(Transaction trans) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean Delete(String hash) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean Create_DB() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean Open_DB() { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/src/main/java/org/bdware/sc/blockdb/SqliteDBUtil.java b/src/main/java/org/bdware/sc/blockdb/SqliteDBUtil.java deleted file mode 100644 index be8fa92..0000000 --- a/src/main/java/org/bdware/sc/blockdb/SqliteDBUtil.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.bdware.sc.blockdb; - -import org.bdware.sc.commParser.BDLedger.Block; -import org.bdware.sc.commParser.BDLedger.BlockBody; -import org.bdware.sc.commParser.BDLedger.BlockHeader; -import org.bdware.sc.util.HashUtil; - -import java.io.File; -import java.sql.*; - -public class SqliteDBUtil { - private Connection conn; - - public static SqliteDBUtil connect(String url) { - try { - String name = "org.sqlite.JDBC"; - SqliteDBUtil util = new SqliteDBUtil(); - String path = "jdbc:sqlite:"; - File file = new File(url); - path = path + file.getAbsolutePath(); - System.out.println("[SqliteDBUtil] connect:" + path); - Class.forName(name); - util.conn = DriverManager.getConnection(path); - return util; - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - public BlockBody getBlockBody(String headerHash, String bodyHash) { - try { - Statement stmt = conn.createStatement(); - // ResultSet result = stmt.executeQuery("select * from BlockHeader where hash = - // " + headerHash); - String sql = "select * from BlockBody where ID = ?"; - PreparedStatement pre = conn.prepareStatement(sql); - pre.setBytes(1, HashUtil.str16ToBytes(bodyHash)); - ResultSet result = pre.executeQuery(); - // Assert we get only one!!!! - while (result.next()) { - System.out.println(result.getBytes("ID")); - return BlockBody.fromBytes(result.getBytes("Data")); - } - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - public Block getBlock(String headerHash, String bodyHash) { - try { - BlockHeader header = new BlockHeader(); - BlockBody body = new BlockBody(); - Statement stmt = conn.createStatement(); - String sql = "select * from BlockBody where ID = ?"; - PreparedStatement pre = conn.prepareStatement(sql); - pre.setBytes(1, HashUtil.str16ToBytes(bodyHash)); - ResultSet result = pre.executeQuery(); - while (result.next()) { - body = BlockBody.fromBytes(result.getBytes("Data")); - } - String sql1 = "select * from BlockHeader where Hash = ?"; - pre = conn.prepareStatement(sql1); - pre.setBytes(1, HashUtil.str16ToBytes(headerHash)); - result = pre.executeQuery(); - while (result.next()) { - header.index = result.getInt(1); - header.hash = result.getBytes(2); - header.version = result.getInt(3); - header.timestamp = result.getInt(4); - header.prevblockID = result.getBytes(5); - header.merkleroot = result.getBytes(6); - header.creatorID = result.getBytes(7); - Block block = new Block(header,body); - return block; - //return Block.fromBytes(result.getBytes("Data")); - } - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - public byte[] bodyselectall() { - try { - Statement stmt = conn.createStatement(); - // ResultSet result = stmt.executeQuery("select * from BlockHeader where hash = - // " + headerHash); - String sql = "select * from BlockBody limit 1,1"; - PreparedStatement pre = conn.prepareStatement(sql); - ResultSet result = pre.executeQuery(); - // Assert we get only one!!!! - while (result.next()) { - return result.getBytes(1); - } - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - public byte[] headerselectall() { - try { - Statement stmt = conn.createStatement(); - // ResultSet result = stmt.executeQuery("select * from BlockHeader where hash = - // " + headerHash); - String sql = "select * from BlockHeader limit 1,1"; - PreparedStatement pre = conn.prepareStatement(sql); - ResultSet result = pre.executeQuery(); - // Assert we get only one!!!! - while (result.next()) { - return result.getBytes(2); - } - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } -} diff --git a/src/main/java/org/bdware/sc/blockdb/TimeDBUtil.java b/src/main/java/org/bdware/sc/blockdb/TimeDBUtil.java deleted file mode 100644 index 8dfb183..0000000 --- a/src/main/java/org/bdware/sc/blockdb/TimeDBUtil.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.bdware.sc.blockdb; - -import org.bdware.sc.commParser.BDLedger.Transaction; - -import java.util.Map; - -public class TimeDBUtil implements DBRepository{ - - @Override - public String Get(Map condition) { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean Put(Transaction trans) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean Delete(String hash) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean Create_DB() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean Open_DB() { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/src/main/java/org/bdware/sc/boundry/JavaScriptEntry.java b/src/main/java/org/bdware/sc/boundry/JavaScriptEntry.java index a2f5b38..8769e57 100644 --- a/src/main/java/org/bdware/sc/boundry/JavaScriptEntry.java +++ b/src/main/java/org/bdware/sc/boundry/JavaScriptEntry.java @@ -1,12 +1,10 @@ package org.bdware.sc.boundry; import com.google.gson.JsonObject; -import com.google.gson.JsonParser; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.bdware.sc.ContractProcess; import org.bdware.sc.bean.ContractRequest; -import org.bdware.sc.boundry.utils.SQLUtil; import org.bdware.sc.conn.ResultCallback; import org.bdware.sc.conn.SocketGet; import org.bdware.sc.engine.DesktopEngine; @@ -25,9 +23,6 @@ import wrp.jdk.nashorn.internal.runtime.ScriptFunction; import wrp.jdk.nashorn.internal.runtime.ScriptObject; import wrp.jdk.nashorn.internal.scripts.JO; -import javax.mail.*; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeMessage; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; @@ -35,11 +30,13 @@ import java.io.PrintStream; import java.math.BigInteger; import java.net.URL; import java.net.URLConnection; -import java.security.Security; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; -import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; @@ -84,25 +81,6 @@ public class JavaScriptEntry { return HashUtil.hashByteArray(hash); } - public static Connection getMysqlConnection(String url, String usrName, String pwd) { - return SQLUtil.getConnection("jdbc:mysql://" + url, usrName, pwd); - } - - public static String example(String arg) { - LOGGER.debug("called: " + arg); - return arg + 1; - } - - // public static MongoClient connectMongoDb(String url, int port, String dbName, String usrName, - // String pwd) { - // return getMongoDBConnection(url, port, dbName, usrName, pwd); - // } - // - // public static MongoClient getMongoDBConnection(String url, int port, String dbName, String - // usrName, String pwd) { - // return MongoDBUtil.connect(url, port, dbName, usrName, pwd); - // } - public static String bytes2Str(byte[] bytes) { return new String(bytes); } @@ -153,44 +131,6 @@ public class JavaScriptEntry { return bo.toByteArray(); } - // private static String list2Str(List reservedList) { - // return JsonUtil.toJson(reservedList); - // } - // - // private static String map2Str(Map map) { - // return JsonUtil.toJson(map); - // } - - // private static CloseableHttpClient getHttpClient(String url) { - // try { - // SSLContext sslcontext = SSLContexts.custom().loadTrustMaterial(null, new TrustStrategy() { - // - // @Override - // public boolean isTrusted(java.security.cert.X509Certificate[] arg0, String arg1) - // throws java.security.cert.CertificateException { - // return true; - // } - // }).build(); - // - // SSLConnectionSocketFactory sslSf = new SSLConnectionSocketFactory(sslcontext, null, null, - // new NoopHostnameVerifier()); - // int tle = 10; - // if (url.contains("data.tj.gov.cn")) - // tle = 3; - // return HttpClients.custom().setSSLSocketFactory(sslSf) - // .setKeepAliveStrategy(new ConnectionKeepAliveStrategy() { - // @Override - // public long getKeepAliveDuration(HttpResponse arg0, HttpContext arg1) { - // return 0; - // } - // }).setConnectionTimeToLive(tle, TimeUnit.SECONDS).build(); - // - // } catch (Exception e) { - // e.printStackTrace(); - // } - // return null; - // } - public static InputStream httpAsInputStream(String url) { try { URL realUrl = new URL(url); @@ -202,51 +142,6 @@ public class JavaScriptEntry { } } - // public static String httpPost(String str) { - // System.out.println("JavaSScriptEntry httpPost:" + str); - // PostRequest req = new PostRequest(); - // req = JsonUtil.fromJson(str, PostRequest.class); - // // System.out.println("url========>" + req.url); - // // System.out.println("data=======>" + req.data); - // - // Result r = new Result(); - // try { - // URL url = new URL(req.url);// - // HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - // connection.setDoOutput(true); - // connection.setDoInput(true); - // connection.setUseCaches(false); - // connection.setInstanceFollowRedirects(true); - // connection.setRequestMethod("POST"); // 璁剧疆璇锋眰鏂瑰紡 - // connection.setRequestProperty("Accept", "application/json"); // 璁剧疆鎺ユ敹鏁版嵁鐨勬牸寮� - // connection.setRequestProperty("Content-Type", "application/json"); // 璁剧疆鍙戦�佹暟鎹殑鏍煎紡 - // connection.connect(); - // OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream(), "UTF-8"); // - // utf-8缂栫爜 - // out.append(req.data); - // out.flush(); - // out.close(); - // - // r.resposeCode = connection.getResponseCode(); - // InputStream input = connection.getInputStream(); - // - // Scanner sc = new Scanner(input); - // StringBuilder sb = new StringBuilder(); - // for (; sc.hasNextLine();) { - // sb.append(sc.nextLine()).append("\n"); - // } - // sc.close(); - // r.response = sb.toString(); - // return JsonUtil.toJson(r); - // } catch (Throwable e) { - // r.resposeCode = 505; - // // ByteArrayOutputStream bo = new ByteArrayOutputStream(); - // // e.printStackTrace(new PrintStream(bo)); - // r.response = e.getMessage(); - // return JsonUtil.toJson(r); - // } - // } - public static void executeFunction(ScriptFunction callback, Object arg) { DesktopEngine.applyWithGlobal(callback, currentEngine.getNashornGlobal(), arg); } @@ -404,123 +299,6 @@ public class JavaScriptEntry { } } - /*public static String executeContract(String contractID, String action, String arg) { - //redo,use record data - if(currentSyncUtil.transRecoverUtil != null && currentSyncUtil.transRecoverUtil.recovering){ - String k = TransRecordUtil.produceExecuteIdentifier(contractID,action,arg); - return currentSyncUtil.transRecoverUtil.curRecoverRecord.getExecuteResult(k); - } - - try { - ContractRequest app = new ContractRequest(); - app.setContractID(contractID).setAction(action).setArg(arg); - //app.doSignature(keyPair.getPrivateKey().toString(16)); - app.doSignature(keyPair); - String result = get.syncGet("dd", "executeContract", JsonUtil.toJson(app)); - if(currentSyncUtil.startFlag && currentSyncUtil.currType == SyncType.Trans){ - String k = currentSyncUtil.transRecordUtil.produceExecuteIdentifier(contractID,action,arg); - currentSyncUtil.transRecordUtil.recordExecutes(k,result); - } - return result; - } catch (Exception e) { - ByteArrayOutputStream bo = new ByteArrayOutputStream(); - e.printStackTrace(new PrintStream(bo)); - String result = bo.toString(); - if(currentSyncUtil.startFlag && currentSyncUtil.currType == SyncType.Trans){ - String k = TransRecordUtil.produceExecuteIdentifier(contractID,action,arg); - currentSyncUtil.transRecordUtil.recordExecutes(k,result); - } - return result; - } - }*/ - - // public static String queryContractIdByDOI(String contractDOI) throws Exception { - // DigitalObject contractDO; - // DoipClient doipClient = - // DoipClient.createByRepoUrlAndMsgFmt( - // DOIPMainServer.repoUrl, DoipMessageFormat.PACKET.getName()); - // DoMessage response = doipClient.retrieve(contractDOI, null, null); - // if (response.parameters.response == DoResponse.Success) { - // contractDO = DigitalObject.parse(response.body); - // } else { - // response = DOAClient.getGlobalInstance().retrieve(contractDOI, null, null); - // contractDO = DigitalObject.parse(response.body); - // } - // ContractInstanceDO contractInstanceDO = - // (ContractInstanceDO) - // ContractManager.toObject(contractDO.elements.get(0).getData()); - // return contractInstanceDO.id; - // } - - // public static String executeContractByDOI(String contractDOI, String action, String arg) { - // try { - // String contractID = queryContractIdByDOI(contractDOI); - // return executeContract(contractID, action, arg); - // } catch (Exception e) { - // ByteArrayOutputStream bo = new ByteArrayOutputStream(); - // e.printStackTrace(new PrintStream(bo)); - // return bo.toString(); - // } - // } - // - // public static String getAuthInfo() { - // try { - // DigitalObject contractDO; - // DoipClient doipClient = - // DoipClient.createByRepoUrlAndMsgFmt( - // DOIPMainServer.repoUrl, DoipMessageFormat.PACKET.getName()); - // DoMessage response = doipClient.retrieve(authInfoPersistDOI, null, null); - // if (response.parameters.response != DoResponse.Success) { - // response = DOAClient.getGlobalInstance().retrieve(authInfoPersistDOI, null, - // null); - // } - // contractDO = DigitalObject.parse(response.body); - // return new String(contractDO.elements.get(0).getData()); - // } catch (Exception e) { - // ByteArrayOutputStream bo = new ByteArrayOutputStream(); - // e.printStackTrace(new PrintStream(bo)); - // return "Failed: " + bo.toString(); - // } - // } - // - // public static String setAuthInfo(String authInfo) { - // try { - // - // DigitalObject contractDO = new DigitalObject(authInfoPersistDOI, DoType.Json); - // Element e = new Element("authInfo", "JsonString"); - // e.setData(authInfo.getBytes()); - // contractDO.addElements(e); - // - // DoipClient doipClient = - // DoipClient.createByRepoUrlAndMsgFmt( - // DOIPMainServer.repoUrl, DoipMessageFormat.PACKET.getName()); - // DoMessage response = doipClient.update(contractDO); - // if (response.parameters.response != DoResponse.Success) { - // DoHandleRecord dohr = - // DOAClient.getGlobalInstance().resolveDO(authInfoPersistDOI); - // if (dohr == null) { - // return "Failed: Can not resolve authInfoPersistDOI: " + - // authInfoPersistDOI; - // } - // ServiceHandleRecord repoHandleRecord = - // DOAClient.getGlobalInstance().resolveDOIPService(dohr.repository); - // doipClient = - // DoipClient.createByRepoUrlAndMsgFmt( - // repoHandleRecord.getListenerInfos().get(0).url, - // DoipMessageFormat.PACKET.getName()); - // response = doipClient.update(contractDO); - // if (response.parameters.response != DoResponse.Success) { - // return "Failed: Can not update authInfoPersistDOI: " + authInfoPersistDOI; - // } - // } - // return "Succeeded"; - // } catch (Exception e) { - // ByteArrayOutputStream bo = new ByteArrayOutputStream(); - // e.printStackTrace(new PrintStream(bo)); - // return "Failed: " + bo.toString(); - // } - // } - public static String executeContractAsync( String contractID, String action, String arg, final ScriptFunction cb) { try { @@ -696,46 +474,6 @@ public class JavaScriptEntry { // TODO } - public static String sendEmail(String json) { - try { - final JsonObject jo = JsonParser.parseString(json).getAsJsonObject(); - Properties props = new Properties(); - props.setProperty("mail.debug", "false"); - props.setProperty("mail.smtp.auth", "true"); - props.setProperty("mail.smtp.host", jo.get("host").getAsString()); - props.setProperty("mail.smtp.port", jo.get("port").getAsString()); - props.setProperty("mail.transport.protocol", "smtp"); - props.put("mail.smtp.auth", "true"); - Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); - final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory"; - props.setProperty("mail.smtp.socketFactory.class", SSL_FACTORY); - props.setProperty("mail.smtp.socketFactory.fallback", "false"); - props.setProperty("mail.smtp.socketFactory.port", jo.get("port").getAsString()); - Session session = - Session.getDefaultInstance( - props, - new Authenticator() { - public PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication( - jo.get("from").getAsString(), - jo.get("pwd").getAsString()); // 发件人邮件用户名、密码 - } - }); - // 创建邮件对象 - - Message msg = new MimeMessage(session); - msg.setSubject(jo.get("subject").getAsString()); - msg.setText(jo.get("content").getAsString()); - msg.setFrom(new InternetAddress(jo.get("from").getAsString())); - msg.addRecipient( - Message.RecipientType.TO, new InternetAddress(jo.get("to").getAsString())); - Transport.send(msg); - } catch (Exception e) { - e.printStackTrace(); - return "failed"; - } - return "success"; - } public static ScriptObject getCaller(int i) { JO ret = new JO(PropertyMap.newMap()); @@ -752,8 +490,4 @@ public class JavaScriptEntry { public String response; } - static class PostRequest { - String url; - String data; - } } diff --git a/src/main/java/org/bdware/sc/boundry/utils/DOIPUtil.java b/src/main/java/org/bdware/sc/boundry/utils/DOIPUtil.java new file mode 100644 index 0000000..f440778 --- /dev/null +++ b/src/main/java/org/bdware/sc/boundry/utils/DOIPUtil.java @@ -0,0 +1,142 @@ +package org.bdware.sc.boundry.utils; + +import com.google.gson.JsonObject; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.bdware.doip.codec.digitalObject.DigitalObject; +import org.bdware.doip.codec.digitalObject.Element; +import org.bdware.doip.codec.doipMessage.DoipMessage; +import org.bdware.doip.codec.doipMessage.DoipMessageFactory; +import org.bdware.doip.codec.operations.BasicOperations; +import org.bdware.doip.endpoint.doipClient.DoipClientImpl; +import org.bdware.doip.endpoint.doipClient.DoipMessageCallback; +import org.bdware.sc.compiler.PermissionStub; +import org.bdware.sc.node.Permission; +import org.bdware.sc.util.JsonUtil; + +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; + +@PermissionStub(permission = Permission.DOIP) +public class DOIPUtil { + private static final Logger LOGGER = LogManager.getLogger(DOIPUtil.class); + private final String url; + private final DoipClientImpl doipClient; + + private DOIPUtil(String url) { + this.url = url; + this.doipClient = new DoipClientImpl(); + doipClient.connect(url); + } + + public static DOIPUtil createClient(String url) { + return new DOIPUtil(url); + } + + public String test(String doi) { + return "create DOClient And hello " + doi + " World"; + } + + public boolean reconnect() { + try { + if (doipClient != null) + doipClient.reconnect(); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + private DoipMessage syncGetMessage(DoipMessage message) { + List ret = new ArrayList<>(); + DoipMessage msg = null; + try { + doipClient.sendMessage(message, new DoipMessageCallback() { + @Override + public void onResult(DoipMessage doipMessage) { + ret.add(doipMessage); + synchronized (ret) { + ret.notify(); + } + } + }); + synchronized (ret) { + ret.wait(5000); + } + if (ret.size() > 0) + msg = ret.get(0); + if (msg != null) { + return msg; + } else return DoipMessageFactory.createTimeoutResponse(message.requestID); + } catch (Exception ie) { + ie.printStackTrace(); + return DoipMessageFactory.createConnectFailedResponse(message.requestID); + } + } + + private static String convertDoipMsgToString(DoipMessage ret) { + try { + LOGGER.info(new String(ret.body.encodedData)); + DigitalObject respDO = ret.body.getDataAsDigitalObject(); + return respDO.toString(); + } catch (Exception ie) { + ie.printStackTrace(); + return "send doip message error: " + ie.getMessage(); + } + } + + public String hello(String repoID) { + DoipMessage msg = (new DoipMessageFactory.DoipMessageBuilder()).createRequest(repoID, BasicOperations.Hello.getName()).create(); + return convertDoipMsgToString(syncGetMessage(msg)); + } + + public String retrieve(String doi, String args) { + DoipMessage msg = (new DoipMessageFactory.DoipMessageBuilder()).createRequest(doi, BasicOperations.Retrieve.getName()) + .setBody(args.getBytes(StandardCharsets.UTF_8)).create(); + return convertDoipMsgToString(syncGetMessage(msg)); + } + + public String call(String doi, String action, String args) { + JsonObject jo = new JsonObject(); + jo.addProperty("action", action); + jo.addProperty("args", args); + DoipMessage msg = (new DoipMessageFactory.DoipMessageBuilder()) + .createRequest(doi, BasicOperations.Retrieve.getName()) + .setBody(jo.toString().getBytes(StandardCharsets.UTF_8)).create(); + return convertDoipMsgToString(syncGetMessage(msg)); + } + + public String create(String repoID, String doString) { + DigitalObject digitalObject = JsonUtil.fromJson(doString, DigitalObject.class); + for (Element e : digitalObject.elements) { + if (null != e.dataString) { + e.setData(e.dataString.getBytes()); + } + e.dataString = null; + } + DoipMessage msg = + new DoipMessageFactory.DoipMessageBuilder() + .createRequest(repoID, BasicOperations.Create.getName()) + .setBody(digitalObject) + .create(); + return convertDoipMsgToString(syncGetMessage(msg)); + } + + public String delete(String doID) { + DoipMessage msg = + new DoipMessageFactory.DoipMessageBuilder() + .createRequest(doID, BasicOperations.Delete.getName()) + .create(); + return convertDoipMsgToString(syncGetMessage(msg)); + } + + public String listOperation(String doID) { + DoipMessage msg = + new DoipMessageFactory.DoipMessageBuilder() + .createRequest(doID, BasicOperations.ListOps.getName()) + .create(); + return convertDoipMsgToString(syncGetMessage(msg)); + } +} diff --git a/src/main/java/org/bdware/sc/boundry/utils/DOMUtil.java b/src/main/java/org/bdware/sc/boundry/utils/DOMUtil.java index 9521f82..fff82d8 100644 --- a/src/main/java/org/bdware/sc/boundry/utils/DOMUtil.java +++ b/src/main/java/org/bdware/sc/boundry/utils/DOMUtil.java @@ -7,4 +7,4 @@ public class DOMUtil { public static Document parse(String html) { return Jsoup.parse(html); } -} +} \ No newline at end of file diff --git a/src/main/java/org/bdware/sc/boundry/utils/EmailUtil.java b/src/main/java/org/bdware/sc/boundry/utils/EmailUtil.java new file mode 100644 index 0000000..d1066c9 --- /dev/null +++ b/src/main/java/org/bdware/sc/boundry/utils/EmailUtil.java @@ -0,0 +1,53 @@ +package org.bdware.sc.boundry.utils; + +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import javax.mail.*; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeMessage; +import java.security.Security; +import java.util.Properties; + +public class EmailUtil { + public static String sendEmail(String json) { + try { + final JsonObject jo = JsonParser.parseString(json).getAsJsonObject(); + Properties props = new Properties(); + props.setProperty("mail.debug", "false"); + props.setProperty("mail.smtp.auth", "true"); + props.setProperty("mail.smtp.host", jo.get("host").getAsString()); + props.setProperty("mail.smtp.port", jo.get("port").getAsString()); + props.setProperty("mail.transport.protocol", "smtp"); + props.put("mail.smtp.auth", "true"); + Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); + final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory"; + props.setProperty("mail.smtp.socketFactory.class", SSL_FACTORY); + props.setProperty("mail.smtp.socketFactory.fallback", "false"); + props.setProperty("mail.smtp.socketFactory.port", jo.get("port").getAsString()); + Session session = + Session.getDefaultInstance( + props, + new Authenticator() { + public PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication( + jo.get("from").getAsString(), + jo.get("pwd").getAsString()); // 发件人邮件用户名、密码 + } + }); + // 创建邮件对象 + + Message msg = new MimeMessage(session); + msg.setSubject(jo.get("subject").getAsString()); + msg.setText(jo.get("content").getAsString()); + msg.setFrom(new InternetAddress(jo.get("from").getAsString())); + msg.addRecipient( + Message.RecipientType.TO, new InternetAddress(jo.get("to").getAsString())); + Transport.send(msg); + } catch (Exception e) { + e.printStackTrace(); + return "failed"; + } + return "success"; + } +} diff --git a/src/main/java/org/bdware/sc/boundry/utils/FileUtil.java b/src/main/java/org/bdware/sc/boundry/utils/FileUtil.java index c9dc12a..491d972 100644 --- a/src/main/java/org/bdware/sc/boundry/utils/FileUtil.java +++ b/src/main/java/org/bdware/sc/boundry/utils/FileUtil.java @@ -12,7 +12,7 @@ import java.io.PrintStream; public class FileUtil extends org.bdware.sc.util.FileUtil { private static String getInternalFile(String path) { File parent = new File("./ContractDB/" + ContractProcess.instance.getContractName()); - if (path.contains("..")) { + if (path.contains("")) { return null; } File f = new File(parent, path); diff --git a/src/main/java/org/bdware/sc/boundry/utils/MongoDBUtil.java b/src/main/java/org/bdware/sc/boundry/utils/MongoDBUtil.java index 75e8c77..7c0218c 100644 --- a/src/main/java/org/bdware/sc/boundry/utils/MongoDBUtil.java +++ b/src/main/java/org/bdware/sc/boundry/utils/MongoDBUtil.java @@ -3,6 +3,38 @@ package org.bdware.sc.boundry.utils; import org.bdware.sc.compiler.PermissionStub; import org.bdware.sc.node.Permission; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; + @PermissionStub(permission = Permission.MongoDB) -public class MongoDBUtil extends org.bdware.sc.blockdb.MongoDBUtil { +public class MongoDBUtil { + public static Object connect(String url, int port, String dbName, String usrName, String pwd) { + try { + Class serverAddr = Class.forName("com.mongodb.ServerAddress"); + Constructor cons = serverAddr.getConstructor(String.class, Integer.TYPE); + Object serverAddress = cons.newInstance(url, port); + List addrs = new ArrayList<>(); + addrs.add(serverAddress); + Method createeScramSha1 = + Class.forName("com.mongodb.MongoCredential") + .getDeclaredMethod( + "createScramSha1Credential", + String.class, + String.class, + char[].class); + Object credential = createeScramSha1.invoke(null, usrName, dbName, pwd.toCharArray()); + List credentials = new ArrayList<>(); + credentials.add(credential); + Constructor mongoClient = + Class.forName("com.mongodb.MongoClient").getConstructor(List.class, List.class); + Object client = mongoClient.newInstance(addrs, credentials); + // 通过连接认证获取MongoDB连接 + return client; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } } diff --git a/src/main/java/org/bdware/sc/boundry/utils/RocksDBUtil.java b/src/main/java/org/bdware/sc/boundry/utils/RocksDBUtil.java index 843e403..f9c0739 100644 --- a/src/main/java/org/bdware/sc/boundry/utils/RocksDBUtil.java +++ b/src/main/java/org/bdware/sc/boundry/utils/RocksDBUtil.java @@ -35,10 +35,8 @@ public class RocksDBUtil { this.path = path; Options options = new Options(); options.setCreateIfMissing(true); - File parent = new File("./ContractDB/" + ContractProcess.getContractDir()); File dir = new File(parent, path); - System.out.println("[EEEEEEEEEERO]"); LOGGER.info("init RocksDB in " + dir.getAbsolutePath()); if (!dir.exists()) { LOGGER.trace("create directory " + dir.getAbsolutePath() + ": " + dir.mkdirs()); diff --git a/src/main/java/org/bdware/sc/boundry/utils/UtilRegistry.java b/src/main/java/org/bdware/sc/boundry/utils/UtilRegistry.java index f456a1c..e7f84dd 100644 --- a/src/main/java/org/bdware/sc/boundry/utils/UtilRegistry.java +++ b/src/main/java/org/bdware/sc/boundry/utils/UtilRegistry.java @@ -17,7 +17,6 @@ public class UtilRegistry { public static Map stubClzNameMap = new HashMap<>(); public static List> getUtilClasses() { - List allName = Permission.allName(); List> ret = new ArrayList<>(); try { diff --git a/src/main/java/org/bdware/sc/compiler/PermissionStub.java b/src/main/java/org/bdware/sc/compiler/PermissionStub.java new file mode 100644 index 0000000..0668ec5 --- /dev/null +++ b/src/main/java/org/bdware/sc/compiler/PermissionStub.java @@ -0,0 +1,15 @@ +package org.bdware.sc.compiler; + +import org.bdware.sc.node.Permission; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface PermissionStub { + Permission permission(); + +} \ No newline at end of file diff --git a/src/main/java/org/bdware/sc/compiler/PermissionStubGenerator.java b/src/main/java/org/bdware/sc/compiler/PermissionStubGenerator.java new file mode 100644 index 0000000..b19c04a --- /dev/null +++ b/src/main/java/org/bdware/sc/compiler/PermissionStubGenerator.java @@ -0,0 +1,81 @@ +package org.bdware.sc.compiler; + +import org.objectweb.asm.*; + +import java.io.IOException; +import java.io.InputStream; + +public class PermissionStubGenerator extends ClassVisitor implements Opcodes { + private final String p; + + public PermissionStubGenerator(int api, ClassVisitor cn, String permission) { + super(api, cn); + this.p = permission; + } + + public static byte[] generateStub(Class clz, String permission) { + PermissionStub stub = clz.getAnnotation(PermissionStub.class); + if (stub == null) + return null; + try { + String resource = clz.getCanonicalName().replaceAll("\\.", "/") + ".class"; + InputStream input = clz.getClassLoader().getResourceAsStream(resource); + ClassReader cr; + cr = new ClassReader(input); + ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); + PermissionStubGenerator generator = new PermissionStubGenerator(ASM4, cw, permission); + cr.accept(generator, 0); + + return cw.toByteArray(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { + if (cv != null) { + cv.visit(version, access, name + "Stub", null, "java/lang/Object", null); + } + MethodVisitor mv = cv.visitMethod(ACC_PUBLIC, "", "()V", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "", "()V"); + mv.visitInsn(RETURN); + Label l1 = new Label(); + mv.visitLabel(l1); + // mv.visitLocalVariable("this", "Lcom/yancloud/sc/boundry/utils/FileUtilStub;", + // null, l0, l1, 0); + mv.visitMaxs(1, 1); + mv.visitEnd(); + } + + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + if (cv != null) { + if (name.equals("")) + return null; + if (name.equals("")) { + return null; + } + + MethodVisitor mv = cv.visitMethod(access, name, desc, signature, + new String[]{"javax/script/ScriptException"}); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitTypeInsn(NEW, "javax/script/ScriptException"); + mv.visitInsn(DUP); + mv.visitLdcInsn("Do not have " + p + " Permission"); + mv.visitMethodInsn(INVOKESPECIAL, "javax/script/ScriptException", "", "(Ljava/lang/String;)V"); + mv.visitInsn(ATHROW); + mv.visitMaxs(5, 20); + mv.visitEnd(); + + return null; + } + return null; + } +} diff --git a/src/main/java/org/bdware/sc/trace/ProgramPointCounter.java b/src/main/java/org/bdware/sc/trace/ProgramPointCounter.java index 9025fc3..ee1c031 100644 --- a/src/main/java/org/bdware/sc/trace/ProgramPointCounter.java +++ b/src/main/java/org/bdware/sc/trace/ProgramPointCounter.java @@ -2,18 +2,14 @@ package org.bdware.sc.trace; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import com.sun.mail.iap.ByteArray; import org.bdware.analysis.CFGraph; import org.bdware.sc.ContractProcess; -import wrp.jdk.nashorn.internal.runtime.ScriptObject; -import wrp.jdk.nashorn.internal.runtime.ScriptRuntime; import wrp.jdk.nashorn.internal.runtime.TraceMethod; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.util.HashMap; import java.util.Map; -import java.util.Set; import java.util.Stack; public class ProgramPointCounter extends ContractProcess.Logger implements TraceMethod { diff --git a/src/test/java/org/bdware/sc/boundry/utils/test/DOIPUtilTest.java b/src/test/java/org/bdware/sc/boundry/utils/test/DOIPUtilTest.java new file mode 100644 index 0000000..3dd8e58 --- /dev/null +++ b/src/test/java/org/bdware/sc/boundry/utils/test/DOIPUtilTest.java @@ -0,0 +1,17 @@ +package org.bdware.sc.boundry.utils.test; + +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.bdware.sc.boundry.utils.DOIPUtil; +import org.junit.Test; + +public class DOIPUtilTest { + static Logger LOGGER = LogManager.getLogger(DOIPUtilTest.class); + + @Test + public void testRetrieve() { + DOIPUtil util = DOIPUtil.createClient("tcp://127.0.0.1:21032"); + LOGGER.info(util.retrieve("AnnotationExample", "{\"operation\":\"main\",\"arg\":\"\"}")); + + } +} diff --git a/src/test/java/org/bdware/sc/test/synctest/TransRecordTest.java b/src/test/java/org/bdware/sc/test/synctest/TransRecordTest.java index 01f5858..a0d49c7 100644 --- a/src/test/java/org/bdware/sc/test/synctest/TransRecordTest.java +++ b/src/test/java/org/bdware/sc/test/synctest/TransRecordTest.java @@ -1,16 +1,13 @@ package org.bdware.sc.test.synctest; -import org.bdware.sc.conn.ByteUtil; +import com.google.gson.JsonPrimitive; import org.bdware.sc.redo.TransRecord; -import java.io.*; -import java.util.zip.GZIPInputStream; - public class TransRecordTest { - static TransRecord currentTransRecord = new TransRecord("myFun","myArg"); + static TransRecord currentTransRecord = new TransRecord("myFun", new JsonPrimitive("myArg")); - public static void main(String[] args){ + public static void main(String[] args) { // currentTransRecord.executes.put("k1","v1"); // currentTransRecord.executes.put("k2","v2"); // currentTransRecord.executes.put("k3","v3");