diff --git a/src/main/java/com/bellmann/common/constant/SecurityConstants.java b/src/main/java/com/bellmann/common/constant/SecurityConstants.java
index ef6c4e7..4f31931 100644
--- a/src/main/java/com/bellmann/common/constant/SecurityConstants.java
+++ b/src/main/java/com/bellmann/common/constant/SecurityConstants.java
@@ -25,4 +25,7 @@ public interface SecurityConstants {
String DOMAIN_PREFIX = "domain:";
+
+ String RANGT_TYPE = "authorization_code";
+
}
diff --git a/src/main/java/com/bellmann/common/util/Base64.java b/src/main/java/com/bellmann/common/util/Base64.java
new file mode 100644
index 0000000..71a31de
--- /dev/null
+++ b/src/main/java/com/bellmann/common/util/Base64.java
@@ -0,0 +1,160 @@
+package com.bellmann.common.util;
+
+import java.io.*;
+
+public class Base64 {
+
+ protected static char getChar(int sixbit) {
+ if (sixbit >= 0 && sixbit <= 25) {
+ return (char)(65 + sixbit);
+ }
+
+ if (sixbit >= 26 && sixbit <= 51) {
+ return (char)(97 + (sixbit - 26));
+ }
+
+ if (sixbit >= 52 && sixbit <= 61) {
+ return (char)(48 + (sixbit - 52));
+ }
+
+ if (sixbit == 62) {
+ return '+';
+ }
+
+ return sixbit != 63 ? '?' : '/';
+ }
+
+ protected static int getValue(char c) {
+ if (c >= 'A' && c <= 'Z') {
+ return c - 65;
+ }
+
+ if (c >= 'a' && c <= 'z') {
+ return (c - 97) + 26;
+ }
+
+ if (c >= '0' && c <= '9') {
+ return (c - 48) + 52;
+ }
+
+ if (c == '+') {
+ return 62;
+ }
+
+ if (c == '/') {
+ return 63;
+ }
+
+ return c != '=' ? -1 : 0;
+ }
+
+ public static String encode(byte raw[]) {
+ StringBuffer encoded = new StringBuffer();
+
+ for (int i = 0; i < raw.length; i += 3) {
+ encoded.append(encodeBlock(raw, i));
+ }
+
+ return encoded.toString();
+ }
+
+ protected static char[] encodeBlock(byte raw[], int offset) {
+ int block = 0;
+ int slack = raw.length - offset - 1;
+ int end = slack < 2 ? slack : 2;
+
+ for (int i = 0; i <= end; i++) {
+ byte b = raw[offset + i];
+
+ int neuter = b >= 0 ? ((int) (b)) : b + 256;
+ block += neuter << 8 * (2 - i);
+ }
+
+ char base64[] = new char[4];
+
+ for (int i = 0; i < 4; i++) {
+ int sixbit = block >>> 6 * (3 - i) & 0x3f;
+ base64[i] = getChar(sixbit);
+ }
+
+ if (slack < 1) {
+ base64[2] = '=';
+ }
+
+ if (slack < 2) {
+ base64[3] = '=';
+ }
+
+ return base64;
+ }
+
+ public static byte[] decode(String base64) {
+ int pad = 0;
+
+ for (int i = base64.length() - 1; base64.charAt(i) == '='; i--) {
+ pad++;
+ }
+
+ int length = (base64.length() * 6) / 8 - pad;
+ byte raw[] = new byte[length];
+ int rawindex = 0;
+
+ for (int i = 0; i < base64.length(); i += 4) {
+ int block = (getValue(base64.charAt(i)) << 18) +
+ (getValue(base64.charAt(i + 1)) << 12) +
+ (getValue(base64.charAt(i + 2)) << 6) +
+ getValue(base64.charAt(i + 3));
+
+ for (int j = 0; j < 3 && rawindex + j < raw.length; j++) {
+ raw[rawindex + j] = (byte)(block >> 8 * (2 - j) & 0xff);
+ }
+
+ rawindex += 3;
+ }
+
+ return raw;
+ }
+
+ public static String objectToString(Object o) {
+ if (o == null) {
+ return null;
+ }
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(32000);
+
+ try {
+ ObjectOutputStream os =
+ new ObjectOutputStream(new BufferedOutputStream(baos));
+ os.flush();
+ os.writeObject(o);
+ os.flush();
+ }
+ catch(IOException e) {
+ e.printStackTrace();
+ }
+
+ return encode(baos.toByteArray());
+ }
+
+ public static Object stringToObject(String s) {
+ if (s == null) {
+ return null;
+ }
+
+ byte byteArray[] = decode(s);
+
+ ByteArrayInputStream baos = new ByteArrayInputStream(byteArray);
+
+ try {
+ ObjectInputStream is =
+ new ObjectInputStream(new BufferedInputStream(baos));
+
+ return is.readObject();
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/bellmann/common/util/Base64Utils.java b/src/main/java/com/bellmann/common/util/Base64Utils.java
new file mode 100644
index 0000000..095e8e4
--- /dev/null
+++ b/src/main/java/com/bellmann/common/util/Base64Utils.java
@@ -0,0 +1,140 @@
+package com.bellmann.common.util;
+
+
+import java.io.*;
+
+
+
+/**
+ *
+ * BASE64编码解码工具包
+ *
+ *
+ * 依赖javabase64-1.3.1.jar
+ *
+ *
+ * @author IceWee
+ * @date 2012-5-19
+ * @version 1.0
+ */
+public class Base64Utils {
+
+ /**
+ * 文件读取缓冲区大小
+ */
+ private static final int CACHE_SIZE = 1024;
+
+ /**
+ *
+ * BASE64字符串解码为二进制数据
+ *
+ *
+ * @param base64
+ * @return
+ * @throws Exception
+ */
+ public static byte[] decode(String base64) throws Exception {
+ // return Base64.decode(base64.getBytes());
+ return Base64.decode(base64);
+ }
+
+ /**
+ *
+ * 二进制数据编码为BASE64字符串
+ *
+ *
+ * @param bytes
+ * @return
+ * @throws Exception
+ */
+ public static String encode(byte[] bytes) throws Exception {
+ return new String(Base64.encode(bytes));
+ }
+
+ /**
+ *
+ * 将文件编码为BASE64字符串
+ *
+ *
+ * 大文件慎用,可能会导致内存溢出
+ *
+ *
+ * @param filePath 文件绝对路径
+ * @return
+ * @throws Exception
+ */
+ public static String encodeFile(String filePath) throws Exception {
+ byte[] bytes = fileToByte(filePath);
+ return encode(bytes);
+ }
+
+ /**
+ *
+ * BASE64字符串转回文件
+ *
+ *
+ * @param filePath 文件绝对路径
+ * @param base64 编码字符串
+ * @throws Exception
+ */
+ public static void decodeToFile(String filePath, String base64) throws Exception {
+ byte[] bytes = decode(base64);
+ byteArrayToFile(bytes, filePath);
+ }
+
+ /**
+ *
+ * 文件转换为二进制数组
+ *
+ *
+ * @param filePath 文件路径
+ * @return
+ * @throws Exception
+ */
+ public static byte[] fileToByte(String filePath) throws Exception {
+ byte[] data = new byte[0];
+ File file = new File(filePath);
+ if (file.exists()) {
+ FileInputStream in = new FileInputStream(file);
+ ByteArrayOutputStream out = new ByteArrayOutputStream(2048);
+ byte[] cache = new byte[CACHE_SIZE];
+ int nRead = 0;
+ while ((nRead = in.read(cache)) != -1) {
+ out.write(cache, 0, nRead);
+ out.flush();
+ }
+ out.close();
+ in.close();
+ data = out.toByteArray();
+ }
+ return data;
+ }
+
+ /**
+ *
+ * 二进制数据写文件
+ *
+ *
+ * @param bytes 二进制数据
+ * @param filePath 文件生成目录
+ */
+ public static void byteArrayToFile(byte[] bytes, String filePath) throws Exception {
+ InputStream in = new ByteArrayInputStream(bytes);
+ File destFile = new File(filePath);
+ if (!destFile.getParentFile().exists()) {
+ destFile.getParentFile().mkdirs();
+ }
+ destFile.createNewFile();
+ OutputStream out = new FileOutputStream(destFile);
+ byte[] cache = new byte[CACHE_SIZE];
+ int nRead = 0;
+ while ((nRead = in.read(cache)) != -1) {
+ out.write(cache, 0, nRead);
+ out.flush();
+ }
+ out.close();
+ in.close();
+ }
+
+
+}
diff --git a/src/main/java/com/bellmann/common/util/HexByteUtil.java b/src/main/java/com/bellmann/common/util/HexByteUtil.java
new file mode 100644
index 0000000..c2697f9
--- /dev/null
+++ b/src/main/java/com/bellmann/common/util/HexByteUtil.java
@@ -0,0 +1,58 @@
+package com.bellmann.common.util;
+
+
+
+
+/**
+ *功能说明:
+ *
+ *创建人:李涌
+ *
+ *创建时间:2013-10-31 上午8:40:02
+ *
+ *修改人 修改时间 修改描述
+ *
+ *
+ *Copyright (c)2013 福建富士通信息软件有限公司-版权所有
+ *
+ */
+public class HexByteUtil {
+
+ // ---------------------------
+ // 16进制字符串转数组
+ public static byte[] hexStr2ByteArr(String strIn) throws Exception {
+ byte[] arrB = strIn.getBytes();
+ int iLen = arrB.length;
+
+ // 两个字符表示一个字节,所以字节数组长度是字符串长度除以2
+ byte[] arrOut = new byte[iLen / 2];
+ for (int i = 0; i < iLen; i = i + 2) {
+ String strTmp = new String(arrB, i, 2);
+ arrOut[i / 2] = (byte) Integer.parseInt(strTmp, 16);
+ }
+ return arrOut;
+ }
+
+ // 数组转16进制字符串
+ public static String byteArr2HexStr(byte[] arrB) throws Exception {
+ int iLen = arrB.length;
+ // 每个byte用两个字符才能表示,所以字符串的长度是数组长度的两倍
+ StringBuffer sb = new StringBuffer(iLen * 2);
+ for (int i = 0; i < iLen; i++) {
+ int intTmp = arrB[i];
+ // 把负数转换为正数
+ while (intTmp < 0) {
+ intTmp = intTmp + 256;
+ }
+ // 小于0F的数需要在前面补0
+ if (intTmp < 16) {
+ sb.append("0");
+ }
+ sb.append(Integer.toString(intTmp, 16));
+ }
+ // 最大128位
+ String result = sb.toString();
+ return result;
+ }
+
+}
diff --git a/src/main/java/com/bellmann/common/util/HttpUtil.java b/src/main/java/com/bellmann/common/util/HttpUtil.java
new file mode 100644
index 0000000..90d48a3
--- /dev/null
+++ b/src/main/java/com/bellmann/common/util/HttpUtil.java
@@ -0,0 +1,509 @@
+package com.bellmann.common.util;
+
+
+import org.apache.http.HttpEntity;
+import org.apache.http.NameValuePair;
+import org.apache.http.ParseException;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.io.IOException;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+
+/**
+ * 基于 httpclient 4.5版本的 http工具类
+ *
+ */
+public class HttpUtil {
+
+ private static final CloseableHttpClient httpClient;
+ public static final String CHARSET = "UTF-8";
+ // 采用静态代码块,初始化超时时间配置,再根据配置生成默认httpClient对象
+ static {
+ RequestConfig config = RequestConfig.custom().setConnectTimeout(120000).setSocketTimeout(60000).build();
+ httpClient = HttpClientBuilder.create().setDefaultRequestConfig(config).build();
+ }
+
+ /**
+ * 普通get请求
+ * @param url
+ * @param params
+ * @return
+ */
+ public static String doGet(String url, Map params) {
+ return doGet(url, params, CHARSET);
+ }
+
+
+ /**
+ * get请求绕过https安全证书
+ * @param url
+ * @param params
+ * @param authorization
+ * @return
+ */
+ public static String doGetSSL(String url, Map params,String authorization) {
+ return doGetSSL(url, params, CHARSET,authorization);
+ }
+
+ /**
+ * POST传递普通参数 ,可以配置请求token
+ * @param url
+ * @param params
+ * @param token
+ * @param key
+ * @return
+ * @throws IOException
+ */
+ public static String doPost(String url, Map params,String token,String key) throws IOException {
+ return doPost(url, params, CHARSET, token, key);
+ }
+
+ /**
+ * POST传递普通参数
+ * @param url
+ * @param params
+ * @return
+ */
+ public static String doPost(String url, Map params) {
+ return doPost(url, params, CHARSET);
+ }
+
+ /**
+ * post请求进行安全认证
+ * @param url
+ * @param params
+ * @param token
+ * @param key
+ * @return
+ * @throws IOException
+ */
+ public static String doPostSSL(String url, String params,String token,String key) throws IOException {
+ return doPostSSL(url, params, CHARSET, token, key);
+ }
+
+ /**
+ * post字符串请求不进行安全认证
+ * @param url
+ * @param params
+ * @return
+ * @throws IOException
+ */
+ public static String doPost(String url, String params) throws IOException {
+ return doPost(url, params, CHARSET,null,null);
+ }
+
+ public static String doPostByDcoos(String url, String params,String xAppId,String xAppKey) throws IOException {
+ return doPost(url, params, CHARSET,xAppId,xAppKey);
+ }
+
+
+
+
+ /**
+ * HTTP Get 获取内容
+ * @param url 请求的url地址 ?之前的地址
+ * @param params 请求的参数
+ * @param charset 编码格式
+ * @return 页面内容
+ */
+ public static String doGet(String url, Map params, String charset) {
+
+ try {
+ if (params != null && !params.isEmpty()) {
+ List pairs = new ArrayList(params.size());
+ for (Entry entry : params.entrySet()) {
+ String value = entry.getValue();
+ if (value != null) {
+ pairs.add(new BasicNameValuePair(entry.getKey(), value));
+ }
+ }
+ // 将请求参数和url进行拼接
+ url += "?" + EntityUtils.toString(new UrlEncodedFormEntity(pairs, charset));
+ }
+ HttpGet httpGet = new HttpGet(url);
+ CloseableHttpResponse response = httpClient.execute(httpGet);
+ int statusCode = response.getStatusLine().getStatusCode();
+ if (statusCode != 200) {
+ httpGet.abort();
+ throw new RuntimeException("HttpClient,error status code :" + statusCode);
+ }
+ HttpEntity entity = response.getEntity();
+ String result = null;
+ if (entity != null) {
+ result = EntityUtils.toString(entity, "utf-8");
+ }
+ EntityUtils.consume(entity);
+ response.close();
+ return result;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+
+ /**
+ * HTTP Get 获取内容
+ * @param url 请求的url地址 ?之前的地址
+ * @param params 请求的参数
+ * @param charset 编码格式
+ * @return 页面内容
+ */
+ public static String doPost(String url, Map params, String charset) {
+ String result = null;
+ try {
+ if (params != null && !params.isEmpty()) {
+ List pairs = new ArrayList(params.size());
+ for (Entry entry : params.entrySet()) {
+ String value = entry.getValue();
+ if (value != null) {
+ pairs.add(new BasicNameValuePair(entry.getKey(), value));
+ }
+ }
+ // 将请求参数和url进行拼接
+ url += "?" + EntityUtils.toString(new UrlEncodedFormEntity(pairs, charset));
+ }
+ HttpPost httpPost = new HttpPost(url);
+ //TODO 根据需求 选择 Content-Type 是json , 还是 x-www-form-urlencoded"
+ httpPost.setHeader("Content-Type", "application/json");
+ httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
+
+ CloseableHttpResponse response = httpClient.execute(httpPost);
+ int statusCode = response.getStatusLine().getStatusCode();
+// if (statusCode != 200) {
+// httpPost.abort();
+// throw new RuntimeException("HttpClient,error status code :" + statusCode);
+// }
+ HttpEntity entity = response.getEntity();
+
+ if (entity != null) {
+ result = EntityUtils.toString(entity, "utf-8");
+ }
+ EntityUtils.consume(entity);
+ response.close();
+ return result;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+
+ /**
+ * HTTP Post 获取内容
+ * @param url 请求的url地址 ?之前的地址
+ * @param params 请求的参数
+ * @param charset 编码格式
+ * @return 页面内容
+ * @throws IOException
+ */
+ public static String doPost(String url, Map params, String charset,String token,String key)
+ throws IOException {
+ List pairs = null;
+ //String param=params.get("key").toString();
+ if (params != null && !params.isEmpty()) {
+ pairs = new ArrayList(params.size());
+ for (Entry entry : params.entrySet()) {
+ String value = (String)entry.getValue();
+ if (value != null) {
+ pairs.add(new BasicNameValuePair(entry.getKey(), value));
+ }
+ }
+
+ }
+ HttpPost httpPost = new HttpPost(url);
+ //TODO 根据需求 选择 Content-Type 是json , 还是 x-www-form-urlencoded"
+ httpPost.setHeader("Content-Type", "application/json");
+ httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
+ if(token != null){
+ httpPost.setHeader("authorization", token);
+ }
+
+ //添加请求头验证信息
+
+ if (pairs != null && pairs.size() > 0) {
+ httpPost.setEntity(new UrlEncodedFormEntity(pairs, CHARSET));
+ }
+ //httpPost.setEntity(new StringEntity("5d615d6b53e46c7c4fae420e585d68822b2505c748fc3d1f31d899e5cc11395be782edef053e28cf7c1be89c2b24265ddb469864ce23d47c63f319bf663ed3add68a3db3252c6659b76d1af7aa04fab64f6433d05e23c6458dbd48c418336382c47634d000b18f43f47eb15e59ecd2f8148d3aa31d76626cae665cb321223202"));
+ CloseableHttpResponse response = null;
+ try {
+
+ //绕过证书安全校验
+ CloseableHttpClient httpsClient = HttpUtil.createSSLClientDefault();
+ response = httpsClient.execute(httpPost);
+
+// response = httpClient.execute(httpPost);
+ int statusCode = response.getStatusLine().getStatusCode();
+ if (statusCode != 200) {
+ httpPost.abort();
+ throw new RuntimeException("HttpClient,error status code :" + statusCode);
+ }
+
+ HttpEntity entity = response.getEntity();
+ String result = null;
+ if (entity != null) {
+ result = EntityUtils.toString(entity, "utf-8");
+ }
+ EntityUtils.consume(entity);
+ return result;
+ } catch (ParseException e) {
+ e.printStackTrace();
+ } finally {
+ if (response != null){
+ response.close();
+ }
+
+ }
+ return null;
+ }
+
+
+
+ /**
+ * HTTP Post 获取内容
+ * @param url 请求的url地址 ?之前的地址
+ * @param params 请求的参数
+ * @param charset 编码格式
+ * @return 页面内容
+ * @throws IOException
+ */
+ public static String doPostSSL(String url, String params, String charset,String token,String key)
+ throws IOException {
+ String result = null;
+ HttpPost httpPost = new HttpPost(url);
+ //TODO 根据需求 选择 Content-Type 是json , 还是 x-www-form-urlencoded"
+ httpPost.setHeader("Content-Type", "application/json");
+ httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
+ if(token != null){
+ httpPost.setHeader("authorization", token);
+ }
+
+ //添加请求头验证信息
+// if (pairs != null && pairs.size() > 0) {
+// httpPost.setEntity(new UrlEncodedFormEntity(pairs, CHARSET));
+// }
+ httpPost.setEntity(new StringEntity(params ,CHARSET));
+ CloseableHttpResponse response = null;
+ try {
+
+ //绕过证书安全校验
+ CloseableHttpClient httpsClient = HttpUtil.createSSLClientDefault();
+ response = httpsClient.execute(httpPost);
+
+ int statusCode = response.getStatusLine().getStatusCode();
+ if (statusCode != 200) {
+ httpPost.abort();
+ throw new RuntimeException("HttpClient,error status code :" + statusCode);
+ }
+
+ HttpEntity entity = response.getEntity();
+
+ if (entity != null) {
+ result = EntityUtils.toString(entity, "utf-8");
+ }
+ EntityUtils.consume(entity);
+ return result;
+ } catch (ParseException e) {
+ e.printStackTrace();
+ } finally {
+ if (response != null){
+ response.close();
+ }
+
+ }
+ return result;
+ }
+
+
+
+
+
+ /**
+ * 不用进行证书安全认证
+ * HTTP Post 获取内容
+ * @param url 请求的url地址 ?之前的地址
+ * @param params 请求的参数
+ * @param charset 编码格式
+ * @return 页面内容
+ * @throws IOException
+ */
+ public static String doPost(String url, String params, String charset,String xAppId,String xAppKey) throws IOException {
+
+ HttpPost httpPost = new HttpPost(url);
+ //TODO 根据需求 选择 Content-Type 是json , 还是 x-www-form-urlencoded"
+ httpPost.setHeader("Content-Type", "application/json");
+// httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
+
+ if(xAppId!=null && !xAppId.equals("") && xAppKey!=null && !xAppKey.equals("") ){
+ //调用dcoos需要的id和key
+ httpPost.setHeader("X-APP-ID", xAppId);
+ httpPost.setHeader("X-APP-KEY", xAppKey);
+ }
+
+ httpPost.setEntity(new StringEntity(params ,CHARSET));
+ CloseableHttpResponse response = null;
+ try {
+
+ //绕过证书安全校验
+ // CloseableHttpClient httpsClient = HttpUtil.createSSLClientDefault();
+ response = httpClient.execute(httpPost);
+
+ int statusCode = response.getStatusLine().getStatusCode();
+// if (statusCode != 200) {
+// httpPost.abort();
+// throw new RuntimeException("HttpClient,error status code :" + statusCode);
+// }
+
+ HttpEntity entity = response.getEntity();
+ String result = null;
+ if (entity != null) {
+ result = EntityUtils.toString(entity,CHARSET);
+ }
+ EntityUtils.consume(entity);
+ return result;
+ } catch (ParseException e) {
+ e.printStackTrace();
+ } finally {
+ if (response != null){
+ response.close();
+ }
+
+ }
+ return null;
+ }
+
+
+
+ /**
+ * HTTPS Get 获取内容
+ * @param url 请求的url地址 ?之前的地址
+ * @param params 请求的参数
+ * @param charset 编码格式
+ * @return 页面内容
+ */
+ public static String doGetSSL(String url, Map params, String charset,String authorization) {
+
+ try {
+ if (params != null && !params.isEmpty()) {
+ List pairs = new ArrayList(params.size());
+ for (Entry entry : params.entrySet()) {
+ String value = entry.getValue();
+ if (value != null) {
+ pairs.add(new BasicNameValuePair(entry.getKey(), value));
+ }
+ }
+ url += "?" + EntityUtils.toString(new UrlEncodedFormEntity(pairs, charset));
+ }
+ HttpGet httpGet = new HttpGet(url);
+ httpGet.setHeader("authorization", authorization);
+ // https 注意这里获取https内容,使用了忽略证书的方式,当然还有其他的方式来获取https内容
+ CloseableHttpClient httpsClient = HttpUtil.createSSLClientDefault();
+ CloseableHttpResponse response = httpsClient.execute(httpGet);
+ int statusCode = response.getStatusLine().getStatusCode();
+ if (statusCode != 200) {
+ httpGet.abort();
+ throw new RuntimeException("HttpClient,error status code :" + statusCode);
+ }
+ HttpEntity entity = response.getEntity();
+ String result = null;
+ if (entity != null) {
+ result = EntityUtils.toString(entity, "utf-8");
+ }
+ EntityUtils.consume(entity);
+ response.close();
+ return result;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * 这里创建了忽略整数验证的CloseableHttpClient对象
+ * @return
+ */
+ public static CloseableHttpClient createSSLClientDefault() {
+ try {
+// SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {
+// // 信任所有
+// public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+// return true;
+// }
+// }).build();
+// SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext);
+// return HttpClients.custom().setSSLSocketFactory(sslsf).build();
+ //信任所有
+ X509TrustManager x509mgr = new X509TrustManager() {
+ // 该方法检查客户端的证书,若不信任该证书则抛出异常
+ @Override
+ public void checkClientTrusted(X509Certificate[] xcs, String string) {
+ }
+ // 该方法检查服务端的证书,若不信任该证书则抛出异常
+ @Override
+ public void checkServerTrusted(X509Certificate[] xcs, String string) {
+ }
+ // 返回受信任的X509证书数组。
+ @Override
+ public X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+ };
+ SSLContext sslContext = SSLContext.getInstance("TLS");
+ sslContext.init(null, new TrustManager[] { x509mgr }, null);
+ ////创建HttpsURLConnection对象,并设置其SSLSocketFactory对象
+ SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+
+ // HttpsURLConnection对象就可以正常连接HTTPS了,无论其证书是否经权威机构的验证,只要实现了接口X509TrustManager的类MyX509TrustManager信任该证书。
+ return HttpClients.custom().setSSLSocketFactory(sslsf).build();
+ } catch (KeyManagementException e) {
+ e.printStackTrace();
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ }
+// catch (KeyStoreException e) {
+// e.printStackTrace();
+// }
+ return HttpClients.createDefault();
+ }
+
+
+
+ public static void main(String[] args) throws IOException {
+
+ //String url="http://127.0.0.1:1206/access/basicDevice/getLunaParamBykey";
+ //String url="http://127.0.0.1:1206/access/basicDevice/getLunaParamBykey/sidjsxxnargazvwr";
+ String url="https://134.108.39.15:3725/interface/modifyPwd";
+ String str = null ;
+ try {
+ String p = HttpUtil.doPostSSL(url, str, "eebd93e6-a022-41ec-a932-255433ca3368",null);
+ System.out.println("返回参数p: "+p);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+
+}
diff --git a/src/main/java/com/bellmann/common/util/RSAUtils.java b/src/main/java/com/bellmann/common/util/RSAUtils.java
new file mode 100644
index 0000000..942abf1
--- /dev/null
+++ b/src/main/java/com/bellmann/common/util/RSAUtils.java
@@ -0,0 +1,479 @@
+package com.bellmann.common.util;
+
+
+import javax.crypto.Cipher;
+import java.io.ByteArrayOutputStream;
+import java.nio.charset.Charset;
+import java.security.*;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.interfaces.RSAPublicKey;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.security.spec.X509EncodedKeySpec;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ * RSA公钥/私钥/签名工具包
+ *
+ *
+ * 罗纳德·李维斯特(Ron [R]ivest)、阿迪·萨莫尔(Adi [S]hamir)和伦纳德·阿德曼(Leonard [A]dleman)
+ *
+ *
+ * 字符串格式的密钥在未在特殊说明情况下都为BASE64编码格式
+ * 由于非对称加密速度极其缓慢,一般文件不使用它来加密而是使用对称加密,
+ * 非对称加密算法可以用来对对称加密的密钥加密,这样保证密钥的安全也就保证了数据的安全
+ *
+ *
+ * @author IceWee
+ * @date 2012-4-26
+ * @version 1.0
+ */
+public class RSAUtils {
+
+ private static final String DEFAULT_CHARSET_NAME = "UTF-8";
+
+ /**
+ * 加密算法RSA
+ */
+ public static final String KEY_ALGORITHM = "RSA";
+ /**
+ * Cipher转换名称.
+ */
+ public static final String TRANSFORMATION_NAME = "RSA/ECB/PKCS1Padding";
+ /**
+ * 签名算法
+ */
+ public static final String SIGNATURE_ALGORITHM = "MD5withRSA";
+
+ /**
+ * 获取公钥的key
+ */
+ private static final String PUBLIC_KEY = "RSAPublicKey";
+
+ /**
+ * 获取私钥的key
+ */
+ private static final String PRIVATE_KEY = "RSAPrivateKey";
+
+ /**
+ * RSA最大加密明文大小
+ */
+ private static final int MAX_ENCRYPT_BLOCK = 117;
+
+ /**
+ * RSA最大解密密文大小
+ */
+ private static final int MAX_DECRYPT_BLOCK = 128;
+
+ /**
+ *
+ * 生成密钥对(公钥和私钥)
+ *
+ *
+ * @return
+ * @throws Exception
+ */
+ public static Map genKeyPair() throws Exception {
+ KeyPairGenerator keyPairGen = KeyPairGenerator
+ .getInstance(KEY_ALGORITHM);
+ keyPairGen.initialize(1024);
+ KeyPair keyPair = keyPairGen.generateKeyPair();
+ RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
+ RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
+ Map keyMap = new HashMap(2);
+ keyMap.put(PUBLIC_KEY, publicKey);
+ keyMap.put(PRIVATE_KEY, privateKey);
+ return keyMap;
+ }
+
+ /**
+ *
+ * 用私钥对信息生成数字签名
+ *
+ *
+ * @param data
+ * 已加密数据
+ * @param privateKey
+ * 私钥(BASE64编码)
+ *
+ * @return
+ * @throws Exception
+ */
+ public static String sign(byte[] data, String privateKey) throws Exception {
+ byte[] keyBytes = Base64Utils.decode(privateKey);
+ PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
+ KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
+ PrivateKey privateK = keyFactory.generatePrivate(pkcs8KeySpec);
+ Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM);
+ signature.initSign(privateK);
+ signature.update(data);
+ return Base64Utils.encode(signature.sign());
+ }
+
+ /**
+ *
+ * 校验数字签名
+ *
+ *
+ * @param data
+ * 已加密数据
+ * @param publicKey
+ * 公钥(BASE64编码)
+ * @param sign
+ * 数字签名
+ *
+ * @return
+ * @throws Exception
+ *
+ */
+ public static boolean verify(byte[] data, String publicKey, String sign)
+ throws Exception {
+ byte[] keyBytes = Base64Utils.decode(publicKey);
+ X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes);
+ KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
+ PublicKey publicK = keyFactory.generatePublic(keySpec);
+ Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM);
+ signature.initVerify(publicK);
+ signature.update(data);
+ return signature.verify(Base64Utils.decode(sign));
+ }
+
+ /**
+ *
+ * 私钥解密
+ *
+ *
+ * @param encryptedData
+ * 已加密数据
+ * @param privateKey
+ * 私钥(BASE64编码)
+ * @return
+ * @throws Exception
+ */
+ public static byte[] decryptByPrivateKey(byte[] encryptedData,
+ String privateKey) throws Exception {
+ byte[] keyBytes = Base64Utils.decode(privateKey);
+ PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
+ KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
+ Key privateK = keyFactory.generatePrivate(pkcs8KeySpec);
+ Cipher cipher = Cipher.getInstance(TRANSFORMATION_NAME);
+ cipher.init(Cipher.DECRYPT_MODE, privateK);
+ int inputLen = encryptedData.length;
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ int offSet = 0;
+ byte[] cache;
+ int i = 0;
+ // 对数据分段解密
+ while (inputLen - offSet > 0) {
+ if (inputLen - offSet > MAX_DECRYPT_BLOCK) {
+ cache = cipher
+ .doFinal(encryptedData, offSet, MAX_DECRYPT_BLOCK);
+ } else {
+ cache = cipher
+ .doFinal(encryptedData, offSet, inputLen - offSet);
+ }
+ out.write(cache, 0, cache.length);
+ i++;
+ offSet = i * MAX_DECRYPT_BLOCK;
+ }
+ byte[] decryptedData = out.toByteArray();
+ out.close();
+ return decryptedData;
+ }
+
+
+
+
+ /**
+ *
+ * 公钥解密
+ *
+ *
+ * @param encryptedData
+ * 已加密数据
+ * @param publicKey
+ * 公钥(BASE64编码)
+ * @return
+ * @throws Exception
+ */
+ public static byte[] decryptByPublicKey(byte[] encryptedData,
+ String publicKey) throws Exception {
+ byte[] keyBytes = Base64Utils.decode(publicKey);
+ X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes);
+ KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
+ Key publicK = keyFactory.generatePublic(x509KeySpec);
+ Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
+ cipher.init(Cipher.DECRYPT_MODE, publicK);
+ int inputLen = encryptedData.length;
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ int offSet = 0;
+ byte[] cache;
+ int i = 0;
+ // 对数据分段解密
+ while (inputLen - offSet > 0) {
+ if (inputLen - offSet > MAX_DECRYPT_BLOCK) {
+ cache = cipher
+ .doFinal(encryptedData, offSet, MAX_DECRYPT_BLOCK);
+ } else {
+ cache = cipher
+ .doFinal(encryptedData, offSet, inputLen - offSet);
+ }
+ out.write(cache, 0, cache.length);
+ i++;
+ offSet = i * MAX_DECRYPT_BLOCK;
+ }
+ byte[] decryptedData = out.toByteArray();
+ out.close();
+ return decryptedData;
+ }
+
+
+ /**
+ *
+ * 公钥加密
+ *
+ *
+ * @param data
+ * 源数据
+ * @param publicKey
+ * 公钥(BASE64编码)
+ * @return
+ * @throws Exception
+ */
+ public static byte[] encryptByPublicKey(byte[] data, String publicKey)
+ throws Exception {
+ byte[] keyBytes = Base64Utils.decode(publicKey);
+ X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes);
+ KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
+ Key publicK = keyFactory.generatePublic(x509KeySpec);
+ // 对数据加密
+ Cipher cipher = Cipher.getInstance(TRANSFORMATION_NAME);
+ cipher.init(Cipher.ENCRYPT_MODE, publicK);
+ int inputLen = data.length;
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ int offSet = 0;
+ byte[] cache;
+ int i = 0;
+ // 对数据分段加密
+ while (inputLen - offSet > 0) {
+ if (inputLen - offSet > MAX_ENCRYPT_BLOCK) {
+ cache = cipher.doFinal(data, offSet, MAX_ENCRYPT_BLOCK);
+ } else {
+ cache = cipher.doFinal(data, offSet, inputLen - offSet);
+ }
+ out.write(cache, 0, cache.length);
+ i++;
+ offSet = i * MAX_ENCRYPT_BLOCK;
+ }
+ byte[] encryptedData = out.toByteArray();
+ out.close();
+ return encryptedData;
+ }
+
+
+
+ /**
+ *
+ * 私钥加密
+ *
+ *
+ * @param data
+ * 源数据
+ * @param privateKey
+ * 私钥(BASE64编码)
+ * @return
+ * @throws Exception
+ */
+ public static byte[] encryptByPrivateKey(byte[] data, String privateKey)
+ throws Exception {
+ byte[] keyBytes = Base64Utils.decode(privateKey);
+ PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
+ KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
+ Key privateK = keyFactory.generatePrivate(pkcs8KeySpec);
+ Cipher cipher = Cipher.getInstance(TRANSFORMATION_NAME);
+ cipher.init(Cipher.ENCRYPT_MODE, privateK);
+ int inputLen = data.length;
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ int offSet = 0;
+ byte[] cache;
+ int i = 0;
+ // 对数据分段加密
+ while (inputLen - offSet > 0) {
+ if (inputLen - offSet > MAX_ENCRYPT_BLOCK) {
+ cache = cipher.doFinal(data, offSet, MAX_ENCRYPT_BLOCK);
+ } else {
+ cache = cipher.doFinal(data, offSet, inputLen - offSet);
+ }
+ out.write(cache, 0, cache.length);
+ i++;
+ offSet = i * MAX_ENCRYPT_BLOCK;
+ }
+ byte[] encryptedData = out.toByteArray();
+ out.close();
+ return encryptedData;
+ }
+
+
+
+ /**
+ *
+ * 获取私钥
+ *
+ *
+ * @param keyMap
+ * 密钥对
+ * @return
+ * @throws Exception
+ */
+ public static String getPrivateKey(Map keyMap)
+ throws Exception {
+ Key key = (Key) keyMap.get(PRIVATE_KEY);
+ return Base64Utils.encode(key.getEncoded());
+ }
+
+ /**
+ *
+ * 获取公钥
+ *
+ *
+ * @param keyMap
+ * 密钥对
+ * @return
+ * @throws Exception
+ */
+ public static String getPublicKey(Map keyMap)
+ throws Exception {
+ Key key = (Key) keyMap.get(PUBLIC_KEY);
+ return Base64Utils.encode(key.getEncoded());
+ }
+
+
+
+ /**
+ * 对信息进行加密,通过判断是否为DES 和 RSA,进行不同的加密
+ * @param algorithm
+ * @param dataStr
+ * @param privateKey
+ * @return
+ * @throws Exception
+ */
+ public static String encryptByPrivateKeyStr(String algorithm,String dataStr, String privateKey)
+ throws Exception {
+
+ if(RSAUtils.KEY_ALGORITHM.equals(algorithm)){
+ byte[] data =dataStr.getBytes(DEFAULT_CHARSET_NAME);
+ String encryptedDateStr = HexByteUtil.byteArr2HexStr(encryptByPrivateKey(data, privateKey));
+ return encryptedDateStr;
+ }else if(SimpleDESCry.DES_ALGORITHM.equals(algorithm)){
+ return encryptWithDes(dataStr, privateKey);
+ }
+ return null;
+ }
+
+ /**
+ * DEC算法加密
+ * @param json
+ * @param key
+ * @return
+ * @throws Exception
+ */
+ public static String encryptWithDes(String json,String key) throws Exception{
+ SimpleDESCry sc = new SimpleDESCry();
+ return sc.cry(new StringBuffer(Base64.encode(json.getBytes(Charset.forName("UTF-8")))),key).toString();
+ }
+
+ /**
+ * 公钥加密
+ * @param dataStr
+ * @param publicKey
+ * @return
+ * @throws Exception
+ */
+ public static String encryptByPublicKeyStr(String dataStr, String publicKey)
+ throws Exception {
+ byte[] data =dataStr.getBytes(DEFAULT_CHARSET_NAME);
+ String encryptedDateStr = HexByteUtil.byteArr2HexStr(encryptByPublicKey(data, publicKey));
+ //String encryptedDateStr = Base64Utils.encode(encryptByPublicKey(data, publicKey));
+ return encryptedDateStr;
+ }
+
+
+ /**
+ * 对信息进行解密,通过判断是否为DES 和 RSA,进行不同公钥的解密
+ * @param algorithm
+ * @param encryptedDataStr
+ * @param publicKey
+ * @return
+ * @throws Exception
+ */
+ public static String decryptByPublicKeyStr(String algorithm,String encryptedDataStr,
+ String publicKey) throws Exception {
+
+ if(RSAUtils.KEY_ALGORITHM.equals(algorithm)){
+ byte[] encryptedData = HexByteUtil.hexStr2ByteArr(encryptedDataStr);
+ String str = new String(decryptByPublicKey(encryptedData, publicKey),DEFAULT_CHARSET_NAME);
+ return str;
+ }else if(SimpleDESCry.DES_ALGORITHM.equals(algorithm)){
+ return decryptAccessTokenWithDes(encryptedDataStr, publicKey);
+ }
+ return null;
+
+ }
+ /**
+ * 公钥解密
+ * @param encryptString
+ * @param key
+ * @return
+ * @throws Exception
+ */
+ public static String decryptAccessTokenWithDes(String encryptString ,String key) throws Exception{
+ SimpleDESCry sc = new SimpleDESCry();
+ return new String(Base64.decode(sc.decry(new StringBuffer(encryptString), key).toString()),Charset.forName("UTF-8"));
+ }
+
+
+ /**
+ * 私钥解密
+ * @param encryptedDataStr
+ * @param privateKey
+ * @return
+ * @throws Exception
+ */
+ public static String decryptByPrivateKeyStr(String encryptedDataStr,
+ String privateKey) throws Exception {
+ byte[] encryptedData = HexByteUtil.hexStr2ByteArr(encryptedDataStr);
+ String str = new String(decryptByPrivateKey(encryptedData, privateKey),DEFAULT_CHARSET_NAME);
+ return str;
+ }
+
+
+ /**
+ * 采用RSAUtils进行加密、解密的样例
+ * @param args
+ */
+ public static void main(String[] args) {
+
+ //采用RSA 进行加密、解密
+ String pri_key="MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJUmTjX8Ac7cu/CKGgEbEHztvD0JkueVCasiwBBKYDLGnmxoQRPOcQ4Qa5T6NAgoedDwdzTMcx11fZOBFeYE737JNISgzAm5bV5kv7puJGR/xRFOh34xK0fdV36uX+/ou834BA518IWXYHtfNu+J0oXhdFRUF2N6BkjV6cxOMHxxAgMBAAECgYBLCSFx4V3bf4uBwUjB46bQ4x2/q3Bf18gsc+giifiJswkCyxRqbYLNK4+kPJguvoZCiqe+RVloqbJKojetKDCAV0etcxNWn7fatBi/I9Ip3OgDtmOjViQPtJfEuNM2gnMUdPLUjGmlA/3avQ4jL0M94OVk6o6Quu08AaZADfvkzQJBAN86uy/u4xaUG6xu8zIvMhcovlsEwMOZwD6ZGBXP6Ks0Xq141Uh9oUdAnrKENDiWrnePDPwwtcy80gX259hVfn8CQQCrC43N7/dlp1sF3uFlVPklSVdRxopy3FdIGN59O4CfspES6OGlx6sBvHDj0Y/xOUE7y9gOfiLmZPdUXGHArm0PAkEAxWFM+kkkCmbTQVipOQp6I/gmuJwvRcTBM5hyr3ayqA8aWBCrpflPjY0ZxYcYFaFGivi15pe7aFjc6+ExhxuxSQJAJnZNp95rIle0tyg8RP4LnF/Wm9PqdBOqKNM2zLBhpwePadImU5IHmTdXp1MLbDH0wk5/QhsJHAfeOgEgFiTi7wJAFJSLH9cfF3Bm8dO621dg6salg7Lc8u96geBHkCq9tngX1SgH7sTChIdRKR/IPG+JBskuPl/C5rImhdRbMk/Cfw==";
+
+ String pub_key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVJk41/AHO3LvwihoBGxB87bw9CZLnlQmrIsAQSmAyxp5saEETznEOEGuU+jQIKHnQ8Hc0zHMddX2TgRXmBO9+yTSEoMwJuW1eZL+6biRkf8URTod+MStH3Vd+rl/v6LvN+AQOdfCFl2B7XzbvidKF4XRUVBdjegZI1enMTjB8cQIDAQAB";
+
+ String pwd = "76K7e#";
+
+ try {
+ pwd = RSAUtils.encryptByPrivateKeyStr("RSA",pwd, pri_key);
+ System.out.println("加密== "+ pwd);
+
+ pwd = RSAUtils.decryptByPublicKeyStr("RSA",pwd, pub_key);
+ System.out.println("解密== "+ pwd);
+
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+
+}
diff --git a/src/main/java/com/bellmann/common/util/SimpleDESCry.java b/src/main/java/com/bellmann/common/util/SimpleDESCry.java
new file mode 100644
index 0000000..3f29323
--- /dev/null
+++ b/src/main/java/com/bellmann/common/util/SimpleDESCry.java
@@ -0,0 +1,259 @@
+package com.bellmann.common.util;
+
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ *
+ *功能说明:内部DES加密算法实现,兼容C语言加解密.该方法源码由CRM-曾臻提供.
+ *
+ *创建人:李涌
+ *
+ *创建时间:2013-11-29 下午5:11:18
+ *
+ *修改人 修改时间 修改描述
+ *
+ *
+ *Copyright (c)2013 福建富士通信息软件有限公司-版权所有
+ *
+ */
+public class SimpleDESCry {
+
+ public static final String DES_ALGORITHM = "DES";
+
+ public static final String PRIVATE_KEY = "FFCS_EAM2014";
+ // 明文字符串最大长度
+ private static final int SOURCE_STRING_MAX_LEN = 2048;
+ // 密文字符串最大长度
+ private static final int ENCRYPT_STRING_MAX_LEN = 2048;
+
+ private static final Charset default_charset = Charset.forName("UTF-8");
+
+ private static final StringBuffer str_set=new StringBuffer("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_=+{}[]|\':;.>,/`~!@#$%^&*()");//="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_=+{}[]|\':;.>,/`~!@#$%^&*()";
+ private static final StringBuffer str_pw_set=new StringBuffer("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890");//="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+ private static final char ch_double_quotes = '"';// = '"';
+ //StringBuffer key =new StringBuffer();//= "*bv_.azqadec;d7efbikop,01-fre382";
+
+ StringBuffer des=new StringBuffer();
+ StringBuffer org=new StringBuffer();
+ StringBuffer errormsg=new StringBuffer();
+
+ public SimpleDESCry() {
+ //str_set.append("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_=+{}[]|\':;.>,/`~!@#$%^&*()");
+ //str_pw_set.append("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890");
+ //ch_double_quotes = '"';
+ //key.append(privateKey);
+ }
+ public StringBuffer cry(StringBuffer src2,String privateKey){
+ byte[] src=src2.toString().getBytes(default_charset);
+ StringBuffer tmpch=new StringBuffer();
+ int k;
+ int n_invalid = 1;
+ int i=src.length;
+ int l_set=str_set.length();
+
+ if(!isvalid_org_text(src2)) return des;
+
+ des.setLength(0);
+
+ for(k=0;kSOURCE_STRING_MAX_LEN)
+ {
+ errormsg.setLength(0);
+ errormsg.append("source string is too long!\n");
+ return false;
+ }
+
+ for(int k = 0;kENCRYPT_STRING_MAX_LEN || src_pw.length()%2>0 || src_pw.length()==0)
+ {
+ errormsg.setLength(0);
+ errormsg.append("length of the source string is error!\n");
+ return false;
+ }
+
+ char p_src;
+ char p_pw_set;
+ short n_valid;
+ for(int i=0;i list=new ArrayList();
+
+ for(int i=0;i login(@RequestParam("code")String code) {
+ return Result.success(authService.login(code));
+ }
+
@Operation(summary = "注销")
@DeleteMapping("/logout")
public Result logout() {
diff --git a/src/main/java/com/bellmann/mapper/SysUserMapper.java b/src/main/java/com/bellmann/mapper/SysUserMapper.java
index 7d637a1..0336ac4 100644
--- a/src/main/java/com/bellmann/mapper/SysUserMapper.java
+++ b/src/main/java/com/bellmann/mapper/SysUserMapper.java
@@ -9,6 +9,7 @@ import com.bellmann.model.entity.SysUser;
import com.bellmann.model.dto.UserAuthInfo;
import com.bellmann.model.query.UserPageQuery;
import com.bellmann.model.vo.UserExportVO;
+import com.bellmann.security.model.SysUserDetails;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
diff --git a/src/main/java/com/bellmann/model/login/AccessTokenResponse.java b/src/main/java/com/bellmann/model/login/AccessTokenResponse.java
new file mode 100644
index 0000000..4e1e707
--- /dev/null
+++ b/src/main/java/com/bellmann/model/login/AccessTokenResponse.java
@@ -0,0 +1,98 @@
+package com.bellmann.model.login;
+
+
+
+import java.io.Serializable;
+
+/**
+ * 自定义 token 信息体
+ *
+ * @author xiangy
+ * @date 2023-1-15
+ */
+
+public class AccessTokenResponse implements Serializable {
+
+ private static final long serialVersionUID = -1L;
+
+ /**
+ * 事务ID
+ */
+
+ private String sessionid;
+
+ /**
+ * token 信息
+ */
+
+ private String tokenvalue;
+
+ /**
+ * 用户信息
+ */
+
+ private LdapStaffVo user;
+
+ /**
+ * 系统发生跳转时传递的组织UUID.
+ */
+
+ private String currentorguuid;
+
+ /**
+ * 单点使用的备用字段
+ */
+ private String ssoSpare;
+
+ public String getSessionid() {
+ return sessionid;
+ }
+
+ public void setSessionid(String sessionid) {
+ this.sessionid = sessionid;
+ }
+
+ public String getTokenvalue() {
+ return tokenvalue;
+ }
+
+ public void setTokenvalue(String tokenvalue) {
+ this.tokenvalue = tokenvalue;
+ }
+
+ public LdapStaffVo getUser() {
+ return user;
+ }
+
+ public void setUser(LdapStaffVo user) {
+ this.user = user;
+ }
+
+ public String getCurrentorguuid() {
+ return currentorguuid;
+ }
+
+ public void setCurrentorguuid(String currentorguuid) {
+ this.currentorguuid = currentorguuid;
+ }
+
+ public String getSsoSpare() {
+ return ssoSpare;
+ }
+
+ public void setSsoSpare(String ssoSpare) {
+ this.ssoSpare = ssoSpare;
+ }
+
+ public static long getSerialversionuid() {
+ return serialVersionUID;
+ }
+
+ @Override
+ public String toString() {
+ return "AccessTokenResponse [sessionid=" + sessionid + ", tokenvalue=" + tokenvalue + ", user=" + user
+ + ", currentorguuid=" + currentorguuid + ", ssoSpare=" + ssoSpare + "]";
+ }
+
+
+}
diff --git a/src/main/java/com/bellmann/model/login/BsOrCsResponeResult.java b/src/main/java/com/bellmann/model/login/BsOrCsResponeResult.java
new file mode 100644
index 0000000..eda2d70
--- /dev/null
+++ b/src/main/java/com/bellmann/model/login/BsOrCsResponeResult.java
@@ -0,0 +1,36 @@
+package com.bellmann.model.login;
+
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * @author xiangy
+ */
+
+public class BsOrCsResponeResult {
+ //token 的超时时间,默认 129590 描述
+ @JsonProperty("expires_in")
+ private String expires_in ;
+ //token 加密报文
+ @JsonProperty("access_token")
+ private String access_token ;
+ public String getExpires_in() {
+ return expires_in;
+ }
+ public void setExpires_in(String expires_in) {
+ this.expires_in = expires_in;
+ }
+ public String getAccess_token() {
+ return access_token;
+ }
+ public void setAccess_token(String access_token) {
+ this.access_token = access_token;
+ }
+ @Override
+ public String toString() {
+ return "BsOrCsResponeResult [expires_in=" + expires_in + ", access_token=" + access_token + "]";
+ }
+
+
+
+}
diff --git a/src/main/java/com/bellmann/model/login/LdapStaffVo.java b/src/main/java/com/bellmann/model/login/LdapStaffVo.java
new file mode 100644
index 0000000..488801f
--- /dev/null
+++ b/src/main/java/com/bellmann/model/login/LdapStaffVo.java
@@ -0,0 +1,156 @@
+package com.bellmann.model.login;
+
+
+import java.io.Serializable;
+
+
+public class LdapStaffVo implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -8056124373704500401L;
+
+ /**
+ * 用户主账号.
+ */
+
+ private String staffAccount;
+
+ /**
+ * 姓名.
+ */
+
+ private String staffName;
+
+ /**
+ * 手机号码.
+ */
+ private String mobilePhone;
+
+ /**
+ * 身份证号.
+ */
+ private String certNumber;
+
+ /**
+ * 业务系统从账号:用户真实使用的账号
+ */
+ private String relaStaffAccount;
+
+ /**
+ * 集团人力编码
+ */
+
+ private String ctHrCode;
+
+ /**
+ * 集团邮箱
+ */
+
+ private String ctMail;
+
+ /**
+ * 新增主数据中心组织的区域标识
+ */
+ private String uooOrgAreaCode;
+
+ /**
+ * 新增主数据中心组织id标识
+ */
+ private Long uooOrgId;
+
+ public String getStaffAccount() {
+ return staffAccount;
+ }
+
+ public void setStaffAccount(String staffAccount) {
+ this.staffAccount = staffAccount;
+ }
+
+ public String getStaffName() {
+ return staffName;
+ }
+
+ public void setStaffName(String staffName) {
+ this.staffName = staffName;
+ }
+
+ public String getMobilePhone() {
+ return mobilePhone;
+ }
+
+ public void setMobilePhone(String mobilePhone) {
+ this.mobilePhone = mobilePhone;
+ }
+
+ public String getCertNumber() {
+ return certNumber;
+ }
+
+ public void setCertNumber(String certNumber) {
+ this.certNumber = certNumber;
+ }
+
+ public String getRelaStaffAccount() {
+ return relaStaffAccount;
+ }
+
+ public void setRelaStaffAccount(String relaStaffAccount) {
+ this.relaStaffAccount = relaStaffAccount;
+ }
+
+ public String getCtHrCode() {
+ return ctHrCode;
+ }
+
+ public void setCtHrCode(String ctHrCode) {
+ this.ctHrCode = ctHrCode;
+ }
+
+ public String getCtMail() {
+ return ctMail;
+ }
+
+ public void setCtMail(String ctMail) {
+ this.ctMail = ctMail;
+ }
+
+ public String getUooOrgAreaCode() {
+ return uooOrgAreaCode;
+ }
+
+ public void setUooOrgAreaCode(String uooOrgAreaCode) {
+ this.uooOrgAreaCode = uooOrgAreaCode;
+ }
+
+ public Long getUooOrgId() {
+ return uooOrgId;
+ }
+
+ public void setUooOrgId(Long uooOrgId) {
+ this.uooOrgId = uooOrgId;
+ }
+
+ public static long getSerialversionuid() {
+ return serialVersionUID;
+ }
+
+
+ @Override
+ public String toString() {
+ return "Test{" +
+ "staffAccount='" + staffAccount + '\'' +
+ ", staffName='" + staffName + '\'' +
+ ", mobilePhone='" + mobilePhone + '\'' +
+ ", certNumber='" + certNumber + '\'' +
+ ", relaStaffAccount='" + relaStaffAccount + '\'' +
+ ", ctHrCode='" + ctHrCode + '\'' +
+ ", ctMail='" + ctMail + '\'' +
+ ", uooOrgAreaCode='" + uooOrgAreaCode + '\'' +
+ ", uooOrgId=" + uooOrgId +
+ '}';
+ }
+
+
+}
diff --git a/src/main/java/com/bellmann/runner/ServiceManagerRunner.java b/src/main/java/com/bellmann/runner/ServiceManagerRunner.java
index b84bbbc..0e62f24 100644
--- a/src/main/java/com/bellmann/runner/ServiceManagerRunner.java
+++ b/src/main/java/com/bellmann/runner/ServiceManagerRunner.java
@@ -16,7 +16,7 @@ public class ServiceManagerRunner implements ApplicationRunner {
new Thread("ServiceManager") {
@Override
public void run() {
- UIService.getInstance().start();
+// UIService.getInstance().start();
}
}.start();
log.info("ServiceManager started");
diff --git a/src/main/java/com/bellmann/security/util/JwtUtils.java b/src/main/java/com/bellmann/security/util/JwtUtils.java
index 4fc4023..59a36d7 100644
--- a/src/main/java/com/bellmann/security/util/JwtUtils.java
+++ b/src/main/java/com/bellmann/security/util/JwtUtils.java
@@ -85,6 +85,32 @@ public class JwtUtils {
}
+ public static String generateToken(SysUserDetails userDetails) {
+
+ //SysUserDetails userDetails = (SysUserDetails) authentication.getPrincipal();
+ Map payload = new HashMap<>();
+ payload.put(JwtClaimConstants.USER_ID, userDetails.getUserId()); // 用户ID
+ payload.put(JwtClaimConstants.DEPT_ID, userDetails.getDeptId()); // 部门ID
+ payload.put(JwtClaimConstants.DATA_SCOPE, userDetails.getDataScope()); // 数据权限范围
+ payload.put(JwtClaimConstants.GROUP_ID,userDetails.getGroupId());//用户分组ID(管理域ID)
+ // claims 中添加角色信息
+ Set roles = userDetails.getAuthorities().stream()
+ .map(GrantedAuthority::getAuthority)
+ .collect(Collectors.toSet());
+ payload.put(JwtClaimConstants.AUTHORITIES, roles);
+
+
+ Date now = new Date();
+ Date expiration = DateUtil.offsetSecond(now, ttl);
+ payload.put(JWTPayload.ISSUED_AT, now);
+ payload.put(JWTPayload.EXPIRES_AT, expiration);
+ payload.put(JWTPayload.SUBJECT, userDetails.getUsername());
+ payload.put(JWTPayload.JWT_ID, IdUtil.simpleUUID());
+
+ return JWTUtil.createToken(payload, JwtUtils.key);
+ }
+
+
/**
* 从 JWT Token 中解析 Authentication 用户认证信息
*
diff --git a/src/main/java/com/bellmann/service/AuthService.java b/src/main/java/com/bellmann/service/AuthService.java
index a3abed5..538fdb5 100644
--- a/src/main/java/com/bellmann/service/AuthService.java
+++ b/src/main/java/com/bellmann/service/AuthService.java
@@ -20,6 +20,8 @@ public interface AuthService {
*/
LoginResult login(String username, String password);
+ LoginResult login(String code);
+
/**
* 登出
*/
diff --git a/src/main/java/com/bellmann/service/impl/AuthServiceImpl.java b/src/main/java/com/bellmann/service/impl/AuthServiceImpl.java
index 24a8094..b13a42a 100644
--- a/src/main/java/com/bellmann/service/impl/AuthServiceImpl.java
+++ b/src/main/java/com/bellmann/service/impl/AuthServiceImpl.java
@@ -7,16 +7,27 @@ import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.jwt.JWTPayload;
+import com.alibaba.fastjson.JSONObject;
import com.bellmann.common.constant.SecurityConstants;
import com.bellmann.common.enums.CaptchaTypeEnum;
+import com.bellmann.common.util.HttpClientResult;
+import com.bellmann.common.util.HttpClientUtil;
+import com.bellmann.common.util.HttpUtil;
+import com.bellmann.common.util.RSAUtils;
+import com.bellmann.config.Config4A;
+import com.bellmann.mapper.SysUserMapper;
import com.bellmann.model.dto.CaptchaResult;
import com.bellmann.model.dto.LoginResult;
+import com.bellmann.model.dto.UserAuthInfo;
+import com.bellmann.model.login.AccessTokenResponse;
+import com.bellmann.model.login.BsOrCsResponeResult;
+import com.bellmann.model.login.LdapStaffVo;
import com.bellmann.plugin.captcha.CaptchaProperties;
-import com.bellmann.service.AuthService;
+import com.bellmann.security.model.SysUserDetails;
import com.bellmann.security.util.JwtUtils;
+import com.bellmann.service.AuthService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpHeaders;
import org.springframework.security.authentication.AuthenticationManager;
@@ -24,11 +35,13 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.awt.*;
+import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@@ -51,6 +64,10 @@ public class AuthServiceImpl implements AuthService {
private final Font captchaFont;
private final CaptchaProperties captchaProperties;
+ private final Config4A config4A;
+
+ private final SysUserMapper userMapper;
+
/**
* 登录
*
@@ -70,6 +87,71 @@ public class AuthServiceImpl implements AuthService {
.build();
}
+ @Override
+ public LoginResult login(String code) {
+
+ //HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
+ //String code4A = request.getParameter("code");
+ log.info("start login ... {}", code);
+ //调用4A的令牌换取接口
+ //填充请求信息
+ Map map = new HashMap();
+ map.put("grant_type",SecurityConstants.RANGT_TYPE);
+ map.put("redirect_uri", config4A.getRedirectUrl());
+ map.put("code",code);
+ //填充目标系统id : 假设目标系统为ITSM系统
+ map.put("client_id", config4A.getClientId());
+
+ // 要求使用code访问4a统一登录平台,申请access_token
+ String res = HttpUtil.doPost(config4A.getHttpTokenAuthUrl(), map);
+ BsOrCsResponeResult bsOrCsResponeResult = null;
+ bsOrCsResponeResult = JSONObject.parseObject(res, BsOrCsResponeResult.class);
+
+ String token = bsOrCsResponeResult.getAccess_token();
+ try {
+ token = RSAUtils.decryptByPrivateKeyStr(token, config4A.getSecurity());
+ }catch (Exception e) {
+ log.info("decry pass error : {}", token);
+ }
+ log.info("token success : {}", token);
+ AccessTokenResponse tokenResponse = JSONObject.parseObject(token, AccessTokenResponse.class);
+ LdapStaffVo ldapStaffVo = tokenResponse.getUser();
+
+ // 获取到用户信息, 模拟登录
+ UserAuthInfo user = userMapper.getUserAuthInfo(ldapStaffVo.getStaffAccount());
+ SysUserDetails userDetails = new SysUserDetails(user);
+// UsernamePasswordAuthenticationToken authenticationToken =
+// new UsernamePasswordAuthenticationToken(ldapStaffVo.getStaffName().toLowerCase().trim(),
+// "bellmannAdmin");
+// Authentication authentication = authenticationManager.authenticate(authenticationToken);
+ String accessToken = JwtUtils.generateToken(userDetails);
+ return LoginResult.builder()
+ .tokenType("Bearer")
+ .accessToken(accessToken)
+ .build();
+ }
+
+
+ public static void main(String[] args) {
+
+ BsOrCsResponeResult bsOrCsResponeResult = new BsOrCsResponeResult();
+
+ String content = "{\"expires_in\":\"105819\",\"access_token\":\"20e2ffab563a5b6ef683820529270d7ab89893a1c40aa1531b4805bfad6f290976d941d9dd5fb1506ff07f406963a6609126358b47974efd6bfda9e97952a378f9313d5792bb0ecb1a7c6d6eb108d6dc64489f18e4c70d220a9d87daf3edfcd67e087d7b48136ced65d237e9b6468bce2f09d5eef9e09cbd1b8009bb25dd1b9504231cf8b5c03de351976fad120e6962644a8b83ce87c22de0adc851f44a444d35cb582fbcfed3ff9e97866070f51f94ac921784c4f7c0c56f92cdb1eca78c1f04bc7a27e524b33a3f70dcf14844a57d3004cab133edf4fa753cb7e5746277057550351bef7c8c48aba6f527768d5e160f0a0398c89b67a740ddf71d6c4e3a9228e999035fb8063a31429cb4d637783e010f4378611f8961df7ec1dd403f3e28cd79a27988bd6b474817bdbe528fe4467e2b95acb64177d20b12a152cbac2751571a82a97e0357d28e31a88d59b6e1232963566f51b469e814dc836b4c500f04e3838c7a8ba82dcc382a36bd2ee266b4b1b0c38940fe328070d3b6b789f8f2ae3aae0d1560213318084b03aa63c193c1d11f6bad6f56233a86c055bd23cf300d2806f48ad39c690359a192a72da63a31b9291c20f74019cb192326d4209580597f69d13aede9989eac01225ac016f923d5a7d5dde883d035b58662ecbb91af23972cd3637d3248595f82354661b10065239892f1f050f1ce7ad2c0d91eb8af70116d51d23a1bc90803c564896c6377f40b712d4e267020389fc315e37dc5b48c02d113aefba9f669fc1e139a3924e99c070c96114de543c01faee3633db5857e9202bb514fffca4ae2ba69538dc600cf119b6bd819cf5a4923c3d0937789018ec30aa6b359ef1b5fa234d894f2298b6e4537333fb3c37153707285b02ecde7d545cae9eef71097d02a3506c4087a7d1db565215d37ace9bb63598476d3609cf2b4512e5cd4e30e49e6b746f974525890863a5a7243e185da1900464a66914542a1725f03dc6aef689d3f6515c2d34f709b5d9b2c21ab86fdeb7eadf9f47b21777a6761848114c792891593dd14e425cc9a6ecd0c4e705f3398681a2f418c2512032bfe77f86b36b2bf4e2141fb40f714ad228a616913a494c81869401fa810c70957a9dfb0e876c123ddee2bd156d290649176510bf40c27f819bc35300711febc502cf957007c4a811b19af0b3e25e66ea6d0509f1c732eb3870a86c2084a6e69dc784741403ae878889e0203bdfb97d0965e73b6e4cd2fcecb5a9a2f02dfb071992a9886060c1f850ef845479ea2eed62918012e5eb4efced2e592a9b678ec262a20ed08aadebd3c7663448967d6d52fe8d6a305c2af772b7fe42aca0bc8de4749370771162c88d6dcc2268eb8cf2a75a9db90006b2fc5b2eaf0a5a876ddf48b208ca91d008a687f1b4065320f24091791951526a1232969d8080226966f2265aacef937d64fdc21fcb26e703d921f402efb8525af798529cd1e4080210e36a62ccce7527cce9fa62eee0d24ffd4c3dc8fe9ef63084540cd5b386e2339a47e453c4f74df88a4224bfc3b11f2851caf5f1e1f40d3e37ec9b62cc2466c52bf961f4eea7aae0926ba02275a02e964a269da47268c8c2654e0b1bdeae1817712bf\"}";
+
+ bsOrCsResponeResult = JSONObject.parseObject(content, BsOrCsResponeResult.class);
+
+ String token = bsOrCsResponeResult.getAccess_token();
+
+ String config4A = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJESA0kRw+/cIwUNGp9iJS/dZAg3fEy3izQfN0gAE8EYWhCMwPt8EH1UWNuK3+ka0qUbbwzwXOAR2e54p4zK06GqI8Vym83XOQ7G2kfT1Q657VDMnMym9eYdRf+i5qndb/7vjsV5qVuijxmwvtc0ITmciIHZSIS9Wt6W0/AJ2iBhAgMBAAECgYAA9pLHQssPXgGtBEjhl0YaLuD9xXmJrFvMHytvqtF2wh3B959F5C1bWaqj3YSOUIdmwXt/pV5mffPZl5s8LfIRAYb6PChTMElll5AL0ETs6MSusxO9+PhPzkpFmUcNr4WmtbNIhbHB8GIJAGPDwH/jdt8AGgBXEQ8ORuv+owFd2QJBAMzXHVuIF0KyHBpyaFLolkJR2N4WC5BiOXpav+dkdXTzJqIoYp4ZJ8XrIUOHz305d7uivwOMLMT/E0OZZCU0Q5kCQQC1TWKDcVlpA3PWUSXYTFaGHVzc1kwtuPHtOWqBP02Wsc5QfigJgnH+7SOj2OLvYGM5Y65jofm/qL4G8+ldecAJAkBZeo5kcWpXxB3qn5dawCcDCWXGfbLHe2DIReQWXBfC4oQ5yZJqpWpuVmvNaAIHHZdj64+tKQpVc2ci3FqWteHhAkAKe1/fs5T0wlNXJ7flanxyIo504hrjZdbu3SvwLwXAWaVQ+Ao+ioEmuPUfivGL32m9LqstbXbwAsSByGZMljZpAkEAlBOzSpUJdRWsIIrDA9W5jBFXpMS46fYqWR2gVvglTmN1PSZqU694tOf3uwSaqGchHibMqen5z+9HU4XR5vZj9A==";
+ try {
+ token = RSAUtils.decryptByPrivateKeyStr(token, config4A);
+ }catch (Exception e) {
+ log.info("decry pass error : {}", token);
+ }
+ log.info("token success : {}", token);
+
+ }
+
/**
* 注销
*/
diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml
index 1cc4003..a483226 100644
--- a/src/main/resources/application-dev.yml
+++ b/src/main/resources/application-dev.yml
@@ -10,15 +10,15 @@ spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: org.postgresql.Driver
- url: jdbc:postgresql://180.166.220.225:5432/itms-new
- username: postgres
- password: V8GNgzJ1
+ url: jdbc:postgresql://172.22.135.68:5432/itms?currentSchema=itms
+ username: itms
+ password: itms_cs
redis:
database: 6
- host: 47.115.231.99
+ host: localhost
port: 6379
- password: 522227lxlfml.
+# password: 522227lxlfml.
timeout: 10s
lettuce:
pool:
@@ -113,3 +113,9 @@ captcha:
# 验证码有效期(秒)
expire-seconds: 120
+login:
+ url: http://134.96.180.12:30597/index
+ clientId: CTZJITMS20230606
+ security: MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJESA0kRw+/cIwUNGp9iJS/dZAg3fEy3izQfN0gAE8EYWhCMwPt8EH1UWNuK3+ka0qUbbwzwXOAR2e54p4zK06GqI8Vym83XOQ7G2kfT1Q657VDMnMym9eYdRf+i5qndb/7vjsV5qVuijxmwvtc0ITmciIHZSIS9Wt6W0/AJ2iBhAgMBAAECgYAA9pLHQssPXgGtBEjhl0YaLuD9xXmJrFvMHytvqtF2wh3B959F5C1bWaqj3YSOUIdmwXt/pV5mffPZl5s8LfIRAYb6PChTMElll5AL0ETs6MSusxO9+PhPzkpFmUcNr4WmtbNIhbHB8GIJAGPDwH/jdt8AGgBXEQ8ORuv+owFd2QJBAMzXHVuIF0KyHBpyaFLolkJR2N4WC5BiOXpav+dkdXTzJqIoYp4ZJ8XrIUOHz305d7uivwOMLMT/E0OZZCU0Q5kCQQC1TWKDcVlpA3PWUSXYTFaGHVzc1kwtuPHtOWqBP02Wsc5QfigJgnH+7SOj2OLvYGM5Y65jofm/qL4G8+ldecAJAkBZeo5kcWpXxB3qn5dawCcDCWXGfbLHe2DIReQWXBfC4oQ5yZJqpWpuVmvNaAIHHZdj64+tKQpVc2ci3FqWteHhAkAKe1/fs5T0wlNXJ7flanxyIo504hrjZdbu3SvwLwXAWaVQ+Ao+ioEmuPUfivGL32m9LqstbXbwAsSByGZMljZpAkEAlBOzSpUJdRWsIIrDA9W5jBFXpMS46fYqWR2gVvglTmN1PSZqU694tOf3uwSaqGchHibMqen5z+9HU4XR5vZj9A==
+ redirectUrl: http://172.20.133.149:8080/login
+ httpTokenAuthUrl: http://134.96.180.12:30597/zjOauth/oauth/token
diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml
index 854f215..1d544bd 100644
--- a/src/main/resources/application-prod.yml
+++ b/src/main/resources/application-prod.yml
@@ -112,3 +112,10 @@ captcha:
# 验证码有效期(秒)
expire-seconds: 120
+
+login:
+ url: http://134.108.76.137:7001/index
+ clientId: CTZJITMS20230606
+ security: MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJESA0kRw+/cIwUNGp9iJS/dZAg3fEy3izQfN0gAE8EYWhCMwPt8EH1UWNuK3+ka0qUbbwzwXOAR2e54p4zK06GqI8Vym83XOQ7G2kfT1Q657VDMnMym9eYdRf+i5qndb/7vjsV5qVuijxmwvtc0ITmciIHZSIS9Wt6W0/AJ2iBhAgMBAAECgYAA9pLHQssPXgGtBEjhl0YaLuD9xXmJrFvMHytvqtF2wh3B959F5C1bWaqj3YSOUIdmwXt/pV5mffPZl5s8LfIRAYb6PChTMElll5AL0ETs6MSusxO9+PhPzkpFmUcNr4WmtbNIhbHB8GIJAGPDwH/jdt8AGgBXEQ8ORuv+owFd2QJBAMzXHVuIF0KyHBpyaFLolkJR2N4WC5BiOXpav+dkdXTzJqIoYp4ZJ8XrIUOHz305d7uivwOMLMT/E0OZZCU0Q5kCQQC1TWKDcVlpA3PWUSXYTFaGHVzc1kwtuPHtOWqBP02Wsc5QfigJgnH+7SOj2OLvYGM5Y65jofm/qL4G8+ldecAJAkBZeo5kcWpXxB3qn5dawCcDCWXGfbLHe2DIReQWXBfC4oQ5yZJqpWpuVmvNaAIHHZdj64+tKQpVc2ci3FqWteHhAkAKe1/fs5T0wlNXJ7flanxyIo504hrjZdbu3SvwLwXAWaVQ+Ao+ioEmuPUfivGL32m9LqstbXbwAsSByGZMljZpAkEAlBOzSpUJdRWsIIrDA9W5jBFXpMS46fYqWR2gVvglTmN1PSZqU694tOf3uwSaqGchHibMqen5z+9HU4XR5vZj9A==
+ redirectUrl: http://172.20.133.184:8080/login
+ httpTokenAuthUrl: http://134.108.76.137:7001/zjOauth/oauth/token
diff --git a/src/test/java/com/bellmann/DemoTest.java b/src/test/java/com/bellmann/DemoTest.java
new file mode 100644
index 0000000..2a67d91
--- /dev/null
+++ b/src/test/java/com/bellmann/DemoTest.java
@@ -0,0 +1,39 @@
+package com.bellmann;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.bellmann.common.util.RSAUtils;
+import com.bellmann.config.Config4A;
+import com.bellmann.model.login.BsOrCsResponeResult;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+@Slf4j
+public class DemoTest {
+
+
+ @Autowired
+ private Config4A config4A;
+
+ @Test
+ public void test1() {
+ BsOrCsResponeResult bsOrCsResponeResult = new BsOrCsResponeResult();
+
+ String content = "{\"expires_in\":\"105819\",\"access_token\":\"20e2ffab563a5b6ef683820529270d7ab89893a1c40aa1531b4805bfad6f290976d941d9dd5fb1506ff07f406963a6609126358b47974efd6bfda9e97952a378f9313d5792bb0ecb1a7c6d6eb108d6dc64489f18e4c70d220a9d87daf3edfcd67e087d7b48136ced65d237e9b6468bce2f09d5eef9e09cbd1b8009bb25dd1b9504231cf8b5c03de351976fad120e6962644a8b83ce87c22de0adc851f44a444d35cb582fbcfed3ff9e97866070f51f94ac921784c4f7c0c56f92cdb1eca78c1f04bc7a27e524b33a3f70dcf14844a57d3004cab133edf4fa753cb7e5746277057550351bef7c8c48aba6f527768d5e160f0a0398c89b67a740ddf71d6c4e3a9228e999035fb8063a31429cb4d637783e010f4378611f8961df7ec1dd403f3e28cd79a27988bd6b474817bdbe528fe4467e2b95acb64177d20b12a152cbac2751571a82a97e0357d28e31a88d59b6e1232963566f51b469e814dc836b4c500f04e3838c7a8ba82dcc382a36bd2ee266b4b1b0c38940fe328070d3b6b789f8f2ae3aae0d1560213318084b03aa63c193c1d11f6bad6f56233a86c055bd23cf300d2806f48ad39c690359a192a72da63a31b9291c20f74019cb192326d4209580597f69d13aede9989eac01225ac016f923d5a7d5dde883d035b58662ecbb91af23972cd3637d3248595f82354661b10065239892f1f050f1ce7ad2c0d91eb8af70116d51d23a1bc90803c564896c6377f40b712d4e267020389fc315e37dc5b48c02d113aefba9f669fc1e139a3924e99c070c96114de543c01faee3633db5857e9202bb514fffca4ae2ba69538dc600cf119b6bd819cf5a4923c3d0937789018ec30aa6b359ef1b5fa234d894f2298b6e4537333fb3c37153707285b02ecde7d545cae9eef71097d02a3506c4087a7d1db565215d37ace9bb63598476d3609cf2b4512e5cd4e30e49e6b746f974525890863a5a7243e185da1900464a66914542a1725f03dc6aef689d3f6515c2d34f709b5d9b2c21ab86fdeb7eadf9f47b21777a6761848114c792891593dd14e425cc9a6ecd0c4e705f3398681a2f418c2512032bfe77f86b36b2bf4e2141fb40f714ad228a616913a494c81869401fa810c70957a9dfb0e876c123ddee2bd156d290649176510bf40c27f819bc35300711febc502cf957007c4a811b19af0b3e25e66ea6d0509f1c732eb3870a86c2084a6e69dc784741403ae878889e0203bdfb97d0965e73b6e4cd2fcecb5a9a2f02dfb071992a9886060c1f850ef845479ea2eed62918012e5eb4efced2e592a9b678ec262a20ed08aadebd3c7663448967d6d52fe8d6a305c2af772b7fe42aca0bc8de4749370771162c88d6dcc2268eb8cf2a75a9db90006b2fc5b2eaf0a5a876ddf48b208ca91d008a687f1b4065320f24091791951526a1232969d8080226966f2265aacef937d64fdc21fcb26e703d921f402efb8525af798529cd1e4080210e36a62ccce7527cce9fa62eee0d24ffd4c3dc8fe9ef63084540cd5b386e2339a47e453c4f74df88a4224bfc3b11f2851caf5f1e1f40d3e37ec9b62cc2466c52bf961f4eea7aae0926ba02275a02e964a269da47268c8c2654e0b1bdeae1817712bf\"}";
+
+ bsOrCsResponeResult = JSONObject.parseObject(content, BsOrCsResponeResult.class);
+
+ String token = bsOrCsResponeResult.getAccess_token();
+
+// String config4A = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJESA0kRw+/cIwUNGp9iJS/dZAg3fEy3izQfN0gAE8EYWhCMwPt8EH1UWNuK3+ka0qUbbwzwXOAR2e54p4zK06GqI8Vym83XOQ7G2kfT1Q657VDMnMym9eYdRf+i5qndb/7vjsV5qVuijxmwvtc0ITmciIHZSIS9Wt6W0/AJ2iBhAgMBAAECgYAA9pLHQssPXgGtBEjhl0YaLuD9xXmJrFvMHytvqtF2wh3B959F5C1bWaqj3YSOUIdmwXt/pV5mffPZl5s8LfIRAYb6PChTMElll5AL0ETs6MSusxO9+PhPzkpFmUcNr4WmtbNIhbHB8GIJAGPDwH/jdt8AGgBXEQ8ORuv+owFd2QJBAMzXHVuIF0KyHBpyaFLolkJR2N4WC5BiOXpav+dkdXTzJqIoYp4ZJ8XrIUOHz305d7uivwOMLMT/E0OZZCU0Q5kCQQC1TWKDcVlpA3PWUSXYTFaGHVzc1kwtuPHtOWqBP02Wsc5QfigJgnH+7SOj2OLvYGM5Y65jofm/qL4G8+ldecAJAkBZeo5kcWpXxB3qn5dawCcDCWXGfbLHe2DIReQWXBfC4oQ5yZJqpWpuVmvNaAIHHZdj64+tKQpVc2ci3FqWteHhAkAKe1/fs5T0wlNXJ7flanxyIo504hrjZdbu3SvwLwXAWaVQ+Ao+ioEmuPUfivGL32m9LqstbXbwAsSByGZMljZpAkEAlBOzSpUJdRWsIIrDA9W5jBFXpMS46fYqWR2gVvglTmN1PSZqU694tOf3uwSaqGchHibMqen5z+9HU4XR5vZj9A==";
+ try {
+ token = RSAUtils.decryptByPrivateKeyStr(token, config4A.getSecurity());
+ }catch (Exception e) {
+ log.info("decry pass error : {}", token);
+ }
+ log.info("token success : {}", token);
+ }
+}