Преглед на файлове

更新依赖项,升级JDK17

Frost преди 1 година
родител
ревизия
7c47e24991

+ 58 - 98
pom.xml

@@ -4,7 +4,7 @@
 	<parent>
 		<groupId>org.springframework.boot</groupId>
 		<artifactId>spring-boot-starter-parent</artifactId>
-		<version>2.2.11.RELEASE</version>
+		<version>2.6.6</version>
 		<relativePath/>
 		<!--  lookup parent from repository  -->
 	</parent>
@@ -15,44 +15,50 @@
 	<name>springboot-sso-login</name>
 	<description>Demo project for Spring Boot</description>
 	<properties>
-		<java.version>1.8</java.version>
-		<tomcat.version>9.0.63</tomcat.version>
-		<log4j2.version>2.17.2</log4j2.version>
+		<java.version>17</java.version>
+		<tomcat.version>9.0.88</tomcat.version>
 	</properties>
 
 	<dependencies>
 		<!--&lt;!&ndash; 添加依赖 &#45;&#45;!>-->
 		<dependency>
-    		<groupId>org.apache.tomcat.embed</groupId>
-    		<artifactId>tomcat-embed-core</artifactId>
-    		<version>${tomcat.version}</version>
+			<groupId>org.yaml</groupId>
+			<artifactId>snakeyaml</artifactId>
+			<version>2.1</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.tomcat.embed</groupId>
+			<artifactId>tomcat-embed-core</artifactId>
+			<version>${tomcat.version}</version>
 		</dependency>
 		<!--MyBatis核心依赖-->
-		<!--<dependency>
+		<dependency>
 			<groupId>org.mybatis</groupId>
 			<artifactId>mybatis</artifactId>
-			<version>3.4.6</version>
-		</dependency>-->
+			<version>3.5.8</version>
+		</dependency>
 		<dependency>
-    		<groupId>org.apache.tomcat</groupId>
-    		<artifactId>tomcat-juli</artifactId>
-    		<version>${tomcat.version}</version>
+			<groupId>org.apache.tomcat</groupId>
+			<artifactId>tomcat-juli</artifactId>
+			<version>${tomcat.version}</version>
 		</dependency>
 
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-web</artifactId>
-			  <exclusions>
-                 <exclusion>
-                     <groupId>org.springframework.boot</groupId>
-					 <artifactId>spring-boot-starter-tomcat</artifactId>
-                 </exclusion>
-              </exclusions>
+			<exclusions>
+				<exclusion>
+					<groupId>org.springframework.boot</groupId>
+					<artifactId>spring-boot-starter-tomcat</artifactId>
+				</exclusion>
+			</exclusions>
 		</dependency>
 
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-thymeleaf</artifactId>
+			<version>3.1.3</version>
 		</dependency>
 		<dependency>
 			<groupId>org.projectlombok</groupId>
@@ -61,18 +67,13 @@
 		<dependency>
 			<groupId>org.mybatis.spring.boot</groupId>
 			<artifactId>mybatis-spring-boot-starter</artifactId>
-			<version>2.0.1</version>
+			<version>3.0.3</version>
 		</dependency>
 
-		<!-- <dependency>D
-                    <groupId>org.springframework.boot</groupId>
-                    <artifactId>spring-boot-devtools</artifactId>
-                    &lt;!&ndash;<scope>runtime</scope>
-                    <optional>true</optional>&ndash;&gt;
-            </dependency> -->
 		<dependency>
 			<groupId>mysql</groupId>
 			<artifactId>mysql-connector-java</artifactId>
+			<version>8.0.28</version>
 			<scope>runtime</scope>
 		</dependency>
 		<!--  tomcat的支持. -->
@@ -84,7 +85,7 @@
 		<dependency>
 			<groupId>com.github.pagehelper</groupId>
 			<artifactId>pagehelper</artifactId>
-			<version>5.3.0</version>
+			<version>5.3.1</version>
 		</dependency>
 		<dependency>
 			<groupId>com.github.pagehelper</groupId>
@@ -94,7 +95,7 @@
 		<dependency>
 			<groupId>junit</groupId>
 			<artifactId>junit</artifactId>
-			<version>4.12</version>
+			<version>4.13.1</version>
 		</dependency>
 		<!--<dependency>
 			<groupId>com.alibaba</groupId>
