服务来源有效认证

This commit is contained in:
fengjunfeng
2022-01-24 10:39:27 +08:00
parent f21a67fc7e
commit 5cd51759d8
2 changed files with 16 additions and 30 deletions

View File

@@ -41,9 +41,9 @@ public class LicenseController {
*/ */
@PostMapping("/licenseOperation") @PostMapping("/licenseOperation")
public Object licenseOperation(@RequestBody LicenseInfo licenseInfo) { public Object licenseOperation(@RequestBody LicenseInfo licenseInfo) {
// if (!verify(licenseInfo.getServerId())){ if (!verify(licenseInfo.getServerId())){
// return null; return null;
// } }
if (licenseInfo.getType().equals(Constant.LICENSE_C2V)){ if (licenseInfo.getType().equals(Constant.LICENSE_C2V)){
//获取C2V信息 //获取C2V信息
return HaspUtil.readC2V(licenseInfo.getVendorCode(),licenseInfo.getFeatureId()); return HaspUtil.readC2V(licenseInfo.getVendorCode(),licenseInfo.getFeatureId());
@@ -77,9 +77,8 @@ public class LicenseController {
headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
HttpEntity<JSONObject> httpEntity = new HttpEntity<>(null, headers); HttpEntity<JSONObject> httpEntity = new HttpEntity<>(null, headers);
String url = "http://" + GetIpProtUtil.getLocalIP() +":" + port + "/getServerId"; String url = "http://" + GetIpProtUtil.getLocalIP() +":" + port + "/getServerId";
ResponseEntity<Map> entity = restTemplate.exchange(url, HttpMethod.GET,httpEntity,Map.class); String str = restTemplate.exchange(url, HttpMethod.GET,httpEntity,String.class).getBody();
log.info("license status: {}", JSONUtil.toJsonStr(entity)); log.info("license bifang_api server id: {}", str);
String str = MapUtil.get(entity.getBody(), "data", String.class);
if (str.equals(serverId)){ if (str.equals(serverId)){
return true; return true;
} }
@@ -90,16 +89,16 @@ public class LicenseController {
} }
@PostMapping("/test") // @PostMapping("/test")
public Object test() { // public Object test() {
verify("1111"); // verify("1111");
//
if (CacheManager.getCache("test") == null){ // if (CacheManager.getCache("test") == null){
CacheManager.addCache("test","11111"); // CacheManager.addCache("test","11111");
}else { // }else {
System.out.println(CacheManager.getCache("test")); // System.out.println(CacheManager.getCache("test"));
} // }
return null; // return null;
} // }
} }

View File

@@ -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() {
}
}