From 37b7a682fef5de4d4304d787af58b5d79271497b Mon Sep 17 00:00:00 2001 From: yuemian <--list> Date: Tue, 3 Sep 2024 17:30:45 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E7=90=86=E6=9C=BA=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E5=8A=A0=E5=AF=86=E4=BC=A0=E8=BE=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/PhysicalServerServiceImpl.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/service/impl/PhysicalServerServiceImpl.java b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/service/impl/PhysicalServerServiceImpl.java index 1c852c5c..84caf05b 100644 --- a/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/service/impl/PhysicalServerServiceImpl.java +++ b/bocloud.ctstack.plugin/src/main/java/com/bocloud/ctstack/plugin/service/impl/PhysicalServerServiceImpl.java @@ -15,6 +15,8 @@ import com.bocloud.ctstack.plugin.repository.VolumeRepository; import com.bocloud.ctstack.plugin.repository.VpcRepository; import com.bocloud.ctstack.plugin.service.PhysicalServerService; import com.google.common.collect.Maps; +import com.megatron.common.encrypt.AESEncryptor; +import com.megatron.common.encrypt.Encryptor; import com.megatron.common.model.GeneralResult; import com.megatron.common.model.GridBean; import com.megatron.common.model.Pager; @@ -24,6 +26,7 @@ import com.megatron.common.utils.GridHelper; import com.megatron.framework.lock.AutoCloseLock; import com.megatron.framework.lock.LockFactory; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -91,6 +94,16 @@ public class PhysicalServerServiceImpl implements PhysicalServerService { public GeneralResult create(PhysicalServer physicalServer, RequestContext context) { // 云平台ID Long vendorId = physicalServer.getVendorId(); + if (!StringUtils.isEmpty(physicalServer.getPassword())) { + Encryptor encryptor = new AESEncryptor(); + try { + String password = encryptor.decrypt(physicalServer.getPassword().trim(), null); + physicalServer.setPassword(password); + } catch (Exception e) { + log.error("Get error message:{}", e); + return new GeneralResult(false, e.getMessage()); + } + } String path = CloudVendor.class.getSimpleName() + "_" + vendorId + "_SYNC"; try (AutoCloseLock lock = lockFactory.getACLock(path)) { if (!lock.acquire(10, TimeUnit.SECONDS)) {