标准收发器客户端添加日志
This commit is contained in:
+5
-5
@@ -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
|
||||
+37
-10
@@ -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;
|
||||
@@ -81,7 +82,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,7 +103,10 @@ public class SignClient{
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
System.err.println("连接签名服务器异常" + e.getMessage());
|
||||
throw new RuntimeException("调用rawSign异常:" + e.getMessage(), e);
|
||||
} finally {
|
||||
System.out.println("请求结束, 连接资源已释放");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,8 +163,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,7 +183,10 @@ public class SignClient{
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
System.err.println("连接签名服务器异常" + e.getMessage());
|
||||
throw new RuntimeException("调用rawVerify异常", e);
|
||||
} finally {
|
||||
System.out.println("请求结束, 连接资源已释放");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,7 +234,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 +254,10 @@ public class SignClient{
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
System.err.println("连接签名服务器异常" + e.getMessage());
|
||||
throw new RuntimeException("调用dettachedSign异常", e);
|
||||
} finally {
|
||||
System.out.println("请求结束, 连接资源已释放");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,8 +305,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 +327,10 @@ public class SignClient{
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
System.err.println("连接签名服务器异常" + e.getMessage());
|
||||
throw new RuntimeException("调用dettachedVerify异常", e);
|
||||
} finally {
|
||||
System.out.println("请求结束, 连接资源已释放");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,8 +379,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 +399,10 @@ public class SignClient{
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
System.err.println("连接签名服务器异常" + e.getMessage());
|
||||
throw new RuntimeException("调用dettachedVerifySimple异常", e);
|
||||
} finally {
|
||||
System.out.println("请求结束, 连接资源已释放");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -422,8 +445,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 +465,10 @@ public class SignClient{
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
System.err.println("连接签名服务器异常" + e.getMessage());
|
||||
throw new RuntimeException("调用uploadCert异常", e);
|
||||
} finally {
|
||||
System.out.println("请求结束, 连接资源已释放");
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.config;
|
||||
package cn.com.infosec.netsign.agent.config;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
+1
-2
@@ -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;
|
||||
}
|
||||
+2
-4
@@ -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
-1
@@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
public class CertificateInfo {
|
||||
private String subjectDN;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
+4
-4
@@ -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
-1
@@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.dto;
|
||||
package cn.com.infosec.netsign.agent.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
+2
-2
@@ -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
-1
@@ -1,4 +1,4 @@
|
||||
package com.cisd.openapi.util;
|
||||
package cn.com.infosec.netsign.agent.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
+1
-1
@@ -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
-1
@@ -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
-1
@@ -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
-1
@@ -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
-1
@@ -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.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
|
||||
Reference in New Issue
Block a user