@@ -50,6 +50,12 @@ public EncryptionFilter(EncryptionConfig config, EncryptAlgorithm encryptAlgorit
50
50
this .encryptAlgorithm = encryptAlgorithm ;
51
51
}
52
52
53
+ public EncryptionFilter (String key ) {
54
+ EncryptionConfig config = new EncryptionConfig ();
55
+ config .setKey (key );
56
+ this .encryptionConfig = config ;
57
+ }
58
+
53
59
public EncryptionFilter (String key , List <String > responseEncryptUriList , List <String > requestDecyptUriList ,
54
60
String responseCharset , boolean debug ) {
55
61
this .encryptionConfig = new EncryptionConfig (key , responseEncryptUriList , requestDecyptUriList , responseCharset , debug );
@@ -75,8 +81,9 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
75
81
return ;
76
82
}
77
83
78
- boolean decryptionStatus = encryptionConfig .getRequestDecyptUriList ().contains (uri );
79
- boolean encryptionStatus = encryptionConfig .getResponseEncryptUriList ().contains (uri );
84
+
85
+ boolean decryptionStatus = this .contains (encryptionConfig .getRequestDecyptUriList (), uri , req .getMethod ());
86
+ boolean encryptionStatus = this .contains (encryptionConfig .getResponseEncryptUriList (), uri , req .getMethod ());
80
87
81
88
// 没有配置具体加解密的URI默认全部都开启加解密
82
89
if (encryptionConfig .getRequestDecyptUriList ().size () == 0
@@ -147,6 +154,18 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
147
154
148
155
}
149
156
157
+ private boolean contains (List <String > list , String uri , String methodType ) {
158
+ if (list .contains (uri )) {
159
+ return true ;
160
+ }
161
+ String prefixUri = methodType .toLowerCase () + ":" + uri ;
162
+ logger .debug ("contains uri: {}" , prefixUri );
163
+ if (list .contains (prefixUri )) {
164
+ return true ;
165
+ }
166
+ return false ;
167
+ }
168
+
150
169
@ Override
151
170
public void destroy () {
152
171
0 commit comments