@@ -106,17 +107,7 @@
 			<artifactId>fastjson</artifactId>
 			<version>1.2.83</version>
 		</dependency>
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-test</artifactId>
-			<scope>test</scope>
-			<exclusions>
-				<exclusion>
-					<groupId>org.junit.vintage</groupId>
-					<artifactId>junit-vintage-engine</artifactId>
-				</exclusion>
-			</exclusions>
-		</dependency>
+
 		<dependency>
 			<groupId>javax.servlet</groupId>
 			<artifactId>javax.servlet-api</artifactId>
@@ -149,61 +140,39 @@
 		<dependency>
 			<groupId>commons-codec</groupId>
 			<artifactId>commons-codec</artifactId>
-			<version>1.10</version>
-		</dependency>
-		<!--  验证网络请求  -->
-		<dependency>
-			<groupId>commons-httpclient</groupId>
-			<artifactId>commons-httpclient</artifactId>
-			<version>3.1</version>
+			<version>1.13</version>
 		</dependency>
 
-		<!--<dependency>
-			<groupId>log4j</groupId>
-			<artifactId>log4j</artifactId>
-			<version>1.2.17</version>
-		</dependency>-->
 		<dependency>
-			<groupId>org.projectlombok</groupId>
-			<artifactId>lombok</artifactId>
-			<version>1.16.20</version>
+			<groupId>org.apache.logging.log4j</groupId>
+			<artifactId>log4j-core</artifactId>
+			<version>2.20.0</version>
 		</dependency>
+
 		<dependency>
 			<groupId>org.slf4j</groupId>
-			<artifactId>slf4j-api</artifactId>
-			<version>1.7.26</version>
+			<artifactId>log4j-over-slf4j</artifactId>
+			<version>2.0.7</version>
 		</dependency>
+
 		<dependency>
 			<groupId>org.slf4j</groupId>
-			<artifactId>log4j-over-slf4j</artifactId>
+			<artifactId>slf4j-api</artifactId>
 			<version>1.7.26</version>
 		</dependency>
 
 		<dependency>
 			<groupId>ch.qos.logback</groupId>
 			<artifactId>logback-core</artifactId>
-			<version>1.2.3</version>
+			<version>1.2.13</version>
 		</dependency>
 
-
 		<dependency>
 			<groupId>ch.qos.logback</groupId>
 			<artifactId>logback-classic</artifactId>
-			<version>1.2.3</version>
+			<version>1.2.13</version>
 		</dependency>
 
-		<!-- junit 单元测试 -->
-		<dependency>
-			<groupId>junit</groupId>
-			<artifactId>junit</artifactId>
-			<version>4.12</version>
-		</dependency>
-
-		<dependency>
-			<groupId>commons-logging</groupId>
-			<artifactId>commons-logging</artifactId>
-			<version>1.2</version>
-		</dependency>
 		<dependency>
 			<groupId>jaxen</groupId>
 			<artifactId>jaxen</artifactId>
@@ -218,7 +187,7 @@
 		<dependency>
 			<groupId>org.apache.httpcomponents</groupId>
 			<artifactId>httpclient</artifactId>
-			<version>4.5.2</version>
+			<version>4.5.13</version>
 		</dependency>
 		<dependency>
 			<groupId>org.apache.httpcomponents</groupId>
@@ -234,13 +203,9 @@
 		<dependency>
 			<groupId>org.apache.poi</groupId>
 			<artifactId>poi-ooxml</artifactId>
-			<version>4.1.2</version>
+			<version>5.2.3</version>
 		</dependency>
-		<!-- <dependency>
-                    <groupId>org.apache.commons</groupId>
-                    <artifactId>commons-lang3</artifactId>
-                    <version>2.6</version>
-                </dependency> -->
+
 		<dependency>
 			<groupId>cglib</groupId>
 			<artifactId>cglib</artifactId>
@@ -249,7 +214,7 @@
 		<dependency>
 			<groupId>org.apache.commons</groupId>
 			<artifactId>commons-collections4</artifactId>
-			<version>4.1</version>
+			<version>4.3</version>
 		</dependency>
 		<dependency>
 			<groupId>commons-lang</groupId>
@@ -269,7 +234,7 @@
 		<dependency>
 			<groupId>org.codehaus.jettison</groupId>
 			<artifactId>jettison</artifactId>
-			<version>1.3.7</version>
+			<version>1.5.4</version>
 		</dependency>
 		<dependency>
 			<groupId>com.auth0</groupId>
@@ -281,11 +246,6 @@
 			<artifactId>logstash-logback-encoder</artifactId>
 			<version>4.11</version>
 		</dependency>
-		<!--<dependency>
-			<groupId>com.github.ulisesbocchio</groupId>
-			<artifactId>jasypt-spring-boot-starter</artifactId>
-			<version>1.8</version>
-		</dependency>-->
 
 	</dependencies>
 
@@ -294,19 +254,19 @@
 			<plugin>
 				<groupId>org.springframework.boot</groupId>
 				<artifactId>spring-boot-maven-plugin</artifactId>
-				<version>2.2.11.RELEASE</version>
+				<version>3.3.0</version>
 			</plugin>
 		</plugins>
-<!--		<resources>-->
-<!--			<resource>-->
-<!--				<directory>src/main/java</directory>&lt;!&ndash;所在的目录&ndash;&gt;-->
-<!--				<includes>&lt;!&ndash;包括目录下的.properties,.xml文件都会扫描到&ndash;&gt;-->
-<!--					<include>**/*.properties</include>-->
-<!--					<include>**/*.xml</include>-->
-<!--				</includes>-->
-<!--				<filtering>false</filtering>-->
-<!--			</resource>-->
-<!--		</resources>-->
+		<!--		<resources>-->
+		<!--			<resource>-->
+		<!--				<directory>src/main/java</directory>&lt;!&ndash;所在的目录&ndash;&gt;-->
+		<!--				<includes>&lt;!&ndash;包括目录下的.properties,.xml文件都会扫描到&ndash;&gt;-->
+		<!--					<include>**/*.properties</include>-->
+		<!--					<include>**/*.xml</include>-->
+		<!--				</includes>-->
+		<!--				<filtering>false</filtering>-->
+		<!--			</resource>-->
+		<!--		</resources>-->
 	</build>
 	<!--多环境配置信息 a-->
 	<profiles>
@@ -371,4 +331,4 @@
         </build> -->
 	<!--  打包方式  -->
 	<!--  <packaging>war</packaging>  -->
-</project>
+</project>

+ 12 - 10
src/main/java/com/zhou/SpringbootSsoLoginApplication.java

@@ -2,6 +2,8 @@ package com.zhou;
 
 
 
+import ch.qos.logback.classic.LoggerContext;
+import org.slf4j.LoggerFactory;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@@ -14,6 +16,8 @@ import com.trs.idm.client.filter.GeneralSSOFilter;
 import com.trs.idm.client.listener.CoSessionListener;
 import com.trs.idm.client.servlet.LoginProxyServlet;
 
+import java.net.URL;
+
 @SpringBootApplication//(exclude = {DataSourceAutoConfiguration.class})
 public class SpringbootSsoLoginApplication {
 
@@ -21,38 +25,36 @@ public class SpringbootSsoLoginApplication {
 		System.out.println("项目SSO启动");
 		SpringApplication.run(SpringbootSsoLoginApplication.class, args);
 	}
-	
+
 	@Bean
 	public ServletListenerRegistrationBean<CoSessionListener> getCossionListener(){
-		ServletListenerRegistrationBean<CoSessionListener> servletListenerRegistrationBean = new ServletListenerRegistrationBean<CoSessionListener>(new CoSessionListener());
-		return servletListenerRegistrationBean;
+        return new ServletListenerRegistrationBean<CoSessionListener>(new CoSessionListener());
 	}
-	
+
 	@Bean
 	public FilterRegistrationBean<GeneralSSOFilter> getSSOLoginFilter(){
 		FilterRegistrationBean<GeneralSSOFilter> filterRegistrationBean = new FilterRegistrationBean<GeneralSSOFilter>(new GeneralSSOFilter());
 		filterRegistrationBean.addUrlPatterns("/*");
 		return filterRegistrationBean;
 	}
-	
-	
+
+
 	@Bean
 	public ServletRegistrationBean<LoginProxyServlet> getSSOProxyServlet(){
-		ServletRegistrationBean<LoginProxyServlet> servletRegistrationBean = 
+		ServletRegistrationBean<LoginProxyServlet> servletRegistrationBean =
 				new ServletRegistrationBean<LoginProxyServlet>(new LoginProxyServlet());
 		servletRegistrationBean.addUrlMappings("/TRSIdSSSOProxyServlet");
 		servletRegistrationBean.setLoadOnStartup(100);
 		return servletRegistrationBean;
 	}
-	
+
 	@Bean
 	public ServletRegistrationBean<LoginProxyServlet> getLongUrlServlet(){
-		ServletRegistrationBean<LoginProxyServlet> servletRegistrationBean = 
+		ServletRegistrationBean<LoginProxyServlet> servletRegistrationBean =
 				new ServletRegistrationBean<LoginProxyServlet>(new LoginProxyServlet());
 		servletRegistrationBean.addUrlMappings("/idsAgents/GetLongUrlServlet");
 		servletRegistrationBean.setLoadOnStartup(100);
 		return servletRegistrationBean;
 	}
 
-
 }

