Browse Source

删除注释代码

tags/24080901
CMM 1 year ago
parent
commit
9f3729e041
1 changed files with 17 additions and 17 deletions
  1. +17
    -17
      pmapi/src/main/java/com/ningdatech/pmapi/irs/sign/IRSAPIRequest.java

+ 17
- 17
pmapi/src/main/java/com/ningdatech/pmapi/irs/sign/IRSAPIRequest.java View File

@@ -9,12 +9,15 @@ import com.ningdatech.pmapi.todocenter.model.dto.SignReqDTO;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.ContentType;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

@@ -56,16 +59,9 @@ public class IRSAPIRequest {
ReqData.put("posX", posX);
ReqData.put("posY", posY);
ReqData.put("signType", signType);
// ReqData.put("key", "单位");
ReqData.put("posPage", posPage);
ReqData.put("fileName", fileName);
resp = post(ReqData, "post");

//JSONObject jsonObject = JSON.parseObject(resp);
//String data = jsonObject.getString("data");
//JSONObject jsondata = JSON.parseObject(data);
//String signFileB64 = jsondata.getString("signFileB64");
//IRSAPIRequest.base64StringToPdf(signFileB64, "D:\\test21.pdf");
} catch (Exception e) {
throw new BizException("调用IRS盖章接口失败,印章编号为:" + sealSn + StrPool.SEMICOLON + e.getMessage());
}
@@ -93,16 +89,11 @@ public class IRSAPIRequest {
byte[] hash = hasher.doFinal(message.getBytes());
DatatypeConverter.printHexBinary(hash);
String sign = DatatypeConverter.printBase64Binary(hash);
/*byte[] stream1 = message.toString().getBytes("UTF-8");
String sign = sign1(stream1);*/

// 计算电子印章组件signature值
String myData = data.toString();
System.out.println(myData);
byte[] stream = data.toString().getBytes(StandardCharsets.UTF_8);
// 签名数据,根据签名算法,对请求数据进行签名
String signature = sign(stream);
//System.out.println(signature);
// 设置HTTP请求头
HttpEntityEnclosingRequestBase req = new HttpPost(IrsSealPlatformProperties.apiUrl);
// project-id为用户的projectId
@@ -120,9 +111,20 @@ public class IRSAPIRequest {
req.setEntity(entity);

// 执行请求
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
CloseableHttpClient cli = httpClientBuilder.build();
HttpResponse res = cli.execute(req);
// 自定义 RequestConfig 设置请求超时时间
RequestConfig requestConfig = RequestConfig.custom()
// 连接超时时间,单位:毫秒
.setConnectTimeout(5000)
// 连接请求超时时间,单位:毫秒
.setConnectionRequestTimeout(5000)
// 数据读取超时时间,单位:毫秒
.setSocketTimeout(5000)
.build();
// 通过 HttpClientBuilder 的 custom() 方法创建自定义的 HttpClient
HttpClient customHttpClient = HttpClients.custom()
.setDefaultRequestConfig(requestConfig)
.build();
HttpResponse res = customHttpClient.execute(req);
int statusCode = res.getStatusLine().getStatusCode();
System.out.println(statusCode);
if (200 != statusCode) {
@@ -134,7 +136,6 @@ public class IRSAPIRequest {
byte[] resp = readStream(in);
String strRes = new String(resp, StandardCharsets.UTF_8);
System.out.println(strRes);
cli.close();
return strRes;
}

@@ -232,7 +233,6 @@ public class IRSAPIRequest {
bout.flush();
byte[] bytes = baos.toByteArray();
return String.valueOf(Base64.getEncoder().encode(bytes));
//return encoder.encodeBuffer(bytes);

} catch (IOException e) {
e.printStackTrace();


Loading…
Cancel
Save