Commit 76c1aa41 by 杨林龙

优化RSA秘钥生成方式 yangll

1 parent 1494d65d
...@@ -3,6 +3,8 @@ package cn.com.glsx.openplatform.model; ...@@ -3,6 +3,8 @@ package cn.com.glsx.openplatform.model;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.Column;
import javax.persistence.Table;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
...@@ -17,6 +19,7 @@ import java.util.Date; ...@@ -17,6 +19,7 @@ import java.util.Date;
/** /**
* 广告管理表 * 广告管理表
*/ */
@Table(name = "t_platform_ad")
public class PlatformAd implements Serializable { public class PlatformAd implements Serializable {
/** /**
* 主键 * 主键
...@@ -41,11 +44,13 @@ public class PlatformAd implements Serializable { ...@@ -41,11 +44,13 @@ public class PlatformAd implements Serializable {
/** /**
* 界面类型 1 APP 2 H5 * 界面类型 1 APP 2 H5
*/ */
@Column(name = "interface_type")
private Byte interfaceType; private Byte interfaceType;
/** /**
* 界面参数 * 界面参数
*/ */
@Column(name = "interface_url")
private String interfaceUrl; private String interfaceUrl;
/** /**
...@@ -58,6 +63,7 @@ public class PlatformAd implements Serializable { ...@@ -58,6 +63,7 @@ public class PlatformAd implements Serializable {
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "create_time")
private Date createTime; private Date createTime;
/** /**
...@@ -65,16 +71,19 @@ public class PlatformAd implements Serializable { ...@@ -65,16 +71,19 @@ public class PlatformAd implements Serializable {
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "update_time")
private Date updateTime; private Date updateTime;
/** /**
* 创建人 * 创建人
*/ */
@Column(name = "create_by")
private Integer createBy; private Integer createBy;
/** /**
* 更新人 * 更新人
*/ */
@Column(name = "update_by")
private Integer updateBy; private Integer updateBy;
/** /**
......
...@@ -3,6 +3,8 @@ package cn.com.glsx.openplatform.model; ...@@ -3,6 +3,8 @@ package cn.com.glsx.openplatform.model;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.Column;
import javax.persistence.Table;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
...@@ -17,6 +19,7 @@ import java.util.Date; ...@@ -17,6 +19,7 @@ import java.util.Date;
/** /**
* api管理表 * api管理表
*/ */
@Table(name = "t_platform_api")
public class PlatformApi implements Serializable { public class PlatformApi implements Serializable {
/** /**
* 主键 * 主键
...@@ -26,21 +29,25 @@ public class PlatformApi implements Serializable { ...@@ -26,21 +29,25 @@ public class PlatformApi implements Serializable {
/** /**
* API分类 1 授权管理 2 设备管理 3 数据服务 * API分类 1 授权管理 2 设备管理 3 数据服务
*/ */
@Column(name = "api_classification")
private Integer apiClassification; private Integer apiClassification;
/** /**
* API名称 * API名称
*/ */
@Column(name = "api_name")
private String apiName; private String apiName;
/** /**
* 请求方式 1 GET 2 POST * 请求方式 1 GET 2 POST
*/ */
@Column(name = "request_method")
private Integer requestMethod; private Integer requestMethod;
/** /**
* API接口 * API接口
*/ */
@Column(name = "api_interface")
private String apiInterface; private String apiInterface;
/** /**
...@@ -58,6 +65,7 @@ public class PlatformApi implements Serializable { ...@@ -58,6 +65,7 @@ public class PlatformApi implements Serializable {
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "create_time")
private Date createTime; private Date createTime;
/** /**
...@@ -65,16 +73,19 @@ public class PlatformApi implements Serializable { ...@@ -65,16 +73,19 @@ public class PlatformApi implements Serializable {
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "update_time")
private Date updateTime; private Date updateTime;
/** /**
* 创建人 * 创建人
*/ */
@Column(name = "create_by")
private Integer createBy; private Integer createBy;
/** /**
* 更新人 * 更新人
*/ */
@Column(name = "update_by")
private Integer updateBy; private Integer updateBy;
/** /**
......
...@@ -3,6 +3,8 @@ package cn.com.glsx.openplatform.model; ...@@ -3,6 +3,8 @@ package cn.com.glsx.openplatform.model;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.Column;
import javax.persistence.Table;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
...@@ -17,6 +19,7 @@ import java.util.Date; ...@@ -17,6 +19,7 @@ import java.util.Date;
/** /**
* api调用表 * api调用表
*/ */
@Table(name = "t_platform_api_call")
public class PlatformApiCall implements Serializable { public class PlatformApiCall implements Serializable {
/** /**
* 主键 * 主键
...@@ -46,6 +49,7 @@ public class PlatformApiCall implements Serializable { ...@@ -46,6 +49,7 @@ public class PlatformApiCall implements Serializable {
/** /**
* 调用结果 0 失败 1 成功 * 调用结果 0 失败 1 成功
*/ */
@Column(name = "call_result")
private Integer callResult; private Integer callResult;
/** /**
...@@ -53,11 +57,13 @@ public class PlatformApiCall implements Serializable { ...@@ -53,11 +57,13 @@ public class PlatformApiCall implements Serializable {
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "create_time")
private Date createTime; private Date createTime;
/** /**
* 创建人 * 创建人
*/ */
@Column(name = "create_by")
private Integer createBy; private Integer createBy;
/** /**
......
...@@ -3,6 +3,8 @@ package cn.com.glsx.openplatform.model; ...@@ -3,6 +3,8 @@ package cn.com.glsx.openplatform.model;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.Column;
import javax.persistence.Table;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
...@@ -17,6 +19,7 @@ import java.util.Date; ...@@ -17,6 +19,7 @@ import java.util.Date;
/** /**
* APP下载数量表 * APP下载数量表
*/ */
@Table(name = "t_platform_app_download")
public class PlatformAppDownload implements Serializable { public class PlatformAppDownload implements Serializable {
/** /**
* 主键 * 主键
...@@ -33,11 +36,13 @@ public class PlatformAppDownload implements Serializable { ...@@ -33,11 +36,13 @@ public class PlatformAppDownload implements Serializable {
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "create_time")
private Date createTime; private Date createTime;
/** /**
* 创建人 * 创建人
*/ */
@Column(name = "create_by")
private Integer createBy; private Integer createBy;
/** /**
......
...@@ -3,6 +3,8 @@ package cn.com.glsx.openplatform.model; ...@@ -3,6 +3,8 @@ package cn.com.glsx.openplatform.model;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.Column;
import javax.persistence.Table;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
...@@ -17,6 +19,7 @@ import java.util.Date; ...@@ -17,6 +19,7 @@ import java.util.Date;
/** /**
* 客户管理表 * 客户管理表
*/ */
@Table(name = "t_platform_customer")
public class PlatformCustomer implements Serializable { public class PlatformCustomer implements Serializable {
/** /**
* 主键 * 主键
...@@ -26,11 +29,13 @@ public class PlatformCustomer implements Serializable { ...@@ -26,11 +29,13 @@ public class PlatformCustomer implements Serializable {
/** /**
* 客户名称 * 客户名称
*/ */
@Column(name = "customer_name")
private String customerName; private String customerName;
/** /**
* 联系人 * 联系人
*/ */
@Column(name = "contact_person")
private String contactPerson; private String contactPerson;
/** /**
...@@ -41,11 +46,13 @@ public class PlatformCustomer implements Serializable { ...@@ -41,11 +46,13 @@ public class PlatformCustomer implements Serializable {
/** /**
* 联系电话 * 联系电话
*/ */
@Column(name = "contact_number")
private String contactNumber; private String contactNumber;
/** /**
* 联系邮箱 * 联系邮箱
*/ */
@Column(name = "contact_email")
private String contactEmail; private String contactEmail;
/** /**
...@@ -91,16 +98,19 @@ public class PlatformCustomer implements Serializable { ...@@ -91,16 +98,19 @@ public class PlatformCustomer implements Serializable {
/** /**
* 公钥 * 公钥
*/ */
@Column(name = "public_key")
private String publicKey; private String publicKey;
/** /**
* 私钥 * 私钥
*/ */
@Column(name = "private_key")
private String privateKey; private String privateKey;
/** /**
* 渠道号 * 渠道号
*/ */
@Column(name = "channel_number")
private String channelNumber; private String channelNumber;
/** /**
...@@ -108,6 +118,7 @@ public class PlatformCustomer implements Serializable { ...@@ -108,6 +118,7 @@ public class PlatformCustomer implements Serializable {
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "create_time")
private Date createTime; private Date createTime;
/** /**
...@@ -115,16 +126,19 @@ public class PlatformCustomer implements Serializable { ...@@ -115,16 +126,19 @@ public class PlatformCustomer implements Serializable {
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "update_time")
private Date updateTime; private Date updateTime;
/** /**
* 创建人 * 创建人
*/ */
@Column(name = "create_by")
private Integer createBy; private Integer createBy;
/** /**
* 更新人 * 更新人
*/ */
@Column(name = "update_by")
private Integer updateBy; private Integer updateBy;
/** /**
......
...@@ -3,6 +3,8 @@ package cn.com.glsx.openplatform.model; ...@@ -3,6 +3,8 @@ package cn.com.glsx.openplatform.model;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.Column;
import javax.persistence.Table;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
...@@ -17,6 +19,7 @@ import java.util.Date; ...@@ -17,6 +19,7 @@ import java.util.Date;
/** /**
* 设备管理表 * 设备管理表
*/ */
@Table(name = "t_platform_device")
public class PlatformDevice implements Serializable { public class PlatformDevice implements Serializable {
/** /**
* 主键 * 主键
...@@ -26,11 +29,13 @@ public class PlatformDevice implements Serializable { ...@@ -26,11 +29,13 @@ public class PlatformDevice implements Serializable {
/** /**
* 设备SN * 设备SN
*/ */
@Column(name = "device_sn")
private String deviceSn; private String deviceSn;
/** /**
* 类型 * 类型
*/ */
@Column(name = "device_type")
private String deviceType; private String deviceType;
/** /**
...@@ -48,6 +53,7 @@ public class PlatformDevice implements Serializable { ...@@ -48,6 +53,7 @@ public class PlatformDevice implements Serializable {
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "activat_time")
private Date activatTime; private Date activatTime;
/** /**
...@@ -60,6 +66,7 @@ public class PlatformDevice implements Serializable { ...@@ -60,6 +66,7 @@ public class PlatformDevice implements Serializable {
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "create_time")
private Date createTime; private Date createTime;
/** /**
...@@ -67,16 +74,19 @@ public class PlatformDevice implements Serializable { ...@@ -67,16 +74,19 @@ public class PlatformDevice implements Serializable {
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "update_time")
private Date updateTime; private Date updateTime;
/** /**
* 创建人 * 创建人
*/ */
@Column(name = "create_by")
private Integer createBy; private Integer createBy;
/** /**
* 更新人 * 更新人
*/ */
@Column(name = "update_by")
private Integer updateBy; private Integer updateBy;
/** /**
......
...@@ -3,6 +3,8 @@ package cn.com.glsx.openplatform.model; ...@@ -3,6 +3,8 @@ package cn.com.glsx.openplatform.model;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.Column;
import javax.persistence.Table;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
...@@ -17,6 +19,7 @@ import java.util.Date; ...@@ -17,6 +19,7 @@ import java.util.Date;
/** /**
* 用户管理表 * 用户管理表
*/ */
@Table(name = "t_platform_user")
public class PlatformUser implements Serializable { public class PlatformUser implements Serializable {
/** /**
* 主键 * 主键
...@@ -31,11 +34,13 @@ public class PlatformUser implements Serializable { ...@@ -31,11 +34,13 @@ public class PlatformUser implements Serializable {
/** /**
* 联系电话 * 联系电话
*/ */
@Column(name = "contact_number")
private String contactNumber; private String contactNumber;
/** /**
* 微信ID * 微信ID
*/ */
@Column(name = "wechat_id")
private String wechatId; private String wechatId;
/** /**
...@@ -73,6 +78,7 @@ public class PlatformUser implements Serializable { ...@@ -73,6 +78,7 @@ public class PlatformUser implements Serializable {
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "last_login_time")
private Date lastLoginTime; private Date lastLoginTime;
/** /**
...@@ -85,6 +91,7 @@ public class PlatformUser implements Serializable { ...@@ -85,6 +91,7 @@ public class PlatformUser implements Serializable {
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "create_time")
private Date createTime; private Date createTime;
/** /**
...@@ -92,16 +99,19 @@ public class PlatformUser implements Serializable { ...@@ -92,16 +99,19 @@ public class PlatformUser implements Serializable {
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "update_time")
private Date updateTime; private Date updateTime;
/** /**
* 创建人 * 创建人
*/ */
@Column(name = "create_by")
private Integer createBy; private Integer createBy;
/** /**
* 更新人 * 更新人
*/ */
@Column(name = "update_by")
private Integer updateBy; private Integer updateBy;
/** /**
......
...@@ -4,7 +4,6 @@ import cn.com.glsx.openplatform.model.PlatformUser; ...@@ -4,7 +4,6 @@ import cn.com.glsx.openplatform.model.PlatformUser;
import cn.com.glsx.openplatform.vo.UserVo; import cn.com.glsx.openplatform.vo.UserVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.oreframework.datasource.mybatis.mapper.OreMapper; import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.Date; import java.util.Date;
......
...@@ -3,18 +3,19 @@ package cn.com.glsx.openplatform.service; ...@@ -3,18 +3,19 @@ package cn.com.glsx.openplatform.service;
import cn.com.glsx.openplatform.mapper.PlatformCustomerMapper; import cn.com.glsx.openplatform.mapper.PlatformCustomerMapper;
import cn.com.glsx.openplatform.model.PlatformCustomer; import cn.com.glsx.openplatform.model.PlatformCustomer;
import cn.com.glsx.openplatform.vo.R; import cn.com.glsx.openplatform.vo.R;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.db.Page; import cn.hutool.db.Page;
import com.alibaba.dubbo.config.annotation.Service; import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import net.dreamlu.mica.core.utils.RsaUtil; import net.dreamlu.mica.core.utils.RsaUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import sun.misc.BASE64Encoder;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.security.PrivateKey; import java.security.PrivateKey;
import java.security.PublicKey; import java.security.PublicKey;
import java.util.List; import java.util.List;
import java.util.UUID;
@Service @Service
public class CustomerMgrServiceImpl implements CustomerMgrService { public class CustomerMgrServiceImpl implements CustomerMgrService {
...@@ -57,13 +58,14 @@ public class CustomerMgrServiceImpl implements CustomerMgrService { ...@@ -57,13 +58,14 @@ public class CustomerMgrServiceImpl implements CustomerMgrService {
@Override @Override
public int register(PlatformCustomer customer) { public int register(PlatformCustomer customer) {
String modulus = UUID.randomUUID().toString(); String modulus = RandomUtil.randomNumbers(512);
String exponent = UUID.randomUUID().toString(); String exponent = RandomUtil.randomNumbers(64);
PrivateKey privateKey = RsaUtil.generatePrivateKey(modulus, exponent); PrivateKey privateKey = RsaUtil.generatePrivateKey(modulus, exponent);
PublicKey publicKey = RsaUtil.generatePublicKey(modulus, exponent); PublicKey publicKey = RsaUtil.generatePublicKey(modulus, exponent);
customer.setPrivateKey(privateKey.getAlgorithm()); BASE64Encoder enc = new BASE64Encoder();
customer.setPublicKey(publicKey.getAlgorithm()); customer.setPrivateKey(enc.encode(privateKey.getEncoded()));
customer.setPublicKey(enc.encode(publicKey.getEncoded()));
String province = customerMapper.getAddressStr(customer.getProvince()); String province = customerMapper.getAddressStr(customer.getProvince());
String city = customerMapper.getAddressStr(customer.getCity()); String city = customerMapper.getAddressStr(customer.getCity());
...@@ -81,4 +83,21 @@ public class CustomerMgrServiceImpl implements CustomerMgrService { ...@@ -81,4 +83,21 @@ public class CustomerMgrServiceImpl implements CustomerMgrService {
public List<String> getAddressOptionList(int id) { public List<String> getAddressOptionList(int id) {
return customerMapper.getAddressOptionList(id); return customerMapper.getAddressOptionList(id);
} }
public static void main(String[] args) {
// String modulus = UUID.randomUUID().toString().replaceAll("-", "");
// String exponent = UUID.randomUUID().toString().replaceAll("-", "");
String modulus = RandomUtil.randomNumbers(512);
String exponent = RandomUtil.randomNumbers(64);
// String emodulus1 = "121312131213121312131213121312131121312131213213121312131213121312131213121312131213121312131213112131213121321312131213121312131213121312131213121312121312131213121312131213121312131121312131213213121";
// String exponent1 = "121312131213121312131213121312131121312131213213121312131213121312131213121312131213121312131213112131213121321312131213121312131213121312131213121312121312131213121312131213121312131121312131213";
PrivateKey privateKey = RsaUtil.generatePrivateKey(modulus, exponent);
PublicKey publicKey = RsaUtil.generatePublicKey(modulus, exponent);
BASE64Encoder enc = new BASE64Encoder();
System.out.println("privateKey = " + enc.encode(privateKey.getEncoded()));
System.out.println("privateKey = " + enc.encode(privateKey.getEncoded()).length());
System.out.println("publicKey = " + enc.encode(publicKey.getEncoded()));
System.out.println("publicKey = " + enc.encode(publicKey.getEncoded()).length());
}
} }
package cn.com.glsx.openplatform.service;
import cn.com.glsx.openplatform.Main;
import cn.com.glsx.openplatform.model.PlatformCustomer;
import cn.hutool.core.util.RandomUtil;
import net.dreamlu.mica.core.utils.RsaUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.annotation.Resource;
import java.security.PrivateKey;
import java.security.PublicKey;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Main.class)
public class CustomerMgrServiceImplTest {
@Resource
private CustomerMgrService customerMgrService;
@Test
public void register() {
String modulus = RandomUtil.randomNumbers(512);
String exponent = RandomUtil.randomNumbers(64);
PlatformCustomer customer = new PlatformCustomer();
customer.setCustomerName("yagnll");
customer.setAddress("");
PrivateKey privateKey = RsaUtil.generatePrivateKey(modulus, exponent);
PublicKey publicKey = RsaUtil.generatePublicKey(modulus, exponent);
customer.setPrivateKey(privateKey.getAlgorithm());
customer.setPublicKey(publicKey.getAlgorithm());
customerMgrService.register(customer);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!