|
|
@@ -0,0 +1,32 @@
|
|
|
+package com.zhiqiyun.open.router.config;
|
|
|
+
|
|
|
+import com.dliyun.oap.framework.security.TransportSecurity;
|
|
|
+import com.dliyun.oap.framework.security.algorithm.DES;
|
|
|
+import com.zhiqiyun.open.core.models.AppKeyInfo;
|
|
|
+import com.zhiqiyun.open.core.service.AppKeyInfoService;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+
|
|
|
+public class DesTransportSecurity implements TransportSecurity {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AppKeyInfoService appKeyInfoService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String responseEncrypt(String appKey, String s) {
|
|
|
+ if (StringUtils.isNotBlank(appKey)) {
|
|
|
+ AppKeyInfo appSecretInfo = this.appKeyInfoService.getById(appKey);
|
|
|
+ s = DES.encrypt(appSecretInfo.getEncryptKey(), s);
|
|
|
+ }
|
|
|
+ return s;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String requestDecrypt(String appKey, String s) {
|
|
|
+ if (StringUtils.isNotBlank(appKey)) {
|
|
|
+ AppKeyInfo appSecretInfo = this.appKeyInfoService.getById(appKey);
|
|
|
+ s = DES.decrypt(appSecretInfo.getEncryptKey(), s);
|
|
|
+ }
|
|
|
+ return s;
|
|
|
+ }
|
|
|
+}
|