diff options
| author | fengjunfeng <[email protected]> | 2022-01-24 10:39:27 +0800 |
|---|---|---|
| committer | fengjunfeng <[email protected]> | 2022-01-24 10:39:27 +0800 |
| commit | 5cd51759d8397580d379bd0dc405ef1886b580f0 (patch) | |
| tree | 741766af598fbb845bf83da5b5ce595893ec275c /src | |
| parent | f21a67fc7eebed2b0b65d3985cf987375301805a (diff) | |
服务来源有效认证
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/java/com/license/controller/LicenseController.java | 33 | ||||
| -rw-r--r-- | src/test/java/com/sentinel/license/LicenseApplicationTests.java | 13 |
2 files changed, 16 insertions, 30 deletions
diff --git a/src/main/java/com/license/controller/LicenseController.java b/src/main/java/com/license/controller/LicenseController.java index 01b3f71..24c9cd8 100644 --- a/src/main/java/com/license/controller/LicenseController.java +++ b/src/main/java/com/license/controller/LicenseController.java @@ -41,9 +41,9 @@ public class LicenseController { */ @PostMapping("/licenseOperation") public Object licenseOperation(@RequestBody LicenseInfo licenseInfo) { -// if (!verify(licenseInfo.getServerId())){ -// return null; -// } + if (!verify(licenseInfo.getServerId())){ + return null; + } if (licenseInfo.getType().equals(Constant.LICENSE_C2V)){ //获取C2V信息 return HaspUtil.readC2V(licenseInfo.getVendorCode(),licenseInfo.getFeatureId()); @@ -77,9 +77,8 @@ public class LicenseController { headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); HttpEntity<JSONObject> httpEntity = new HttpEntity<>(null, headers); String url = "http://" + GetIpProtUtil.getLocalIP() +":" + port + "/getServerId"; - ResponseEntity<Map> entity = restTemplate.exchange(url, HttpMethod.GET,httpEntity,Map.class); - log.info("license status: {}", JSONUtil.toJsonStr(entity)); - String str = MapUtil.get(entity.getBody(), "data", String.class); + String str = restTemplate.exchange(url, HttpMethod.GET,httpEntity,String.class).getBody(); + log.info("license bifang_api server id: {}", str); if (str.equals(serverId)){ return true; } @@ -90,16 +89,16 @@ public class LicenseController { } - @PostMapping("/test") - public Object test() { - verify("1111"); - - if (CacheManager.getCache("test") == null){ - CacheManager.addCache("test","11111"); - }else { - System.out.println(CacheManager.getCache("test")); - } - return null; - } +// @PostMapping("/test") +// public Object test() { +// verify("1111"); +// +// if (CacheManager.getCache("test") == null){ +// CacheManager.addCache("test","11111"); +// }else { +// System.out.println(CacheManager.getCache("test")); +// } +// return null; +// } } diff --git a/src/test/java/com/sentinel/license/LicenseApplicationTests.java b/src/test/java/com/sentinel/license/LicenseApplicationTests.java deleted file mode 100644 index 8f7f818..0000000 --- a/src/test/java/com/sentinel/license/LicenseApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.sentinel.license; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class LicenseApplicationTests { - - @Test - void contextLoads() { - } - -} |