+ 12 - 2
src/main/java/com/zhou/controller/HttpInterfacController.java

@@ -91,9 +91,14 @@ public class HttpInterfacController {
 							if(list.size()>0){
 								HttpInterface hife =list.get(0);
 								System.out.println("getIpHttpInterface");
+//								System.out.println(hife.getURL());
+//								pmr.setType(1);
+//								pmr.setData(hife.getURL());
 								System.out.println(hife.getURL());
 								pmr.setType(1);
-								pmr.setData(hife.getURL());
+								// 在这里添加脱敏处理
+								String anonymizedIP = anonymizeIP(hife.getURL());
+								pmr.setData(anonymizedIP);
 								break;
 							}else {
 								break;
@@ -116,7 +121,12 @@ public class HttpInterfacController {
 		return new ResponseEntity<>(map, HttpStatus.OK);
 
 	}
-
+	// 脱敏IP地址的方法
+	private String anonymizeIP(String ip) {
+		String[] ipParts = ip.split("\\.");
+		// 假设IP地址格式正确,且没有进行错误检查
+		return ipParts[0] + "." + ipParts[1] + ".*.*";
+	}
 
 
 	public JSONObject getJSONParam(HttpServletRequest request){

+ 13 - 2
src/main/java/com/zhou/controller/IndexController.java

@@ -120,7 +120,11 @@ public class IndexController {
 								String  keyBytes = "rC3PEniq57QXiWk40BDw3inW";
 								DesUtils du =new DesUtils();
 								String email = du.decode(user.getEmail(),keyBytes);
-								user.setEmail(email);
+								//user.setEmail(email);
+								// 在这里修改电子邮件地址,使用匿名化方法
+								String anonymizedEmail = anonymizeEmail(email);
+								user.setEmail(anonymizedEmail);
+
 								UsersVo vo = usersPoToVo(user);
 								voList.add(vo);
 							}
@@ -161,7 +165,14 @@ public class IndexController {
 		}
 
 	}
-
+	// 脱敏电子邮件地址的方法
+	private String anonymizeEmail(String email) {
+		int atIndex = email.indexOf('@');
+		String domain = email.substring(atIndex);
+		String localPart = email.substring(0, atIndex);
+		String maskedLocalPart = localPart.replaceAll("(?<=.{2}).", "*");
+		return maskedLocalPart + domain;
+	}
 	/**
 	 * 根据ID查询
 	 * @param request

+ 3 - 1
src/main/java/com/zhou/tools/IPUtil.java

@@ -2,9 +2,11 @@ package com.zhou.tools;
 
 import java.net.InetAddress;
 
-import lombok.extern.slf4j.Slf4j;
+
 import ch.qos.logback.classic.pattern.ClassicConverter;
 import ch.qos.logback.classic.spi.ILoggingEvent;
+import lombok.extern.slf4j.Slf4j;
+
 @Slf4j
 public class IPUtil extends ClassicConverter {
 

+ 4 - 5
src/main/resources/application-CX.properties

@@ -1,3 +1,4 @@
+logging.config=classpath\:logback.xml
 server.ssl.key-store=server.keystore
 server.ssl.key-alias=tomcat
 server.ssl.enabled=true
@@ -9,7 +10,7 @@ server.tomcat.max-threads=1200
 server.tomcat.max-connections=10000
 server.tomcat.accept-count=400
 server.tomcat.min-spare-threads=600
-server.connection-timeout=120000
+server.tomcat.connection-timeout=120000
 
 #thymeleaf dispose
 spring.thymeleaf.mode=HTML5
@@ -26,7 +27,7 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
 fastjson.parser.safeMode=true
 
 #Company_minute
-EXPIRE_TIME: 240
+EXPIRE_TIME= 30
 
 
 #test_cloudOut
@@ -35,6 +36,4 @@ appSecret : 2D06BFE5-10B2-40BC-89A6-5C47AAD08472
 apiKey : kENe0S6cyYnqcHTtqLDwD3lwRFNVTyfd
 
 
-#==================== 日志配合·标准  ============================
-#logging.config=classpath:logback-boot.xml
-logging.config=classpath\:logback.xml
+

+ 7 - 18
src/main/resources/logback.xml

@@ -1,18 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration scan="true" scanPeriod="60 seconds" debug="true">
-
     <property name="LOG_HOME" value="./logs" />
     <property name="APP_Name" value="CLIENT_SERVER" />
     <contextName>${APP_Name}</contextName>
-
     <conversionRule conversionWord="ip" converterClass="com.zhou.tools.IPUtil" />
-    <!--  控制台输出   -->
+    <!-- 控制台输出 -->
     <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
         <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
             <level>INFO</level>
         </filter>
         <encoder>
-            <pattern>SSO [%ip] %d{yyyy-MM-dd HH:mm:ss.SSS} [%level]  [RequestId : %X{processId}] [CallId : %X{callId}]   [class: %logger{50}.%M] [ line: %line]  : %msg%n</pattern>
+            <pattern>SSO [%ip] %d{yyyy-MM-dd HH:mm:ss.SSS} [%level] [RequestId : %X{processId}] [CallId : %X{callId}] [class: %logger{50}.%M] [ line: %line] : %msg%n</pattern>
         </encoder>
     </appender>
     <!-- logger logfile -->
@@ -27,7 +25,6 @@
                 <maxFileSize>50MB</maxFileSize>
             </timeBasedFileNamingAndTriggeringPolicy>
         </rollingPolicy>
-
         <encoder>
             <pattern>SSO [%ip] %d{yyyy-MM-dd HH:mm:ss.SSS} [%level]  [RequestId : %X{processId}] [CallId : %X{callId}]   [class: %logger{50}.%M] [ line: %line]  : %msg%n</pattern>
         </encoder>
@@ -41,23 +38,16 @@
         <appender-ref ref ="logger-logfile"/>
         <includeCallerData>true</includeCallerData>
     </appender>
-
-
-
-
-
     <!-- logfile-error -->
     <appender name="logfile-error" class="ch.qos.logback.core.rolling.RollingFileAppender">
         <file>${LOG_HOME}/ERROR.log</file>
         <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
             <fileNamePattern>${LOG_HOME}/history/ERROR_%d{yyyyMMdd}.log.%i.gz</fileNamePattern>
             <maxHistory>30</maxHistory>
-
             <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                 <maxFileSize>50MB</maxFileSize>
             </timeBasedFileNamingAndTriggeringPolicy>
         </rollingPolicy>
-
         <encoder>
             <pattern>SSO [%ip] %d{yyyy-MM-dd HH:mm:ss.SSS} [%level]  [RequestId : %X{processId}] [CallId : %X{callId}]   [class: %logger{50}.%M] [ line: %line]  : %msg%n</pattern>
         </encoder>
@@ -65,7 +55,6 @@
             <level>ERROR</level>
         </filter>
     </appender>
-
     <appender name ="async_logfile-error" class= "ch.qos.logback.classic.AsyncAppender">
         <!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
         <discardingThreshold >0</discardingThreshold>
@@ -75,17 +64,17 @@
         <appender-ref ref ="logfile-error"/>
         <includeCallerData>true</includeCallerData>
     </appender>
-    <logger name="com.zhou" level="INFO" additivity="false">
+    <!-- 定义logger -->
+    <logger name="org.springframework.boot.SpringApplication" level="INFO">
         <appender-ref ref="stdout" />
     </logger>
-
+<!--    <logger name="com.zhou" level="INFO" additivity="false">-->
+<!--        <appender-ref ref="stdout" />-->
+<!--    </logger>-->
     <logger name="com.zhou" level="ERROR" additivity="false">
         <appender-ref ref="async_logfile-error" />
     </logger>
-
     <logger name="com.zhou" level="INFO" additivity="false">
         <appender-ref ref="async_logger-logfile" />
     </logger>
-
-
 </configuration>

+ 0 - 13
src/test/java/com/zhou/SpringbootSsoLoginApplicationTests.java

@@ -1,13 +0,0 @@
-package com.zhou;
-
-import org.junit.Test;
-import org.springframework.boot.test.context.SpringBootTest;
-
-@SpringBootTest
-class SpringbootSsoLoginApplicationTests {
-
-	@Test
-	void contextLoads() {
-	}
-
-}