处理问题

This commit is contained in:
wanggeng 2022-08-23 12:02:47 +08:00
parent dd7fe484db
commit ab63d88141
2 changed files with 84 additions and 51 deletions

View File

@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import ink.wgink.common.manager.env.EnvManager; import ink.wgink.common.manager.env.EnvManager;
import ink.wgink.login.base.manager.ConfigManager; import ink.wgink.login.base.manager.ConfigManager;
import org.apache.commons.lang3.StringUtils;
import javax.net.ssl.*; import javax.net.ssl.*;
import java.io.*; import java.io.*;
@ -34,7 +35,9 @@ import java.util.Map.Entry;
*/ */
public class SMCHttpUtil { public class SMCHttpUtil {
/** 请求超时时间 */ /**
* 请求超时时间
*/
private static Integer TIMEOUT = 3000; private static Integer TIMEOUT = 3000;
private static final String CHECK_MEETING_URL = "huaweiSmcCheckMeetingUrl"; private static final String CHECK_MEETING_URL = "huaweiSmcCheckMeetingUrl";
private static final String CHECK_MEETING_NAME_URL = "huaweiSmcCheckMeetingNameUrl"; private static final String CHECK_MEETING_NAME_URL = "huaweiSmcCheckMeetingNameUrl";
@ -50,6 +53,9 @@ public class SMCHttpUtil {
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
@Override @Override
public boolean verify(String urlHostName, SSLSession session) { public boolean verify(String urlHostName, SSLSession session) {
if (StringUtils.isBlank(urlHostName)) {
return false;
}
return true; return true;
} }
}); });
@ -60,7 +66,7 @@ public class SMCHttpUtil {
private static void trustAllHttpsCertificates() throws NoSuchAlgorithmException, KeyManagementException { private static void trustAllHttpsCertificates() throws NoSuchAlgorithmException, KeyManagementException {
TrustManager[] trustAllCerts = new TrustManager[1]; TrustManager[] trustAllCerts = new TrustManager[1];
trustAllCerts[0] = new TrustAllManager(); trustAllCerts[0] = new TrustAllManager();
SSLContext sc = SSLContext.getInstance("SSL"); SSLContext sc = SSLContext.getInstance("TLSv1.2");
sc.init(null, trustAllCerts, null); sc.init(null, trustAllCerts, null);
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
} }
@ -71,14 +77,21 @@ public class SMCHttpUtil {
} }
public void checkServerTrusted(X509Certificate[] certs, String authType) throws CertificateException { public void checkServerTrusted(X509Certificate[] certs, String authType) throws CertificateException {
if (certs == null && StringUtils.isBlank(authType)) {
throw new CertificateException("异常");
}
} }
public void checkClientTrusted(X509Certificate[] certs, String authType) throws CertificateException { public void checkClientTrusted(X509Certificate[] certs, String authType) throws CertificateException {
if (certs == null && StringUtils.isBlank(authType)) {
throw new CertificateException("异常");
}
} }
} }
/** /**
* 删除会议室 * 删除会议室
*
* @param meetingId 会议室ID * @param meetingId 会议室ID
* @return * @return
* @throws Exception * @throws Exception
@ -97,6 +110,7 @@ public class SMCHttpUtil {
/** /**
* 创建会议室 * 创建会议室
*
* @param name 名称 ( : 集宁区-张三丰) * @param name 名称 ( : 集宁区-张三丰)
* @param username 账号 * @param username 账号
* @return * @return
@ -146,6 +160,7 @@ public class SMCHttpUtil {
/** /**
* 获取随机的会议终端号码 * 获取随机的会议终端号码
*
* @return * @return
*/ */
private String getMeetingNumber() throws Exception { private String getMeetingNumber() throws Exception {
@ -162,6 +177,7 @@ public class SMCHttpUtil {
/** /**
* 验证会议室是否已经存在 * 验证会议室是否已经存在
*
* @return * @return
*/ */
public Boolean checkMeetingExists(String username) throws Exception { public Boolean checkMeetingExists(String username) throws Exception {
@ -175,6 +191,7 @@ public class SMCHttpUtil {
/** /**
* 验证会议室是否已经存在 * 验证会议室是否已经存在
*
* @return * @return
*/ */
public Boolean checkMeetingNameExists(String name) throws Exception { public Boolean checkMeetingNameExists(String name) throws Exception {
@ -213,12 +230,13 @@ public class SMCHttpUtil {
/** /**
* jsonPost请求 * jsonPost请求
* @Description: TODO *
* @param @param postUrl * @param @param postUrl
* @param @param json * @param @param json
* @param @return * @param @return
* @return String * @return String
* @throws * @throws
* @Description: TODO
* @author 崔宝铖 * @author 崔宝铖
* @date 2019年6月19日 * @date 2019年6月19日
*/ */
@ -260,8 +278,12 @@ public class SMCHttpUtil {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
try { try {
if (out != null) { out.close();} if (out != null) {
if (br != null) {br.close();} out.close();
}
if (br != null) {
br.close();
}
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
@ -275,13 +297,14 @@ public class SMCHttpUtil {
/** /**
* Post请求 * Post请求
* @Description: TODO *
* @param @param postUrl * @param @param postUrl
* @param @param param * @param @param param
* @param @return * @param @return
* @return String * @return String
* @throws IOException * @throws IOException
* @throws * @throws
* @Description: TODO
* @author 崔宝铖 * @author 崔宝铖
* @date 2019年6月19日 * @date 2019年6月19日
*/ */
@ -343,8 +366,12 @@ public class SMCHttpUtil {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
try { try {
if (out != null) { out.close();} if (out != null) {
if (in != null) {in.close();} out.close();
}
if (in != null) {
in.close();
}
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
@ -358,13 +385,14 @@ public class SMCHttpUtil {
/** /**
* Get请求 * Get请求
* @Description: TODO *
* @param @param getUrl 请求地址 * @param @param getUrl 请求地址
* @param @param param 请求参数 * @param @param param 请求参数
* @param @return * @param @return
* @param @throws Exception * @param @throws Exception
* @return RetBody<PageData> * @return RetBody<PageData>
* @throws * @throws
* @Description: TODO
* @author 崔宝铖 * @author 崔宝铖
* @date 2019年6月19日 * @date 2019年6月19日
*/ */
@ -374,6 +402,7 @@ public class SMCHttpUtil {
/** /**
* 初始化Token * 初始化Token
*
* @param getUrl * @param getUrl
* @param param * @param param
* @param property * @param property
@ -431,8 +460,12 @@ public class SMCHttpUtil {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
try { try {
if (out != null) { out.close();} if (out != null) {
if (in != null) {in.close();} out.close();
}
if (in != null) {
in.close();
}
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }

View File

@ -156,7 +156,7 @@ logging:
file: file:
name: /project/logs/usercenter-logs.log name: /project/logs/usercenter-logs.log
level: level:
root: error root: debug
org.springframework.data.mongodb: debug org.springframework.data.mongodb: debug
org.springframework.boot.autoconfigure.security.servlet: debug org.springframework.boot.autoconfigure.security.servlet: debug
ink.wgink: debug ink.wgink: debug