Merge remote-tracking branch 'origin/V1.00' into V1.00
This commit is contained in:
commit
cae94149cb
@ -53,19 +53,37 @@
|
||||
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}-${project.version}</finalName>
|
||||
|
||||
<plugins>
|
||||
<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>
|
||||
<version>3.7.1</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>cn.com.infosec.netsign.agent.Main</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
|
||||
<appendAssemblyId>false</appendAssemblyId>
|
||||
</configuration>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
|
||||
@ -1,26 +1,12 @@
|
||||
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;
|
||||
|
||||
public class Main
|
||||
{
|
||||
public static void main(String[] args) {
|
||||
OkHttpClient okHttpClient = OkHttpClientHolder.getClient();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
SignServerProperties properties = SignServerPropertiesLoader.getProperties();
|
||||
|
||||
PBCAgent2G signClient = new PBCAgent2G(
|
||||
okHttpClient,
|
||||
objectMapper,
|
||||
properties
|
||||
);
|
||||
PBCAgent2G signClient = new PBCAgent2G();
|
||||
|
||||
try {
|
||||
signClient.rawSign("test".getBytes(StandardCharsets.UTF_8), "dn");
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
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.exception.BusinessException;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
@ -20,20 +20,75 @@ public class PBCAgent2G{
|
||||
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 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<>();
|
||||
|
||||
public PBCAgent2G(OkHttpClient okHttpClient,
|
||||
ObjectMapper objectMapper,
|
||||
SignServerProperties properties) {
|
||||
this.okHttpClient = okHttpClient;
|
||||
this.objectMapper = objectMapper;
|
||||
this.properties = properties;
|
||||
public PBCAgent2G() {
|
||||
this.okHttpClient = OkHttpClientHolder.getClient();
|
||||
this.objectMapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@ -76,10 +131,10 @@ public class PBCAgent2G{
|
||||
);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(buildUrl(properties.getRawSignPath()))
|
||||
.url(buildUrl(rawSignPath))
|
||||
.post(requestBody)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.addHeader("X-API-Key", properties.getApiKey())
|
||||
.addHeader("X-API-Key", apiKey)
|
||||
.build();
|
||||
|
||||
|
||||
@ -158,10 +213,10 @@ public class PBCAgent2G{
|
||||
);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(buildUrl(properties.getRawVerifyPath()))
|
||||
.url(buildUrl(rawVerifyPath))
|
||||
.post(requestBody)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.addHeader("X-API-Key", properties.getApiKey())
|
||||
.addHeader("X-API-Key", apiKey)
|
||||
.build();
|
||||
|
||||
System.out.println("准备连接签名服务器");
|
||||
@ -228,10 +283,10 @@ public class PBCAgent2G{
|
||||
);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(buildUrl(properties.getDettachedSignPath()))
|
||||
.url(buildUrl(dettachedSignPath))
|
||||
.post(requestBody)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.addHeader("X-API-Key", properties.getApiKey())
|
||||
.addHeader("X-API-Key", apiKey)
|
||||
.build();
|
||||
|
||||
|
||||
@ -300,10 +355,10 @@ public class PBCAgent2G{
|
||||
);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(buildUrl(properties.getDettachedVerifyPath()))
|
||||
.url(buildUrl(dettachedVerifyPath))
|
||||
.post(requestBody)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.addHeader("X-API-Key", properties.getApiKey())
|
||||
.addHeader("X-API-Key", apiKey)
|
||||
.build();
|
||||
|
||||
System.out.println("准备连接签名服务器");
|
||||
@ -374,10 +429,10 @@ public class PBCAgent2G{
|
||||
);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(buildUrl(properties.getDettachedVerifySimplePath()))
|
||||
.url(buildUrl(dettachedVerifySimplePath))
|
||||
.post(requestBody)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.addHeader("X-API-Key", properties.getApiKey())
|
||||
.addHeader("X-API-Key", apiKey)
|
||||
.build();
|
||||
|
||||
System.out.println("准备连接签名服务器");
|
||||
@ -440,10 +495,10 @@ public class PBCAgent2G{
|
||||
);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(buildUrl(properties.getUploadCertPath()))
|
||||
.url(buildUrl(uploadCertPath))
|
||||
.post(requestBody)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.addHeader("X-API-Key", properties.getApiKey())
|
||||
.addHeader("X-API-Key", apiKey)
|
||||
.build();
|
||||
|
||||
System.out.println("准备连接签名服务器");
|
||||
@ -480,7 +535,7 @@ public class PBCAgent2G{
|
||||
|
||||
|
||||
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("/")) {
|
||||
return baseUrl.substring(0, baseUrl.length() - 1) + path;
|
||||
@ -489,7 +544,7 @@ public class PBCAgent2G{
|
||||
if (!baseUrl.endsWith("/") && !path.startsWith("/")) {
|
||||
return baseUrl + "/" + path;
|
||||
}
|
||||
|
||||
System.out.println(baseUrl + path);
|
||||
return baseUrl + path;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user