终端 可秘钥 连接
This commit is contained in:
parent
63d45c6ae6
commit
ec75b66281
@ -12,6 +12,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -64,6 +65,13 @@ public class SecretKeyController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除密钥")
|
||||
@PreAuthorize("@ss.hasPermission('ci:secretKey:delete')")
|
||||
public CommonResult deleteSecretKeyList(@RequestParam("id") Long id) {
|
||||
return success(secretKeyService.deleteById(id));
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
@Operation(summary = "获取密钥信息列表")
|
||||
public CommonResult<PageResult<SecretKeyVO>> getSecretKeyPage(@Valid @RequestBody SecretKeyVO secretKeyVO) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cd.casic.module.machine.service;
|
||||
|
||||
import cd.casic.framework.commons.pojo.CommonResult;
|
||||
import cd.casic.framework.commons.pojo.PageResult;
|
||||
import cd.casic.module.machine.dal.dataobject.MachineInfoDO;
|
||||
import cd.casic.module.machine.dal.dataobject.SecretKeyDO;
|
||||
@ -30,6 +31,9 @@ public interface SecretKeyService {
|
||||
*/
|
||||
void deleteSecretKeyList(List<Long> ids);
|
||||
|
||||
|
||||
Integer deleteById(Long id);
|
||||
|
||||
/**
|
||||
* 根据id获取密钥对象
|
||||
*/
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cd.casic.module.machine.service.impl;
|
||||
|
||||
import cd.casic.framework.commons.pojo.CommonResult;
|
||||
import cd.casic.framework.commons.pojo.PageResult;
|
||||
import cd.casic.framework.commons.util.object.BeanUtils;
|
||||
import cd.casic.module.machine.controller.vo.SecretKeyVO;
|
||||
@ -56,8 +57,9 @@ public class SecretKeyServiceImpl implements SecretKeyService {
|
||||
SecretKeyDO secretKeyDO = BeanUtils.toBean(secretKeyVO, SecretKeyDO.class);
|
||||
//密码加密
|
||||
secretKeyDO.setPassword(CryptogramUtil.doEncrypt(secretKeyVO.getPassword()));
|
||||
//公钥加密
|
||||
//公私钥加密
|
||||
secretKeyDO.setPublicKey(CryptogramUtil.doEncrypt(secretKeyVO.getPublicKey()));
|
||||
secretKeyDO.setPrivateKey(CryptogramUtil.doEncrypt(secretKeyVO.getPrivateKey()));
|
||||
secretKeyMapper.insert(secretKeyDO);
|
||||
return secretKeyDO.getId();
|
||||
}
|
||||
@ -104,4 +106,8 @@ public class SecretKeyServiceImpl implements SecretKeyService {
|
||||
}
|
||||
return secretKeyDO;
|
||||
}
|
||||
@Override
|
||||
public Integer deleteById(Long id){
|
||||
return secretKeyMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import lombok.NoArgsConstructor;
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
//@DesensitizeObject 、、todo 自动脱敏的注解
|
||||
//@DesensitizeObject 自动脱敏的注解
|
||||
@Schema(name = "TerminalAccessDTO", description = "终端访问参数")
|
||||
public class TerminalAccessDTO {
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cd.casic.module.terminal.host.jsch;
|
||||
|
||||
|
||||
import cd.casic.module.machine.utils.CryptogramUtil;
|
||||
import cd.casic.module.terminal.common.AesEncryptUtils;
|
||||
import cd.casic.module.terminal.common.AppConst;
|
||||
import cd.casic.module.terminal.controller.dto.TerminalConnectDTO;
|
||||
@ -72,13 +73,13 @@ public class SessionStores {
|
||||
if (useKey) {
|
||||
// 加载密钥
|
||||
String publicKey = Optional.ofNullable(conn.getPublicKey())
|
||||
.map(AesEncryptUtils::decryptAsString)
|
||||
.map(CryptogramUtil::doDecrypt)
|
||||
.orElse(null);
|
||||
String privateKey = Optional.ofNullable(conn.getPrivateKey())
|
||||
.map(AesEncryptUtils::decryptAsString)
|
||||
.map(CryptogramUtil::doDecrypt)
|
||||
.orElse(null);
|
||||
String password = Optional.ofNullable(conn.getPrivateKeyPassword())
|
||||
.map(AesEncryptUtils::decryptAsString)
|
||||
.map(CryptogramUtil::doDecrypt)
|
||||
.orElse(null);
|
||||
sessionHolder.addIdentityValue(String.valueOf(conn.getKeyId()),
|
||||
privateKey,
|
||||
@ -91,8 +92,7 @@ public class SessionStores {
|
||||
if (!useKey) {
|
||||
String password = conn.getPassword();
|
||||
if (!Strings.isEmpty(password)) {
|
||||
// session.password(AesEncryptUtils.decryptAsString(password));
|
||||
session.password(password);
|
||||
session.password(CryptogramUtil.doDecrypt(password));
|
||||
}
|
||||
}
|
||||
// 超时时间
|
||||
|
Loading…
x
Reference in New Issue
Block a user