From d76ffc5fd17fc6714e562943fc6a89ca19cdad35 Mon Sep 17 00:00:00 2001 From: yg3630536 <125480926@qq.com> Date: Mon, 23 Dec 2019 10:12:30 +0800 Subject: [PATCH 1/2] adapt jdk for fisco bcos1.3 --- .ci/script/build-ci.sh | 2 +- build-tools/bin/setup.sh | 7 +------ check-info.sh | 3 +-- gradle.properties | 2 +- .../weid/service/impl/engine/BaseEngine.java | 6 +++--- src/main/java/com/webank/weid/util/JsonUtil.java | 15 ++++++++++++++- 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.ci/script/build-ci.sh b/.ci/script/build-ci.sh index 201de2070..28c840eb4 100644 --- a/.ci/script/build-ci.sh +++ b/.ci/script/build-ci.sh @@ -7,7 +7,7 @@ weid_config_tpl=${java_source_code_dir}/src/main/resources/weidentity.properties weid_config=${java_source_code_dir}/src/main/resources/weidentity.properties font=${java_source_code_dir}/src/main/resources/NotoSansCJKtc-Regular.ttf -JAVA_OPTS='-Djdk.tls.namedGroups="secp256k1"' +JAVA_OPTS='-Djdk.tls.namedGroups="secp256r1,secp256k1"' function modify_config() { diff --git a/build-tools/bin/setup.sh b/build-tools/bin/setup.sh index 0e890b08f..c4eacbad6 100644 --- a/build-tools/bin/setup.sh +++ b/build-tools/bin/setup.sh @@ -8,7 +8,7 @@ app_xml_config=${java_source_code_dir}/src/main/resources/fisco.properties weid_config_tpl=${java_source_code_dir}/src/main/resources/weidentity.properties.tpl weid_config=${java_source_code_dir}/src/main/resources/weidentity.properties -JAVA_OPTS='-Djdk.tls.namedGroups="secp256k1"' +JAVA_OPTS='-Djdk.tls.namedGroups="secp256r1,secp256k1"' CLASSPATH=${java_source_code_dir}/dist/conf @@ -134,11 +134,6 @@ function gradle_build_sdk() done - if [[ $bcos_version == 1 ]]; - then - JAVA_OPTS='' - fi - export BLOCKCHIAN_NODE_INFO=$(echo -e ${content}) export WEID_ADDRESS="0x0" export CPT_ADDRESS="0x0" diff --git a/check-info.sh b/check-info.sh index 1af578e48..a61a3eb8a 100644 --- a/check-info.sh +++ b/check-info.sh @@ -1,6 +1,6 @@ #!/bin/bash -JAVA_OPTS='-Djdk.tls.namedGroups="secp256k1"' +JAVA_OPTS='-Djdk.tls.namedGroups="secp256r1,secp256k1"' classpathDir="./dist/conf" libDir="./dist/lib" set -- `getopt c:l: "$@"` @@ -148,7 +148,6 @@ function check_user_config() { else echo "the client.keystore is exists and the MD5 is `md5sum $client_keystore | cut -d " " -f1`" fi - JAVA_OPTS='' elif [[ $bcos_version == 2* ]]; then if [ ! -f "$node_crt" ]; diff --git a/gradle.properties b/gradle.properties index 26a343991..90d54615b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ org.gradle.jvmargs='-Dfile.encoding=UTF-8' -jdkTlsNamedGroups=secp256k1 +jdkTlsNamedGroups=secp256r1,secp256k1 signing.keyId= signing.password= signing.secretKeyRingFile= diff --git a/src/main/java/com/webank/weid/service/impl/engine/BaseEngine.java b/src/main/java/com/webank/weid/service/impl/engine/BaseEngine.java index 366649b81..0af067b2f 100644 --- a/src/main/java/com/webank/weid/service/impl/engine/BaseEngine.java +++ b/src/main/java/com/webank/weid/service/impl/engine/BaseEngine.java @@ -85,7 +85,7 @@ protected static T reloadContract( logger.info(cls.getSimpleName() + " init succ"); } catch (Exception e) { logger.error("load contract :{} failed. Error message is :{}", - cls.getSimpleName(), e); + cls.getSimpleName(), e.getMessage(), e); throw new LoadContractException(); } @@ -116,11 +116,11 @@ protected static T getContractService(String contractAddress, Class cls) } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { logger.error("load contract :{} failed. Error message is :{}", - cls.getSimpleName(), e); + cls.getSimpleName(), e.getMessage(), e); throw new LoadContractException(); } catch (Exception e) { logger.error("load contract Exception:{} failed. Error message is :{}", - cls.getSimpleName(), e); + cls.getSimpleName(), e.getMessage(), e); throw new LoadContractException(); } diff --git a/src/main/java/com/webank/weid/util/JsonUtil.java b/src/main/java/com/webank/weid/util/JsonUtil.java index 3b48a0a46..34929da91 100644 --- a/src/main/java/com/webank/weid/util/JsonUtil.java +++ b/src/main/java/com/webank/weid/util/JsonUtil.java @@ -80,6 +80,7 @@ public class JsonUtil { * * @param cptJsonSchema Map类型的JsonSchema * @return 返回有效Key的集合 + * @throws IOException 可能出现的异常,如JSON序列化异常 */ public static List extractCptProperties(Map cptJsonSchema) throws IOException { @@ -92,6 +93,7 @@ public static List extractCptProperties(Map cptJsonSchem * * @param cptJsonSchema Json类型的JsonSchema * @return 返回有效Key的集合 + * @throws IOException 可能出现的异常,如JSON序列化异常 */ public static List extractCptProperties(String cptJsonSchema) throws IOException { @@ -208,6 +210,7 @@ private static void buildByType(Map resultMap, String key, JType * * @param credential 凭证 * @return 返回处理后的平级Json + * @throws IOException 可能出现的异常,如JSON序列化异常 */ public static Map credentialToMonolayer(CredentialPojo credential) throws IOException { @@ -236,6 +239,7 @@ private static Map monolayerToMap(String json) throws IOExceptio * * @param claimPolicy 披露策略 * @return 返回处理后的平级Json + * @throws IOException 可能出现的异常,如JSON序列化异常 */ public static String claimPolicyToMonolayer(ClaimPolicy claimPolicy) throws IOException { @@ -248,7 +252,9 @@ public static String claimPolicyToMonolayer(ClaimPolicy claimPolicy) throws IOEx * 将多级Json转换成平级Json,无补全处理. * * @param json 多级Json字符串 + * @param radix 需要转换的进制 * @return 返回平级Json + * @throws IOException 可能出现的异常,如JSON序列化异常 */ public static String jsonToMonolayer(String json, int radix) throws IOException { @@ -259,6 +265,7 @@ public static String jsonToMonolayer(String json, int radix) throws IOException * 将多级Json转换成平级Json. * * @param jsonNode 多级的JsonNode + * @param radix 需要转换的进制 * @return 返回平级Json */ public static String jsonToMonolayer(JsonNode jsonNode, int radix) { @@ -549,7 +556,10 @@ private static String decimalToString(String value, int radix) { } /** - * 带循环下标的循环. + * 带循环下标的循环. + * @param 循环出来的泛型对象 + * @param consumer 用户包装循环的Consumer + * @return 包装了循环出来的对象和下标的对象 */ public static Consumer consumerWithIndex(BiConsumer consumer) { @@ -569,7 +579,9 @@ class Index { * 将平级Json转换成多级Json. * * @param json 平级Json字符串 + * @param radix 需要转换的进制 * @return 返回一个多级的Json字符串 + * @throws IOException 可能出现的异常,如JSON序列化异常 */ public static String monolayerToJson(String json, int radix) throws IOException { @@ -580,6 +592,7 @@ public static String monolayerToJson(String json, int radix) throws IOException * 将平级Json转换成多级Json. * * @param jsonNode 平级JsonNode对象 + * @param radix 需要转换的进制 * @return 返回一个多级的Json字符串 */ public static String monolayerToJson(JsonNode jsonNode, int radix) { From 6d56189b04ef420c37551869fe99943183dc3115 Mon Sep 17 00:00:00 2001 From: yg3630536 <125480926@qq.com> Date: Tue, 24 Dec 2019 10:36:14 +0800 Subject: [PATCH 2/2] fix bug --- .../webank/weid/suite/persistence/sql/driver/MysqlDriver.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/webank/weid/suite/persistence/sql/driver/MysqlDriver.java b/src/main/java/com/webank/weid/suite/persistence/sql/driver/MysqlDriver.java index 72b8093ca..0ffd17256 100644 --- a/src/main/java/com/webank/weid/suite/persistence/sql/driver/MysqlDriver.java +++ b/src/main/java/com/webank/weid/suite/persistence/sql/driver/MysqlDriver.java @@ -145,7 +145,8 @@ public ResponseData save(String domain, String id, String data) { String dataKey = DataToolUtils.getHash(id); try { SqlDomain sqlDomain = new SqlDomain(domain); - Object[] datas = {dataKey, data, sqlDomain.getExpire()}; + Date now = sqlDomain.getNow(); + Object[] datas = {dataKey, data, sqlDomain.getExpire(), now, now}; return new SqlExecutor(sqlDomain).execute(SqlExecutor.SQL_SAVE, datas); } catch (WeIdBaseException e) { logger.error("[mysql->save] save the data error.", e);