Merge remote-tracking branch 'origin/V1.00' into V1.00
This commit is contained in:
commit
cae94149cb
@ -53,19 +53,37 @@
|
|||||||
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
<finalName>${project.artifactId}-${project.version}</finalName>
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>3.4.2</version>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<version>3.7.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<archive>
|
<archive>
|
||||||
<manifest>
|
<manifest>
|
||||||
<mainClass>cn.com.infosec.netsign.agent.Main</mainClass>
|
<mainClass>cn.com.infosec.netsign.agent.Main</mainClass>
|
||||||
</manifest>
|
</manifest>
|
||||||
</archive>
|
</archive>
|
||||||
|
|
||||||
<descriptorRefs>
|
<descriptorRefs>
|
||||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||||
</descriptorRefs>
|
</descriptorRefs>
|
||||||
|
|
||||||
|
<appendAssemblyId>false</appendAssemblyId>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>make-assembly</id>
|
<id>make-assembly</id>
|
||||||
|
|||||||
@ -1,26 +1,12 @@
|
|||||||
package cn.com.infosec.netsign.agent;
|
package cn.com.infosec.netsign.agent;
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
public class Main
|
public class Main
|
||||||
{
|
{
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
OkHttpClient okHttpClient = OkHttpClientHolder.getClient();
|
PBCAgent2G signClient = new PBCAgent2G();
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
|
||||||
SignServerProperties properties = SignServerPropertiesLoader.getProperties();
|
|
||||||
|
|
||||||
PBCAgent2G signClient = new PBCAgent2G(
|
|
||||||
okHttpClient,
|
|
||||||
objectMapper,
|
|
||||||
properties
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
signClient.rawSign("test".getBytes(StandardCharsets.UTF_8), "dn");
|
signClient.rawSign("test".getBytes(StandardCharsets.UTF_8), "dn");
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
package cn.com.infosec.netsign.agent;
|
package cn.com.infosec.netsign.agent;
|
||||||
|
|
||||||
import cn.com.infosec.netsign.agent.config.SignServerProperties;
|
import cn.com.infosec.netsign.agent.config.OkHttpClientHolder;
|
||||||
import cn.com.infosec.netsign.agent.dto.*;
|
import cn.com.infosec.netsign.agent.dto.*;
|
||||||
import cn.com.infosec.netsign.agent.exception.BusinessException;
|
import cn.com.infosec.netsign.agent.exception.BusinessException;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
@ -20,20 +20,75 @@ public class PBCAgent2G{
|
|||||||
MediaType.parse("application/json; charset=utf-8");
|
MediaType.parse("application/json; charset=utf-8");
|
||||||
|
|
||||||
|
|
||||||
|
private static final String baseUrl = "http://127.0.0.1:8080/api/v1/openapi";
|
||||||
|
private static final String apiKey = "key";
|
||||||
|
|
||||||
|
private static final String rawSignPath = "/rawSign";
|
||||||
|
private static final String rawVerifyPath = "/rawVerify";
|
||||||
|
|
||||||
|
private static final String dettachedSignPath = "/dettachedSign";
|
||||||
|
private static final String dettachedVerifyPath = "/dettachedVerify";
|
||||||
|
private static final String dettachedVerifySimplePath = "/dettachedVerifySimple";
|
||||||
|
|
||||||
|
private static final String uploadCertPath = "/uploadCert";
|
||||||
|
|
||||||
private final OkHttpClient okHttpClient;
|
private final OkHttpClient okHttpClient;
|
||||||
private final ObjectMapper objectMapper;
|
private final ObjectMapper objectMapper;
|
||||||
|
private boolean isDebug;
|
||||||
|
private String encoding;
|
||||||
|
private int orderdn;
|
||||||
|
private int timeout;
|
||||||
|
|
||||||
private final SignServerProperties properties;
|
|
||||||
private final ThreadLocal<Integer> lastReturnCode = new ThreadLocal<>();
|
private final ThreadLocal<Integer> lastReturnCode = new ThreadLocal<>();
|
||||||
|
|
||||||
public PBCAgent2G(OkHttpClient okHttpClient,
|
public PBCAgent2G() {
|
||||||
ObjectMapper objectMapper,
|
this.okHttpClient = OkHttpClientHolder.getClient();
|
||||||
SignServerProperties properties) {
|
this.objectMapper = new ObjectMapper();
|
||||||
this.okHttpClient = okHttpClient;
|
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
this.properties = properties;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PBCAgent2G(boolean usingSingleServiceList) {
|
||||||
|
this.okHttpClient = OkHttpClientHolder.getClient();
|
||||||
|
this.objectMapper = new ObjectMapper();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void isDebug(boolean isDebug){
|
||||||
|
this.isDebug = isDebug;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEncoding(String encoding){
|
||||||
|
this.encoding = encoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrderdn(int orderdn){
|
||||||
|
this.orderdn = orderdn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeout(int timeout){
|
||||||
|
this.timeout = timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getReturnCode(){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean closeSignServer(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean openSignServer(String ip, int port, String password){
|
||||||
|
System.out.println(ip);
|
||||||
|
System.out.println(port);
|
||||||
|
System.out.println(password);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
public boolean[] openSignServer(String ip, String port,String password){
|
||||||
|
System.out.println(ip);
|
||||||
|
System.out.println(port);
|
||||||
|
System.out.println(password);
|
||||||
|
return new boolean[]{true};
|
||||||
|
};
|
||||||
|
|
||||||
public String rawSign(byte[] origBytes, String dn) {
|
public String rawSign(byte[] origBytes, String dn) {
|
||||||
|
|
||||||
@ -76,10 +131,10 @@ public class PBCAgent2G{
|
|||||||
);
|
);
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(buildUrl(properties.getRawSignPath()))
|
.url(buildUrl(rawSignPath))
|
||||||
.post(requestBody)
|
.post(requestBody)
|
||||||
.addHeader("Content-Type", "application/json")
|
.addHeader("Content-Type", "application/json")
|
||||||
.addHeader("X-API-Key", properties.getApiKey())
|
.addHeader("X-API-Key", apiKey)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
||||||
@ -158,10 +213,10 @@ public class PBCAgent2G{
|
|||||||
);
|
);
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(buildUrl(properties.getRawVerifyPath()))
|
.url(buildUrl(rawVerifyPath))
|
||||||
.post(requestBody)
|
.post(requestBody)
|
||||||
.addHeader("Content-Type", "application/json")
|
.addHeader("Content-Type", "application/json")
|
||||||
.addHeader("X-API-Key", properties.getApiKey())
|
.addHeader("X-API-Key", apiKey)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
System.out.println("准备连接签名服务器");
|
System.out.println("准备连接签名服务器");
|
||||||
@ -228,10 +283,10 @@ public class PBCAgent2G{
|
|||||||
);
|
);
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(buildUrl(properties.getDettachedSignPath()))
|
.url(buildUrl(dettachedSignPath))
|
||||||
.post(requestBody)
|
.post(requestBody)
|
||||||
.addHeader("Content-Type", "application/json")
|
.addHeader("Content-Type", "application/json")
|
||||||
.addHeader("X-API-Key", properties.getApiKey())
|
.addHeader("X-API-Key", apiKey)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
||||||
@ -300,10 +355,10 @@ public class PBCAgent2G{
|
|||||||
);
|
);
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(buildUrl(properties.getDettachedVerifyPath()))
|
.url(buildUrl(dettachedVerifyPath))
|
||||||
.post(requestBody)
|
.post(requestBody)
|
||||||
.addHeader("Content-Type", "application/json")
|
.addHeader("Content-Type", "application/json")
|
||||||
.addHeader("X-API-Key", properties.getApiKey())
|
.addHeader("X-API-Key", apiKey)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
System.out.println("准备连接签名服务器");
|
System.out.println("准备连接签名服务器");
|
||||||
@ -374,10 +429,10 @@ public class PBCAgent2G{
|
|||||||
);
|
);
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(buildUrl(properties.getDettachedVerifySimplePath()))
|
.url(buildUrl(dettachedVerifySimplePath))
|
||||||
.post(requestBody)
|
.post(requestBody)
|
||||||
.addHeader("Content-Type", "application/json")
|
.addHeader("Content-Type", "application/json")
|
||||||
.addHeader("X-API-Key", properties.getApiKey())
|
.addHeader("X-API-Key", apiKey)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
System.out.println("准备连接签名服务器");
|
System.out.println("准备连接签名服务器");
|
||||||
@ -440,10 +495,10 @@ public class PBCAgent2G{
|
|||||||
);
|
);
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(buildUrl(properties.getUploadCertPath()))
|
.url(buildUrl(uploadCertPath))
|
||||||
.post(requestBody)
|
.post(requestBody)
|
||||||
.addHeader("Content-Type", "application/json")
|
.addHeader("Content-Type", "application/json")
|
||||||
.addHeader("X-API-Key", properties.getApiKey())
|
.addHeader("X-API-Key", apiKey)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
System.out.println("准备连接签名服务器");
|
System.out.println("准备连接签名服务器");
|
||||||
@ -480,7 +535,7 @@ public class PBCAgent2G{
|
|||||||
|
|
||||||
|
|
||||||
private String buildUrl(String path) {
|
private String buildUrl(String path) {
|
||||||
String baseUrl = properties.getBaseUrl();
|
String baseUrl = "http://127.0.0.1:8080/api/v1/openapi";
|
||||||
|
|
||||||
if (baseUrl.endsWith("/") && path.startsWith("/")) {
|
if (baseUrl.endsWith("/") && path.startsWith("/")) {
|
||||||
return baseUrl.substring(0, baseUrl.length() - 1) + path;
|
return baseUrl.substring(0, baseUrl.length() - 1) + path;
|
||||||
@ -489,7 +544,7 @@ public class PBCAgent2G{
|
|||||||
if (!baseUrl.endsWith("/") && !path.startsWith("/")) {
|
if (!baseUrl.endsWith("/") && !path.startsWith("/")) {
|
||||||
return baseUrl + "/" + path;
|
return baseUrl + "/" + path;
|
||||||
}
|
}
|
||||||
|
System.out.println(baseUrl + path);
|
||||||
return baseUrl + path;
|
return baseUrl + path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user