Skip to content

Commit b9cb202

Browse files
committed
创建统一接口实体类
1 parent 452a754 commit b9cb202

File tree

24 files changed

+1069
-18
lines changed

24 files changed

+1069
-18
lines changed

settings.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,7 @@ project(":wedpr-components-initializer").projectDir=file("wedpr-components/initi
6868
include "wedpr-adm"
6969
project(":wedpr-adm").projectDir=file("wedpr-adm")
7070

71+
include "wedpr-components-privacy-exchanges"
72+
project(":wedpr-components-privacy-exchanges").projectDir=file("wedpr-components/privacy-exchanges")
73+
7174

wedpr-adm/conf/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ useSMCrypto = "false" # RPC SM crypto type
1919
[network]
2020
messageTimeout = "10000"
2121
defaultGroup="group0" # Console default group to connect
22-
peers=["127.0.0.1:20200", "127.0.0.1:20201"] # The peer list to connect
22+
peers=["139.159.202.235:20200", "139.159.202.235:20201"] # The peer list to connect
2323

2424
[account]
2525
keyStoreDir = "account" # The directory to load/store the account file, default is "account"

wedpr-adm/conf/wedpr.properties

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,40 @@ wedpr.uuid.generator.worker.id=10
99
# TODO: add this option
1010
# use dpm or not
1111
wedpr.enable.dpm = false
12-
12+
wedpr.crypto.symmetric.key=12345678
13+
wedpr.crypto.symmetric.iv=123456
1314
### the mybatis related configuration
1415
#wedpr.mybatis.config.path=mybatis-config.xml
1516
# TODO: instead use CMDB value
16-
wedpr.mybatis.url=jdbc:mysql://127.0.0.1/wedpr3?characterEncoding=UTF-8&allowMultiQueries=true
17+
wedpr.mybatis.url=jdbc:mysql://192.168.2.20:3306/wedpr3?characterEncoding=UTF-8&allowMultiQueries=true
1718
#wedpr.mybatis.username=[*user_ppcs_modeladm]
1819
#wedpr.mybatis.password=[*pass_ppcs_modeladm]
19-
wedpr.mybatis.username=
20-
wedpr.mybatis.password=
20+
wedpr.mybatis.username=root
21+
wedpr.mybatis.password=dinglian@123
2122

2223
wedpr.mybatis.driverClassName=com.mysql.cj.jdbc.Driver
2324

2425
wedpr.mybatis.mapperLocations=classpath*:mapper/*Mapper.xml
25-
# Note: the basePackage can't set to com.webank.wedpr simply for the mybatis will scan the Service
26-
wedpr.mybatis.BasePackage=com.webank.wedpr.components.meta.resource.follower.dao,com.webank.wedpr.components.meta.sys.config.dao,com.webank.wedpr.components.project.dao,com.webank.wedpr.components.meta.setting.template.dao,com.webank.wedpr.components.sync.dao,com.webank.wedpr.components.authorization.dao,com.webank.wedpr.components.dataset.mapper,com.webank.wedpr.components.user.mapper,com.webank.wedpr.components.meta.agency.dao
27-
# wedpr.mybatis.typeAliasesPackage=
26+
wedpr.mybatis.BasePackage=com.webank.wedpr.components.meta.resource.follower.dao,com.webank.wedpr.components.meta.sys.config.dao,com.webank.wedpr.components.project.dao,com.webank.wedpr.components.meta.setting.template.dao,com.webank.wedpr.components.sync.dao,com.webank.wedpr.components.authorization.dao,com.webank.wedpr.components.dataset.mapper,com.webank.wedpr.components.user.mapper,com.webank.wedpr.components.meta.agency.dao,com.webank.wedpr.components.api.credential.dao,com.webank.wedpr.components.integration.jupyter.dao
27+
2828

2929
### the blockchain configuration
3030
wedpr.chain.group_id=group0
3131
wedpr.chain.config_path=config.toml
3232

3333
### the election related configuration
34-
wedpr.leader.election.keep.alive.seconds=30
35-
wedpr.leader.election.expire.seconds=60
34+
wedpr.leader.election.keep.alive.seconds=10
35+
wedpr.leader.election.expire.seconds=15
3636

3737
### the sync module related configuration
38-
wedpr.agency=WeBank
38+
wedpr.agency=SGD
39+
3940
wedpr.sync.recorder.factory.contract_address=0x4721d1a77e0e76851d460073e64ea06d9c104194
4041
wedpr.sync.sequencer.contract_address=0x6849f21d1e455e9f0712b1e99fa4fcd23758e8f1
42+
4143
wedpr.sync.recorder.contract_version=1
4244
wedpr.sync.queue_limit=100000
43-
wedpr.sync.worker_idle_ms=10
45+
wedpr.sync.worker_idle_ms=1000
4446

4547
wedpr.thread.max.blocking.queue.size=1000
4648

@@ -50,23 +52,23 @@ wedpr.scheduler.query.job.status.interval.ms=30000
5052
wedpr.scheduler.interval.ms=30000
5153

5254
# the executor related config
53-
wedpr.executor.job.cache.dir=./.cache/jobs
54-
wedpr.executor.psi.tmp.file.name=psi_prepare.csv
55+
#wedpr.executor.job.cache.dir=./.jobs/cache
56+
#wedpr.executor.psi.tmp.file.name=.psi.tmp
5557
wedpr.executor.psi.prepare.file.name=psi_prepare.csv
56-
wedpr.executor.ml.url=
58+
wedpr.executor.ml.url=127.0.0.1:44471
5759
wedpr.executor.ml.connect.request.timeout.ms=10000
5860
wedpr.executor.ml.connect.timeout.ms=5000
5961
wedpr.executor.ml.request.timeout.ms=60000
6062
wedpr.executor.ml.max.total.connection=5
6163

6264

63-
wedpr.executor.psi.url=
65+
wedpr.executor.psi.url=127.0.0.1:12200
6466
wedpr.executor.psi.connect.request.timeout.ms=10000
6567
wedpr.executor.psi.connect.timeout.ms=5000
6668
wedpr.executor.psi.request.timeout.ms=60000
6769
wedpr.executor.psi.max.total.connection=5
6870

69-
wedpr.executor.psi.token=
71+
wedpr.executor.psi.token=ppcs_psi_apikey
7072

7173

7274

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIDITCCAgkCFCOfjmHXWUMHMnfxY9r00nBFkbLlMA0GCSqGSIb3DQEBCwUAMEwx
3+
HDAaBgNVBAMME0ZJU0NPLUJDT1MtMmViNTFmYWUxHDAaBgNVBAoME0ZJU0NPLUJD
4+
T1MtMmViNTFmYWUxDjAMBgNVBAsMBWNoYWluMCAXDTI0MDcxNTE1MDI0OVoYDzIx
5+
MjQwNjIxMTUwMjQ5WjBMMRwwGgYDVQQDDBNGSVNDTy1CQ09TLTJlYjUxZmFlMRww
6+
GgYDVQQKDBNGSVNDTy1CQ09TLTJlYjUxZmFlMQ4wDAYDVQQLDAVjaGFpbjCCASIw
7+
DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKAJWhwjeYiMCUfikNk2VMXt3ujE
8+
+DDzKuF9iaa/8FJS0g3xhgNX/7FmbahSZORkOTngKMdY/Lt7+dmnI95niXl4Z57m
9+
YdWJIE4e+1ojmzaLDjsSuWqI4nl8SF2ECqM+8t79JNhTg5OT1SpUHKGStkTEqil/
10+
gP46Q7SXMlAy+9kueKCvjtukKqRNX8ckDfQqqbX8xcv+SF9sMZUnoeF3oQw8DQwx
11+
mrjMCOJtKvMnDdrnlXq526gms1X1UCqiEEczZ6dKvxWa4j5cQ5FRB72N4fxu14oM
12+
dBthaO3gUO7dQEXIEnIa1Gq+b8SVPciE3Ze0/uoOktMjlSHMR4u48LMTNbECAwEA
13+
ATANBgkqhkiG9w0BAQsFAAOCAQEAWqZsE5dzVObDK+tKX3ehcu4JsTZJLWuv2zO6
14+
VOERYgCJEoAjLpXlDlygvzBiM75BVersZ1dZzyXTk0UziG3fJD4pYrWJCO3EZGrE
15+
zQ5ARPtIkSDsjF7dIriMbBJv1VoD3hcRHi0LgsInPArmAfIPQgwVeW/aFunu8aMj
16+
BCdpxdMKMLCJLMaSAc9F1ZASw/48CROB7XFnxDlkC/dzWi3RTK1FYyyfCKey+NCQ
17+
QOxx5ZyH6BroFNHFU31TDL90VR7e+Jgz/R8VFDpcp11rbm02QyeIZwyBZuOVXtkh
18+
EmOq/mqaDalaliyUdiPYk1zhOJobp3VDiVyT7TT0fZvJs/1tRQ==
19+
-----END CERTIFICATE-----
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIDLTCCAhWgAwIBAgIUWiDtDUDbj77dZY7gUuM5Q9geTJswDQYJKoZIhvcNAQEL
3+
BQAwTDEcMBoGA1UEAwwTRklTQ08tQkNPUy0yZWI1MWZhZTEcMBoGA1UECgwTRklT
4+
Q08tQkNPUy0yZWI1MWZhZTEOMAwGA1UECwwFY2hhaW4wIBcNMjQwNzE1MTUwMjQ5
5+
WhgPMjEyNDA2MjExNTAyNDlaMEQxHDAaBgNVBAMME0ZJU0NPLUJDT1MtMmViNTFm
6+
YWUxEzARBgNVBAoMCmZpc2NvLWJjb3MxDzANBgNVBAsMBmFnZW5jeTCCASIwDQYJ
7+
KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMKtFiSZ0H8/n/oIdX9sYKHyBzHINHdF
8+
OXnEyGLf5CBheSJJ46IMWAbUCIf7sDS04DA+02G4yq7lAyS2DIq9ipkBNINo6QFp
9+
WpRQqFKkxHBCj27hYUuRMNqQ+IslvOKM1WTXStYErfJt3TzksRPPbkhXCa+BLYX8
10+
LIGRbAwR1152fVw9R+6ElhbreHWkhE6VMrznysbyWYaTo9G7QzptI2OVh2iNHZQ4
11+
OLMwABo582xdujfDF9+FI2SF1l7Hsixm5kqaS2RfMV+ZZ11gboCQsV90eDPu5ad9
12+
Edyg4Pqv3gN0VwTxeHG8ttbwIWJ3ygnb0xhh14YsNMsBPLEG4e/eIsECAwEAAaMN
13+
MAswCQYDVR0TBAIwADANBgkqhkiG9w0BAQsFAAOCAQEAGshhzi4tNbbUuReeITCK
14+
7CcwKBI2zZXZV0PARpjHNdr6SSxG5+1ueZbs665ie8R+JhWUYaPeaMfVuLG2u5Pc
15+
COLqRN+OGuIp0B2NYyYPqGVB+MQCCn8EcUaeAVm3+BNgXzSvGB70rwzUHuwKesO5
16+
J7VLoKeJYJKlhkoMBjT4jue630sJz8xwQs/+4HyocBROlz7tDCee2KYUTv8n+JIe
17+
zwymYemqdGXF9XA5XyzNEJWWDv+UsloeFp8Gems3TnPoeSwIVsq/dx8UWhk1Z3JU
18+
dH77KYv1Zm3XWBHL8oEIGJXB6hcTrz/boeSzj1yG7+Qa0X9R3hdy289djz+YBw36
19+
Vw==
20+
-----END CERTIFICATE-----
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-----BEGIN PRIVATE KEY-----
2+
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDCrRYkmdB/P5/6
3+
CHV/bGCh8gcxyDR3RTl5xMhi3+QgYXkiSeOiDFgG1AiH+7A0tOAwPtNhuMqu5QMk
4+
tgyKvYqZATSDaOkBaVqUUKhSpMRwQo9u4WFLkTDakPiLJbzijNVk10rWBK3ybd08
5+
5LETz25IVwmvgS2F/CyBkWwMEddedn1cPUfuhJYW63h1pIROlTK858rG8lmGk6PR
6+
u0M6bSNjlYdojR2UODizMAAaOfNsXbo3wxffhSNkhdZex7IsZuZKmktkXzFfmWdd
7+
YG6AkLFfdHgz7uWnfRHcoOD6r94DdFcE8XhxvLbW8CFid8oJ29MYYdeGLDTLATyx
8+
BuHv3iLBAgMBAAECggEAJ7BD8GhPYnHlOoNY+QZuWPXP061eTOaXBiVBOS8uAg/9
9+
MylfOB1OIO4/YwHD9arefdeBHs4evDNCRcy7l9l2lSTywMu1nS0OY2hiOJ8Q0VYw
10+
icl3HYHXNOgTU8L41DMkGi/uON2xXNhbH1v8Ye6LLEJaXiZ20ncL18p+/aLxhndE
11+
D5OfUz4yyquWq9/3IycGG5EowtSkL6yyMk9jcdWnsWwPAJ9hLsASj6ad/CRgIBt4
12+
ubHvWGz//Dglbf+LHI1Ieuqrd3zvW0bMkk0jRpCgPkiinZzeR5NuE5gVbQs+xMKs
13+
BbU93Xk0Xb00KOjl6FKAgCffS97zB8REjTStyttrAQKBgQD6KqY1FqybZbWxhuAs
14+
Mkvta4vIcmSsMeGOOcre8MIFy5AC7WF8zCrWLmM6GltDMhBTaJ/XqnGmq1xZFU4c
15+
tTRMpaChFf0KgM5esM8YaFCfLFrlRg6v9eC+fW9ta4Sw293/zk9sJ6GWMiyiPjb+
16+
A1SGmrXRoLTz7XC123e2UdrLEQKBgQDHNzDk14vV9u1Jju80lcwhV7wSgHEb3Dfh
17+
/q8n4/HdQJQ3ANMwJ7IA8OEg62FzsPguF3R4ZbyMn0FBPG1lVVCV2M0DuVjraXjR
18+
+DyxyD0ue1sCErFJ0pwyvdKRyqriC9+EjvTnsulBqGSnxz+JMLsN0wYRSE8OnRWq
19+
RYb9LoP8sQKBgQD0oLwC8fc7xkvUG4Ye8dgZhK8eBe64C9b60zy0oU25iQN8OVC5
20+
TpUc+COD774KiWw5g/e6VyvnxW36lsDZhcBsqxHWM8BLgwVKxy7cOTWNUTxZMxat
21+
roxk+hf6MceBgp8lxEMaCe8TBmFrDdeMsQj4z1S4dqQ8W5V53/DCUmzXYQKBgQCV
22+
rhEtkApADFTDVQLDlt2WG85ydFEH5tGSGwLNzQXYAIKcRSFoaBrlfBca3eANxeTi
23+
9LqND5u4aJvmARoM7iorPIblimiWEFw4HvSze0kE2KhLiXHtjrHPqjJBWm5EgzlA
24+
5wx53kJGE9j0+s7xLE0PGQPRDmxgBYTWt4CyUDXZMQKBgHJseRzggZvnerO02LLm
25+
EvX3//I2GxgvoeJQtLwwgiHWHCAVShIOt5yIimu+PIkaxfV9eR9+HRsjKXXaOme0
26+
E3h18dESRcj0vAtf6oE+QuqGTkxvXYlABqgm2dpknmguDLs+wsktv2bVtXpqvg8i
27+
rstAgWT+6mcUSpUxMePwt+xO
28+
-----END PRIVATE KEY-----
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[cryptoMaterial]
2+
3+
certPath = "conf" # The certification path
4+
disableSsl = "false" # Communication with nodes without SSL
5+
useSMCrypto = "false" # RPC SM crypto type
6+
7+
# The following configurations take the certPath by default if commented
8+
# caCert = "conf/ca.crt" # CA cert file path
9+
# sslCert = "conf/sdk.crt" # SSL cert file path
10+
# sslKey = "conf/sdk.key" # SSL key file path
11+
12+
# The following configurations take the sm certPath by default if commented
13+
# caCert = "conf/sm_ca.crt" # SM CA cert file path
14+
# sslCert = "conf/sm_sdk.crt" # SM SSL cert file path
15+
# sslKey = "conf/sm_sdk.key" # SM SSL key file path
16+
# enSslCert = "conf/sm_ensdk.crt" # SM encryption cert file path
17+
# enSslKey = "conf/sm_ensdk.key" # SM ssl cert file path
18+
19+
[network]
20+
messageTimeout = "10000"
21+
defaultGroup="group0" # Console default group to connect
22+
peers=["139.159.202.235:30200", "139.159.202.235:30201"] # The peer list to connect
23+
24+
[account]
25+
keyStoreDir = "account" # The directory to load/store the account file, default is "account"
26+
# accountFilePath = "" # The account file path (default load from the path specified by the keyStoreDir)
27+
accountFileFormat = "pem" # The storage format of account file (Default is "pem", "p12" as an option)
28+
29+
# accountAddress = "" # The transactions sending account address
30+
# Default is a randomly generated account
31+
# The randomly generated account is stored in the path specified by the keyStoreDir
32+
33+
# password = "" # The password used to load the account file
34+
35+
[threadPool]
36+
# threadPoolSize = "16" # The size of the thread pool to process message callback
37+
# Default is the number of cpu cores
38+
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
logging.level.root=INFO
2+
3+
# mybatis sql log
4+
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
5+
spring.jackson.date-format = yyyy-MM-dd HH:mm:ss
6+
7+
spring.jackson.time-zone =GMT+8
8+
# Spring configurations
9+
server.port = 12000
10+
spring.application.name=PPCS-MODELADM
11+
spring.main.allow-bean-definition-overriding =true
12+
13+
spring.servlet.multipart.max-file-size = 20MB
14+
spring.servlet.multipart.max-request-size = -1
15+
16+
# mybatis configuration
17+
#mybatis.mapper-locations=classpath:mapper/*Mapper.xml
18+
19+
## dataset configuration
20+
wedpr.dataset.debugMode=false
21+
wedpr.dataset.debugMode.userTokenField=Wedpr-Test-User-Token
22+
23+
# excel
24+
wedpr.datasource.excel.defaultSheet=0
25+
26+
# maximum number of data per page for paginated queries
27+
wedpr.dataset.maxBatchSize=10
28+
29+
# thread pool config
30+
wedpr.dataset.largeFileDataDir=./wedpr/largeFile/
31+
wedpr.dataset.threadPool.namePrefix=dataset-th
32+
wedpr.dataset.threadPool.maxPoolSize=16
33+
wedpr.dataset.threadPool.corePoolSize=16
34+
wedpr.dataset.threadPool.queueCapacity=100
35+
36+
# data source config
37+
wedpr.dataset.dataSourceType[0].label=CSV\u6587\u4EF6
38+
wedpr.dataset.dataSourceType[0].value=CSV
39+
40+
wedpr.dataset.dataSourceType[1].label=EXCEL\u6587\u4EF6
41+
wedpr.dataset.dataSourceType[1].value=EXCEL
42+
43+
wedpr.dataset.dataSourceType[2].label=HDFS
44+
wedpr.dataset.dataSourceType[2].value=HDFS
45+
46+
wedpr.dataset.dataSourceType[3].label=HIVE
47+
wedpr.dataset.dataSourceType[3].value=HIVE
48+
wedpr.dataset.dataSourceType[3].supportDynamicType=true
49+
50+
wedpr.dataset.dataSourceType[4].label=\u6570\u636E\u5E93
51+
wedpr.dataset.dataSourceType[4].value=DB
52+
wedpr.dataset.dataSourceType[4].supportDynamicType=true
53+
wedpr.dataset.dataSourceType[4].children[0].label=MYSQL
54+
wedpr.dataset.dataSourceType[4].children[0].value=MYSQL
55+
wedpr.dataset.dataSourceType[4].children[1].label=\u8FBE\u68A6
56+
wedpr.dataset.dataSourceType[4].children[1].value=DM
57+
wedpr.dataset.dataSourceType[4].children[2].label=POSTFRESQL
58+
wedpr.dataset.dataSourceType[4].children[2].value=POSTFRESQL
59+
wedpr.dataset.dataSourceType[4].children[3].label=\u9AD8\u65AF
60+
wedpr.dataset.dataSourceType[4].children[3].value=GAUSS
61+
wedpr.dataset.dataSourceType[4].children[4].label=\u4EBA\u5927\u91D1\u4ED3
62+
wedpr.dataset.dataSourceType[4].children[4].value=KING
63+
wedpr.dataset.dataSourceType[4].children[5].label=\u795E\u901A
64+
wedpr.dataset.dataSourceType[4].children[5].value=SHENTONG
65+
66+
# storage download shard size 20M
67+
wedpr.storage.download.shardSize=20971520
68+
69+
# storage type: LOCAL\u3001HDFS
70+
wedpr.storage.type=LOCAL
71+
72+
# LOCAL
73+
wedpr.storage.local.basedir=./wedpr/localStorage/
74+
75+
# HDFS
76+
wedpr.storage.hdfs.baseDir=/user
77+
wedpr.storage.hdfs.url=hdfs://wedpr-0001:9900
78+
79+
# USER
80+
wedpr.user.jwt.secret=123456
81+
# 1h ?unit is ms?
82+
wedpr.user.jwt.expireTime=3600000
83+
wedpr.user.jwt.delimiter=|
84+
wedpr.user.jwt.cacheSize=10000
85+
wedpr.user.jwt.privateKey=
86+
wedpr.user.jwt.publicKey=
87+
wedpr.user.jwt.sessionKey=
88+
89+
springfox.documentation.enabled=true
90+

wedpr-components/http-client/src/main/java/com/webank/wedpr/components/http/client/HttpClientImpl.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,44 @@ public String executePostAndGetString(BaseRequest request, Integer successCode)
9393
}
9494
}
9595

96+
public String executeHttpsPostAndGetString(
97+
BaseRequest request, Integer successCode, String token) throws Exception {
98+
StringEntity requestEntity = null;
99+
CloseableHttpResponse response = null;
100+
try {
101+
CloseableHttpClient httpClient =
102+
HttpClientPool.getHttpsClient(this.maxConnTotal, this.requestConfig);
103+
HttpPost httpPost = new HttpPost(this.url);
104+
requestEntity = new StringEntity(request.serialize());
105+
httpPost.setEntity(requestEntity);
106+
httpPost.setHeader(CONTENT_TYPE_KEY, DEFAULT_CONTENT_TYPE);
107+
if (token != null) {
108+
httpPost.setHeader("token", token);
109+
}
110+
response = httpClient.execute(httpPost);
111+
if (successCode != null) {
112+
if (response.getStatusLine().getStatusCode() != successCode) {
113+
throw new WeDPRException(
114+
"send request: "
115+
+ request.serialize()
116+
+ " failed, status: "
117+
+ response.getStatusLine().toString()
118+
+ ", detail: "
119+
+ EntityUtils.toString(response.getEntity()));
120+
}
121+
}
122+
String result = EntityUtils.toString(response.getEntity());
123+
logger.info(
124+
"##### executeHttpsPostAndGetString, request: {}, response: {}, response: {}",
125+
request.serialize(),
126+
result,
127+
response.toString());
128+
return result;
129+
} finally {
130+
releaseResource(response, requestEntity);
131+
}
132+
}
133+
96134
private void releaseResource(CloseableHttpResponse response, StringEntity requestEntity)
97135
throws Exception {
98136
HttpClientPool.consume(requestEntity);

wedpr-components/http-client/src/main/java/com/webank/wedpr/components/http/client/HttpClientPool.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@
1717

1818
import java.io.IOException;
1919
import java.io.InputStream;
20+
import java.security.KeyManagementException;
21+
import java.security.KeyStoreException;
22+
import java.security.NoSuchAlgorithmException;
2023
import org.apache.http.HttpEntity;
2124
import org.apache.http.client.config.RequestConfig;
25+
import org.apache.http.conn.ssl.NoopHostnameVerifier;
26+
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
2227
import org.apache.http.impl.client.CloseableHttpClient;
2328
import org.apache.http.impl.client.HttpClients;
2429
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
30+
import org.apache.http.ssl.SSLContextBuilder;
2531

2632
public class HttpClientPool {
2733
private static final PoolingHttpClientConnectionManager poolingHttpClientConnectionManager =
@@ -36,6 +42,28 @@ public static CloseableHttpClient getHttpClient(int maxConnTotal, RequestConfig
3642
.build();
3743
}
3844

45+
public static CloseableHttpClient getHttpsClient(
46+
int maxConnTotal, RequestConfig requestConfig) {
47+
CloseableHttpClient build = null;
48+
try {
49+
build =
50+
HttpClients.custom()
51+
.setSSLContext(
52+
SSLContextBuilder.create()
53+
.loadTrustMaterial(new TrustSelfSignedStrategy())
54+
.build())
55+
.setSSLHostnameVerifier(new NoopHostnameVerifier())
56+
.setConnectionManager(poolingHttpClientConnectionManager)
57+
.setMaxConnTotal(maxConnTotal)
58+
.setMaxConnPerRoute((maxConnTotal / 2 > 0 ? maxConnTotal / 2 : 1))
59+
.setDefaultRequestConfig(requestConfig)
60+
.build();
61+
} catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) {
62+
e.printStackTrace();
63+
}
64+
return build;
65+
}
66+
3967
public static void consume(HttpEntity entity) throws IOException {
4068
if (entity == null) {
4169
return;
@@ -50,7 +78,7 @@ public static void consume(HttpEntity entity) throws IOException {
5078
}
5179

5280
public static String getUrl(String url) {
53-
if (url.startsWith("http://")) {
81+
if (url.startsWith("http://") || url.startsWith("https://")) {
5482
return url;
5583
}
5684
return String.format("http://%s", url);

0 commit comments

Comments
 (0)