服务来源有效认证

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")
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;
// }
}

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