merge newest origin/master

This commit is contained in:
haoeliu@foxmail.com 2023-03-15 15:39:05 +08:00
commit 0d7424cd7f
5 changed files with 34 additions and 30 deletions

View File

@ -6,7 +6,7 @@ plugins {
}
group = "org.bdware.sc"
version = "2.0.0"
version = "1.8.0"
repositories {
mavenCentral()
@ -60,7 +60,7 @@ jar {
}
from {
// uncomment this when publish,
//while develop at local use "false"
// while develop at local use "false"
configurations.runtimeClasspath.filter {
// it.getAbsolutePath().contains("/lib/")
false
@ -173,18 +173,18 @@ publishing {
maven {
name 'bdwareSnapshotRepository'
url 'https://oss.sonatype.org/content/repositories/snapshots'
// credentials {
// username = "${NEXUS_USERNAME}"
// password = "${NEXUS_PASSWORD}"
// }
credentials {
username = "${NEXUS_USERNAME}"
password = "${NEXUS_PASSWORD}"
}
}
maven {
name 'bdwareRepository'
url 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
// credentials {
// username = "${NEXUS_USERNAME}"
// password = "${NEXUS_PASSWORD}"
// }
credentials {
username = "${NEXUS_USERNAME}"
password = "${NEXUS_PASSWORD}"
}
}
}
}

View File

@ -1,6 +1,8 @@
{
"agentHttpAddr": "127.0.0.1:18000",
"script": "/Users/huaqiancai/BDWare/datanet/datanet-gateway-bundle/datanet-gateway-backend/build/gateway.ypk",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"privKey": "589d94ee5688358a1c5c18430dd9c75097ddddebf769f139da36a807911d20f8"
"agentAddress": "127.0.0.1:18000",
"ypkPath": "/Users/huaqiancai/BDWare/datanet/datanet-gateway-bundle/datanet-gateway-backend/build/gateway.ypk",
"privateKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"publicKey": "589d94ee5688358a1c5c18430dd9c75097ddddebf769f139da36a807911d20f8",
"killBeforeStart":"ContractName",
"createParam":{}
}

View File

@ -132,7 +132,8 @@ public class YJSCompiler {
if (czb.containsPath(str)) {
continue;
}
ZipEntry entry = zf.getEntry("/" + str);
ZipEntry entry = zf.getEntry(str.startsWith("/") ? str : "/" + str);
if (null == entry) {
throw new IllegalStateException("missing import:" + str);
}

View File

@ -153,15 +153,15 @@ public class JSONTool {
return JsonUtil.fromJson(JsonUtil.toJson(obj), JsonObject.class);
}else if (obj instanceof Number) {
return new JsonPrimitive((Number) obj);
} else if (obj instanceof String) {
return new JsonPrimitive((String) obj);
} else if (obj instanceof Character) {
return new JsonPrimitive((Character) obj);
}
if (obj instanceof Boolean) {
} else if (obj instanceof Boolean) {
return new JsonPrimitive((Boolean) obj);
} else if (obj.getClass() == Boolean.TYPE) {
return new JsonPrimitive((boolean) obj);
}
return JsonNull.INSTANCE;
}

View File

@ -3,6 +3,8 @@ package org.bdware.sc.engine.hook;
import com.google.gson.JsonElement;
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.JSEngine;
import org.bdware.sc.bean.ContractRequest;
import org.bdware.sc.boundry.ScriptReturnException;
@ -12,13 +14,12 @@ import org.bdware.sc.node.AnnotationHook;
import org.bdware.sc.node.AnnotationNode;
import org.bdware.sc.node.ArgPacks;
import org.bdware.sc.node.FunctionNode;
import wrp.jdk.nashorn.internal.objects.Global;
import wrp.jdk.nashorn.internal.runtime.Context;
import wrp.jdk.nashorn.internal.runtime.PropertyMap;
import wrp.jdk.nashorn.internal.scripts.JO;
@YJSAnnotation(name = "Access")
public class AccessHandler implements AnnotationHook {
static Logger LOGGER = LogManager.getLogger(AccessHandler.class);
public String acFunction;
public boolean requireSign;
@ -46,15 +47,18 @@ public class AccessHandler implements AnnotationHook {
}
return argPacks;
}
if (!argPacks.request.verifySignature()) {
LOGGER.info("verify failed! clear requester," + argPacks.request.getContentStr() +
" -> " + argPacks.request.getPublicKey() + "sign:" + argPacks.request.getSignature());
//TODO
//FIXME here!
// argPacks.request.setRequester(null);
} else
LOGGER.info("verify success!" + argPacks.request.getRequester());
if (acFunction == null) return argPacks;
DesktopEngine de = (DesktopEngine) desktopEngine;
Global oldGlobal = Context.getGlobal();
Global newGlobal = de.getDesktopGlobal();
boolean globalChanged = (oldGlobal != newGlobal);
try {
if (globalChanged) {
Context.setGlobal(newGlobal);
}
ContractRequest input = argPacks.request;
JO jo = new JO(PropertyMap.newMap());
jo.put("requester", input.getRequester(), false);
@ -69,9 +73,6 @@ public class AccessHandler implements AnnotationHook {
jo.addProperty("code", "401");
jo.addProperty("msg", "access check meets exception! " + e);
throw new ScriptReturnException(jo);
} finally {
if (globalChanged) Context.setGlobal(oldGlobal);
}
}