update 对外接口的加解密
This commit is contained in:
@@ -155,5 +155,13 @@
|
|||||||
<classifier>jdk17</classifier>
|
<classifier>jdk17</classifier>
|
||||||
<systemPath>${project.basedir}/lib/aspose-words-21.1-jdk17-cracked.jar</systemPath>
|
<systemPath>${project.basedir}/lib/aspose-words-21.1-jdk17-cracked.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.banboocloud</groupId>
|
||||||
|
<artifactId>bim-codec</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<classifier>jdk17</classifier>
|
||||||
|
<systemPath>${project.basedir}/lib/bim-codec-1.0.0.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@@ -1,78 +1,84 @@
|
|||||||
//package com.jero.modules.iam;
|
package com.jero.modules.iam;
|
||||||
//import com.banboocloud.Codec.BamboocloudFacade;
|
|
||||||
//import com.ruoyi.common.utils.reflect.ReflectUtils;
|
import com.bamboocloud.codec.BamboocloudFacade;
|
||||||
//import org.slf4j.Logger;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
//import org.slf4j.LoggerFactory;
|
|
||||||
//
|
import javax.servlet.http.HttpServletRequest;
|
||||||
//import javax.servlet.http.HttpServletRequest;
|
import java.io.BufferedReader;
|
||||||
//import java.io.BufferedReader;
|
import java.io.IOException;
|
||||||
//import java.io.IOException;
|
import java.util.Iterator;
|
||||||
//import java.util.Iterator;
|
import java.util.Map;
|
||||||
//import java.util.Map;
|
import java.util.TreeMap;
|
||||||
//import java.util.TreeMap;
|
@Slf4j
|
||||||
//public class BamboocloudUtils {
|
public class BamboocloudUtils {
|
||||||
// private static Logger logger = LoggerFactory.getLogger(ReflectUtils.class);
|
public static void main(String[] args) {
|
||||||
// public static boolean checkUsernamePassword(String username, String password) {
|
String aes = BamboocloudFacade.encrypt("{\"uid\":\"104\",\"bimRequestId\":\"95d73fe7aa7a4930a3edea779708a46c\",\"resultCode\":\"0\",\"message\":\"success\"}", "123456", "AES");
|
||||||
// logger.info("username --->" + username + " password --- >" + password + " ----ok");
|
System.out.println(aes);
|
||||||
// if("bbcadmin".equals(username)&&"P@ssw0rd".equals(password)) {
|
String aes1 = getPlaintext("KJ3jbIflWkNiEq3oxE2d5oxtKRLO3CC7edGrq57RIB02RSRgPljiNcTfuWYLS3sc1tbZMLm5fWG2guLK100g9MkWH9NhlxorPSlcP8LaYuP5NeZ1wFP8iKqr5RredwXfDA3J1fjOCAJfzPvJ4HSb1w==", "123456", "AES");
|
||||||
// return true;
|
System.out.println(aes1);
|
||||||
// }
|
}
|
||||||
// else {
|
public static boolean checkUsernamePassword(String username, String password) {
|
||||||
// return false;
|
log.info("username --->" + username + " password --- >" + password + " ----ok");
|
||||||
// }
|
if("bbcadmin".equals(username)&&"P@ssw0rd".equals(password)) {
|
||||||
// }
|
return true;
|
||||||
//
|
}
|
||||||
// public static String getPlaintext(String ciphertext, String key, String type) {
|
else {
|
||||||
// return BamboocloudFacade.decrypt(ciphertext, key, type);
|
return false;
|
||||||
// }
|
}
|
||||||
//
|
}
|
||||||
// public static Boolean verify(Map<String, Object> reqmap, String type) {
|
|
||||||
// Map<String, Object> verifymap = new TreeMap<String, Object>();
|
public static String getPlaintext(String ciphertext, String key, String type) {
|
||||||
// StringBuffer sb = new StringBuffer();
|
return BamboocloudFacade.decrypt(ciphertext, key, type);
|
||||||
// Iterator<String> it = reqmap.keySet().iterator();
|
}
|
||||||
// while (it.hasNext()) {
|
|
||||||
// String key = (String) it.next();
|
public static Boolean verify(Map<String, Object> reqmap, String type) {
|
||||||
// verifymap.put(key, reqmap.get(key));
|
Map<String, Object> verifymap = new TreeMap<String, Object>();
|
||||||
// }
|
StringBuffer sb = new StringBuffer();
|
||||||
// Iterator<String> ittree = verifymap.keySet().iterator();
|
Iterator<String> it = reqmap.keySet().iterator();
|
||||||
// while (ittree.hasNext()) {
|
while (it.hasNext()) {
|
||||||
// String key = (String) ittree.next();
|
String key = (String) it.next();
|
||||||
// if (!"signature".equals(key)) {
|
verifymap.put(key, reqmap.get(key));
|
||||||
// sb.append(key).append("=").append(verifymap.get(key)).append("&");
|
}
|
||||||
// }
|
Iterator<String> ittree = verifymap.keySet().iterator();
|
||||||
// }
|
while (ittree.hasNext()) {
|
||||||
// sb.deleteCharAt(sb.length() - 1);
|
String key = (String) ittree.next();
|
||||||
// System.out.println(reqmap.get("signature") + " now " + sb.toString());
|
if (!"signature".equals(key)) {
|
||||||
// return BamboocloudFacade.verify(reqmap.get("signature").toString(), sb.toString(), type);
|
sb.append(key).append("=").append(verifymap.get(key)).append("&");
|
||||||
// }
|
}
|
||||||
//
|
}
|
||||||
// public static String getRequestBody(HttpServletRequest request) {
|
sb.deleteCharAt(sb.length() - 1);
|
||||||
// BufferedReader br = null;
|
System.out.println(reqmap.get("signature") + " now " + sb.toString());
|
||||||
// StringBuilder sb = new StringBuilder();
|
return BamboocloudFacade.verify(reqmap.get("signature").toString(), sb.toString(), type);
|
||||||
// String str = "";
|
}
|
||||||
// try {
|
|
||||||
// br = request.getReader();
|
public static String getRequestBody(HttpServletRequest request) {
|
||||||
// while ((str = br.readLine()) != null) {
|
BufferedReader br = null;
|
||||||
// sb.append(str);
|
StringBuilder sb = new StringBuilder();
|
||||||
// }
|
String str = "";
|
||||||
// br.close();
|
try {
|
||||||
// } catch (IOException e) {
|
br = request.getReader();
|
||||||
// e.printStackTrace();
|
while ((str = br.readLine()) != null) {
|
||||||
// if (br != null)
|
sb.append(str);
|
||||||
// try {
|
}
|
||||||
// br.close();
|
br.close();
|
||||||
// } catch (IOException eo) {
|
} catch (IOException e) {
|
||||||
// eo.printStackTrace();
|
e.printStackTrace();
|
||||||
// }
|
if (br != null) {
|
||||||
// } finally {
|
try {
|
||||||
// if (br != null) {
|
br.close();
|
||||||
// try {
|
} catch (IOException eo) {
|
||||||
// br.close();
|
eo.printStackTrace();
|
||||||
// } catch (IOException e) {
|
}
|
||||||
// e.printStackTrace();
|
}
|
||||||
// }
|
} finally {
|
||||||
// }
|
if (br != null) {
|
||||||
// }
|
try {
|
||||||
// return sb.toString();
|
br.close();
|
||||||
// }
|
} catch (IOException e) {
|
||||||
//}
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,52 +1,42 @@
|
|||||||
//package com.jero.modules.iam;
|
package com.jero.modules.iam;
|
||||||
//import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
//import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
//import com.banboocloud.Codec.BamboocloudFacade;
|
|
||||||
//import com.ruoyi.common.utils.reflect.ReflectUtils;
|
import com.bamboocloud.codec.BamboocloudFacade;
|
||||||
//import com.ruoyi.framework.web.controller.BaseController;
|
import com.jero.modules.system.service.ISysDepartService;
|
||||||
//import com.ruoyi.project.system.dept.domain.Dept;
|
import com.jero.modules.system.service.ISysRoleService;
|
||||||
//import com.ruoyi.project.system.dept.service.IDeptService;
|
import com.jero.modules.system.service.ISysUserService;
|
||||||
//import com.ruoyi.project.system.dict.domain.DictData;
|
import io.swagger.annotations.Api;
|
||||||
//import com.ruoyi.project.system.dict.service.IDictDataService;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
//import com.ruoyi.project.system.post.domain.Post;
|
import io.swagger.annotations.ApiOperation;
|
||||||
//import com.ruoyi.project.system.post.service.IPostService;
|
import org.slf4j.Logger;
|
||||||
//import com.ruoyi.project.system.role.domain.Role;
|
import org.slf4j.LoggerFactory;
|
||||||
//import com.ruoyi.project.system.role.service.IRoleService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
//import com.ruoyi.project.system.user.domain.User;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
//import com.ruoyi.project.system.user.domain.UserRole;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
//import com.ruoyi.project.system.user.service.IUserService;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
//import com.ruoyi.project.tool.swagger.accessory.*;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
//import io.swagger.annotations.Api;
|
|
||||||
//import io.swagger.annotations.ApiImplicitParam;
|
import javax.servlet.ServletException;
|
||||||
//import io.swagger.annotations.ApiOperation;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
//import org.slf4j.Logger;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
//import org.slf4j.LoggerFactory;
|
import java.io.BufferedReader;
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
import java.io.IOException;
|
||||||
//import org.springframework.web.bind.annotation.PostMapping;
|
import java.io.PrintWriter;
|
||||||
//import org.springframework.web.bind.annotation.RequestMapping;
|
import java.util.*;
|
||||||
//import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
//import org.springframework.web.bind.annotation.RestController;
|
|
||||||
//
|
|
||||||
//import javax.servlet.ServletException;
|
|
||||||
//import javax.servlet.http.HttpServletRequest;
|
|
||||||
//import javax.servlet.http.HttpServletResponse;
|
|
||||||
//import java.io.BufferedReader;
|
|
||||||
//import java.io.IOException;
|
|
||||||
//import java.io.PrintWriter;
|
|
||||||
//import java.util.*;
|
|
||||||
//public class BbcController {
|
//public class BbcController {
|
||||||
//
|
//
|
||||||
// @Autowired
|
// @Autowired
|
||||||
// private IUserService userService;
|
// private ISysUserService userService;
|
||||||
//
|
//
|
||||||
// @Autowired
|
// @Autowired
|
||||||
// private IRoleService roleService;
|
// private ISysRoleService roleService;
|
||||||
//
|
//
|
||||||
// @Autowired
|
// @Autowired
|
||||||
// private IPostService postService;
|
// private IPostService postService;
|
||||||
//
|
//
|
||||||
// @Autowired
|
// @Autowired
|
||||||
// private IDeptService deptService;
|
// private ISysDepartService deptService;
|
||||||
//
|
//
|
||||||
// @Autowired
|
// @Autowired
|
||||||
// private IDictDataService dictDataService;
|
// private IDictDataService dictDataService;
|
||||||
@@ -56,7 +46,7 @@
|
|||||||
//
|
//
|
||||||
// private String bimRequestId;
|
// private String bimRequestId;
|
||||||
//
|
//
|
||||||
// private static Logger logger = LoggerFactory.getLogger(ReflectUtils.class);
|
// private static Logger logger = LoggerFactory.getLogger(BbcController.class);
|
||||||
//
|
//
|
||||||
// @ApiOperation("测试")
|
// @ApiOperation("测试")
|
||||||
// @RequestMapping()
|
// @RequestMapping()
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ import java.security.MessageDigest;
|
|||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
public class SHA256Util {
|
public class SHA256Util {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String sha256StrJava = getSHA256StrJava("123456");
|
||||||
|
System.out.println(sha256StrJava);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 利用java原生的摘要实现SHA256加密密后的报文
|
* 利用java原生的摘要实现SHA256加密密后的报文
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user