|
@@ -1,4 +1,5 @@
|
|
|
package com.zhongzheng.common.utils.wisdom;
|
|
|
+
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
|
|
|
import javax.crypto.Mac;
|
|
@@ -113,39 +114,30 @@ public class SignatureUtil {
|
|
|
// }
|
|
|
//
|
|
|
// }
|
|
|
-
|
|
|
getParams(paramMap, buffer);
|
|
|
-
|
|
|
String result = buffer.toString();
|
|
|
-
|
|
|
- System.out.println("签名串:" + result);
|
|
|
-
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
private static void getParams(Map<String, Object> paramMap, StringBuilder buffer) {
|
|
|
List<String> keys = new ArrayList<String>(paramMap.keySet());
|
|
|
Collections.sort(keys);
|
|
|
-
|
|
|
for (String key : keys) {
|
|
|
- if (paramMap.get(key) != null && notfiler(key)){
|
|
|
+ if (paramMap.get(key) != null && notfiler(key)) {
|
|
|
Object obj = paramMap.get(key);
|
|
|
-
|
|
|
if (obj instanceof List<?>) {
|
|
|
try {
|
|
|
List<Map<String, Object>> list = (List<Map<String, Object>>) obj;
|
|
|
-
|
|
|
for (Map<String, Object> map : list) {
|
|
|
- getParams(map , buffer);
|
|
|
+ getParams(map, buffer);
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
System.out.println("list 转map出错 :" + e.getMessage());
|
|
|
}
|
|
|
-
|
|
|
- }else if (obj instanceof Map<?,?>){
|
|
|
+ } else if (obj instanceof Map<?, ?>) {
|
|
|
Map<String, Object> map = (Map<String, Object>) obj;
|
|
|
- getParams(map , buffer);
|
|
|
- }else if (obj instanceof String) {
|
|
|
+ getParams(map, buffer);
|
|
|
+ } else if (obj instanceof String) {
|
|
|
String value = obj.toString();
|
|
|
if (StringUtils.isNotBlank(value)) {
|
|
|
try {
|
|
@@ -163,88 +155,21 @@ public class SignatureUtil {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private static boolean notfiler(String key){
|
|
|
+ private static boolean notfiler(String key) {
|
|
|
boolean flag = true;
|
|
|
Map<String, Integer> map = new HashMap<>();
|
|
|
-
|
|
|
map.put("examineeZipFiles", 0);
|
|
|
-
|
|
|
- if (map.containsKey(key)){
|
|
|
+ if (map.containsKey(key)) {
|
|
|
flag = false;
|
|
|
}
|
|
|
-
|
|
|
return flag;
|
|
|
}
|
|
|
|
|
|
- private static Map<String, Object> getMap(List<Map<String, Object>> paramMapList, String key){
|
|
|
+ private static Map<String, Object> getMap(List<Map<String, Object>> paramMapList, String key) {
|
|
|
Map<String, Object> paramMap = new HashMap<>();
|
|
|
paramMap.put(key, paramMapList);
|
|
|
|
|
|
return paramMap;
|
|
|
}
|
|
|
|
|
|
- public static void main(String[] args) throws Exception {
|
|
|
- //参数
|
|
|
-// Map<String, Object> paramMap = new HashMap<>();
|
|
|
-//
|
|
|
- String key = "ZZ-YXT-GZ-20220820-0001";
|
|
|
-//
|
|
|
-// paramMap.put("appid", key);
|
|
|
-// paramMap.put("appname", "中正云学堂");
|
|
|
-// paramMap.put("tenantId", 10001);
|
|
|
-//
|
|
|
-// //服务端返回的签名
|
|
|
-// String signature = createSignature(paramMap, key);
|
|
|
-//
|
|
|
-// System.out.println("sign:"+ signature);
|
|
|
-//
|
|
|
-// boolean signatureValid = isSignatureValid(paramMap, key, signature);
|
|
|
-//
|
|
|
-// System.out.println("valid:"+ signatureValid);
|
|
|
-//
|
|
|
-// paramMap.put("l", "30");
|
|
|
-//
|
|
|
-// boolean signatureValid1 = isSignatureValid(paramMap, key, signature);
|
|
|
-//
|
|
|
-// System.out.println("valid1:"+ signatureValid1);
|
|
|
-
|
|
|
-// String s = "/bbacc/yy/sss.zip";
|
|
|
-//
|
|
|
-// int index1 = s.lastIndexOf("/");
|
|
|
-// int index2 = s.lastIndexOf(".");
|
|
|
-//
|
|
|
-// String res = s.substring(index1 + 1, index2);
|
|
|
-//
|
|
|
-// System.out.println(res);
|
|
|
-
|
|
|
- List<Map<String, Object>> map = new ArrayList<>();
|
|
|
-
|
|
|
- Map<String, Object> param = new LinkedHashMap<>();
|
|
|
-
|
|
|
- param.put("centerId", 245404160);
|
|
|
- param.put("examCode", "DD6614110143");
|
|
|
- param.put("zipFileName", "111考生证件照");
|
|
|
-
|
|
|
- List<Map<String, Object>> map1 = new ArrayList<>();
|
|
|
-
|
|
|
- Map<String, Object> param1 = new LinkedHashMap<>();
|
|
|
-
|
|
|
- param1.put("examineeCode", "ZS123456");
|
|
|
- param1.put("examineeName", "ddsfs");
|
|
|
- param1.put("idCardImg1", "oss/images/avatar/53/1651809521815_1361907024");
|
|
|
- param1.put("idCardImg2", "oss/images/avatar/53/1651807661764_861745654");
|
|
|
- param1.put("idNumber", "fsdfdsfs");
|
|
|
- param1.put("phone_num", "18565397890");
|
|
|
- param1.put("reportStatus", "未签署");
|
|
|
-
|
|
|
- map1.add(param1);
|
|
|
-
|
|
|
- param.put("examinees",map1);
|
|
|
-
|
|
|
- map.add(param);
|
|
|
-
|
|
|
- String signature = createSignature(map, key);
|
|
|
-
|
|
|
- System.out.println(signature);
|
|
|
- }
|
|
|
}
|