diff --git a/build.gradle b/build.gradle
index 4bd8192..ff16a7e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -6,7 +6,28 @@ plugins {
}
group = 'com.bsmlab.dfx'
-version = '0.0.1-SNAPSHOT'
+version = '0.1'
+
+// git commit hash -> application.yml
+def gitCommitId = ''
+try {
+ def stdout = new ByteArrayOutputStream()
+ providers.exec {
+ commandLine 'git', 'rev-parse', '--short', 'HEAD'
+ standardOutput = stdout;
+ }.result.get()
+ gitCommitId = stdout.toString().trim()
+}
+catch (Exception ignored) {
+ print "git commit ID is not available."
+}
+
+// gradle project properties -> application.yml
+processResources {
+ filesMatching('**/application.yml') {
+ expand(project.properties + [commitId: gitCommitId, version: version])
+ }
+}
java {
toolchain {
diff --git a/src/database/create-database.sql b/src/database/create-database.sql
index 370b83c..5f3d934 100644
--- a/src/database/create-database.sql
+++ b/src/database/create-database.sql
@@ -172,5 +172,21 @@ COMMENT ON COLUMN TB_DFX_AGENT_MESSAGE_HISTORY.MESSAGE_DATA_COUNT IS '메시지
COMMENT ON COLUMN TB_DFX_AGENT_MESSAGE_HISTORY.PROCESS_ACK_TS IS '처리결과 수신 시간';
-
+CREATE TABLE TB_DFX_CRYPTO_KEY (
+ KEY_VALUE VARCHAR(256) NOT NULL
+ , HASH_VALUE VARCHAR(256) NOT NULL
+ , ALGORITHM_NAME VARCHAR(64) NOT NULL
+ , MODE_NAME VARCHAR(64) NOT NULL
+ , TARGET_AGENT_HOST_ID VARCHAR(256)
+ , APPLY_TS TIMESTAMPTZ(3)
+ , DATA_ENCRYPTION_YN VARCHAR(1)
+);
+COMMENT ON TABLE TB_DFX_CRYPTO_KEY IS '암호화키정보';
+COMMENT ON COLUMN TB_DFX_CRYPTO_KEY.KEY_VALUE IS 'KEY VALUE';
+COMMENT ON COLUMN TB_DFX_CRYPTO_KEY.HASH_VALUE IS 'HASH VALUE';
+COMMENT ON COLUMN TB_DFX_CRYPTO_KEY.ALGORITHM_NAME IS '알고리즘';
+COMMENT ON COLUMN TB_DFX_CRYPTO_KEY.MODE_NAME IS '모드';
+COMMENT ON COLUMN TB_DFX_CRYPTO_KEY.TARGET_AGENT_HOST_ID IS '적용 에이전트 ID';
+COMMENT ON COLUMN TB_DFX_CRYPTO_KEY.APPLY_TS IS '적용 시간';
+COMMENT ON COLUMN TB_DFX_CRYPTO_KEY.DATA_ENCRYPTION_YN IS '데이터 암호화 여부';
diff --git a/src/main/front/src/router/index.js b/src/main/front/src/router/index.js
index dc5f632..d489b21 100644
--- a/src/main/front/src/router/index.js
+++ b/src/main/front/src/router/index.js
@@ -26,6 +26,13 @@ const router = createRouter({
props: { contentId: 'agent-manage-view' },
meta: { isRequiredAuth: true },
},
+ {
+ path: '/key-manage.html',
+ name: 'key-manage',
+ component: MainView,
+ props: { contentId: 'key-manage-view' },
+ meta: { isRequiredAuth: true },
+ },
{
path: '/message-history.html',
name: 'message-history',
diff --git a/src/main/front/src/views/CryptoKeyManageView.vue b/src/main/front/src/views/CryptoKeyManageView.vue
new file mode 100644
index 0000000..0e8e38a
--- /dev/null
+++ b/src/main/front/src/views/CryptoKeyManageView.vue
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/front/src/views/MainView.vue b/src/main/front/src/views/MainView.vue
index abf8bf5..fe7f888 100644
--- a/src/main/front/src/views/MainView.vue
+++ b/src/main/front/src/views/MainView.vue
@@ -4,6 +4,7 @@ import { userApi } from '@/components/userInfo'
import { useRouter, RouterLink } from 'vue-router'
import DashboardView from './DashboardView.vue'
import AgentManageView from './AgentManageView.vue'
+import CryptoKeyManageView from './CryptoKeyManageView.vue'
import MessageHistoryView from './MessageHistoryView.vue'
import { computed } from 'vue'
@@ -25,6 +26,8 @@ const currentContent = computed(() => {
return DashboardView
} else if (props.contentId == 'agent-manage-view') {
return AgentManageView
+ } else if (props.contentId == 'key-manage-view') {
+ return CryptoKeyManageView
} else if (props.contentId == 'message-history-view') {
return MessageHistoryView
} else {
@@ -65,6 +68,9 @@ const currentContent = computed(() => {
Agents
+
+ Crypto Keys
+
Messages
diff --git a/src/main/java/com/bsmlab/dfx/agent/listener/dto/CommandDto.java b/src/main/java/com/bsmlab/dfx/agent/listener/dto/CommandDto.java
index 783dc9d..458ec34 100644
--- a/src/main/java/com/bsmlab/dfx/agent/listener/dto/CommandDto.java
+++ b/src/main/java/com/bsmlab/dfx/agent/listener/dto/CommandDto.java
@@ -15,5 +15,6 @@ public class CommandDto {
public static enum CommandType {
ALIVE,
INFORMATION,
+ SAVE_CONFIG,
}
}
diff --git a/src/main/java/com/bsmlab/dfx/dfxconsole/app/agent/DfxAgentInfoController.java b/src/main/java/com/bsmlab/dfx/dfxconsole/app/agent/DfxAgentInfoController.java
index a7a2b97..7b9c8c4 100644
--- a/src/main/java/com/bsmlab/dfx/dfxconsole/app/agent/DfxAgentInfoController.java
+++ b/src/main/java/com/bsmlab/dfx/dfxconsole/app/agent/DfxAgentInfoController.java
@@ -1,7 +1,6 @@
package com.bsmlab.dfx.dfxconsole.app.agent;
import com.bsmlab.dfx.agent.config.AgentConfigDto;
-import com.bsmlab.dfx.agent.listener.dto.ReceiveMessageDto;
import com.bsmlab.dfx.dfxconsole.app.agent.service.*;
import com.bsmlab.dfx.dfxconsole.framework.dto.SearchParameterDto;
import com.bsmlab.dfx.dfxconsole.framework.support.ResponseUtils;
@@ -48,6 +47,17 @@ public class DfxAgentInfoController {
}
}
+ @PostMapping("/app-api/agent/saveAgentConfigDto")
+ public ResponseEntity> saveAgentConfigDto(@RequestBody AgentConfigDto agentConfigDto) {
+ try {
+ dfxAgentInfoService.sendAgentConfigDtoToSave(agentConfigDto);
+ return ResponseEntity.ok().body(agentConfigDto);
+ }
+ catch(JsonProcessingException e) {
+ return ResponseEntity.internalServerError().body(ResponseUtils.toExceptionResponseDto(e));
+ }
+ }
+
@PostMapping("/app-api/agent/getAgentMessageDtoListTotalCount")
public ResponseEntity getAgentMessageDtoListTotalCount() {
int totalCount = dfxAgentMessageHistoryService.selectDfxAgentMessageDtoListTotalCount();
diff --git a/src/main/java/com/bsmlab/dfx/dfxconsole/app/agent/service/DfxAgentInfoService.java b/src/main/java/com/bsmlab/dfx/dfxconsole/app/agent/service/DfxAgentInfoService.java
index e4b7bac..bb8b21a 100644
--- a/src/main/java/com/bsmlab/dfx/dfxconsole/app/agent/service/DfxAgentInfoService.java
+++ b/src/main/java/com/bsmlab/dfx/dfxconsole/app/agent/service/DfxAgentInfoService.java
@@ -1,20 +1,33 @@
package com.bsmlab.dfx.dfxconsole.app.agent.service;
import com.bsmlab.dfx.agent.config.AgentConfigDto;
+import com.bsmlab.dfx.agent.listener.dto.CommandDto;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import java.util.List;
+import java.util.UUID;
@Slf4j
@RequiredArgsConstructor
@Service
+@Getter
public class DfxAgentInfoService {
+ @Value("${spring.application.name}")
+ private String applicationName;
+ @Value("${spring.application.version}")
+ private String applicationVersion;
+ @Value("${spring.application.commitId}")
+ private String applicationCommitId;
private final DfxAgentInfoMapper dfxAgentInfoMapper;
public List getDfxAgentInfoDtoList() {
@@ -39,6 +52,23 @@ public class DfxAgentInfoService {
}
}
+ public void sendAgentConfigDtoToSave(AgentConfigDto agentConfigDto) throws JsonProcessingException {
+ ObjectMapper objectMapper = new ObjectMapper();
+
+ String agentConfigDtoString = objectMapper.writeValueAsString(agentConfigDto);
+ String messageUuid = UUID.randomUUID().toString();
+ CommandDto commandDto = CommandDto.builder().commandType(CommandDto.CommandType.SAVE_CONFIG).messageUuid(messageUuid).data(agentConfigDtoString).build();
+
+ HttpHeaders httpHeaders = new HttpHeaders();
+ httpHeaders.setContentType(MediaType.APPLICATION_JSON);
+ httpHeaders.set("User-Agent", this.getApplicationName() + ", version: " + this.getApplicationVersion() + "(" + this.getApplicationCommitId() + ")"
+ + ", host ID: " + agentConfigDto.getStatusChecker().getConsoleHostName()
+ + ", action: " + CommandDto.CommandType.SAVE_CONFIG
+ );
+ //TODO agent에 agentConfigDto를 전송하려고 하였으나 암호화 적용하는 것이 좋을 듯 하여 암호화 적용 방법 모색중임
+
+ }
+
public void saveDetailForRefreshDfxAgentInfoDto(DfxAgentInfoDto dfxAgentInfoDto) throws JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper();
AgentConfigDto agentConfigDto = objectMapper.readValue(dfxAgentInfoDto.getSettingsData(), new TypeReference(){});
diff --git a/src/main/java/com/bsmlab/dfx/dfxconsole/app/agent/service/DfxCryptoKeyDto.java b/src/main/java/com/bsmlab/dfx/dfxconsole/app/agent/service/DfxCryptoKeyDto.java
new file mode 100644
index 0000000..7c89a42
--- /dev/null
+++ b/src/main/java/com/bsmlab/dfx/dfxconsole/app/agent/service/DfxCryptoKeyDto.java
@@ -0,0 +1,19 @@
+package com.bsmlab.dfx.dfxconsole.app.agent.service;
+
+import lombok.*;
+
+@NoArgsConstructor
+@AllArgsConstructor
+@Setter
+@Getter
+@Builder
+@ToString
+public class DfxCryptoKeyDto {
+ private String keyValue;
+ private String hashValue;
+ private String algorithmName;
+ private String modeName;
+ private String targetAgentHostId;
+ private long applyTs;
+ private String dataEncryptionYn;
+}
diff --git a/src/main/java/com/bsmlab/dfx/dfxconsole/app/agent/service/DfxCryptoKeyMapper.java b/src/main/java/com/bsmlab/dfx/dfxconsole/app/agent/service/DfxCryptoKeyMapper.java
new file mode 100644
index 0000000..e317ffa
--- /dev/null
+++ b/src/main/java/com/bsmlab/dfx/dfxconsole/app/agent/service/DfxCryptoKeyMapper.java
@@ -0,0 +1,15 @@
+package com.bsmlab.dfx.dfxconsole.app.agent.service;
+
+import com.bsmlab.dfx.dfxconsole.framework.dto.SearchParameterDto;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+@Mapper
+public interface DfxCryptoKeyMapper {
+ List selectDfxCryptoKeyList(SearchParameterDto searchParameterDto);
+ int selectDfxCryptoKeyListTotalCount(SearchParameterDto searchParameterDto);
+ DfxCryptoKeyDto selectDfxCryptoKeyByKeyValue(DfxCryptoKeyDto dfxCryptoKeyDto);
+ void insertDfxCryptoKey(DfxCryptoKeyDto dfxCryptoKeyDto);
+ int updateDfxCryptoKeyToApply(DfxCryptoKeyDto dfxCryptoKeyDto);
+}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index ae5e0c5..2312cc1 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -1,6 +1,8 @@
spring:
application:
- name: dfxconsole
+ name: DFXConsole
+ version: ${version}
+ commitId: ${commitId}
devtools:
restart:
enabled: true
diff --git a/src/main/resources/mapper/app/dfx-agent-message-history.xml b/src/main/resources/mapper/app/dfx-agent-message-history.xml
index 4b4c937..020d67a 100644
--- a/src/main/resources/mapper/app/dfx-agent-message-history.xml
+++ b/src/main/resources/mapper/app/dfx-agent-message-history.xml
@@ -169,7 +169,7 @@
SET PROCESS_STATUS_CODE = #{processStatusCode}
, PROCESS_ACK_TS = NOW()
WHERE 1 = 1
- SENDER_AGENT_ID = #{senderAgentId}
+ AND SENDER_AGENT_ID = #{senderAgentId}
AND MESSAGE_UUID = #{messageUuid}
]]>
diff --git a/src/main/resources/mapper/app/dfx-crypto-key.xml b/src/main/resources/mapper/app/dfx-crypto-key.xml
new file mode 100644
index 0000000..9ccbb07
--- /dev/null
+++ b/src/main/resources/mapper/app/dfx-crypto-key.xml
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+