Commit 4ae52f29 by liulianglang

单点登录,用户姓名,撤控

parent 1301bb61
...@@ -54,4 +54,25 @@ public class gjcxController { ...@@ -54,4 +54,25 @@ public class gjcxController {
} }
} }
@PostMapping("/deleteBkzp")
public R deleteBkzp(String certNo){
try {
return R.ok().data(ztService.deleteBkzp(certNo));
} catch (Exception e) {
e.printStackTrace();
return R.error(e.getMessage());
}
}
@PostMapping("/deleteYjjl")
public R deleteYjjl(String xxzjbh){
try {
return R.ok().data(ztService.deleteYjjl(xxzjbh));
} catch (Exception e) {
e.printStackTrace();
return R.error(e.getMessage());
}
}
} }
package org.springblade.founder.ztrxyj.entity;
import lombok.Data;
import java.util.Date;
@Data
public class ZtryYjYhcz {
/**
* 信息主键
*/
private String xxzjbh;
/**
* 信息主键
*/
private String glxxzjbh;
/**
* 信息登记人员_姓名
*/
private String xxdjryXm;
/**
* 信息登记人员_联系电话
*/
private String xxdjryLxdh;
/**
* 信息登记单位_公安机关名称
*/
private String xxdjdwGajgmc;
/**
* 信息登记人员_公民身份号码
*/
private String xxdjryGmsfhm;
/**
* 信息登记单位_公安机关机构代码
*/
private String xxdjdwGajgjgdm;
/**
* 登记时间
*/
private Date djsj;
/**
* 操作类型:1删除
*/
private String czlx;
}
...@@ -21,7 +21,25 @@ public class Ztryyjxx { ...@@ -21,7 +21,25 @@ public class Ztryyjxx {
private String score; private String score;
private String captureTime; private String captureTime;
private String captureTimeKssj; private String captureTimeKssj;
private String scrxm;
public String getScrxm() {
return scrxm;
}
public void setScrxm(String scrxm) {
this.scrxm = scrxm;
}
public String getScrdwmc() {
return scrdwmc;
}
public void setScrdwmc(String scrdwmc) {
this.scrdwmc = scrdwmc;
}
private String scrdwmc;
public String getCaptureTimeKssj() { public String getCaptureTimeKssj() {
return captureTimeKssj; return captureTimeKssj;
} }
...@@ -47,6 +65,16 @@ public class Ztryyjxx { ...@@ -47,6 +65,16 @@ public class Ztryyjxx {
private String deviceId; private String deviceId;
private String deviceName; private String deviceName;
private String captureUrl; private String captureUrl;
public String getScbz() {
return scbz;
}
public void setScbz(String scbz) {
this.scbz = scbz;
}
private String scbz;
private int page; private int page;
......
...@@ -3,6 +3,7 @@ package org.springblade.founder.ztrxyj.mapper; ...@@ -3,6 +3,7 @@ package org.springblade.founder.ztrxyj.mapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.springblade.founder.ztrxyj.entity.ZtryBksj; import org.springblade.founder.ztrxyj.entity.ZtryBksj;
import org.springblade.founder.ztrxyj.entity.ZtryYjYhcz;
import org.springblade.founder.ztrxyj.entity.Ztryyjxx; import org.springblade.founder.ztrxyj.entity.Ztryyjxx;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -23,4 +24,10 @@ public interface ztgjMapper { ...@@ -23,4 +24,10 @@ public interface ztgjMapper {
List<ZtryBksj> getBkzpList(ZtryBksj ztryBksj); List<ZtryBksj> getBkzpList(ZtryBksj ztryBksj);
int getBkzpListCount(ZtryBksj ztryBksj); int getBkzpListCount(ZtryBksj ztryBksj);
ZtryBksj getMaztryZp(String certNo);
int updatesftsZtzp(String certNo);
int insertYjYhcz(ZtryYjYhcz ztryYjYhcz);
int updateYjsc(String xxzjbh);
} }
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.founder.ztrxyj.mapper.ztgjMapper"> <mapper namespace="org.springblade.founder.ztrxyj.mapper.ztgjMapper">
<insert id="insertYjYhcz">
insert into tb_maztry_yj_yhcz(xxzjbh,glxxzjbh, xxdjry_xm, xxdjry_lxdh, xxdjdw_gajgmc, xxdjry_gmsfhm, xxdjdw_gajgjgdm, djsj, czlx)
values (#{xxzjbh},#{glxxzjbh}, #{xxdjryXm}, #{xxdjryLxdh}, #{xxdjdwGajgmc}, #{xxdjryGmsfhm}, #{xxdjdwGajgjgdm}, now(), #{czlx})
</insert>
<update id="updatesftsZtzp">
update tb_ry_maztryzp set sfts = '3' ,gxsj=now()
where identitycard=#{ certNo , jdbcType=VARCHAR }
</update>
<update id="updateYjsc">
update tb_maztry_yj set scbz='1',gxsj=now() where xxzjbh = #{xxzjbh}
</update>
<select id="getListYjgj" resultType="org.springblade.founder.ztrxyj.entity.Ztryyjxx"> <select id="getListYjgj" resultType="org.springblade.founder.ztrxyj.entity.Ztryyjxx">
select xxzjbh, faceName, faceUrl, score, captureTime, select xxzjbh, faceName, faceUrl, score, captureTime,
faceDbId, faceCertNo, alarmTime, faceDbName, panoramaUrl, deviceId, deviceName, captureUrl from tb_maztry_yj yj right join ( faceDbId, faceCertNo, alarmTime, faceDbName, panoramaUrl, deviceId, deviceName,
select captureUrl from tb_maztry_yj yj right join (
faceCertNo idcard, max(captureTime) zpsj
from tb_maztry_yj select idcard,zpsj from ( select
faceCertNo idcard, max(captureTime) zpsj
from tb_maztry_yj
<where> <where>
<if test="xxzjbh != null and xxzjbh != ''"> and scbz='0'
<if test="xxzjbh != null and xxzjbh != ''">
and xxzjbh = #{xxzjbh} and xxzjbh = #{xxzjbh}
</if> </if>
<if test="faceName != null and faceName != ''"> <if test="faceName != null and faceName != ''">
...@@ -23,10 +40,10 @@ from tb_maztry_yj ...@@ -23,10 +40,10 @@ from tb_maztry_yj
and captureTime = #{captureTime} and captureTime = #{captureTime}
</if> </if>
<if test="captureTimeKssj != null and captureTimeKssj != ''"> <if test="captureTimeKssj != null and captureTimeKssj != ''">
and captureTime <![CDATA[>=]]> DATE_FORMAT(#{captureTimeKssj,jdbcType=VARCHAR},'%Y-%m-%d %H:%i:%s') and captureTime <![CDATA[>=]]> DATE_FORMAT(#{captureTimeKssj,jdbcType=VARCHAR},'%Y-%m-%d %H:%i:%s')
</if> </if>
<if test="captureTimeJssj != null and captureTimeJssj != ''"> <if test="captureTimeJssj != null and captureTimeJssj != ''">
and captureTime <![CDATA[<]]> DATE_FORMAT(#{captureTimeJssj,jdbcType=VARCHAR},'%Y-%m-%d %H:%i:%s') and captureTime <![CDATA[<]]> DATE_FORMAT(#{captureTimeJssj,jdbcType=VARCHAR},'%Y-%m-%d %H:%i:%s')
</if> </if>
<if test="faceDbId != null and faceDbId != ''"> <if test="faceDbId != null and faceDbId != ''">
and faceDbId = #{faceDbId} and faceDbId = #{faceDbId}
...@@ -50,16 +67,21 @@ from tb_maztry_yj ...@@ -50,16 +67,21 @@ from tb_maztry_yj
</where> </where>
group by faceCertNo order by zpsj desc limit #{ page }, #{ limit } group by
) bb on yj.faceCertNo=bb.idcard and yj.captureTime=bb.zpsj faceCertNo ) abc left join tb_ry_maztryzp zp on zp.identitycard=abc.idcard where zp.sfts='1'
order
by abc.zpsj desc limit #{ page }, #{ limit }
) bb on yj.faceCertNo=bb.idcard and yj.captureTime=bb.zpsj
</select> </select>
<select id="getListYjgjCount" resultType="java.lang.Integer"> <select id="getListYjgjCount" resultType="java.lang.Integer">
select count(1) from ( select select count(1) from ( select idcard,zpsj from ( select
faceCertNo idcard, max(captureTime) zpsj faceCertNo idcard, max(captureTime) zpsj
from tb_maztry_yj from tb_maztry_yj
<where> <where>
and scbz='0'
<if test="xxzjbh != null and xxzjbh != ''"> <if test="xxzjbh != null and xxzjbh != ''">
and xxzjbh = #{xxzjbh} and xxzjbh = #{xxzjbh}
</if> </if>
...@@ -74,10 +96,10 @@ from tb_maztry_yj ...@@ -74,10 +96,10 @@ from tb_maztry_yj
and captureTime = #{captureTime} and captureTime = #{captureTime}
</if> </if>
<if test="captureTimeKssj != null and captureTimeKssj != ''"> <if test="captureTimeKssj != null and captureTimeKssj != ''">
and captureTime <![CDATA[>=]]> DATE_FORMAT(#{captureTimeKssj,jdbcType=VARCHAR},'%Y-%m-%d %H:%i:%s') and captureTime <![CDATA[>=]]> DATE_FORMAT(#{captureTimeKssj,jdbcType=VARCHAR},'%Y-%m-%d %H:%i:%s')
</if> </if>
<if test="captureTimeJssj != null and captureTimeJssj != ''"> <if test="captureTimeJssj != null and captureTimeJssj != ''">
and captureTime <![CDATA[<]]> DATE_FORMAT(#{captureTimeJssj,jdbcType=VARCHAR},'%Y-%m-%d %H:%i:%s') and captureTime <![CDATA[<]]> DATE_FORMAT(#{captureTimeJssj,jdbcType=VARCHAR},'%Y-%m-%d %H:%i:%s')
</if> </if>
<if test="faceDbId != null and faceDbId != ''"> <if test="faceDbId != null and faceDbId != ''">
and faceDbId = #{faceDbId} and faceDbId = #{faceDbId}
...@@ -101,14 +123,21 @@ from tb_maztry_yj ...@@ -101,14 +123,21 @@ from tb_maztry_yj
</where> </where>
group by
group by faceCertNo ) bb faceCertNo ) abc left join tb_ry_maztryzp zp on zp.identitycard=abc.idcard where zp.sfts='1'
) bb
</select> </select>
<select id="getListYjXqgj" resultType="org.springblade.founder.ztrxyj.entity.Ztryyjxx"> <select id="getListYjXqgj" resultType="org.springblade.founder.ztrxyj.entity.Ztryyjxx">
select xxzjbh, faceName, faceUrl, score, captureTime, select xxzjbh, faceName, faceUrl, score, captureTime,
faceDbId, faceCertNo, alarmTime, faceDbName, panoramaUrl, deviceId, deviceName, captureUrl faceDbId, faceCertNo, alarmTime, faceDbName, panoramaUrl, deviceId, deviceName, captureUrl,
(select cz.xxdjry_xm from tb_maztry_yj_yhcz cz where cz.glxxzjbh=yj.xxzjbh limit 1 ) scrxm,
(select cz.xxdjdw_gajgmc from tb_maztry_yj_yhcz cz where cz.glxxzjbh=yj.xxzjbh limit 1) scrdwmc
from tb_maztry_yj yj from tb_maztry_yj yj
<where> <where>
<if test="scbz != null and scbz != ''">
and scbz=#{scbz}
</if>
<if test="xxzjbh != null and xxzjbh != ''"> <if test="xxzjbh != null and xxzjbh != ''">
and xxzjbh = #{xxzjbh} and xxzjbh = #{xxzjbh}
</if> </if>
...@@ -155,6 +184,10 @@ group by faceCertNo ) bb ...@@ -155,6 +184,10 @@ group by faceCertNo ) bb
<select id="getListYjXqgjCount" resultType="java.lang.Integer"> <select id="getListYjXqgjCount" resultType="java.lang.Integer">
select count(1) from tb_maztry_yj yj select count(1) from tb_maztry_yj yj
<where> <where>
<if test="scbz != null and scbz != ''">
and scbz=#{scbz}
</if>
<if test="xxzjbh != null and xxzjbh != ''"> <if test="xxzjbh != null and xxzjbh != ''">
and xxzjbh = #{xxzjbh} and xxzjbh = #{xxzjbh}
</if> </if>
...@@ -219,6 +252,10 @@ group by faceCertNo ) bb ...@@ -219,6 +252,10 @@ group by faceCertNo ) bb
and xm = #{name} and xm = #{name}
</if> </if>
</select> </select>
<select id="getMaztryZp" resultType="org.springblade.founder.ztrxyj.entity.ZtryBksj">
select ztry.xm as name,ztry.identitycard as certNo ,ztry.ckzp as imgFace from tb_ry_maztryzp ztry
where ztry.identitycard=#{certNo}
</select>
</mapper> </mapper>
...@@ -14,5 +14,7 @@ public interface ztgjService { ...@@ -14,5 +14,7 @@ public interface ztgjService {
Map<String, Object> getBkzpList(ZtryBksj ztryBksj); Map<String, Object> getBkzpList(ZtryBksj ztryBksj);
Map<String, Object> deleteBkzp(String certNo);
Map<String, Object> deleteYjjl(String xxzjbh);
} }
...@@ -4,13 +4,17 @@ import com.alibaba.fastjson.JSONArray; ...@@ -4,13 +4,17 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springblade.core.secure.utils.SecureUtil;
import org.springblade.founder.utils.EasyUIPage; import org.springblade.founder.utils.EasyUIPage;
import org.springblade.founder.utils.HttpClient; import org.springblade.founder.utils.HttpClient;
import org.springblade.founder.utils.R; import org.springblade.founder.utils.R;
import org.springblade.founder.ztrxyj.entity.ZtryBksj; import org.springblade.founder.ztrxyj.entity.ZtryBksj;
import org.springblade.founder.ztrxyj.entity.ZtryYjYhcz;
import org.springblade.founder.ztrxyj.entity.Ztryyjxx; import org.springblade.founder.ztrxyj.entity.Ztryyjxx;
import org.springblade.founder.ztrxyj.mapper.ztgjMapper; import org.springblade.founder.ztrxyj.mapper.ztgjMapper;
import org.springblade.founder.ztrxyj.utils.TokenUtils;
import org.springblade.modules.system.entity.XzxtUser;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -66,6 +70,81 @@ public class ztgjServiceImpl implements ztgjService { ...@@ -66,6 +70,81 @@ public class ztgjServiceImpl implements ztgjService {
} }
@Override @Override
public Map<String, Object> deleteBkzp(String certNo) {
ZtryBksj sj=ztgj.getMaztryZp(certNo);
String url = "http://74.10.30.174:18093/govServerWeb/personFace/pictureToFaceDb";
String token="";
if(sj!=null) {
if(StringUtils.isEmpty(token)){
token= TokenUtils.getHnKyToken();
}
Map herders=new HashMap();
//设置请求的header参数
herders.put("Authorization",token);
herders.put("Content-Type","application/json");
//推送布控入库人像
// JSONObject params = new JSONObject();// 请求参数
// params.put("imgFace",imgFace);
// params.put("captureBeginTime"
// ,gxsjKssj);
// params.put("captureEndTime",gxsjJssj);
// params.put("","");
sj.setImgFace(sj.getImgFace().replaceAll("\\s*|\r|\n|\t",""));
// System.out.println(sj.getImgFace());
sj.setOperate("0");
sj.setFaceDBId("700046010603000104");
try {
String resultString = HttpClient.doPostJson(url, herders, JSONObject.toJSONString(sj));
System.out.println("bksjts==="+resultString);
JSONObject result=JSONObject.parseObject(resultString);
if(result.getInteger("code")==200){
ztgj.updatesftsZtzp(certNo);
}else {
//推送未成功2,删除3,推送成功1
ztgj.updatesftsZtzp(certNo);
}
}catch (Exception e){
e.printStackTrace();
}
}
return null;
}
@Override
public Map<String, Object> deleteYjjl(String xxzjbh) {
XzxtUser user = SecureUtil.getUserXzxt();
ZtryYjYhcz yhcz=new ZtryYjYhcz();
yhcz.setXxzjbh(getOrderIdByUuid());
yhcz.setGlxxzjbh(xxzjbh);
yhcz.setXxdjryXm(user.getRealname());
yhcz.setXxdjdwGajgjgdm(user.getUnitcode());
yhcz.setXxdjdwGajgmc(user.getUnitname());
yhcz.setXxdjryGmsfhm(user.getIdentitycard());
yhcz.setXxdjryLxdh(user.getPhone());
yhcz.setCzlx("1"); //删除
ztgj.updateYjsc(xxzjbh);
ztgj.insertYjYhcz(yhcz);
return null;
}
private static String getOrderIdByUuid() {
//最大支持1-9个集群机器部署
int machineId = 1;
int hashCodeV = UUID.randomUUID().toString().hashCode();
//有可能是负数
if (hashCodeV < 0) {
hashCodeV = -hashCodeV;
}
// 0 代表前面补充0
// 4 代表长度为4
// d 代表参数为正数型
return machineId + String.format("%015d", hashCodeV);
}
@Override
public Map<String, Object> getListYjXqgj(Ztryyjxx ztryyjxx) { public Map<String, Object> getListYjXqgj(Ztryyjxx ztryyjxx) {
Map<String, Object> rtMap = new HashMap<>(); Map<String, Object> rtMap = new HashMap<>();
EasyUIPage easyUIPage = new EasyUIPage(); EasyUIPage easyUIPage = new EasyUIPage();
......
package org.springblade.founder.ztrxyj.utils;
import cn.hutool.core.exceptions.ExceptionUtil;
import lombok.extern.slf4j.Slf4j;
import java.io.*;
import java.util.Properties;
@Slf4j
public class PropertieUtil {
/**
* 读取配置文件某属性绝对路径下的token
*/
public String readTokenValue(String key, String url) {
String value = "";
try {
Properties prop = new Properties();
// FileInputStream fileInputStream = new FileInputStream(url);
InputStream fileInputStream = this.getClass().getResourceAsStream("/token.properties");
prop.load(fileInputStream);
value = prop.getProperty(key);
fileInputStream.close();
} catch (Exception e) {
e.printStackTrace();
log.error(ExceptionUtil.getMessage(e));
}
return value;
}
/**
* 将值写入配置文件绝对路径下的token
*/
public void writeTokenProperties(String token_url, String parameterName, String parameterValue) throws Exception {
String filePath = token_url;
// 获取配置文件
Properties pps = new Properties();
// FileInputStream fileInputStream = new FileInputStream(filePath);
InputStream fileInputStream = this.getClass().getResourceAsStream("/token.properties");
InputStream in = new BufferedInputStream(fileInputStream);
InputStreamReader inputStreamReader = new InputStreamReader(in, "UTF-8");
pps.load(inputStreamReader);
inputStreamReader.close();
in.close();
fileInputStream.close();
//true表示追加打开,false表示每次都是清空重写
OutputStream out = new FileOutputStream(filePath);
// 设置配置名称和值
pps.setProperty(parameterName, parameterValue);
// comments 等于配置文件的注释
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(out, "UTF-8");
pps.store(outputStreamWriter, "Update " + parameterName + " name");
out.flush();
outputStreamWriter.close();
out.close();
}
}
package org.springblade.founder.ztrxyj.utils;
import org.apache.commons.codec.binary.Base64;
import java.security.*;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
/**
* SHA1WithRSA-数字签名工具类
* Created by yangyang on 2022/04/27.
*/
public class RsaUtil {
//加密算法
public static final String SIGN_ALGORITHMS = "SHA1WithRSA";
//私钥
private static final String privateKey = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANF/IIsbi9+v5V0VlXeDWp3LlWNXf1gQ3EYjbdj4qMJJoVaLUv2T6fsQq4MTGO6h0HaPQPb80g2VXXgtwOBAGhTN5ifi8VLkHp8h+sU3/hmR2q3eyUeUEaX8t53leWQiI462O23bysectI5lmqzkL/68LTzSpu8z308XSWOFdXKVAgMBAAECgYA7qjIxjCndDjKLvT7xZ8aiFD46qcvJ4BtsGmEJn2Ao3WGGzW1YbQ0BhTDjxseeBxXg/lGpRj3ownZ5aMZ616bVa8xFdI9agmElnM78RhUgJNtOelY4yB3vMQmdpYxhA6Zp+Z10DCvKyxiostqrLw/zdSr8ZkmRof1DUMml5FZzYQJBAPe8zQsHqXeGSjvAEpPpBX87Wzc7/T6tObuOokxOrWfPmZFO7qy2rsdOkmn8LghIhzvOognoT6DiBhO4UIgJAMkCQQDYe9Kfju7JhbhE0SRh+1hSRRV8+6vRmpTIxJpy+AN3Oc6oeiQ6UE7/ZxyeZ0pDgmBZGJDBHoX1rIYrsuMmgrVtAkEA0YwHO88tTwZuAABFNoshtS71xtCdMsi/TqAlM7pQ/sAgu0IyrDCRwc/6FF/UZ/lBOhtcAFlaEVFdpox+wbIr0QJBAM9BJHF7ruKiMbs4m2Nu9ay11Q+2BlYCb0US7Gb7SJ4hatdjMEHf1vGvrvd8Hd4p+MHzwcoRxeBhToaRmeSpqLUCQFFTCNRlE/0Qo8hKLJlu8NpN00/VznTp+llGsSelmpOJ3QVWWoFR4egxfkvS5k+lU3Xwwu4ljXh7gLxPRfTprgk=";
//公钥
private static final String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDRfyCLG4vfr+VdFZV3g1qdy5VjV39YENxGI23Y+KjCSaFWi1L9k+n7EKuDExjuodB2j0D2/NINlV14LcDgQBoUzeYn4vFS5B6fIfrFN/4Zkdqt3slHlBGl/Led5XlkIiOOtjtt28rHnLSOZZqs5C/+vC080qbvM99PF0ljhXVylQIDAQAB";
/**
* 使用私钥给入参签名
* @param param 签名的数据
* @return 返回入参签名16进制字符串
* */
public static String sign(String param) {
try {
//获取privatekey
byte[] privateKeyByte = new Base64().decode(privateKey);
KeyFactory keyfactory = KeyFactory.getInstance("RSA");
PKCS8EncodedKeySpec encoderule = new PKCS8EncodedKeySpec(privateKeyByte);
PrivateKey key = keyfactory.generatePrivate(encoderule);
//用私钥给入参加签
Signature sign = Signature.getInstance(SIGN_ALGORITHMS);
sign.initSign(key);
sign.update(param.getBytes());
byte[] signature = sign.sign();
//将签名的入参转换成16进制字符串
return Base64.encodeBase64String(signature);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 用公钥验证签名
* @param param 入参
* @param signature 使用私钥签名的入参字符串
* @param publicKey 公钥
* @return 返回验证结果
* */
// public static boolean verifyRes(String param,String signature,String publicKey){
// try {
// //获取公钥
// KeyFactory keyFactory=KeyFactory.getInstance("RSA");
// byte[] publicKeyByte= new Base64().decode(publicKey);
// X509EncodedKeySpec encodeRule=new X509EncodedKeySpec(publicKeyByte);
// PublicKey key= keyFactory.generatePublic(encodeRule);
//
// //用获取到的公钥对 入参中未加签参数param入参中的加签之后的参数signature进行验签
// Signature sign=Signature.getInstance(SIGN_ALGORITHMS);
// sign.initVerify(key);
// sign.update(param.getBytes());
//
// //将16进制码转成字符数组
// byte[] hexByte = Base64.decodeBase64(signature);
// //验证签名
// return sign.verify(hexByte);
//
// } catch (Exception e) {
// e.printStackTrace();
// }
// return false;
// }
/**
* byte数组转换成十六进制字符串
* @param bytes byte数组
* @return 返回十六进制字符串
*/
private static String bytesToHexStr(byte[] bytes) {
StringBuffer stringBuffer = new StringBuffer("");
for (int i = 0; i < bytes.length; ++i) {
stringBuffer.append(Integer.toHexString(0x0100 + (bytes[i] & 0x00FF)).substring(1).toUpperCase());
}
return stringBuffer.toString();
}
/**
* 十六进制字符串转成byte数组
* @param hexStr 十六进制字符串
* @return 返回byte数组
* */
private static byte[] hexStrToBytes(String hexStr) {
byte[] bytes = new byte[hexStr.length() / 2];
for (int i = 0; i < bytes.length; i++) {
bytes[i] = (byte) Integer.parseInt(hexStr.substring(2 * i, 2 * i + 2), 16);
}
return bytes;
}
public static void main(String[] args) {
String param = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI3NC4xMC4zMC4xNzQiLCJpc3MiOiJ0b2tlbi5idWlsZGVyIiwiaWF0IjoxNjUxMjIyOTcwfQ.WIbBf23zZ-KKpCbOX9z6qX0Tqzyanl_WBnvE8YWyle4.xingjdj";
String sign = sign(param);
System.out.println("签名后的参数>>>"+sign);
// System.out.println("验证结果>>>"+verifyRes(param,sign,publicKey));
}
}
...@@ -123,7 +123,7 @@ public class AuthController { ...@@ -123,7 +123,7 @@ public class AuthController {
if (StringUtils.isNotEmpty(username)) {//用户名不为空时继续验证 if (StringUtils.isNotEmpty(username)) {//用户名不为空时继续验证
SysNewUser user = new SysNewUser(); SysNewUser user = new SysNewUser();
user.setUsername(username); user.setUsername(username);
user.setTrueName(jsonObj.getString("realname")); user.setTrueName(jsonObj.getString("trueName"));
user.setIdentitycard(jsonObj.getString("identitycard")); user.setIdentitycard(jsonObj.getString("identitycard"));
user.setUnitcode(jsonObj.getString("unitcode")); user.setUnitcode(jsonObj.getString("unitcode"));
user.setUnitname(jsonObj.getString("unitname")); user.setUnitname(jsonObj.getString("unitname"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment