|
@@ -1,7 +1,5 @@
|
|
|
package org.jeecg.modules.app.esign.auth;
|
|
|
|
|
|
-import com.google.gson.Gson;
|
|
|
-import com.google.gson.JsonObject;
|
|
|
import org.jeecg.modules.app.esign.comm.EsignHttpHelper;
|
|
|
import org.jeecg.modules.app.esign.comm.EsignHttpResponse;
|
|
|
import org.jeecg.modules.app.esign.constant.EsignDemoConfig;
|
|
@@ -21,43 +19,43 @@ public class AuthDemo extends Exception {
|
|
|
private static String eSignAppId=EsignDemoConfig.EsignAppId;
|
|
|
private static String eSignAppSecret=EsignDemoConfig.EsignAppSecret;
|
|
|
|
|
|
- public static void main(String[] args) throws EsignDemoException {
|
|
|
- Gson gson = new Gson();
|
|
|
- /* 获取个人认证授权链接*/
|
|
|
- EsignHttpResponse getPsnAuthUrl = getPsnAuthUrl();
|
|
|
- JsonObject getPsnAuthUrlObject = gson.fromJson(getPsnAuthUrl.getBody(), JsonObject.class);
|
|
|
- JsonObject data = getPsnAuthUrlObject.getAsJsonObject("data");
|
|
|
- String authUrl = data.get("authUrl").getAsString();
|
|
|
- System.err.println("个人授权链接:"+authUrl);
|
|
|
- /* 查询个人认证授权状态*/
|
|
|
- EsignHttpResponse getPsnIdentityInfo = getPsnIdentityInfo();
|
|
|
- JsonObject getPsnIdentityInfoObject = gson.fromJson(getPsnIdentityInfo.getBody(), JsonObject.class);
|
|
|
- String realnameStatus =getPsnIdentityInfoObject.getAsJsonObject("data").get("realnameStatus").getAsString();//授权状态authorizeUserInfo
|
|
|
- System.err.println("个人认证状态:"+realnameStatus);
|
|
|
- /* 获取企业认证授权链接*/
|
|
|
- EsignHttpResponse getOrgAuthUrl = getOrgAuthUrl();
|
|
|
- JsonObject getOrgAuthUrlObject = gson.fromJson(getOrgAuthUrl.getBody(), JsonObject.class);
|
|
|
- String orgAuthUrl = getOrgAuthUrlObject.getAsJsonObject("data").get("authUrl").getAsString();
|
|
|
- System.err.println("企业授权链接:"+orgAuthUrl);
|
|
|
- /* 查询企业认证授权状态*/
|
|
|
- EsignHttpResponse getOrgIdentityInfo = getOrgIdentityInfo();
|
|
|
- JsonObject getOrgIdentityInfoObject = gson.fromJson(getOrgIdentityInfo.getBody(), JsonObject.class);
|
|
|
- String orgRealnameStatus = getOrgIdentityInfoObject.getAsJsonObject("data").get("realnameStatus").getAsString();//授权状态authorizeUserInfo
|
|
|
- System.err.println("企业认证状态:"+orgRealnameStatus);
|
|
|
-
|
|
|
- }
|
|
|
+// public static void main(String[] args) throws EsignDemoException {
|
|
|
+// Gson gson = new Gson();
|
|
|
+// /* 获取个人认证授权链接*/
|
|
|
+// EsignHttpResponse getPsnAuthUrl = getPsnAuthUrl();
|
|
|
+// JsonObject getPsnAuthUrlObject = gson.fromJson(getPsnAuthUrl.getBody(), JsonObject.class);
|
|
|
+// JsonObject data = getPsnAuthUrlObject.getAsJsonObject("data");
|
|
|
+// String authUrl = data.get("authUrl").getAsString();
|
|
|
+// System.err.println("个人授权链接:"+authUrl);
|
|
|
+// /* 查询个人认证授权状态*/
|
|
|
+// EsignHttpResponse getPsnIdentityInfo = getPsnIdentityInfo();
|
|
|
+// JsonObject getPsnIdentityInfoObject = gson.fromJson(getPsnIdentityInfo.getBody(), JsonObject.class);
|
|
|
+// String realnameStatus =getPsnIdentityInfoObject.getAsJsonObject("data").get("realnameStatus").getAsString();//授权状态authorizeUserInfo
|
|
|
+// System.err.println("个人认证状态:"+realnameStatus);
|
|
|
+// /* 获取企业认证授权链接*/
|
|
|
+// EsignHttpResponse getOrgAuthUrl = getOrgAuthUrl();
|
|
|
+// JsonObject getOrgAuthUrlObject = gson.fromJson(getOrgAuthUrl.getBody(), JsonObject.class);
|
|
|
+// String orgAuthUrl = getOrgAuthUrlObject.getAsJsonObject("data").get("authUrl").getAsString();
|
|
|
+// System.err.println("企业授权链接:"+orgAuthUrl);
|
|
|
+// /* 查询企业认证授权状态*/
|
|
|
+// EsignHttpResponse getOrgIdentityInfo = getOrgIdentityInfo();
|
|
|
+// JsonObject getOrgIdentityInfoObject = gson.fromJson(getOrgIdentityInfo.getBody(), JsonObject.class);
|
|
|
+// String orgRealnameStatus = getOrgIdentityInfoObject.getAsJsonObject("data").get("realnameStatus").getAsString();//授权状态authorizeUserInfo
|
|
|
+// System.err.println("企业认证状态:"+orgRealnameStatus);
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
|
* 获取个人认证链接
|
|
|
* @return
|
|
|
* @throws EsignDemoException
|
|
|
*/
|
|
|
- public static EsignHttpResponse getPsnAuthUrl() throws EsignDemoException {
|
|
|
+ public static EsignHttpResponse getPsnAuthUrl(String phoneNumber) throws EsignDemoException {
|
|
|
String apiaddr="/v3/psn-auth-url";
|
|
|
//请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
|
|
|
String jsonParm="{\n" +
|
|
|
" \"psnAuthConfig\": {\n" +
|
|
|
- " \"psnAccount\": \"184xxxxx04\",\n" +
|
|
|
+ " \"psnAccount\": \"" + phoneNumber + "\",\n" +
|
|
|
" \"psnAuthPageConfig\": {\n" +
|
|
|
" \"psnEditableFields\": [\n" +
|
|
|
" \"name\",\n" +
|
|
@@ -94,9 +92,8 @@ public class AuthDemo extends Exception {
|
|
|
/**
|
|
|
* 查询个人认证授权状态
|
|
|
*/
|
|
|
- public static EsignHttpResponse getPsnIdentityInfo() throws EsignDemoException {
|
|
|
- String psnAccount="184xxxxx04";
|
|
|
- String apiaddr="/v3/persons/identity-info?psnAccount="+psnAccount;
|
|
|
+ public static EsignHttpResponse getPsnIdentityInfo(String phoneNumber) throws EsignDemoException {
|
|
|
+ String apiaddr="/v3/persons/identity-info?psnAccount="+phoneNumber;
|
|
|
|
|
|
//请求参数body体,json格式。get或者delete请求时jsonString传空json:"{}"或者null
|
|
|
String jsonParm=null;
|