【update】 IAM 对接相关资料
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
//package com.jero.modules.iam;
|
||||
//import com.banboocloud.Codec.BamboocloudFacade;
|
||||
//import com.ruoyi.common.utils.reflect.ReflectUtils;
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//import java.io.BufferedReader;
|
||||
//import java.io.IOException;
|
||||
//import java.util.Iterator;
|
||||
//import java.util.Map;
|
||||
//import java.util.TreeMap;
|
||||
//public class BamboocloudUtils {
|
||||
// private static Logger logger = LoggerFactory.getLogger(ReflectUtils.class);
|
||||
// public static boolean checkUsernamePassword(String username, String password) {
|
||||
// logger.info("username --->" + username + " password --- >" + password + " ----ok");
|
||||
// if("bbcadmin".equals(username)&&"P@ssw0rd".equals(password)) {
|
||||
// return true;
|
||||
// }
|
||||
// else {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static String getPlaintext(String ciphertext, String key, String type) {
|
||||
// return BamboocloudFacade.decrypt(ciphertext, key, type);
|
||||
// }
|
||||
//
|
||||
// public static Boolean verify(Map<String, Object> reqmap, String type) {
|
||||
// Map<String, Object> verifymap = new TreeMap<String, Object>();
|
||||
// StringBuffer sb = new StringBuffer();
|
||||
// Iterator<String> it = reqmap.keySet().iterator();
|
||||
// while (it.hasNext()) {
|
||||
// String key = (String) it.next();
|
||||
// verifymap.put(key, reqmap.get(key));
|
||||
// }
|
||||
// Iterator<String> ittree = verifymap.keySet().iterator();
|
||||
// while (ittree.hasNext()) {
|
||||
// String key = (String) ittree.next();
|
||||
// if (!"signature".equals(key)) {
|
||||
// sb.append(key).append("=").append(verifymap.get(key)).append("&");
|
||||
// }
|
||||
// }
|
||||
// sb.deleteCharAt(sb.length() - 1);
|
||||
// System.out.println(reqmap.get("signature") + " now " + sb.toString());
|
||||
// return BamboocloudFacade.verify(reqmap.get("signature").toString(), sb.toString(), type);
|
||||
// }
|
||||
//
|
||||
// public static String getRequestBody(HttpServletRequest request) {
|
||||
// BufferedReader br = null;
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// String str = "";
|
||||
// try {
|
||||
// br = request.getReader();
|
||||
// while ((str = br.readLine()) != null) {
|
||||
// sb.append(str);
|
||||
// }
|
||||
// br.close();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// if (br != null)
|
||||
// try {
|
||||
// br.close();
|
||||
// } catch (IOException eo) {
|
||||
// eo.printStackTrace();
|
||||
// }
|
||||
// } finally {
|
||||
// if (br != null) {
|
||||
// try {
|
||||
// br.close();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return sb.toString();
|
||||
// }
|
||||
//}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,41 @@
|
||||
package com.jero.modules.iam;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class SHA256Util {
|
||||
|
||||
/**
|
||||
* 利用java原生的摘要实现SHA256加密密后的报文
|
||||
*/
|
||||
public static String getSHA256StrJava(String str) {
|
||||
MessageDigest messageDigest;
|
||||
String encodeStr = "";
|
||||
try {
|
||||
messageDigest = MessageDigest.getInstance("SHA-256");
|
||||
messageDigest.update(str.getBytes(StandardCharsets.UTF_8));
|
||||
encodeStr = byte2Hex(messageDigest.digest());
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return encodeStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将byte转为16进制
|
||||
*/
|
||||
private static String byte2Hex(byte[] bytes) {
|
||||
StringBuilder stringBuffer = new StringBuilder();
|
||||
String temp;
|
||||
for (byte aByte : bytes) {
|
||||
temp = Integer.toHexString(aByte & 0xFF);
|
||||
if (temp.length() == 1) {
|
||||
//1得到一位的进行补0操作
|
||||
stringBuffer.append("0");
|
||||
}
|
||||
stringBuffer.append(temp);
|
||||
}
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user