23
23
24
24
import com .cxytiandi .encrypt .springboot .HttpMethodTypePrefixConstant ;
25
25
import com .cxytiandi .encrypt .springboot .annotation .Decrypt ;
26
+ import com .cxytiandi .encrypt .springboot .annotation .DecryptIgnore ;
26
27
import com .cxytiandi .encrypt .springboot .annotation .Encrypt ;
28
+ import com .cxytiandi .encrypt .springboot .annotation .EncryptIgnore ;
27
29
28
30
public class ApiEncryptDataInit implements ApplicationContextAware {
29
31
@@ -43,6 +45,20 @@ public class ApiEncryptDataInit implements ApplicationContextAware {
43
45
*/
44
46
public static List <String > requestDecyptUriList = new ArrayList <String >();
45
47
48
+ /**
49
+ * 忽略加密的接口URI<br>
50
+ * 比如:/user/list<br>
51
+ * 不支持@PathVariable格式的URI
52
+ */
53
+ public static List <String > responseEncryptUriIgnoreList = new ArrayList <String >();
54
+
55
+ /**
56
+ * 忽略对请求内容进行解密的接口URI<br>
57
+ * 比如:/user/list<br>
58
+ * 不支持@PathVariable格式的URI
59
+ */
60
+ public static List <String > requestDecyptUriIgnoreList = new ArrayList <String >();
61
+
46
62
private String contextPath ;
47
63
48
64
@ Override
@@ -79,6 +95,25 @@ private void initData(Map<String, Object> beanMap) {
79
95
logger .debug ("Decrypt URI: {}" , uri );
80
96
requestDecyptUriList .add (uri );
81
97
}
98
+ EncryptIgnore encryptIgnore = AnnotationUtils .findAnnotation (method , EncryptIgnore .class );
99
+ if (encryptIgnore != null ) {
100
+ // 注解中的URI优先级高
101
+ String uri = encryptIgnore .value ();
102
+ if (!StringUtils .hasText (uri )) {
103
+ uri = getApiUri (clz , method );
104
+ }
105
+ logger .debug ("EncryptIgnore URI: {}" , uri );
106
+ responseEncryptUriIgnoreList .add (uri );
107
+ }
108
+ DecryptIgnore decryptIgnore = AnnotationUtils .findAnnotation (method , DecryptIgnore .class );
109
+ if (decryptIgnore != null ) {
110
+ String uri = decryptIgnore .value ();
111
+ if (!StringUtils .hasText (uri )) {
112
+ uri = getApiUri (clz , method );
113
+ }
114
+ logger .debug ("DecryptIgnore URI: {}" , uri );
115
+ requestDecyptUriIgnoreList .add (uri );
116
+ }
82
117
}
83
118
}
84
119
}
0 commit comments