Commit b0337076 by 杨林龙

优化RSA公秘钥生成和使用方式 yangll

1 parent 96ee03a3
...@@ -30,4 +30,6 @@ public interface PlatformCustomerMapper extends OreMapper<PlatformCustomer> { ...@@ -30,4 +30,6 @@ public interface PlatformCustomerMapper extends OreMapper<PlatformCustomer> {
String getAddressStr(@Param("id") Integer id); String getAddressStr(@Param("id") Integer id);
String getPrivateSecret(@Param("appId") int appId); String getPrivateSecret(@Param("appId") int appId);
int register(PlatformCustomer customer);
} }
...@@ -79,7 +79,7 @@ public class CustomerMgrServiceImpl implements CustomerMgrService { ...@@ -79,7 +79,7 @@ public class CustomerMgrServiceImpl implements CustomerMgrService {
String city = customerMapper.getAddressStr(customer.getCity()); String city = customerMapper.getAddressStr(customer.getCity());
String area = customerMapper.getAddressStr(customer.getArea()); String area = customerMapper.getAddressStr(customer.getArea());
customer.setAddress(province + city + area + customer.getAddress()); customer.setAddress(province + city + area + customer.getAddress());
return customerMapper.insertSelective(customer); return customerMapper.register(customer);
} }
@Override @Override
...@@ -106,6 +106,5 @@ public class CustomerMgrServiceImpl implements CustomerMgrService { ...@@ -106,6 +106,5 @@ public class CustomerMgrServiceImpl implements CustomerMgrService {
System.out.println("privateKey = " + enc.encode(privateKey.getEncoded()).length()); 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()));
System.out.println("publicKey = " + enc.encode(publicKey.getEncoded()).length()); System.out.println("publicKey = " + enc.encode(publicKey.getEncoded()).length());
} }
} }
...@@ -35,6 +35,121 @@ ...@@ -35,6 +35,121 @@
create_by, update_by, remark create_by, update_by, remark
</sql> </sql>
<insert id="register" parameterType="cn.com.glsx.openplatform.model.PlatformCustomer">
<selectKey order="AFTER" keyProperty="id" resultType="int">
<!-- 获取最后一次执行insert语句的 key -->
select LAST_INSERT_ID()
</selectKey>
insert into t_platform_secretkey(
public_key,
private_key,
create_time)
values (
#{publicKey,jdbcType=VARCHAR},
#{privateKey,jdbcType=VARCHAR},
now()
);
insert into t_platform_customer
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="customerName != null and customerName != ''">
customer_name,
</if>
<if test="contactPerson != null and contactPerson != ''">
contact_person,
</if>
<if test="password != null and password != ''">
`password`,
</if>
<if test="contactNumber != null and contactNumber != ''">
contact_number,
</if>
<if test="contactEmail != null and contactEmail != ''">
contact_email,
</if>
<if test="province != null">
province,
</if>
<if test="city != null">
city,
</if>
<if test="address != null and address != ''">
address,
</if>
<if test="status != null">
`status`,
</if>
key_id,
<if test="channelNumber != null and channelNumber != ''">
channel_number,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="remark != null and remark != ''">
remark,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="customerName != null and customerName != ''">
#{customerName,jdbcType=VARCHAR},
</if>
<if test="contactPerson != null and contactPerson != ''">
#{contactPerson,jdbcType=VARCHAR},
</if>
<if test="password != null and password != ''">
#{password,jdbcType=VARCHAR},
</if>
<if test="contactNumber != null and contactNumber != ''">
#{contactNumber,jdbcType=VARCHAR},
</if>
<if test="contactEmail != null and contactEmail != ''">
#{contactEmail,jdbcType=VARCHAR},
</if>
<if test="province != null">
#{province,jdbcType=INTEGER},
</if>
<if test="city != null">
#{city,jdbcType=INTEGER},
</if>
<if test="address != null and address != ''">
#{address,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=TINYINT},
</if>
LAST_INSERT_ID(),
<if test="channelNumber != null and channelNumber != ''">
#{channelNumber,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="createBy != null">
#{createBy,jdbcType=INTEGER},
</if>
<if test="updateBy != null">
#{updateBy,jdbcType=INTEGER},
</if>
<if test="remark != null and remark != ''">
#{remark,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="getCustomerMgrList" resultMap="BaseResultMap"> <select id="getCustomerMgrList" resultMap="BaseResultMap">
select a.id, select a.id,
a.customer_name, a.customer_name,
......
...@@ -27,7 +27,7 @@ public class CustomerMgrServiceImplTest { ...@@ -27,7 +27,7 @@ public class CustomerMgrServiceImplTest {
String modulus = RandomUtil.randomNumbers(512); String modulus = RandomUtil.randomNumbers(512);
String exponent = RandomUtil.randomNumbers(64); String exponent = RandomUtil.randomNumbers(64);
PlatformCustomer customer = new PlatformCustomer(); PlatformCustomer customer = new PlatformCustomer();
customer.setCustomerName("yagnll"); customer.setCustomerName("yagnll2");
customer.setAddress(""); customer.setAddress("");
PrivateKey privateKey = RsaUtil.generatePrivateKey(modulus, exponent); PrivateKey privateKey = RsaUtil.generatePrivateKey(modulus, exponent);
PublicKey publicKey = RsaUtil.generatePublicKey(modulus, exponent); PublicKey publicKey = RsaUtil.generatePublicKey(modulus, exponent);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!