Merge remote-tracking branch 'origin/V1.00' into V1.00
This commit is contained in:
commit
fe957fe599
@ -3,8 +3,8 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.cisd</groupId>
|
||||
<artifactId>openapi-sdk</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<artifactId>netsignapi</artifactId>
|
||||
<version>1.0.0</version>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
@ -48,5 +48,34 @@
|
||||
<version>2.19.4</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>cn.com.infosec.netsign.agent.Main</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
package com.cisd.openapi;
|
||||
package cn.com.infosec.netsign.agent;
|
||||
|
||||
|
||||
import com.cisd.openapi.config.OkHttpClientHolder;
|
||||
import com.cisd.openapi.config.SignServerProperties;
|
||||
import com.cisd.openapi.config.SignServerPropertiesLoader;
|
||||
import cn.com.infosec.netsign.agent.config.OkHttpClientHolder;
|
||||
import cn.com.infosec.netsign.agent.config.SignServerProperties;
|
||||
import cn.com.infosec.netsign.agent.config.SignServerPropertiesLoader;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
@ -16,7 +16,7 @@ public class Main
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
SignServerProperties properties = SignServerPropertiesLoader.getProperties();
|
||||
|
||||
SignClient signClient = new SignClient(
|
||||
PBCAgent2G signClient = new PBCAgent2G(
|
||||
okHttpClient,
|
||||
objectMapper,
|
||||
properties
|
||||
@ -1,8 +1,8 @@
|
||||
package com.cisd.openapi;
|
||||
package cn.com.infosec.netsign.agent;
|
||||
|
||||
import com.cisd.openapi.config.SignServerProperties;
|
||||
import com.cisd.openapi.dto.*;
|
||||
import com.cisd.openapi.exception.BusinessException;
|
||||
import cn.com.infosec.netsign.agent.config.SignServerProperties;
|
||||
import cn.com.infosec.netsign.agent.dto.*;
|
||||
import cn.com.infosec.netsign.agent.exception.BusinessException;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@ -14,18 +14,19 @@ import java.util.Base64;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
public class SignClient{
|
||||
public class PBCAgent2G{
|
||||
|
||||
private static final MediaType JSON_MEDIA_TYPE =
|
||||
MediaType.parse("application/json; charset=utf-8");
|
||||
|
||||
|
||||
private final OkHttpClient okHttpClient;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
private final SignServerProperties properties;
|
||||
private final ThreadLocal<Integer> lastReturnCode = new ThreadLocal<>();
|
||||
|
||||
public SignClient(OkHttpClient okHttpClient,
|
||||
public PBCAgent2G(OkHttpClient okHttpClient,
|
||||
ObjectMapper objectMapper,
|
||||
SignServerProperties properties) {
|
||||
this.okHttpClient = okHttpClient;
|
||||
@ -36,6 +37,7 @@ public class SignClient{
|
||||
|
||||
public String rawSign(byte[] origBytes, String dn) {
|
||||
|
||||
System.out.println("调用rawSign, dn:" + dn);
|
||||
String sessionId = UUID.randomUUID().toString().replace("-", "");
|
||||
|
||||
if (origBytes == null) {
|
||||
@ -81,7 +83,9 @@ public class SignClient{
|
||||
.build();
|
||||
|
||||
|
||||
System.out.println("准备连接签名服务器");
|
||||
try (Response response = okHttpClient.newCall(request).execute()) {
|
||||
System.out.println("连接成功,并收到响应");
|
||||
String responseBody = response.body() == null ? "" : response.body().string();
|
||||
JsonNode root = objectMapper.readTree(responseBody);
|
||||
int code = root.get("code").asInt();
|
||||
@ -100,13 +104,16 @@ public class SignClient{
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
System.err.println("连接签名服务器异常" + e.getMessage());
|
||||
throw new RuntimeException("调用rawSign异常:" + e.getMessage(), e);
|
||||
} finally {
|
||||
System.out.println("请求结束, 连接资源已释放");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean rawVerify(byte[] origBytes, String certStr, String dn) {
|
||||
|
||||
System.out.println("调用rawVerify, dn:" + dn);
|
||||
String sessionId = UUID.randomUUID().toString().replace("-", "");
|
||||
|
||||
if (origBytes == null) {
|
||||
@ -157,8 +164,9 @@ public class SignClient{
|
||||
.addHeader("X-API-Key", properties.getApiKey())
|
||||
.build();
|
||||
|
||||
|
||||
System.out.println("准备连接签名服务器");
|
||||
try (Response response = okHttpClient.newCall(request).execute()) {
|
||||
System.out.println("连接成功,并收到响应");
|
||||
String responseBody = response.body() == null ? "" : response.body().string();
|
||||
JsonNode root = objectMapper.readTree(responseBody);
|
||||
int code = root.get("code").asInt();
|
||||
@ -176,13 +184,16 @@ public class SignClient{
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
System.err.println("连接签名服务器异常" + e.getMessage());
|
||||
throw new RuntimeException("调用rawVerify异常", e);
|
||||
} finally {
|
||||
System.out.println("请求结束, 连接资源已释放");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String dettachedSign(byte[] origBytes, String dn) {
|
||||
|
||||
System.out.println("调用dettachedSign, dn:" + dn);
|
||||
String sessionId = UUID.randomUUID().toString().replace("-", "");
|
||||
|
||||
if (origBytes == null) {
|
||||
@ -224,7 +235,9 @@ public class SignClient{
|
||||
.build();
|
||||
|
||||
|
||||
System.out.println("准备连接签名服务器");
|
||||
try (Response response = okHttpClient.newCall(request).execute()) {
|
||||
System.out.println("连接成功,并收到响应");
|
||||
String responseBody = response.body() == null ? "" : response.body().string();
|
||||
JsonNode root = objectMapper.readTree(responseBody);
|
||||
int code = root.get("code").asInt();
|
||||
@ -242,7 +255,10 @@ public class SignClient{
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
System.err.println("连接签名服务器异常" + e.getMessage());
|
||||
throw new RuntimeException("调用dettachedSign异常", e);
|
||||
} finally {
|
||||
System.out.println("请求结束, 连接资源已释放");
|
||||
}
|
||||
}
|
||||
|
||||
@ -290,8 +306,9 @@ public class SignClient{
|
||||
.addHeader("X-API-Key", properties.getApiKey())
|
||||
.build();
|
||||
|
||||
|
||||
System.out.println("准备连接签名服务器");
|
||||
try (Response response = okHttpClient.newCall(request).execute()) {
|
||||
System.out.println("连接成功,并收到响应");
|
||||
String responseBody = response.body() == null ? "" : response.body().string();
|
||||
JsonNode root = objectMapper.readTree(responseBody);
|
||||
int code = root.get("code").asInt();
|
||||
@ -311,7 +328,10 @@ public class SignClient{
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
System.err.println("连接签名服务器异常" + e.getMessage());
|
||||
throw new RuntimeException("调用dettachedVerify异常", e);
|
||||
} finally {
|
||||
System.out.println("请求结束, 连接资源已释放");
|
||||
}
|
||||
}
|
||||
|
||||
@ -360,8 +380,9 @@ public class SignClient{
|
||||
.addHeader("X-API-Key", properties.getApiKey())
|
||||
.build();
|
||||
|
||||
|
||||
System.out.println("准备连接签名服务器");
|
||||
try (Response response = okHttpClient.newCall(request).execute()) {
|
||||
System.out.println("连接成功,并收到响应");
|
||||
String responseBody = response.body() == null ? "" : response.body().string();
|
||||
JsonNode root = objectMapper.readTree(responseBody);
|
||||
int code = root.get("code").asInt();
|
||||
@ -379,7 +400,10 @@ public class SignClient{
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
System.err.println("连接签名服务器异常" + e.getMessage());
|
||||
throw new RuntimeException("调用dettachedVerifySimple异常", e);
|
||||
} finally {
|
||||
System.out.println("请求结束, 连接资源已释放");
|
||||
}
|
||||
}
|
||||
|
||||
@ -422,8 +446,9 @@ public class SignClient{
|
||||
.addHeader("X-API-Key", properties.getApiKey())
|
||||
.build();
|
||||
|
||||
|
||||
System.out.println("准备连接签名服务器");
|
||||
try (Response response = okHttpClient.newCall(request).execute()) {
|
||||
System.out.println("连接成功,并收到响应");
|
||||
String responseBody = response.body() == null ? "" : response.body().string();
|
||||
JsonNode root = objectMapper.readTree(responseBody);
|
||||
int code = root.get("code").asInt();
|
||||
@ -441,7 +466,10 @@ public class SignClient{
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
System.err.println("连接签名服务器异常" + e.getMessage());
|
||||
throw new RuntimeException("调用uploadCert异常", e);
|
||||
} finally {
|
||||
System.out.println("请求结束, 连接资源已释放");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.config;
|
||||
package cn.com.infosec.netsign.agent.config;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.config;
|
||||
package cn.com.infosec.netsign.agent.config;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -21,5 +21,4 @@ public class SignServerProperties {
|
||||
|
||||
private String uploadCertPath;
|
||||
|
||||
private String lastReturnCodePath;
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.config;
|
||||
package cn.com.infosec.netsign.agent.config;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
@ -37,12 +37,10 @@ public class SignServerPropertiesLoader {
|
||||
config.setDettachedVerifyPath(props.getProperty("sign-server.dettachedVerifyPath"));
|
||||
config.setDettachedVerifySimplePath(props.getProperty("sign-server.dettachedVerifySimplePath"));
|
||||
config.setUploadCertPath(props.getProperty("sign-server.uploadCertPath"));
|
||||
config.setLastReturnCodePath(props.getProperty("sign-server.lastReturnCodePath"));
|
||||
|
||||
return config;
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("加载 sign-server 配置失败", e);
|
||||
throw new RuntimeException("加载签名服务器配置失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
public class CertificateInfo {
|
||||
private String subjectDN;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import com.cisd.openapi.util.Base64;
|
||||
import com.cisd.openapi.util.NetSignAgentUtil;
|
||||
import com.cisd.openapi.util.PBCUtil;
|
||||
import cn.com.infosec.netsign.agent.util.Base64;
|
||||
import cn.com.infosec.netsign.agent.util.NetSignAgentUtil;
|
||||
import cn.com.infosec.netsign.agent.util.PBCUtil;
|
||||
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package com.cisd.openapi.exception;
|
||||
package cn.com.infosec.netsign.agent.exception;
|
||||
|
||||
import com.cisd.openapi.dto.ErrorDataResponse;
|
||||
import cn.com.infosec.netsign.agent.dto.ErrorDataResponse;
|
||||
|
||||
public class BusinessException extends RuntimeException {
|
||||
private final ErrorDataResponse errorData;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.util;
|
||||
package cn.com.infosec.netsign.agent.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.util;
|
||||
package cn.com.infosec.netsign.agent.util;
|
||||
|
||||
import java.util.Stack;
|
||||
import java.util.StringTokenizer;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.util;
|
||||
package cn.com.infosec.netsign.agent.util;
|
||||
|
||||
//
|
||||
//import cn.com.infosec.netsign.agent.communication.APIToServer;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.util;
|
||||
package cn.com.infosec.netsign.agent.util;
|
||||
|
||||
//import cn.com.infosec.jce.provider.*;
|
||||
//import cn.com.infosec.jce.provider.fastparser.DerUtil;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.util;
|
||||
package cn.com.infosec.netsign.agent.util;
|
||||
|
||||
public class PBCUtil {
|
||||
public static String getBankID(String dn) {
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.util;
|
||||
package cn.com.infosec.netsign.agent.util;
|
||||
|
||||
|
||||
public class X509NameTokenizer {
|
||||
@ -1,12 +1,11 @@
|
||||
sign-server.baseUrl=http://127.0.0.1:8080
|
||||
sign-server.baseUrl=http://127.0.0.1:8080/api/v1/openapi
|
||||
sign-server.apiKey=key
|
||||
|
||||
sign-server.rawSignPath=/raw/sign
|
||||
sign-server.rawVerifyPath=/raw/verify
|
||||
sign-server.rawSignPath=/rawSign
|
||||
sign-server.rawVerifyPath=/rawVerify
|
||||
|
||||
sign-server.dettachedSignPath=/dettached/sign
|
||||
sign-server.dettachedVerifyPath=/dettached/verify
|
||||
sign-server.dettachedVerifySimplePath=/dettached/verify/simple
|
||||
sign-server.dettachedSignPath=/dettachedSign
|
||||
sign-server.dettachedVerifyPath=/dettachedVerify
|
||||
sign-server.dettachedVerifySimplePath=/dettachedVerifySimple
|
||||
|
||||
sign-server.uploadCertPath=/cert/upload
|
||||
sign-server.lastReturnCodePath=/last/return/code
|
||||
sign-server.uploadCertPath=/uploadCert
|
||||
@ -216,8 +216,7 @@ public class OperationAuditService {
|
||||
if (!AuditStatus.PENDING.equals(existLog.getAuditStatus())) {
|
||||
throw new BizException(ErrorCode.BIZ_ERROR.getCode(), "该日志已审计,禁止重复操作");
|
||||
}
|
||||
String d = buildSignValueSource(existLog, req.getAuditResult());
|
||||
System.out.println(d);
|
||||
|
||||
String auditSign = trim(req.getAuditSign());
|
||||
|
||||
if (auditSign.isEmpty()){
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
package com.cisd.tms.modules.mk.config;
|
||||
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties(prefix = "tms.mk.activate")
|
||||
public class MasterKeyActivateProperties {
|
||||
|
||||
//todo 后续添加到配置文件
|
||||
private String platformUrl = "http://127.0.0.1:8080/device/active";
|
||||
|
||||
public String getPlatformUrl() { return platformUrl; }
|
||||
|
||||
public void setPlatformUrl(String platformUrl) { this.platformUrl = platformUrl; }
|
||||
}
|
||||
@ -13,4 +13,10 @@ public class MasterKeyActivateRequest {
|
||||
private String credential;
|
||||
@Schema(description = "设备激活码", example = "1234567")
|
||||
private String activationCode;
|
||||
|
||||
@Schema(description = "网络地址", example = "192.168.10.100")
|
||||
private String ipAddress;
|
||||
|
||||
@Schema(description = "端口号", example = "80")
|
||||
private Integer port;
|
||||
}
|
||||
|
||||
@ -9,7 +9,6 @@ import com.cisd.tms.modules.device.dto.DeviceInfoResponse;
|
||||
import com.cisd.tms.modules.device.entity.DeviceSoftwareVersionEntity;
|
||||
import com.cisd.tms.modules.device.repository.DeviceSoftwareVersionRepository;
|
||||
import com.cisd.tms.modules.device.service.DeviceService;
|
||||
import com.cisd.tms.modules.mk.config.MasterKeyActivateProperties;
|
||||
import com.cisd.tms.modules.mk.dto.MasterKeyActivateInfoResponse;
|
||||
import com.cisd.tms.modules.mk.dto.MasterKeyActivateRequest;
|
||||
import com.cisd.tms.modules.mk.entity.MasterKeyActivateEntity;
|
||||
@ -29,10 +28,12 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.ConnectException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpTimeoutException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.PublicKey;
|
||||
import java.security.SecureRandom;
|
||||
@ -47,15 +48,15 @@ import java.util.Optional;
|
||||
public class MasterKeyActivateServiceImpl implements MasterKeyActivateService {
|
||||
|
||||
private static final String DEVICE_DIR = "/home/tms/device";
|
||||
public static final String SIGN_FILE = DEVICE_DIR + "/dev.sign";
|
||||
private static final String SIGN_FILE = DEVICE_DIR + "/dev.sign";
|
||||
private static final String ACTIVATION_PUBLIC_KEY_FILE = DEVICE_DIR + "/dev.active.pub";
|
||||
private static final String ACTIVATION_PLATFORM_URL = "/device/active";
|
||||
|
||||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||
|
||||
private static final SecureRandom SECURE_RANDOM = new SecureRandom();
|
||||
|
||||
private final PcieCryptoService pcieCryptoService;
|
||||
private final MasterKeyActivateProperties masterKeyActivateProperties;
|
||||
private final DeviceSoftwareVersionRepository deviceSoftwareVersionRepository;
|
||||
private final DeviceProfileProperties deviceProfileProperties;
|
||||
private final DeviceService deviceService;
|
||||
@ -139,6 +140,23 @@ public class MasterKeyActivateServiceImpl implements MasterKeyActivateService {
|
||||
throw new IllegalArgumentException("设备激活码不能为空");
|
||||
}
|
||||
|
||||
if (masterKeyActivateRequest.getIpAddress() == null){
|
||||
throw new IllegalArgumentException("IP地址不能为空");
|
||||
}
|
||||
|
||||
|
||||
String ipAddress = masterKeyActivateRequest.getIpAddress().trim();
|
||||
|
||||
|
||||
Integer portValue = masterKeyActivateRequest.getPort();
|
||||
|
||||
if (portValue == null || portValue < 1 || portValue > 65535) {
|
||||
throw new IllegalArgumentException("非法端口: " + portValue);
|
||||
}
|
||||
|
||||
String port = String.valueOf(portValue);
|
||||
String url = "http://" + ipAddress + ":" + port + ACTIVATION_PLATFORM_URL;
|
||||
|
||||
try {
|
||||
DeviceFingerprintService deviceFingerprintService = new DeviceFingerprintService();
|
||||
DeviceFingerprint deviceFingerprint = deviceFingerprintService.getDeviceFingerprint();
|
||||
@ -175,10 +193,9 @@ public class MasterKeyActivateServiceImpl implements MasterKeyActivateService {
|
||||
request.setHash(hash);
|
||||
|
||||
String json = OBJECT_MAPPER.writeValueAsString(request);
|
||||
//todo 抛异常
|
||||
// System.out.print(json);
|
||||
HttpRequest httpRequest = HttpRequest.newBuilder()
|
||||
.uri(URI.create(masterKeyActivateProperties.getPlatformUrl()))
|
||||
.uri(URI.create(url))
|
||||
.header("Content-Type", "application/json;charset=UTF-8")
|
||||
.header("Accept", "application/json")
|
||||
.POST(HttpRequest.BodyPublishers.ofString(json, StandardCharsets.UTF_8))
|
||||
@ -204,9 +221,15 @@ public class MasterKeyActivateServiceImpl implements MasterKeyActivateService {
|
||||
masterKeyActivateRepository.update(masterKeyActivateEntity);
|
||||
writeFile(ACTIVATION_PUBLIC_KEY_FILE, deviceActivationPublicKey.getBytes(StandardCharsets.UTF_8));
|
||||
} else {
|
||||
throw new Exception(result.getMsg());
|
||||
throw new RuntimeException(result.getMsg());
|
||||
}
|
||||
|
||||
} catch (ConnectException | HttpTimeoutException e) {
|
||||
|
||||
masterKeyActivateEntity.setActivationStatus(false);
|
||||
masterKeyActivateRepository.update(masterKeyActivateEntity);
|
||||
throw new BizException(ErrorCode.BIZ_ERROR.getCode(), "连接激活平台失败");
|
||||
|
||||
} catch (Exception e) {
|
||||
masterKeyActivateEntity.setActivationStatus(false);
|
||||
masterKeyActivateRepository.update(masterKeyActivateEntity);
|
||||
|
||||
@ -334,9 +334,6 @@ tms:
|
||||
old-pin-base64: ${TMS_MK_INIT_IDENTIFY_OLD_PIN_BASE64:NjY2NjY2}
|
||||
# SDFE_InitIdentify 新 PIN(Base64 编码);主密钥初始化接口会读取该值。
|
||||
new-pin-base64: ${TMS_MK_INIT_IDENTIFY_NEW_PIN_BASE64:NjY2NjY2}
|
||||
activate:
|
||||
# 激活服务平台路径
|
||||
platform-url: ${TMS_MK_ACTIVATE_PLATFORM_URL:http://172.16.18.195:8170/device/active}
|
||||
security:
|
||||
# 内部接口鉴权 token(前后端内部调用需一致)。
|
||||
internal-token: ${TMS_INTERNAL_TOKEN:change-me-internal-token}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user