package com.panzhihua.common.utlis;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import java.util.Base64;
|
|
/**
|
* @program: springcloud_k8s_panzhihuazhihuishequ
|
* @description: 实名认证工具
|
* @author: huang.hongfa weixin hhf9596 qq 959656820
|
* @create: 2021-01-08 09:45
|
**/
|
public class RealNameUtil {
|
private static final String CLIENT_ID="2092261934651932672";
|
private static final String SECRET="de1c0dbb-9197-4724-9cc2-aa94e30a072f";
|
private static final String URL="http://118.121.56.56:18080/users/auth/policeMatch";
|
|
|
/**
|
* 实名认证
|
* @param idcard 身份证
|
* @param name 名字
|
* @return 认证结果 true false
|
*/
|
public static boolean authentication(String idcard,String name){
|
boolean result=false;
|
String headerkey="Authorization";
|
String headervalue="Basic ";
|
String basicStr = CLIENT_ID + ":" + SECRET + ":" + System.currentTimeMillis();
|
String encodeToString = Base64.getEncoder().encodeToString(basicStr.getBytes());
|
JSONObject jsonObject=new JSONObject();
|
jsonObject.put("idNumber",idcard);
|
jsonObject.put("realName",name);
|
String param=jsonObject.toJSONString();
|
String postByJson = HttpClientUtil.sendPostByJson(URL, param, 0, headerkey, headervalue + encodeToString);
|
int code = JSONObject.parseObject(postByJson).getIntValue("code");
|
if (0==code) {
|
result =true;
|
}
|
return result;
|
}
|
|
public static void main(String[] args) {
|
boolean b = RealNameUtil.authentication("340823199112282557", "黄宏发f");
|
System.out.println(b);
|
}
|
|
}
|