|
|
@@ -1,27 +1,22 @@
|
|
1
|
1
|
package com.ruoyi.wisdomarbitrate.service.impl;
|
|
2
|
2
|
|
|
3
|
3
|
|
|
4
|
|
-
|
|
5
|
|
-import cn.hutool.crypto.SmUtil;
|
|
6
|
|
-import cn.hutool.crypto.asymmetric.SM2;
|
|
7
|
|
-import cn.hutool.crypto.symmetric.SymmetricCrypto;
|
|
8
|
4
|
import com.alibaba.fastjson.JSON;
|
|
9
|
5
|
import com.alibaba.fastjson.JSONObject;
|
|
10
|
6
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
11
|
7
|
import com.ruoyi.common.utils.StringUtils;
|
|
12
|
|
-import com.ruoyi.exceptions.TradeException;
|
|
13
|
8
|
import com.ruoyi.wisdomarbitrate.domain.IdentityAuthentication;
|
|
14
|
9
|
import com.ruoyi.wisdomarbitrate.mapper.IdentityAuthenticationMapper;
|
|
15
|
|
-import com.ruoyi.wisdomarbitrate.service.ICaseApplicationService;
|
|
16
|
10
|
import com.ruoyi.wisdomarbitrate.service.IdentityAuthenticationService;
|
|
17
|
|
-
|
|
18
|
11
|
import com.tencentcloudapi.common.Credential;
|
|
|
12
|
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
|
19
|
13
|
import com.tencentcloudapi.common.profile.ClientProfile;
|
|
20
|
14
|
import com.tencentcloudapi.common.profile.HttpProfile;
|
|
21
|
|
-import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
|
22
|
15
|
import com.tencentcloudapi.faceid.v20180301.FaceidClient;
|
|
23
|
|
-import com.tencentcloudapi.faceid.v20180301.models.*;
|
|
24
|
|
-
|
|
|
16
|
+import com.tencentcloudapi.faceid.v20180301.models.GetEidResultRequest;
|
|
|
17
|
+import com.tencentcloudapi.faceid.v20180301.models.GetEidResultResponse;
|
|
|
18
|
+import com.tencentcloudapi.faceid.v20180301.models.GetEidTokenRequest;
|
|
|
19
|
+import com.tencentcloudapi.faceid.v20180301.models.GetEidTokenResponse;
|
|
25
|
20
|
import org.slf4j.Logger;
|
|
26
|
21
|
import org.slf4j.LoggerFactory;
|
|
27
|
22
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -29,15 +24,8 @@ import org.springframework.beans.factory.annotation.Value;
|
|
29
|
24
|
import org.springframework.stereotype.Service;
|
|
30
|
25
|
import org.springframework.transaction.annotation.Transactional;
|
|
31
|
26
|
|
|
32
|
|
-import java.io.FileInputStream;
|
|
33
|
|
-import java.io.IOException;
|
|
34
|
|
-import java.io.InputStream;
|
|
35
|
|
-import java.util.Base64;
|
|
36
|
|
-import java.util.HashMap;
|
|
37
|
|
-import java.util.Map;
|
|
38
|
|
-
|
|
39
|
27
|
@Service
|
|
40
|
|
-public class IdentityAuthenticationServiceImpl implements IdentityAuthenticationService {
|
|
|
28
|
+public class IdentityAuthenticationServiceImpl implements IdentityAuthenticationService {
|
|
41
|
29
|
|
|
42
|
30
|
@Value("${identityAuthentication.credentialSecretId}")
|
|
43
|
31
|
private String credentialSecretId;
|
|
|
@@ -58,9 +46,9 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthenticatio
|
|
58
|
46
|
@Override
|
|
59
|
47
|
public IdentityAuthentication selectIdentityAuthentication(IdentityAuthentication identityAuthentication) {
|
|
60
|
48
|
IdentityAuthentication identityAuthenticationselect = identityAuthenticationMapper.selectIdentityAuthentication(identityAuthentication);
|
|
61
|
|
- if(identityAuthenticationselect!=null){
|
|
|
49
|
+ if (identityAuthenticationselect != null) {
|
|
62
|
50
|
identityAuthenticationselect.setCertificationStatusName("已身份认证");
|
|
63
|
|
- }else {
|
|
|
51
|
+ } else {
|
|
64
|
52
|
IdentityAuthentication identityAuthenticationselectnew = new IdentityAuthentication();
|
|
65
|
53
|
identityAuthenticationselectnew.setCertificationStatusName("未身份认证");
|
|
66
|
54
|
identityAuthenticationselectnew.setCertificationStatus(0);
|
|
|
@@ -71,85 +59,64 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthenticatio
|
|
71
|
59
|
}
|
|
72
|
60
|
|
|
73
|
61
|
@Override
|
|
74
|
|
- public IdentityAuthentication selectIdentityAuthenticaEIDtoken() {
|
|
75
|
|
- IdentityAuthentication identityAuthentication = new IdentityAuthentication();
|
|
76
|
|
- try{
|
|
77
|
|
- Credential authenti = new Credential(credentialSecretId, credentialSecretKey);
|
|
78
|
|
- HttpProfile httpProfileIdenAuth = new HttpProfile();
|
|
79
|
|
- httpProfileIdenAuth.setEndpoint("faceid.tencentcloudapi.com");
|
|
80
|
|
- ClientProfile clientInv= new ClientProfile();
|
|
81
|
|
- clientInv.setHttpProfile(httpProfileIdenAuth);
|
|
82
|
|
- FaceidClient clientIdenAuth = new FaceidClient(authenti, "", clientInv);
|
|
83
|
|
- // 实例化一个请求对象
|
|
84
|
|
- GetEidTokenRequest reqest = new GetEidTokenRequest();
|
|
85
|
|
- //设置请求参数
|
|
86
|
|
- reqest.setMerchantId(merchantId);
|
|
87
|
|
- GetEidTokenResponse respIdenAuth = clientIdenAuth.GetEidToken(reqest);
|
|
88
|
|
- String respJSON = GetEidTokenResponse.toJsonString(respIdenAuth);
|
|
89
|
|
- JSONObject objJSON = JSON.parseObject(respJSON);
|
|
90
|
|
- String eidToken = objJSON.getString("EidToken");
|
|
91
|
|
- String requestId = objJSON.getString("RequestId");
|
|
92
|
|
- identityAuthentication.setEidToken(eidToken);
|
|
93
|
|
- }catch (TencentCloudSDKException e) {
|
|
94
|
|
- log.error("获取Eidtoke异常:", e);
|
|
95
|
|
- throw new RuntimeException("获取Eidtoke异常");
|
|
|
62
|
+ public JSONObject selectIdentityAuthenticaEIDtoken() {
|
|
|
63
|
+ JSONObject objJSON = new JSONObject();
|
|
|
64
|
+ objJSON.put("EidToken", "");
|
|
|
65
|
+ try {
|
|
|
66
|
+ Credential cred = new Credential(credentialSecretId, credentialSecretKey);
|
|
|
67
|
+ // 实例化一个http选项,可选的,没有特殊需求可以跳过
|
|
|
68
|
+ HttpProfile httpProfile = new HttpProfile();
|
|
|
69
|
+ httpProfile.setEndpoint("faceid.tencentcloudapi.com");
|
|
|
70
|
+ // 实例化一个client选项,可选的,没有特殊需求可以跳过
|
|
|
71
|
+ ClientProfile clientProfile = new ClientProfile();
|
|
|
72
|
+ clientProfile.setHttpProfile(httpProfile);
|
|
|
73
|
+ // 实例化要请求产品的client对象,clientProfile是可选的
|
|
|
74
|
+ FaceidClient client = new FaceidClient(cred, "", clientProfile);
|
|
|
75
|
+ // 实例化一个请求对象,每个接口都会对应一个request对象
|
|
|
76
|
+ GetEidTokenRequest req = new GetEidTokenRequest();
|
|
|
77
|
+ // 返回的resp是一个GetEidTokenResponse的实例,与请求对象对应
|
|
|
78
|
+ GetEidTokenResponse resp = client.GetEidToken(req);
|
|
|
79
|
+ // 输出json格式的字符串回包
|
|
|
80
|
+ System.out.println(GetEidTokenResponse.toJsonString(resp));
|
|
|
81
|
+ String respJSON = GetEidTokenResponse.toJsonString(resp);
|
|
|
82
|
+ objJSON = JSON.parseObject(respJSON);
|
|
|
83
|
+ } catch (TencentCloudSDKException e) {
|
|
|
84
|
+ System.out.println(e.toString());
|
|
|
85
|
+ System.out.println("获取Eidtoken失败");
|
|
96
|
86
|
}
|
|
97
|
|
-
|
|
98
|
|
- return identityAuthentication;
|
|
99
|
|
-
|
|
|
87
|
+ return objJSON;
|
|
100
|
88
|
}
|
|
101
|
89
|
|
|
102
|
90
|
@Override
|
|
103
|
91
|
@Transactional
|
|
104
|
|
- public IdentityAuthentication selectIdentityAuthenticaRespon(IdentityAuthentication ientityAuthentication) {
|
|
|
92
|
+ public JSONObject selectIdentityAuthenticaRespon(IdentityAuthentication ientityAuthentication) {
|
|
105
|
93
|
String eidToken = ientityAuthentication.getEidToken();
|
|
106
|
|
- Long userId = ientityAuthentication.getUserId();
|
|
107
|
|
- String userName = ientityAuthentication.getUserName();
|
|
108
|
|
- IdentityAuthentication IdentityAuthenticationRespon = new IdentityAuthentication();
|
|
109
|
|
- IdentityAuthentication IdentityAuthenticationResult = new IdentityAuthentication();
|
|
110
|
|
- if(StringUtils.isNotEmpty(eidToken)){
|
|
111
|
|
- try{
|
|
112
|
|
- Credential authenti = new Credential(credentialSecretId, credentialSecretKey);
|
|
113
|
|
- HttpProfile httpProfileIdenAuth = new HttpProfile();
|
|
114
|
|
- httpProfileIdenAuth.setEndpoint("faceid.tencentcloudapi.com");
|
|
115
|
|
- ClientProfile clientInv= new ClientProfile();
|
|
116
|
|
- clientInv.setHttpProfile(httpProfileIdenAuth);
|
|
117
|
|
- FaceidClient clientIdenAuth = new FaceidClient(authenti, "", clientInv);
|
|
118
|
|
- // 实例化一个请求对象
|
|
119
|
|
- GetEidResultRequest reqest = new GetEidResultRequest();
|
|
120
|
|
- //设置请求参数
|
|
121
|
|
- reqest.setEidToken(eidToken);
|
|
122
|
|
-
|
|
123
|
|
-// reqest.setInfoType("1");
|
|
124
|
|
-// reqest.setInfoType("13");
|
|
125
|
|
-// reqest.setInfoType("2");
|
|
126
|
|
-
|
|
127
|
|
- //获得身份认证结果
|
|
128
|
|
- GetEidResultResponse respIdenAuth = clientIdenAuth.GetEidResult(reqest);
|
|
129
|
|
- String respJSON = GetEidResultResponse.toJsonString(respIdenAuth);
|
|
130
|
|
- JSONObject objJSON = JSON.parseObject(respJSON);
|
|
131
|
|
- IdentityAuthenticationRespon.setCertificationStatus(1);
|
|
132
|
|
- IdentityAuthenticationRespon.setUserName(userName);
|
|
133
|
|
- IdentityAuthenticationRespon.setUserId(userId);
|
|
134
|
|
-
|
|
135
|
|
- JSONObject objEidInfo = JSON.parseObject(objJSON.getString("EidInfo"));
|
|
136
|
|
-// identityAuthenticationMapper.insertIdentityAuthentication(IdentityAuthenticationRespon);
|
|
137
|
|
- IdentityAuthenticationResult.setCertificationStatus(1);
|
|
138
|
|
- IdentityAuthenticationResult.setCertificationStatusName("认证成功");
|
|
139
|
|
- } catch (TencentCloudSDKException e) {
|
|
140
|
|
- log.error("认证失败:", e);
|
|
141
|
|
- throw new RuntimeException("认证失败");
|
|
142
|
|
- }
|
|
143
|
94
|
|
|
|
95
|
+ try {
|
|
|
96
|
+ Credential cred = new Credential(credentialSecretId, credentialSecretKey);
|
|
|
97
|
+ // 实例化一个http选项,可选的,没有特殊需求可以跳过
|
|
|
98
|
+ HttpProfile httpProfile = new HttpProfile();
|
|
|
99
|
+ httpProfile.setEndpoint("faceid.tencentcloudapi.com");
|
|
|
100
|
+ // 实例化一个client选项,可选的,没有特殊需求可以跳过
|
|
|
101
|
+ ClientProfile clientProfile = new ClientProfile();
|
|
|
102
|
+ clientProfile.setHttpProfile(httpProfile);
|
|
|
103
|
+ // 实例化要请求产品的client对象,clientProfile是可选的
|
|
|
104
|
+ FaceidClient client = new FaceidClient(cred, "", clientProfile);
|
|
|
105
|
+ // 实例化一个请求对象,每个接口都会对应一个request对象
|
|
|
106
|
+ GetEidResultRequest req = new GetEidResultRequest();
|
|
|
107
|
+ req.setEidToken(eidToken);
|
|
|
108
|
+ // 返回的resp是一个GetEidResultResponse的实例,与请求对象对应
|
|
|
109
|
+ GetEidResultResponse resp = client.GetEidResult(req);
|
|
|
110
|
+ // 输出json格式的字符串回包
|
|
|
111
|
+ System.out.println(GetEidResultResponse.toJsonString(resp));
|
|
|
112
|
+ String s = GetEidResultResponse.toJsonString(resp);
|
|
|
113
|
+ JSONObject object = JSON.parseObject(s);
|
|
|
114
|
+ return object;
|
|
|
115
|
+ } catch (TencentCloudSDKException e) {
|
|
|
116
|
+ System.out.println(e.toString());
|
|
144
|
117
|
}
|
|
145
|
|
- return IdentityAuthenticationResult;
|
|
|
118
|
+ return null;
|
|
146
|
119
|
}
|
|
147
|
120
|
|
|
148
|
121
|
|
|
149
|
|
-
|
|
150
|
|
-
|
|
151
|
|
-
|
|
152
|
|
-
|
|
153
|
|
-
|
|
154
|
|
-
|
|
155
|
122
|
}
|