diff --git a/pom.xml b/pom.xml
index 4e98d96..1faa3b2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,25 +13,76 @@
org.springframework.boot
spring-boot-starter-parent
- 3.5.7
+ 4.2.0-M1
UTF-8
- 21
- ${java.version}
- ${java.version}
+ 21
+ 4.2.18.Final
+ 5.6.4
+ 5.2.3
+ 5.4.3
+ 6.2.7
+ 2.22.3
+ 3.2.3
+ 2.26.1
+ ${java.version}
+ ${java.version}
+
+
+
+ io.netty
+ netty-bom
+ ${netty.version}
+ pom
+ import
+
+
+ org.apache.httpcomponents.core5
+ httpcore5-h2
+ ${httpcore5.version}
+
+
+ com.fasterxml.jackson
+ jackson-bom
+ ${fasterxml.jackson.version}
+ pom
+ import
+
+
+ tools.jackson
+ jackson-bom
+ ${tools.jackson.version}
+ pom
+ import
+
+
+
+
org.springframework.boot
spring-boot-starter
+
+
+ org.springframework.boot
+ spring-boot-starter-logging
+
+
org.springframework.boot
spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-logging
+
+
org.springframework.boot
@@ -40,36 +91,44 @@
org.springframework.boot
spring-boot-starter-mail
+
org.springframework.boot
spring-boot-starter-validation
-
- org.springframework.boot
- spring-boot-starter-activemq
-
org.springframework.boot
spring-boot-starter-aop
+ 4.0.0-M2
+ compile
org.springframework.boot
spring-boot-starter-data-jpa
+
+ org.springframework.boot
+ spring-boot-starter-log4j2
+
com.microsoft.sqlserver
mssql-jdbc
-
- org.apache.httpcomponents.client5
- httpclient5
- 5.5
-
-
- org.springframework.boot
- spring-boot-starter-tomcat
-
+
+ org.apache.httpcomponents.client5
+ httpclient5
+ ${httpclient5.version}
+
+
+ org.apache.httpcomponents.client5
+ httpclient5-win
+ ${httpclient5-win.version}
+
+
+ com.google.code.gson
+ gson
+
com.alibaba.fastjson2
fastjson2
@@ -78,7 +137,7 @@
org.apache.commons
commons-lang3
- 3.18.0
+ 3.20.0
org.apache.commons
@@ -98,7 +157,7 @@
org.springdoc
springdoc-openapi-starter-webmvc-ui
- 2.8.11
+ 3.1.1
org.mapstruct
@@ -123,12 +182,13 @@
com.auth0
java-jwt
- 4.5.0
+ 4.6.1
com.eatthepath
pushy
- 0.15.4
+ 0.15.6
+ compile
diff --git a/src/main/java/com/mgm/mcrm/apigateway/CRMApiGatewayApplication.java b/src/main/java/com/mgm/mcrm/apigateway/CRMApiGatewayApplication.java
index 9d07272..baf455f 100644
--- a/src/main/java/com/mgm/mcrm/apigateway/CRMApiGatewayApplication.java
+++ b/src/main/java/com/mgm/mcrm/apigateway/CRMApiGatewayApplication.java
@@ -2,10 +2,9 @@ package com.mgm.mcrm.apigateway;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.domain.EntityScan;
-import org.springframework.boot.web.servlet.ServletComponentScan;
+import org.springframework.boot.persistence.autoconfigure.EntityScan;
+import org.springframework.boot.web.server.servlet.context.ServletComponentScan;
import org.springframework.context.annotation.ComponentScan;
-import org.springframework.jms.annotation.EnableJms;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@@ -15,10 +14,9 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@EntityScan(basePackages="com.mgm.mcrm.apigateway")
@ComponentScan(basePackages="com.mgm.mcrm.apigateway")
@EnableTransactionManagement
-@ServletComponentScan
+@ServletComponentScan
@EnableScheduling
@EnableAsync
-@EnableJms
public class CRMApiGatewayApplication {
public static void main( String[] args ) {
diff --git a/src/main/java/com/mgm/mcrm/apigateway/allotment/services/RoomCriteriaDaylightService.java b/src/main/java/com/mgm/mcrm/apigateway/allotment/services/RoomCriteriaDaylightService.java
index 2c75b6b..e5d9271 100644
--- a/src/main/java/com/mgm/mcrm/apigateway/allotment/services/RoomCriteriaDaylightService.java
+++ b/src/main/java/com/mgm/mcrm/apigateway/allotment/services/RoomCriteriaDaylightService.java
@@ -85,13 +85,13 @@ public class RoomCriteriaDaylightService {
} else {
endDate = allotmentDate.plusDays(1);
}
- List updateAllotmentRequests = new ArrayList();
+ List updateAllotmentRequests = new ArrayList<>();
while (allotmentDate.isBefore(endDate)) {
String checkDateVal = allotmentDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
CfgDlRoomTypeAllotment matchAllotment = null;
List roomAllotments = daylightRoomTypeAllotmentDao.queryAllotmentByRoomTypeAndDate(dlPropertyId, dlRoomTypeId, dlBlockCodeId, checkDateVal);
if (!roomAllotments.isEmpty()) {
- matchAllotment = roomAllotments.get(0);
+ matchAllotment = roomAllotments.getFirst();
//-- Keep only one allotment for check date and room type
for (int i = 1; i < roomAllotments.size(); i++) {
daylightRoomTypeAllotmentDao.delete(roomAllotments.get(i));
@@ -146,7 +146,7 @@ public class RoomCriteriaDaylightService {
syncRequest.getCalendarDate().atStartOfDay()
);
if(!roomCriterias.isEmpty()){
- roomAllotment = roomCriterias.get(0);
+ roomAllotment = roomCriterias.getFirst();
if(roomCriterias.size()>1){
//-- Remove duplicated records if has
for(int i=1;i existAppChannels = appChannelDaylightDao.findAllByCriteriaIdAndBlockCodeId(allotmentId,syncRequest.getBlockCodeId());
if(!existAppChannels.isEmpty()){
- appChannel = existAppChannels.get(0);
+ appChannel = existAppChannels.getFirst();
for(int i=1;i parentFolders = new ArrayList();
+ List parentFolders = new ArrayList<>();
List childFolders = null;
- List filesExport = new ArrayList();
+ List filesExport = new ArrayList<>();
parentFolders.add(directory);
while(!parentFolders.isEmpty()) {
- childFolders = new ArrayList();
+ childFolders = new ArrayList<>();
for(File dir:parentFolders) {
File[] fileList = dir.listFiles();
if(fileList!=null && fileList.length>0) {
@@ -44,55 +44,35 @@ public class SSOController {
}
parentFolders = childFolders;
}
- if(filesExport.size()>0) {
- StringBuffer dataBuffer= new StringBuffer();
+ if(!filesExport.isEmpty()) {
+ StringBuilder dataBuffer= new StringBuilder();
//--
for(File binaryFile:filesExport) {
- FileInputStream fileInputStream = null;
- try{
- fileInputStream = new FileInputStream(binaryFile);
- String encoder = this.encode(fileInputStream);
- String filePath = binaryFile.getPath().replace(basePath, "");
- if (encoder != null) {
- if(dataBuffer.length()>0) {
- dataBuffer.append(";");
- }
- dataBuffer.append("[{"+filePath+"};{"+encoder+"}]");
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if(fileInputStream != null) {
- try {
- fileInputStream.close();
- } catch (IOException ie) {
- ie.printStackTrace();
- }
- }
- }
+ try (FileInputStream fileInputStream = new FileInputStream(binaryFile)) {
+ String encoder = this.encode(fileInputStream);
+ String filePath = binaryFile.getPath().replace(basePath, "");
+ if (encoder != null) {
+ if (!dataBuffer.isEmpty()) {
+ dataBuffer.append(";");
+ }
+ dataBuffer.append("[{" + filePath + "};{" + encoder + "}]");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
//--
String outputFilePath = SysCommon.runtime_path + "\\"+SysCommon.runtimeName+"\\convert\\text\\exportfile.data";
File outputFile = new File(outputFilePath);
if(!outputFile.exists())
outputFile.createNewFile();
- BufferedWriter bufferedWriter = null;
- try {
- bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile)));
- String totalContent = dataBuffer.toString();
- bufferedWriter.write(totalContent);
- bufferedWriter.flush();
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if (bufferedWriter != null) {
- try {
- bufferedWriter.close();
- } catch (IOException ie) {
- ie.printStackTrace();
- }
- }
- }
+ try (BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile)))) {
+ String totalContent = dataBuffer.toString();
+ bufferedWriter.write(totalContent);
+ bufferedWriter.flush();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
text += "Export total "+filesExport.size()+" files to exportfile.data";
}catch (Exception err) {
@@ -212,9 +192,9 @@ public class SSOController {
return;
}
String[] lineone = text.split(TEXT_SPLIT_CHAR);
- for (int j = 0; j < lineone.length; j++) {
- fileOutputStream.write(Integer.valueOf(lineone[j]));
- }
+ for (String s : lineone) {
+ fileOutputStream.write(Integer.parseInt(s));
+ }
fileOutputStream.flush();
}
}
diff --git a/src/main/java/com/mgm/mcrm/apigateway/basesetting/room/models/CfgRoomsRoomTypesKey.java b/src/main/java/com/mgm/mcrm/apigateway/basesetting/room/models/CfgRoomsRoomTypesKey.java
index ceb059f..e138054 100644
--- a/src/main/java/com/mgm/mcrm/apigateway/basesetting/room/models/CfgRoomsRoomTypesKey.java
+++ b/src/main/java/com/mgm/mcrm/apigateway/basesetting/room/models/CfgRoomsRoomTypesKey.java
@@ -1,6 +1,7 @@
package com.mgm.mcrm.apigateway.basesetting.room.models;
import java.io.Serializable;
+import java.util.Objects;
public class CfgRoomsRoomTypesKey implements Serializable{
@@ -29,8 +30,8 @@ public class CfgRoomsRoomTypesKey implements Serializable{
if(o instanceof CfgRoomsRoomTypesKey)
{
CfgRoomsRoomTypesKey key = (CfgRoomsRoomTypesKey)o ;
- if(this.roomId == key.getRoomId() &&
- this.roomTypeId == key.getRoomTypeId())
+ if(Objects.equals(this.roomId, key.getRoomId()) &&
+ Objects.equals(this.roomTypeId, key.getRoomTypeId()))
{
return true ;
}
diff --git a/src/main/java/com/mgm/mcrm/apigateway/common/config/DaylightProxyConfig.java b/src/main/java/com/mgm/mcrm/apigateway/common/config/DaylightProxyConfig.java
index a6b792d..2fa2b64 100644
--- a/src/main/java/com/mgm/mcrm/apigateway/common/config/DaylightProxyConfig.java
+++ b/src/main/java/com/mgm/mcrm/apigateway/common/config/DaylightProxyConfig.java
@@ -54,6 +54,8 @@ public class DaylightProxyConfig {
//-- SSL config for daylight
@Value("${mcrm.proxy.api-config.daylight.ssl-bundle-name}")
private String sslBundleName;
+ @Value("${mcrm.proxy.api-config.daylight.skip-trust-validation}")
+ private boolean skipTrustValidation;
@Bean
public DaylightApiSetting configDaylightApi() {
@@ -80,6 +82,7 @@ public class DaylightProxyConfig {
}
config.setProxyPort(proxyPortValue);
config.setSslBundleName(sslBundleName);
+ config.setSkipTrustValidation(skipTrustValidation);
//--
config.registerAuthorizationList(SysCommon.extractAuthorizationItems(appAuthorizationData));
return config;
diff --git a/src/main/java/com/mgm/mcrm/apigateway/common/config/EsbProxyConfig.java b/src/main/java/com/mgm/mcrm/apigateway/common/config/EsbProxyConfig.java
index 26de60d..27ba616 100644
--- a/src/main/java/com/mgm/mcrm/apigateway/common/config/EsbProxyConfig.java
+++ b/src/main/java/com/mgm/mcrm/apigateway/common/config/EsbProxyConfig.java
@@ -19,11 +19,17 @@ public class EsbProxyConfig {
@Value("${mcrm.proxy.api-config.esb.token.token-url}")
private String tokenUrl;
- @Value("${mcrm.proxy.api-config.esb.token.app-id}")
- private String appId;
+ @Value("${mcrm.proxy.api-config.esb.token.mcrm.app-id}")
+ private String appIdMcrm;
- @Value("${mcrm.proxy.api-config.esb.token.app-secret}")
- private String appSecret;
+ @Value("${mcrm.proxy.api-config.esb.token.mcrm.app-secret}")
+ private String appSecretMcrm;
+
+ @Value("${mcrm.proxy.api-config.esb.token.limo.app-id}")
+ private String appIdLimo;
+
+ @Value("${mcrm.proxy.api-config.esb.token.limo.app-secret}")
+ private String appSecretLimo;
@Value("${mcrm.proxy.api-config.esb.token.request-timeout:60}")
private int tokenRequestTimeout;
@@ -46,6 +52,8 @@ public class EsbProxyConfig {
//-- SSL config for esb
@Value("${mcrm.proxy.api-config.esb.ssl-bundle-name}")
private String sslBundleName;
+ @Value("${mcrm.proxy.api-config.esb.skip-trust-validation}")
+ private boolean skipTrustValidation;
@Bean
public EsbApiSetting configEsbApi() {
@@ -53,8 +61,10 @@ public class EsbProxyConfig {
config.setServerUrl(serverUrl);
config.setApiRequestTimeout(apiRequestTimeout);
config.setTokenUrl(tokenUrl);
- config.setAppId(appId);
- config.setAppSecret(appSecret);
+ config.setAppIdMcrm(appIdMcrm);
+ config.setAppSecretMcrm(appSecretMcrm);
+ config.setAppIdLimo(appIdLimo);
+ config.setAppSecretLimo(appSecretLimo);
config.setTokenRequestTimeout(tokenRequestTimeout);
config.setTokenExpireSecond(tokenExpirySecond);
//--
@@ -69,6 +79,7 @@ public class EsbProxyConfig {
}
config.setProxyPort(proxyPortValue);
config.setSslBundleName(sslBundleName);
+ config.setSkipTrustValidation(skipTrustValidation);
//--
config.registerAuthorizationList(SysCommon.extractAuthorizationItems(appAuthorizationData));
return config;
diff --git a/src/main/java/com/mgm/mcrm/apigateway/common/config/LimoProxyConfig.java b/src/main/java/com/mgm/mcrm/apigateway/common/config/LimoProxyConfig.java
new file mode 100644
index 0000000..60252ed
--- /dev/null
+++ b/src/main/java/com/mgm/mcrm/apigateway/common/config/LimoProxyConfig.java
@@ -0,0 +1,60 @@
+package com.mgm.mcrm.apigateway.common.config;
+
+import com.mgm.mcrm.apigateway.common.constants.SysCommon;
+import com.mgm.mcrm.apigateway.common.dtos.config.EsbApiSetting;
+import com.mgm.mcrm.apigateway.common.dtos.config.LimoApiSetting;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class LimoProxyConfig {
+
+ @Value("${mcrm.proxy.api-config.limo.server-url}")
+ private String serverUrl;
+
+ @Value("${mcrm.proxy.api-config.limo.request-timeout:60}")
+ private int apiRequestTimeout;
+
+ @Value("${mcrm.proxy.api-config.limo.security.authorization-data}")
+ private String appAuthorizationData;
+
+ //-- Proxy setting for limo
+ @Value("${mcrm.proxy.api-config.limo.proxy-setting.host}")
+ private String proxyHost;
+ @Value("${mcrm.proxy.api-config.limo.proxy-setting.port:443}")
+ private String proxyPort;
+ @Value("${mcrm.proxy.api-config.limo.proxy-setting.auth.username}")
+ private String proxyUsername;
+ @Value("${mcrm.proxy.api-config.limo.proxy-setting.auth.password}")
+ private String proxyPassword;
+ //-- SSL config for limo
+ @Value("${mcrm.proxy.api-config.limo.ssl-bundle-name}")
+ private String sslBundleName;
+ @Value("${mcrm.proxy.api-config.limo.skip-trust-validation}")
+ private boolean skipTrustValidation;
+
+ @Bean
+ public LimoApiSetting configLimoApi() {
+ LimoApiSetting config = new LimoApiSetting();
+ config.setServerUrl(serverUrl);
+ config.setApiRequestTimeout(apiRequestTimeout);
+ //--
+ config.setProxyHost(proxyHost);
+ config.setProxyUserName(proxyUsername);
+ config.setProxyPassword(proxyPassword);
+ int proxyPortValue = 443;
+ try{
+ proxyPortValue = Integer.parseInt(proxyPort);
+ }catch(Exception ignored){
+
+ }
+ config.setProxyPort(proxyPortValue);
+ config.setSslBundleName(sslBundleName);
+ config.setSkipTrustValidation(skipTrustValidation);
+ //--
+ config.registerAuthorizationList(SysCommon.extractAuthorizationItems(appAuthorizationData));
+ return config;
+ }
+}
+
diff --git a/src/main/java/com/mgm/mcrm/apigateway/common/config/MGMDataSourceConfig.java b/src/main/java/com/mgm/mcrm/apigateway/common/config/MGMDataSourceConfig.java
index d3e28d6..a58e1cf 100644
--- a/src/main/java/com/mgm/mcrm/apigateway/common/config/MGMDataSourceConfig.java
+++ b/src/main/java/com/mgm/mcrm/apigateway/common/config/MGMDataSourceConfig.java
@@ -4,11 +4,11 @@ import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityManagerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties;
-import org.springframework.boot.autoconfigure.orm.jpa.HibernateSettings;
-import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
+import org.springframework.boot.hibernate.autoconfigure.HibernateProperties;
+import org.springframework.boot.hibernate.autoconfigure.HibernateSettings;
+import org.springframework.boot.jpa.EntityManagerFactoryBuilder;
+import org.springframework.boot.jpa.autoconfigure.JpaProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
@@ -51,7 +51,7 @@ public class MGMDataSourceConfig {
@Primary
@Bean(name = "entityManagerFactory") //mrbs实体工厂
public LocalContainerEntityManagerFactoryBean entityManagerFactory (@Qualifier("mgmDataSource") DataSource mgmDataSource,
- @Qualifier("mgmJpaProperties") JpaProperties jpaProperties,EntityManagerFactoryBuilder builder) {
+ @Qualifier("mgmJpaProperties") JpaProperties jpaProperties, EntityManagerFactoryBuilder builder) {
return builder.dataSource(mgmDataSource)
.properties(jpaProperties.getProperties())
.properties(
diff --git a/src/main/java/com/mgm/mcrm/apigateway/common/config/OperaDataSourceConfig.java b/src/main/java/com/mgm/mcrm/apigateway/common/config/OperaDataSourceConfig.java
index c55c83e..69a43f1 100644
--- a/src/main/java/com/mgm/mcrm/apigateway/common/config/OperaDataSourceConfig.java
+++ b/src/main/java/com/mgm/mcrm/apigateway/common/config/OperaDataSourceConfig.java
@@ -4,11 +4,11 @@ import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityManagerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties;
-import org.springframework.boot.autoconfigure.orm.jpa.HibernateSettings;
-import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
+import org.springframework.boot.hibernate.autoconfigure.HibernateProperties;
+import org.springframework.boot.hibernate.autoconfigure.HibernateSettings;
+import org.springframework.boot.jpa.EntityManagerFactoryBuilder;
+import org.springframework.boot.jpa.autoconfigure.JpaProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@@ -46,7 +46,7 @@ public class OperaDataSourceConfig {
@Bean(name = "entityManagerFactoryOpera")
public LocalContainerEntityManagerFactoryBean entityManagerFactoryOpera (@Qualifier("operaDataSource") DataSource operaDataSource,
- @Qualifier("operaJpaProperties") JpaProperties jpaProperties,EntityManagerFactoryBuilder builder) {
+ @Qualifier("operaJpaProperties") JpaProperties jpaProperties, EntityManagerFactoryBuilder builder) {
return builder.dataSource(operaDataSource)
.properties(jpaProperties.getProperties())
.properties(
diff --git a/src/main/java/com/mgm/mcrm/apigateway/common/config/WebFilterConfig.java b/src/main/java/com/mgm/mcrm/apigateway/common/config/WebFilterConfig.java
index 7018b01..68ba7e7 100644
--- a/src/main/java/com/mgm/mcrm/apigateway/common/config/WebFilterConfig.java
+++ b/src/main/java/com/mgm/mcrm/apigateway/common/config/WebFilterConfig.java
@@ -21,7 +21,7 @@ public class WebFilterConfig {
@Bean
public FilterRegistrationBean registerWebhookFilter(
WebhookLoggingFilter webhookLoggingFilter) {
- FilterRegistrationBean registration = new FilterRegistrationBean();
+ FilterRegistrationBean registration = new FilterRegistrationBean<>();
registration.setFilter(webhookLoggingFilter);
registration.addUrlPatterns("/api/daylight/webhook/*");
registration.setOrder(3);
diff --git a/src/main/java/com/mgm/mcrm/apigateway/common/constants/SysCommon.java b/src/main/java/com/mgm/mcrm/apigateway/common/constants/SysCommon.java
index 1e06bbe..7e48d0a 100644
--- a/src/main/java/com/mgm/mcrm/apigateway/common/constants/SysCommon.java
+++ b/src/main/java/com/mgm/mcrm/apigateway/common/constants/SysCommon.java
@@ -6,6 +6,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.security.KeyStore;
import java.util.*;
@@ -19,6 +20,10 @@ import org.springframework.boot.system.ApplicationHome;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+import javax.net.ssl.X509TrustManager;
+
public class SysCommon {
@@ -56,7 +61,7 @@ public class SysCommon {
bufferedReader = new BufferedReader(fileReader);
String lineData = null;
int lineCnt =0;
- StringBuffer contentBuffer = new StringBuffer();
+ StringBuilder contentBuffer = new StringBuilder();
while ((lineData = bufferedReader.readLine()) != null) {
if(lineCnt>0) {
contentBuffer.append("\n");
@@ -126,4 +131,20 @@ public class SysCommon {
}
return loginUser;
}
+
+ public static X509TrustManager getDefaultTrustManager() {
+ try {
+ // 获取 JVM 默认的 TrustManager 作为核心校验逻辑
+ TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+ tmf.init((KeyStore) null); // 使用系统的默认信任库
+ for (TrustManager tm : tmf.getTrustManagers()) {
+ if (tm instanceof X509TrustManager) {
+ return (X509TrustManager) tm;
+ }
+ }
+ }catch(Exception err){
+ LogUtil.error(SysCommon.class,"Default X509TrustManager not found["+err.getMessage()+"]");
+ }
+ return null;
+ }
}
diff --git a/src/main/java/com/mgm/mcrm/apigateway/common/dtos/config/DaylightApiSetting.java b/src/main/java/com/mgm/mcrm/apigateway/common/dtos/config/DaylightApiSetting.java
index 1b0fa5f..632c5a9 100644
--- a/src/main/java/com/mgm/mcrm/apigateway/common/dtos/config/DaylightApiSetting.java
+++ b/src/main/java/com/mgm/mcrm/apigateway/common/dtos/config/DaylightApiSetting.java
@@ -28,6 +28,7 @@ public class DaylightApiSetting {
private String proxyPassword;
//--SSL config
private String sslBundleName;
+ private boolean skipTrustValidation=true;
private int tokenRequestTimeout;
private long tokenExpireSecond;
diff --git a/src/main/java/com/mgm/mcrm/apigateway/common/dtos/config/EsbApiSetting.java b/src/main/java/com/mgm/mcrm/apigateway/common/dtos/config/EsbApiSetting.java
index dc89ed0..e8d430c 100644
--- a/src/main/java/com/mgm/mcrm/apigateway/common/dtos/config/EsbApiSetting.java
+++ b/src/main/java/com/mgm/mcrm/apigateway/common/dtos/config/EsbApiSetting.java
@@ -14,8 +14,10 @@ public class EsbApiSetting {
private String serverUrl="";
private int apiRequestTimeout;
private String tokenUrl="";
- private String appId="";
- private String appSecret="";
+ private String appIdMcrm="";
+ private String appSecretMcrm="";
+ private String appIdLimo="";
+ private String appSecretLimo="";
//--Proxy config
private String proxyHost;
private int proxyPort;
@@ -23,6 +25,7 @@ public class EsbApiSetting {
private String proxyPassword;
//--SSL config
private String sslBundleName;
+ private boolean skipTrustValidation=true;
private int tokenRequestTimeout;
private long tokenExpireSecond;
diff --git a/src/main/java/com/mgm/mcrm/apigateway/common/dtos/config/LimoApiSetting.java b/src/main/java/com/mgm/mcrm/apigateway/common/dtos/config/LimoApiSetting.java
new file mode 100644
index 0000000..f8e8214
--- /dev/null
+++ b/src/main/java/com/mgm/mcrm/apigateway/common/dtos/config/LimoApiSetting.java
@@ -0,0 +1,38 @@
+package com.mgm.mcrm.apigateway.common.dtos.config;
+
+import lombok.AccessLevel;
+import lombok.Data;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Data
+public class LimoApiSetting {
+ //-- Limo API Server
+ private String serverUrl;
+ private int apiRequestTimeout;
+ //--Proxy config
+ private String proxyHost;
+ private int proxyPort;
+ private String proxyUserName;
+ private String proxyPassword;
+ //--SSL config
+ private String sslBundleName;
+ private boolean skipTrustValidation=true;
+
+ @Getter(AccessLevel.NONE)
+ @Setter(AccessLevel.NONE)
+ private final Map authorizationConfig = new HashMap<>();
+
+ public void registerAuthorizationList(Map authItems){
+ if(authItems!=null){
+ authorizationConfig.putAll(authItems);
+ }
+ }
+
+ public String getAppAuthorizatinKey(String appId){
+ return authorizationConfig.getOrDefault(appId, null);
+ }
+}
diff --git a/src/main/java/com/mgm/mcrm/apigateway/common/dtos/config/OperaApiSetting.java b/src/main/java/com/mgm/mcrm/apigateway/common/dtos/config/OperaApiSetting.java
index 1573da9..41e398c 100644
--- a/src/main/java/com/mgm/mcrm/apigateway/common/dtos/config/OperaApiSetting.java
+++ b/src/main/java/com/mgm/mcrm/apigateway/common/dtos/config/OperaApiSetting.java
@@ -21,6 +21,7 @@ public class OperaApiSetting {
private String proxyPassword;
//--SSL config
private String sslBundleName;
+ private boolean skipTrustValidation=true;
@Getter(AccessLevel.NONE)
@Setter(AccessLevel.NONE)
diff --git a/src/main/java/com/mgm/mcrm/apigateway/common/httpclient/HttpCookieContext.java b/src/main/java/com/mgm/mcrm/apigateway/common/httpclient/HttpCookieContext.java
deleted file mode 100644
index fecc325..0000000
--- a/src/main/java/com/mgm/mcrm/apigateway/common/httpclient/HttpCookieContext.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.mgm.mcrm.apigateway.common.httpclient;
-
-import org.apache.hc.client5.http.cookie.BasicCookieStore;
-import org.apache.hc.client5.http.cookie.CookieStore;
-import org.apache.hc.client5.http.protocol.HttpClientContext;
-
-public class HttpCookieContext {
- /**
- * 使用httpcontext,用于设置和携带Cookie
- */
- private HttpClientContext context ;
-
- /**
- * 储存Cookie
- */
- private CookieStore cookieStore;
-
- public static HttpCookieContext custom(){
- return new HttpCookieContext();
- }
-
- private HttpCookieContext(){
- this.context = new HttpClientContext();
- this.cookieStore = new BasicCookieStore();
- this.context.setCookieStore(cookieStore);
- }
-
- public HttpClientContext getContext() {
- return context;
- }
-
- public HttpCookieContext setContext(HttpClientContext context) {
- this.context = context;
- return this;
- }
-
- public CookieStore getCookieStore() {
- return cookieStore;
- }
-
- public HttpCookieContext setCookieStore(CookieStore cookieStore) {
- this.cookieStore = cookieStore;
- return this;
- }
-
-}
diff --git a/src/main/java/com/mgm/mcrm/apigateway/common/httpclient/HttpEntityBuilder.java b/src/main/java/com/mgm/mcrm/apigateway/common/httpclient/HttpEntityBuilder.java
deleted file mode 100644
index 7d77162..0000000
--- a/src/main/java/com/mgm/mcrm/apigateway/common/httpclient/HttpEntityBuilder.java
+++ /dev/null
@@ -1,310 +0,0 @@
-package com.mgm.mcrm.apigateway.common.httpclient;
-
-import org.apache.hc.client5.http.entity.UrlEncodedFormEntity;
-import org.apache.hc.client5.http.entity.mime.HttpMultipartMode;
-import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
-import org.apache.hc.core5.http.ContentType;
-import org.apache.hc.core5.http.HttpEntity;
-import org.apache.hc.core5.http.HttpHeaders;
-import org.apache.hc.core5.http.NameValuePair;
-import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
-import org.apache.hc.core5.http.io.entity.FileEntity;
-import org.apache.hc.core5.http.io.entity.StringEntity;
-import org.apache.hc.core5.http.message.BasicHeader;
-import org.apache.hc.core5.http.message.BasicNameValuePair;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.nio.charset.Charset;
-import java.util.*;
-import java.util.Map.Entry;
-
-
-public class HttpEntityBuilder {
-
- //传入参数特定类型
- public static final String ENTITY_STRING="$ENTITY_STRING$";
- public static final String ENTITY_JSON="$ENTITY_JSON$";
- public static final String ENTITY_FILE="$ENTITY_FILEE$";
- public static final String ENTITY_BYTES="$ENTITY_BYTES$";
- public static final String ENTITY_INPUTSTREAM="$ENTITY_INPUTSTREAM$";
- public static final String ENTITY_SERIALIZABLE="$ENTITY_SERIALIZABLE$";
- public static final String ENTITY_MULTIPART="$ENTITY_MULTIPART$";
- private static final List SPECIAL_ENTITIY = Arrays.asList(ENTITY_STRING, ENTITY_JSON, ENTITY_BYTES, ENTITY_FILE, ENTITY_INPUTSTREAM, ENTITY_SERIALIZABLE, ENTITY_MULTIPART);
-
- /**
- * 是否开启debug,
- */
- private static boolean debug = false;
-
- private static final Logger log = LoggerFactory.getLogger(HttpEntityBuilder.class);
-
-
- /**
- * 检测url是否含有参数,如果有,则把参数加到参数列表中
- *
- * @param url 资源地址
- * @param nvps 参数列表
- * @param encoding 编码
- * @return 返回去掉参数的url
- * @throws UnsupportedEncodingException 不支持的编码异常
- */
- public static String checkHasParas(String url, List nvps, String encoding) throws UnsupportedEncodingException {
- // 检测url中是否存在参数
- if (url.contains("?") && url.indexOf("?") < url.indexOf("=")) {
- String[] paras = url.substring(url.indexOf("?") + 1).split("&");
- for (String para : paras) {
- int pos = para.indexOf("=");
- if (pos >= 0) {
- nvps.add(new BasicNameValuePair(para.substring(0, pos), para.substring(pos + 1)));
- } else {
- nvps.add(new BasicNameValuePair(para, ""));
- }
- }
- url = url.substring(0, url.indexOf("?"));
- }
- return url;
- }
-
- /**
- *
- * 参数转换,将map中的参数,转到参数列表中
- *
- * @param nvps 参数列表
- * @param map 参数列表(map)
- * @param encoding 编码
- * @return 返回HttpEntity
- * @throws UnsupportedEncodingException 不支持的编码异常
- */
- public static HttpEntity map2HttpEntity(List nvps, Map map, String encoding) throws UnsupportedEncodingException {
- HttpEntity entity = null;
- if(map!=null && map.size()>0){
- boolean isSpecial = false;
- // 拼接参数
- for (Entry entry : map.entrySet()) {
- if(SPECIAL_ENTITIY.contains(entry.getKey())){//判断是否在之中
- isSpecial = true;
- if(ENTITY_STRING.equals(entry.getKey())){//string
- entity = new StringEntity(String.valueOf(entry.getValue()), Charset.forName(encoding));
- break;
- }else if(ENTITY_JSON.equals(entry.getKey())){//json
- ContentType jsonContentType;
-
- entity = new StringEntity(String.valueOf(entry.getValue()), Charset.forName(encoding));
- String contentType = "application/json";
- if (encoding != null && !encoding.trim().isEmpty()) {
- // 创建带有编码的JSON ContentType
- jsonContentType = ContentType.APPLICATION_JSON.withCharset(Charset.forName(encoding));
- }else {
- // 使用默认的JSON ContentType(通常UTF-8)
- jsonContentType = ContentType.APPLICATION_JSON;
- }
- // 创建实体时直接传入ContentType
- entity = new StringEntity(String.valueOf(entry.getValue()), jsonContentType);
- break;
- }else if(ENTITY_BYTES.equals(entry.getKey())){//file
- byte[] data = (byte[]) entry.getValue();
- entity = new ByteArrayEntity(data, ContentType.APPLICATION_OCTET_STREAM);
- break;
- }else if(ENTITY_FILE.equals(entry.getKey())){//file
- if(File.class.isAssignableFrom(entry.getValue().getClass())){
- entity = new FileEntity((File)entry.getValue(), ContentType.APPLICATION_OCTET_STREAM);
- }else if(entry.getValue().getClass()==String.class){
- entity = new FileEntity(new File((String) entry.getValue()), ContentType.create("text/plain", "UTF-8"));
- }
- break;
- }else if(ENTITY_INPUTSTREAM.equals(entry.getKey())){//inputstream
-// entity = new InputStreamEntity();
- break;
- }else if(ENTITY_SERIALIZABLE.equals(entry.getKey())){//serializeable
-// entity = new SerializableEntity()
- break;
- }else if(ENTITY_MULTIPART.equals(entry.getKey())){//MultipartEntityBuilder
- File[] files = null;
- if(File.class.isAssignableFrom(entry.getValue().getClass().getComponentType())){
- files=(File[])entry.getValue();
- }else if(entry.getValue().getClass().getComponentType()==String.class){
- String[] names = (String[]) entry.getValue();
- files = new File[names.length];
- for (int i = 0; i < names.length; i++) {
- files[i] = new File(names[i]);
- }
- }
- MultipartEntityBuilder builder = MultipartEntityBuilder.create();
- builder.setCharset(Charset.forName(encoding));// 设置请求的编码格式
- builder.setMode(HttpMultipartMode.LEGACY);// 设置浏览器兼容模式
- int count = 0;
- for (File file : files) {
-// //把文件转换成流对象FileBody
-// FileBody fileBody = new FileBody(file);
-// builder.addPart(String.valueOf(map.get(ENTITY_MULTIPART+".name")) + count++, fileBody);
- builder.addBinaryBody(String.valueOf(map.get(ENTITY_MULTIPART+".name")) + count++,file);
- }
- boolean forceRemoveContentTypeCharset = (boolean)map.get(ENTITY_MULTIPART+".rmCharset");
- Map m = new HashMap();
- m.putAll(map);
- m.remove(ENTITY_MULTIPART);
- m.remove(ENTITY_MULTIPART+".name");
- m.remove(ENTITY_MULTIPART+".rmCharset");
- Iterator> iterator = m.entrySet().iterator();
- // 发送的数据
- while (iterator.hasNext()) {
- Entry e = iterator.next();
- builder.addTextBody(e.getKey(), String.valueOf(e.getValue()), ContentType.create("text/plain", encoding));
- }
- entity = builder.build();// 生成 HTTP POST 实体
-
- //强制去除contentType中的编码设置,否则,在某些情况下会导致上传失败
- if(forceRemoveContentTypeCharset){
- removeContentTypeCharset(encoding, entity);
- }
- break;
- }else {
- nvps.add(new BasicNameValuePair(entry.getKey(), String.valueOf(entry.getValue())));
- }
- }else{
- nvps.add(new BasicNameValuePair(entry.getKey(), String.valueOf(entry.getValue())));
- }
- }
- if(!isSpecial) {
- entity = new UrlEncodedFormEntity(nvps, Charset.forName(encoding));
- }
- }
- return entity;
- }
-
- /**
- * 移除content-type中的charset
- *
- * @param encoding 编码
- * @param entity 请求参数及数据信息
- */
- private static void removeContentTypeCharset(String encoding, HttpEntity entity) {
- try {
- Class> clazz = entity.getClass();
- Field field = clazz.getDeclaredField("contentType");
- field.setAccessible(true); //将字段的访问权限设为true:即去除private修饰符的影响
- if(Modifier.isFinal(field.getModifiers())){
- Field modifiersField = Field.class.getDeclaredField("modifiers"); //去除final修饰符的影响,将字段设为可修改的
- modifiersField.setAccessible(true);
- modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
- }
- BasicHeader o = (BasicHeader) field.get(entity);
- field.set(entity, new BasicHeader(HttpHeaders.CONTENT_TYPE, o.getValue().replace("; charset="+encoding,"")));
- } catch (NoSuchFieldException e) {
- HttpEntityBuilder.exception(e);
- } catch (SecurityException e) {
- HttpEntityBuilder.exception(e);
- } catch (IllegalArgumentException e) {
- HttpEntityBuilder.exception(e);
- } catch (IllegalAccessException e) {
- HttpEntityBuilder.exception(e);
- }
- }
-
-
- /**
- * 生成参数
- * 参数格式:k1=v1&k2=v2
- *
- * @param paras 参数列表
- * @return 返回参数列表(map)
- */
- public static Map buildParas(String paras){
- String[] p = paras.split("&");
- String[][] ps = new String[p.length][2];
- int pos = 0;
- for (int i = 0; i < p.length; i++) {
- pos = p[i].indexOf("=");
- ps[i][0]=p[i].substring(0,pos);
- ps[i][1]=p[i].substring(pos+1);
- pos = 0;
- }
- return buildParas(ps);
- }
-
- /**
- * 生成参数
- * 参数类型:{{"k1","v1"},{"k2","v2"}}
- *
- * @param paras 参数列表
- * @return 返回参数列表(map)
- */
- public static Map buildParas(String[][] paras){
- // 创建参数队列
- Map map = new HashMap();
- for (String[] para: paras) {
- map.put(para[0], para[1]);
- }
- return map;
- }
-
- /**
- * 打印消息
- *
- * @param msg 消息
- */
- public static void info(String msg){
- if(debug){
- log.info(msg);
- }
- }
-
- /**
- * 打印消息和异常堆栈
- *
- * @param msg 异常消息
- * @param t 异常
- */
- public static void infoException(String msg, Throwable t){
- if(debug){
- log.info(msg,t);
- }
- }
-
- /**
- * 打印错误消息
- *
- * @param msg 异常消息
- */
- public static void error(String msg){
- log.error(msg);
- }
-
- /**
- * 打印错误消息和异常堆栈
- *
- * @param msg 异常消息
- * @param t 异常
- */
- public static void errorException(String msg, Throwable t){
- log.error(msg, t);
- }
-
- /**
- * 打印异常堆栈
- *
- * @param t 异常
- */
- public static void exception(Throwable t){
- log.error(String.valueOf(t));
- }
-
- /**
- * 开启打印日志
- */
- public static void debug() {
- debug(true);
- }
- /**
- * 开启或关闭打印日志
- * @param debug 是否开启debug
- */
- public static void debug(boolean debug) {
- HttpEntityBuilder.debug = debug;
- }
-}
diff --git a/src/main/java/com/mgm/mcrm/apigateway/common/httpclient/HttpParameterBuilder.java b/src/main/java/com/mgm/mcrm/apigateway/common/httpclient/HttpParameterBuilder.java
deleted file mode 100644
index 1e33d0f..0000000
--- a/src/main/java/com/mgm/mcrm/apigateway/common/httpclient/HttpParameterBuilder.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.mgm.mcrm.apigateway.common.httpclient;
-
-
-import com.alibaba.fastjson2.JSON;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-/**
- * HTTP 参数构建器
- *
- * 用于构建 HTTP 请求参数(查询字符串、请求体等)。
- *
- * @author Aaka
- */
-public class HttpParameterBuilder {
- private static final Logger log = LoggerFactory.getLogger(HttpParameterBuilder.class);
-
- /**
- * 將參數 Map 轉換為查詢字符串(用於 GET 請求)
- *
- * @param params 參數 Map
- * @return 查詢字符串,格式為 name1=value1&name2=value2
- */
- public static String buildQueryString(Map params) {
- if (params == null || params.isEmpty()) {
- return "";
- }
- return params.entrySet().stream()
- .filter(entry -> entry.getKey() != null && entry.getValue() != null)
- .map(entry -> {
- try {
- String key = URLEncoder.encode(entry.getKey(), StandardCharsets.UTF_8);
- String value = URLEncoder.encode(String.valueOf(entry.getValue()), StandardCharsets.UTF_8);
- return key + "=" + value;
- } catch (Exception e) {
- log.warn("Failed to encode parameter: {}={}", entry.getKey(), entry.getValue(), e);
- return null;
- }
- })
- .filter(java.util.Objects::nonNull)
- .collect(Collectors.joining("&"));
- }
-
-
- /**
- * 將參數 Map 轉換為請求體字符串
- *
- * @param params 參數 Map
- * @param contentType 內容類型
- * @return 請求體字符串
- */
- public static String buildRequestBody(Map params, String contentType) {
- if (params == null || params.isEmpty()) {
- return "";
- }
- // 如果是 JSON 格式
- if (contentType != null && contentType.contains("application/json")) {
- // 使用 FastJSON 將 Map 轉換為 JSON 字符串
- return JSON.toJSONString(params);
- } else {
- // 默認使用 form-urlencoded 格式
- return buildQueryString(params);
- }
- }
-
-}
-
diff --git a/src/main/java/com/mgm/mcrm/apigateway/common/httpclient/HttpRequestOptions.java b/src/main/java/com/mgm/mcrm/apigateway/common/httpclient/HttpRequestOptions.java
deleted file mode 100644
index 016d23e..0000000
--- a/src/main/java/com/mgm/mcrm/apigateway/common/httpclient/HttpRequestOptions.java
+++ /dev/null
@@ -1,375 +0,0 @@
-package com.mgm.mcrm.apigateway.common.httpclient;
-
-import com.mgm.mcrm.apigateway.common.enums.HttpMethods;
-import org.apache.hc.client5.http.classic.HttpClient;
-import org.apache.hc.client5.http.config.RequestConfig;
-import org.apache.hc.client5.http.entity.mime.Header;
-import org.apache.hc.core5.http.protocol.HttpContext;
-import org.apache.hc.core5.util.Timeout;
-
-import java.io.OutputStream;
-import java.nio.charset.Charset;
-import java.util.HashMap;
-import java.util.Map;
-
-public class HttpRequestOptions {
-
- private HttpRequestOptions(){};
-
- /**
- * 获取实例
- * @return 返回当前对象
- */
- public static HttpRequestOptions create(){
- return new HttpRequestOptions();
- }
-
-
- /**
- * HttpClient对象
- */
- private HttpClient client;
-
- /**
- * Header头信息
- */
- private Header[] headers;
-
- /**
- * 是否返回response的headers
- */
- private boolean isReturnRespHeaders;
-
- /**
- * 请求方法
- */
- private HttpMethods method=HttpMethods.POST;
-
- /**
- * 请求方法名称
- */
- private String methodName;
-
- /**
- * 用于cookie操作
- */
- private HttpContext context;
-
- // private Map map;
-
- /**
- * 以json格式作为输入参数
- */
- private String json;
-
- /**
- * 输入输出编码
- */
- private String encoding= Charset.defaultCharset().displayName();
-
- /**
- * 输入编码
- */
- private String inenc;
-
- /**
- * 输出编码
- */
- private String outenc;
-
- /**
- * 设置RequestConfig
- */
- private RequestConfig requestConfig;
-
- /**
- * 解决多线程下载时,strean被close的问题
- */
- private static final ThreadLocal outs = new ThreadLocal();
-
- /**
- * 解决多线程处理时,url被覆盖问题
- */
- private static final ThreadLocal urls = new ThreadLocal();
-
- /**
- * 解决多线程处理时,url被覆盖问题
- */
- private static final ThreadLocal