应用管理

This commit is contained in:
liulu
2024-11-01 15:51:47 +08:00
parent b5df4c2406
commit c82f7d8013
12 changed files with 296 additions and 42 deletions
@@ -0,0 +1,37 @@
package com.sunyard.chsm.mapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sunyard.chsm.model.entity.AppService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.util.CollectionUtils;
import java.util.Collections;
import java.util.List;
/**
* @author liulu
* @since 2024/10/29
*/
@Mapper
public interface AppServiceMapper extends BaseMapper<AppService> {
default List<AppService> selectByAppIds(List<Long> appIds) {
if (CollectionUtils.isEmpty(appIds)) {
return Collections.emptyList();
}
return selectList(
new LambdaQueryWrapper<AppService>()
.in(AppService::getApplicationId, appIds)
);
}
default void deleteByAppId(Long appId) {
delete(
new LambdaQueryWrapper<AppService>()
.eq(AppService::getApplicationId, appId)
);
}
}
@@ -0,0 +1,24 @@
package com.sunyard.chsm.model.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @author liulu
* @since 2024/10/31
*/
@Data
@TableName("sp_app_service")
public class AppService {
private Long id;
private Long applicationId;
private Long serviceId;
private String remark;
private LocalDateTime createTime;
private LocalDateTime updateTime;
}
@@ -15,12 +15,11 @@ public class Application {
private Long id;
private String name;
private String bindService;
private String status;
// 32位uuid
private String appKey;
// 32位uuid
private String appSecrete;
private String appSecret;
private Long creatorId;
private String remark;
@@ -42,15 +42,11 @@ public class BCSdfApiService implements SdfApiService {
BCECPrivateKey priKey = (BCECPrivateKey) keyPair.getPrivate();
byte[] x = pubKey.getQ().getXCoord().getEncoded();
byte[] y = pubKey.getQ().getYCoord().getEncoded();
byte[] d = BigIntegers.asUnsignedByteArray(64, priKey.getD());
byte[] d = BigIntegers.asUnsignedByteArray(32, priKey.getD());
return new EccKey(new EccPubKey(256, x, y), new EccPriKey(256, d));
}
@Override
public EccKey genEccKeyPairAndEncByKek() {
return null;
}
@Override
public byte[] calculateMAC(byte[] symKey, byte[] pucIv, byte[] pucData) {
@@ -75,12 +71,12 @@ public class BCSdfApiService implements SdfApiService {
}
@Override
public byte[] encryptByMKNoPadding(byte[] data) {
public byte[] encryptByMK(byte[] data) {
return data;
}
@Override
public byte[] decryptByMKNoPadding(byte[] data) {
public byte[] decryptByMK(byte[] data) {
return data;
}
@@ -25,14 +25,6 @@ public interface SdfApiService {
*/
EccKey genKeyPairEcc();
/**
* 产生ECC加密密钥对并使用kek加密私钥输出
*
* @return pubKey 返回公钥 | priKey 返回私钥
*/
EccKey genEccKeyPairAndEncByKek();
/**
* 计算MAC
*
@@ -46,15 +38,14 @@ public interface SdfApiService {
byte[] hmac(byte[] key, byte[] srcData);
/**
* 多包杂凑运算
* 杂凑运算
*
* @param pucData 缓冲区指针,用于存放输入的数据明文
* @return hash值
*/
byte[] hash(byte[] pucData);
byte[] encryptByMK(byte[] data);
byte[] encryptByMKNoPadding(byte[] data);
byte[] decryptByMKNoPadding(byte[] data);
byte[] decryptByMK(byte[] data);
}