提交内容:定时任务

备注:定时推送单据至BIP
提交人:邹江涛
This commit is contained in:
zoujiangtao 2024-12-18 09:30:18 +08:00
parent 41fb2f2b2f
commit 8372e0d2b7
1 changed files with 61 additions and 24 deletions

View File

@ -30,6 +30,7 @@ import java.nio.charset.StandardCharsets;
import java.security.cert.X509Certificate;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.logging.Level;
/**
* @Description
@ -44,6 +45,40 @@ public class ApiService {
private static final String API_ENDPOINT = "/iuap-api-auth/open-auth/selfAppAuth/getAccessToken";
public static String getBIPToken(String domainName) {
String token = null;
try {
// 自定义 TrustManager
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(X509Certificate[] certs, String authType) {
}
}
};
// 安装所有信任的管理器
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
// 自定义 HostnameVerifier
HostnameVerifier hostnameVerifier = new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
logger.info("Verifying hostname: " + hostname);
return true; // 始终返回 true绕过验证
}
};
// 设置自定义 HostnameVerifier
HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
long currentTimeMillis = System.currentTimeMillis();
String signature = generateSignature("appKey" + APP_KEY + "timestamp" + currentTimeMillis);
logger.info("getBIPToken → 签名: {}", signature);
@ -58,8 +93,6 @@ public class ApiService {
// return urlString;
logger.info("getBIPToken → 构建URL: {}", urlString);
String token;
try {
// 发送请求
Request request = buildRequest(urlString);
@ -71,8 +104,12 @@ public class ApiService {
token = null;
}
// 处理响应
return token;
logger.info("getBIPToken method completed successfully");
} catch (Exception e) {
logger.info("Error in getBIPToken", e);
}
return token;
}
private static Request buildRequest(String urlString) {
@ -238,7 +275,7 @@ public class ApiService {
if ("TF、NC、OF".contains(objects[0].getString("bankpaystatus"))) {
dynamic.set("shkd_pushstatus", "结算失败");
} else if ("TS".equals(objects[0].getString("bankpaystatus"))){
} else if ("TS".equals(objects[0].getString("bankpaystatus"))) {
dynamic.set("shkd_pushstatus", "已结算");
}