密钥管理接口
This commit is contained in:
@@ -8,15 +8,16 @@ import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 数据的填充模式
|
||||
*
|
||||
* @author Cheney
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum Padding {
|
||||
NOPadding("NoPadding", "NoPadding"),
|
||||
PCKS5Padding( "PKCS5Padding", "PKCS5Padding"),
|
||||
PCKS7Padding( "PKCS7Padding", "PKCS7Padding"),
|
||||
;
|
||||
PCKS5Padding("PKCS5Padding", "PKCS5Padding"),
|
||||
PCKS7Padding("PKCS7Padding", "PKCS7Padding"),
|
||||
;
|
||||
|
||||
private final String code;
|
||||
private final String desc;
|
||||
|
||||
@@ -14,6 +14,8 @@ public interface KeyInfoService {
|
||||
|
||||
Page<KeyInfoDTO.KeyView> selectPageList(KeyInfoDTO.Query query);
|
||||
|
||||
KeyInfoDTO.KeyView selectById(Long id);
|
||||
|
||||
Long save(KeyInfoDTO.KeySave save);
|
||||
|
||||
void update(KeyInfoDTO.KeyUpdate update);
|
||||
|
||||
@@ -158,6 +158,35 @@ public class KeyInfoServiceImpl implements KeyInfoService {
|
||||
return new Page<KeyInfoDTO.KeyView>(page.getCurrent(), page.getSize(), page.getTotal()).setRecords(viewList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyInfoDTO.KeyView selectById(Long id) {
|
||||
KeyInfo keyInfo = keyInfoMapper.selectById(id);
|
||||
Assert.notNull(keyInfo, "密钥ID不存在");
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
KeyInfoDTO.KeyView view = new KeyInfoDTO.KeyView();
|
||||
BeanUtils.copyProperties(keyInfo, view);
|
||||
Optional.of(keyInfo.getKeyType()).map(KeyCategory::of).map(KeyCategory::getDesc).ifPresent(view::setKeyTypeText);
|
||||
Map<String, String> usageMap = KeyUsage.getUsage(keyInfo.getKeyUsage())
|
||||
.stream()
|
||||
.collect(Collectors.toMap(KeyUsage::getCode, KeyUsage::getDesc));
|
||||
view.setKeyUsages(new ArrayList<>(usageMap.keySet()));
|
||||
view.setKeyUsageText(String.join(",", usageMap.values()));
|
||||
KeyStatus keyStatus = KeyStatus.of(keyInfo.getStatus());
|
||||
if (KeyStatus.ENABLED == keyStatus) {
|
||||
if (now.isBefore(keyInfo.getEffectiveTime())) {
|
||||
view.setStatus(KeyStatus.WAIT_ENABLED.getCode());
|
||||
view.setStatusText(KeyStatus.WAIT_ENABLED.getDesc());
|
||||
} else if (now.isAfter(keyInfo.getExpiredTime())) {
|
||||
view.setStatus(KeyStatus.EXPIRED.getCode());
|
||||
view.setStatusText(KeyStatus.EXPIRED.getDesc());
|
||||
}
|
||||
}
|
||||
if (ObjectUtils.isEmpty(view.getStatusText())) {
|
||||
view.setStatusText(keyStatus.getDesc());
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long save(KeyInfoDTO.KeySave save) {
|
||||
|
||||
@@ -218,7 +247,7 @@ public class KeyInfoServiceImpl implements KeyInfoService {
|
||||
|
||||
List<KeyInfo> keyInfos = keyInfoMapper.selectBatchIds(ids);
|
||||
if (CollectionUtils.isEmpty(keyInfos)) {
|
||||
log.warn("enableKey no exist key with ids: {}", ids.stream().map(String::valueOf).collect(Collectors.joining(",")));
|
||||
log.warn("updateKey no exist key with ids: {}", ids.stream().map(String::valueOf).collect(Collectors.joining(",")));
|
||||
return;
|
||||
}
|
||||
List<String> unNormalCodes = keyInfos.stream()
|
||||
|
||||
Reference in New Issue
Block a user