This commit is contained in:
Administrator
2024-05-15 23:44:22 +08:00
parent ae83a86444
commit e3b42d2b95
4 changed files with 42 additions and 5 deletions

View File

@@ -6,6 +6,7 @@
<artifactId>security-api-demo</artifactId> <artifactId>security-api-demo</artifactId>
<groupId>org.example</groupId> <groupId>org.example</groupId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>gateway</artifactId> <artifactId>gateway</artifactId>
@@ -41,7 +42,28 @@
<artifactId>aspectjweaver</artifactId> <artifactId>aspectjweaver</artifactId>
<version>1.9.7</version> <!-- 版本号根据你的需求进行调整 --> <version>1.9.7</version> <!-- 版本号根据你的需求进行调整 -->
</dependency> </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-collections/commons-collections -->
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
<!--json-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.73</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.15</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@@ -2,7 +2,7 @@ package com.demo.gateway.filter;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.common.utils.Md5Utils; import org.apache.commons.codec.digest.DigestUtils;
import com.demo.gateway.config.FilterUtils; import com.demo.gateway.config.FilterUtils;
import com.demo.gateway.pojo.MyCachedBodyOutputMessage; import com.demo.gateway.pojo.MyCachedBodyOutputMessage;
import com.demo.gateway.utils.AESUtil; import com.demo.gateway.utils.AESUtil;
@@ -127,7 +127,7 @@ public class RequestDecryptionGlobalFilter implements GlobalFilter, Ordered {
public void checkSign(String sign, Long dateTimestamp, String requestId, Map<String, Object> paramMap) { public void checkSign(String sign, Long dateTimestamp, String requestId, Map<String, Object> paramMap) {
String str = JSON.toJSONString(paramMap) + requestId + dateTimestamp; String str = JSON.toJSONString(paramMap) + requestId + dateTimestamp;
String tempSign = Md5Utils.getMD5(str.getBytes()); String tempSign = DigestUtils.md5Hex(str);
if (!tempSign.equals(sign)) { if (!tempSign.equals(sign)) {
throw new IllegalArgumentException(SIGN_ERROR_MESSAGE); throw new IllegalArgumentException(SIGN_ERROR_MESSAGE);
} }

View File

@@ -79,6 +79,23 @@
<artifactId>java-jwt</artifactId> <artifactId>java-jwt</artifactId>
<version>3.18.2</version> <version>3.18.2</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-collections/commons-collections -->
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
<!--json-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.73</version>
</dependency>

View File

@@ -11,8 +11,6 @@
<modules> <modules>
<module>gateway</module> <module>gateway</module>
<module>library</module> <module>library</module>
<!-- <module>common</module>--> <!-- <module>common</module>-->
<!-- <module>user</module>--> <!-- <module>user</module>-->
</modules> </modules>