summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfengjunfeng <[email protected]>2022-01-26 09:26:46 +0800
committerfengjunfeng <[email protected]>2022-01-26 09:26:46 +0800
commitd05bc186909b6a36c3ef7ce3aef296ca9821db13 (patch)
tree0097f72a1cb08aa52d4fa36d0e87d172daa1b7a4
parent5cd51759d8397580d379bd0dc405ef1886b580f0 (diff)
parent9a8f2d47ac7b23de461191edc6489b94b57719e9 (diff)
Merge remote-tracking branch 'origin/master' into develop_22.02
# Conflicts: # src/main/java/com/license/bean/Rets.java # src/main/java/com/license/controller/LicenseController.java
-rw-r--r--src/main/java/com/license/controller/LicenseController.java104
1 files changed, 0 insertions, 104 deletions
diff --git a/src/main/java/com/license/controller/LicenseController.java b/src/main/java/com/license/controller/LicenseController.java
deleted file mode 100644
index 24c9cd8..0000000
--- a/src/main/java/com/license/controller/LicenseController.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package com.license.controller;
-
-import cn.hutool.core.map.MapUtil;
-import cn.hutool.json.JSONObject;
-import cn.hutool.json.JSONUtil;
-import cn.hutool.log.Log;
-
-import com.license.bean.LicenseInfo;
-import com.license.cache.CacheManager;
-import com.license.utils.Constant;
-import com.license.utils.GetIpProtUtil;
-import com.license.utils.HaspUtil;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.*;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.client.RestTemplate;
-
-import java.net.SocketException;
-import java.net.UnknownHostException;
-import java.util.Map;
-import java.util.concurrent.CompletableFuture;
-
-/**
- * @author fengjunfeng
- * @date 2021/12/28
- * @time 16:00
- * @description
- **/
-@RestController
-public class LicenseController {
- private static final Log log = Log.get();
- @Autowired
- public RestTemplate restTemplate;
- @Value("${bifang-api.server.port}")
- private String port;
- /**
- * license锁信息交互
- *
- * @return
- */
- @PostMapping("/licenseOperation")
- public Object licenseOperation(@RequestBody LicenseInfo licenseInfo) {
- if (!verify(licenseInfo.getServerId())){
- return null;
- }
- if (licenseInfo.getType().equals(Constant.LICENSE_C2V)){
- //获取C2V信息
- return HaspUtil.readC2V(licenseInfo.getVendorCode(),licenseInfo.getFeatureId());
- }else if (licenseInfo.getType().equals(Constant.LICENSE_UPDATE)){
- //上传license信息
- return HaspUtil.updateKeyWithLicense(licenseInfo.getV2C());
- }else if (licenseInfo.getType().equals(Constant.LICENSE_QUERY)){
- //获取license信息
- return HaspUtil.getLicenseInfo(licenseInfo.getVendorCode(),licenseInfo.getFeatureId());
- }else if (licenseInfo.getType().equals(Constant.LICENSE_VERIFY)){
- //验证license信息
- return HaspUtil.verify(licenseInfo.getVendorCode(),licenseInfo.getFeatureId());
- }else {
- log.info("type error");
- return null;
- }
- }
-
- /**
- *
- * @author fengjunfeng
- * @date 2022/1/20
- * @time 11:14
- * @description
- *
- **/
- public boolean verify(String serverId){
- try {
- HttpHeaders headers = new HttpHeaders();
- headers.setContentType(MediaType.APPLICATION_JSON);
- headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
- HttpEntity<JSONObject> httpEntity = new HttpEntity<>(null, headers);
- String url = "http://" + GetIpProtUtil.getLocalIP() +":" + port + "/getServerId";
- 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;
- }
- }catch (SocketException | UnknownHostException e){
- log.error("获取ip出错");
- }
- return false;
- }
-
-
-// @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;
-// }
-
-}