mirror of
https://gitee.com/BDWare/cp.git
synced 2025-01-10 01:44:08 +00:00
merge newest origin/master
This commit is contained in:
commit
0d7424cd7f
20
build.gradle
20
build.gradle
@ -6,7 +6,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "org.bdware.sc"
|
group = "org.bdware.sc"
|
||||||
version = "2.0.0"
|
version = "1.8.0"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@ -60,7 +60,7 @@ jar {
|
|||||||
}
|
}
|
||||||
from {
|
from {
|
||||||
// uncomment this when publish,
|
// uncomment this when publish,
|
||||||
//while develop at local use "false"
|
// while develop at local use "false"
|
||||||
configurations.runtimeClasspath.filter {
|
configurations.runtimeClasspath.filter {
|
||||||
// it.getAbsolutePath().contains("/lib/")
|
// it.getAbsolutePath().contains("/lib/")
|
||||||
false
|
false
|
||||||
@ -173,18 +173,18 @@ publishing {
|
|||||||
maven {
|
maven {
|
||||||
name 'bdwareSnapshotRepository'
|
name 'bdwareSnapshotRepository'
|
||||||
url 'https://oss.sonatype.org/content/repositories/snapshots'
|
url 'https://oss.sonatype.org/content/repositories/snapshots'
|
||||||
// credentials {
|
credentials {
|
||||||
// username = "${NEXUS_USERNAME}"
|
username = "${NEXUS_USERNAME}"
|
||||||
// password = "${NEXUS_PASSWORD}"
|
password = "${NEXUS_PASSWORD}"
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
name 'bdwareRepository'
|
name 'bdwareRepository'
|
||||||
url 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
|
url 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
|
||||||
// credentials {
|
credentials {
|
||||||
// username = "${NEXUS_USERNAME}"
|
username = "${NEXUS_USERNAME}"
|
||||||
// password = "${NEXUS_PASSWORD}"
|
password = "${NEXUS_PASSWORD}"
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"agentHttpAddr": "127.0.0.1:18000",
|
"agentAddress": "127.0.0.1:18000",
|
||||||
"script": "/Users/huaqiancai/BDWare/datanet/datanet-gateway-bundle/datanet-gateway-backend/build/gateway.ypk",
|
"ypkPath": "/Users/huaqiancai/BDWare/datanet/datanet-gateway-bundle/datanet-gateway-backend/build/gateway.ypk",
|
||||||
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
|
"privateKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
|
||||||
"privKey": "589d94ee5688358a1c5c18430dd9c75097ddddebf769f139da36a807911d20f8"
|
"publicKey": "589d94ee5688358a1c5c18430dd9c75097ddddebf769f139da36a807911d20f8",
|
||||||
|
"killBeforeStart":"ContractName",
|
||||||
|
"createParam":{}
|
||||||
}
|
}
|
@ -132,7 +132,8 @@ public class YJSCompiler {
|
|||||||
if (czb.containsPath(str)) {
|
if (czb.containsPath(str)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ZipEntry entry = zf.getEntry("/" + str);
|
|
||||||
|
ZipEntry entry = zf.getEntry(str.startsWith("/") ? str : "/" + str);
|
||||||
if (null == entry) {
|
if (null == entry) {
|
||||||
throw new IllegalStateException("missing import:" + str);
|
throw new IllegalStateException("missing import:" + str);
|
||||||
}
|
}
|
||||||
|
@ -153,15 +153,15 @@ public class JSONTool {
|
|||||||
return JsonUtil.fromJson(JsonUtil.toJson(obj), JsonObject.class);
|
return JsonUtil.fromJson(JsonUtil.toJson(obj), JsonObject.class);
|
||||||
}else if (obj instanceof Number) {
|
}else if (obj instanceof Number) {
|
||||||
return new JsonPrimitive((Number) obj);
|
return new JsonPrimitive((Number) obj);
|
||||||
|
|
||||||
} else if (obj instanceof String) {
|
} else if (obj instanceof String) {
|
||||||
return new JsonPrimitive((String) obj);
|
return new JsonPrimitive((String) obj);
|
||||||
|
|
||||||
} else if (obj instanceof Character) {
|
} else if (obj instanceof Character) {
|
||||||
return new JsonPrimitive((Character) obj);
|
return new JsonPrimitive((Character) obj);
|
||||||
}
|
} else if (obj instanceof Boolean) {
|
||||||
if (obj instanceof Boolean) {
|
|
||||||
return new JsonPrimitive((Boolean) obj);
|
return new JsonPrimitive((Boolean) obj);
|
||||||
|
} else if (obj.getClass() == Boolean.TYPE) {
|
||||||
|
return new JsonPrimitive((boolean) obj);
|
||||||
|
|
||||||
}
|
}
|
||||||
return JsonNull.INSTANCE;
|
return JsonNull.INSTANCE;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ package org.bdware.sc.engine.hook;
|
|||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
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.JSEngine;
|
||||||
import org.bdware.sc.bean.ContractRequest;
|
import org.bdware.sc.bean.ContractRequest;
|
||||||
import org.bdware.sc.boundry.ScriptReturnException;
|
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.AnnotationNode;
|
||||||
import org.bdware.sc.node.ArgPacks;
|
import org.bdware.sc.node.ArgPacks;
|
||||||
import org.bdware.sc.node.FunctionNode;
|
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.runtime.PropertyMap;
|
||||||
import wrp.jdk.nashorn.internal.scripts.JO;
|
import wrp.jdk.nashorn.internal.scripts.JO;
|
||||||
|
|
||||||
@YJSAnnotation(name = "Access")
|
@YJSAnnotation(name = "Access")
|
||||||
public class AccessHandler implements AnnotationHook {
|
public class AccessHandler implements AnnotationHook {
|
||||||
|
static Logger LOGGER = LogManager.getLogger(AccessHandler.class);
|
||||||
public String acFunction;
|
public String acFunction;
|
||||||
public boolean requireSign;
|
public boolean requireSign;
|
||||||
|
|
||||||
@ -46,15 +47,18 @@ public class AccessHandler implements AnnotationHook {
|
|||||||
}
|
}
|
||||||
return argPacks;
|
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;
|
if (acFunction == null) return argPacks;
|
||||||
DesktopEngine de = (DesktopEngine) desktopEngine;
|
DesktopEngine de = (DesktopEngine) desktopEngine;
|
||||||
Global oldGlobal = Context.getGlobal();
|
|
||||||
Global newGlobal = de.getDesktopGlobal();
|
|
||||||
boolean globalChanged = (oldGlobal != newGlobal);
|
|
||||||
try {
|
try {
|
||||||
if (globalChanged) {
|
|
||||||
Context.setGlobal(newGlobal);
|
|
||||||
}
|
|
||||||
ContractRequest input = argPacks.request;
|
ContractRequest input = argPacks.request;
|
||||||
JO jo = new JO(PropertyMap.newMap());
|
JO jo = new JO(PropertyMap.newMap());
|
||||||
jo.put("requester", input.getRequester(), false);
|
jo.put("requester", input.getRequester(), false);
|
||||||
@ -69,9 +73,6 @@ public class AccessHandler implements AnnotationHook {
|
|||||||
jo.addProperty("code", "401");
|
jo.addProperty("code", "401");
|
||||||
jo.addProperty("msg", "access check meets exception! " + e);
|
jo.addProperty("msg", "access check meets exception! " + e);
|
||||||
throw new ScriptReturnException(jo);
|
throw new ScriptReturnException(jo);
|
||||||
} finally {
|
|
||||||
if (globalChanged) Context.setGlobal(oldGlobal);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user