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