init
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
package com.eactive.eai.httpouttlsinfo;
|
||||
|
||||
import com.eactive.eai.common.dao.BaseDAO;
|
||||
import com.eactive.eai.common.dao.DAOException;
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.data.entity.onl.httpouttlsinfo.HttpOutTlsInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class HttpOutTlsInfoDAO extends BaseDAO {
|
||||
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
private HttpOutTlsInfoLoader httpOutTlsInfoLoader;
|
||||
|
||||
private HttpOutTlsInfoMapper httpOutTlsInfoMapper;
|
||||
|
||||
@Autowired
|
||||
public HttpOutTlsInfoDAO(HttpOutTlsInfoLoader httpOutTlsInfoLoader,
|
||||
HttpOutTlsInfoMapper httpOutTlsInfoMapper) {
|
||||
|
||||
this.httpOutTlsInfoLoader = httpOutTlsInfoLoader;
|
||||
this.httpOutTlsInfoMapper = httpOutTlsInfoMapper;
|
||||
}
|
||||
|
||||
public Map<String, HttpOutTlsInfoVO> getAllHttpOutTlsInfos() throws DAOException {
|
||||
|
||||
try {
|
||||
Stream<HttpOutTlsInfo> httpOutTlsInfos = httpOutTlsInfoLoader.loadAll();
|
||||
Map<String, HttpOutTlsInfoVO> httpOutTlsInfoVOMap = new HashMap<>();
|
||||
|
||||
logger.info("[ @@ Load HttpOutTlsInfo Configuration - starting >>>>>>>>>>>>>>>>> ]");
|
||||
|
||||
httpOutTlsInfos.forEach(httpOutTlsInfo -> {
|
||||
HttpOutTlsInfoVO httpOutTlsInfoVO = httpOutTlsInfoMapper.toVo(httpOutTlsInfo);
|
||||
logger.info("@ " + httpOutTlsInfoVO.toString());
|
||||
httpOutTlsInfoVOMap.put(httpOutTlsInfo.getClientId(), httpOutTlsInfoVO);
|
||||
});
|
||||
|
||||
logger.info("[>>Load HttpOutTlsInfo Configuration - ended ]");
|
||||
return httpOutTlsInfoVOMap;
|
||||
} catch (Exception e) {
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICMM101"));
|
||||
}
|
||||
}
|
||||
|
||||
public HttpOutTlsInfoVO getHttpOutTlsInfo(String clientId) throws Exception {
|
||||
|
||||
try {
|
||||
logger.info("[ @@ Load HttpOutTlsInfo getHttpOutTlsInfo Configuration - starting >>>>>>>>>>>>>>>>> ]");
|
||||
|
||||
HttpOutTlsInfo httpOutTlsInfo = httpOutTlsInfoLoader.findById(clientId)
|
||||
.orElseThrow(() -> new DAOException("HttpOutTlsInfo not found for clientId: " + clientId));
|
||||
|
||||
HttpOutTlsInfoVO httpOutTlsInfoVO = httpOutTlsInfoMapper.toVo(httpOutTlsInfo);
|
||||
|
||||
if(logger.isInfo()) {
|
||||
logger.info("@ " + httpOutTlsInfoVO.toString());
|
||||
logger.info("[>>Load HttpOutTlsInfo getHttpOutTlsInfo Configuration - ended ]");
|
||||
}
|
||||
return httpOutTlsInfoVO;
|
||||
} catch (Exception e) {
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICBM205"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.eactive.eai.httpouttlsinfo;
|
||||
|
||||
import com.eactive.eai.common.dao.DAOException;
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.lifecycle.Lifecycle;
|
||||
import com.eactive.eai.common.lifecycle.LifecycleException;
|
||||
import com.eactive.eai.common.lifecycle.LifecycleListener;
|
||||
import com.eactive.eai.common.lifecycle.LifecycleSupport;
|
||||
import com.eactive.eai.common.util.ApplicationContextProvider;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
public class HttpOutTlsInfoManager implements Lifecycle {
|
||||
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
private Map<String, HttpOutTlsInfoVO> httpOutTlsInfoMap = new HashMap<>();
|
||||
|
||||
private LifecycleSupport lifecycle = new LifecycleSupport(this);
|
||||
|
||||
private boolean started;
|
||||
|
||||
@Autowired
|
||||
private HttpOutTlsInfoDAO httpOutTlsInfoDAO;
|
||||
|
||||
public static HttpOutTlsInfoManager getInstance() {
|
||||
return ApplicationContextProvider.getContext().getBean(HttpOutTlsInfoManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws LifecycleException {
|
||||
if (started)
|
||||
throw new LifecycleException("RECEAIAAC015");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STARTING_EVENT, this);
|
||||
|
||||
try {
|
||||
init();
|
||||
} catch (Exception e) {
|
||||
throw new LifecycleException(ExceptionUtil.getErrorCode(e, "RECEAICKM202"));
|
||||
}
|
||||
|
||||
started = true;
|
||||
lifecycle.fireLifecycleEvent(STARTED_EVENT, this);
|
||||
}
|
||||
|
||||
private void init() throws DAOException {
|
||||
httpOutTlsInfoMap.clear();
|
||||
httpOutTlsInfoMap.putAll(httpOutTlsInfoDAO.getAllHttpOutTlsInfos());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void stop() throws LifecycleException {
|
||||
if (!started)
|
||||
throw new LifecycleException("RECEAICKM203");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STOPING_EVENT, this);
|
||||
|
||||
httpOutTlsInfoMap.clear();
|
||||
|
||||
started = false;
|
||||
lifecycle.fireLifecycleEvent(STOPPED_EVENT, this);
|
||||
}
|
||||
|
||||
public synchronized void reload() throws Exception {
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("HttpOutTlsInfoManager] reload all Started ...");
|
||||
}
|
||||
init();
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("HttpOutTlsInfoManager] reload all finished ...");
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void reload(String clientId) throws Exception {
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("HttpOutTlsInfoManager] reload Started ...");
|
||||
}
|
||||
HttpOutTlsInfoVO httpOutTlsInfoVO = httpOutTlsInfoDAO.getHttpOutTlsInfo(clientId);// eaiSvcCd
|
||||
httpOutTlsInfoMap.put(clientId, httpOutTlsInfoVO);
|
||||
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("HttpOutTlsInfoManager] reload finished ...");
|
||||
}
|
||||
}
|
||||
|
||||
public void addLifecycleListener(LifecycleListener listener) {
|
||||
lifecycle.addLifecycleListener(listener);
|
||||
}
|
||||
|
||||
public LifecycleListener[] findLifecycleListeners() {
|
||||
return lifecycle.findLifecycleListeners();
|
||||
}
|
||||
|
||||
public void removeLifecycleListener(LifecycleListener listener) {
|
||||
lifecycle.removeLifecycleListener(listener);
|
||||
}
|
||||
|
||||
public boolean isStarted() {
|
||||
return this.started;
|
||||
}
|
||||
|
||||
public HttpOutTlsInfoVO getHttpOutTlsInfo(String clientId) {
|
||||
return httpOutTlsInfoMap.get(clientId);
|
||||
}
|
||||
|
||||
public void setHttpOutTlsInfo(String clientId, HttpOutTlsInfoVO httpOutTlsInfoVO) {
|
||||
httpOutTlsInfoMap.put(clientId, httpOutTlsInfoVO);
|
||||
}
|
||||
|
||||
public void removeHttpOutTlsInfo(String clientId) {
|
||||
httpOutTlsInfoMap.remove(clientId);
|
||||
}
|
||||
|
||||
public String[] getAllClientIds() {
|
||||
Set<String> keySet = this.httpOutTlsInfoMap.keySet();
|
||||
String[] names = keySet.toArray(new String[keySet.size()]);
|
||||
Arrays.sort(names);
|
||||
return names;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.eactive.eai.httpouttlsinfo;
|
||||
|
||||
import com.eactive.eai.data.entity.onl.httpouttlsinfo.HttpOutTlsInfo;
|
||||
import com.eactive.eai.data.mapper.GenericMapper;
|
||||
import org.mapstruct.InheritInverseConfiguration;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface HttpOutTlsInfoMapper extends GenericMapper<HttpOutTlsInfoVO, HttpOutTlsInfo> {
|
||||
|
||||
@Override
|
||||
HttpOutTlsInfoVO toVo(HttpOutTlsInfo entity);
|
||||
|
||||
@InheritInverseConfiguration
|
||||
@Override
|
||||
HttpOutTlsInfo toEntity(HttpOutTlsInfoVO vo);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.eactive.eai.httpouttlsinfo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class HttpOutTlsInfoVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String clientId; // 클라이언트 ID
|
||||
private String storeType; // 스토어 타입
|
||||
private String keystoreFilename; // 키스토어 파일명
|
||||
private String keystoreInfo; // 키스토어 정보
|
||||
private String keystorePassword; // 키스토어 비밀번호
|
||||
private String truststoreFilename; // 트러스트스토어 파일명
|
||||
private String truststoreInfo; // 트러스트스토어 정보
|
||||
private String truststorePassword; // 트러스트스토어 비밀번호
|
||||
private LocalDateTime createdAt; // 생성일시
|
||||
private LocalDateTime updatedAt; // 수정일시
|
||||
|
||||
// Getters and Setters
|
||||
|
||||
public String getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public void setClientId(String clientId) {
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
public String getStoreType() {
|
||||
return storeType;
|
||||
}
|
||||
|
||||
public void setStoreType(String storeType) {
|
||||
this.storeType = storeType;
|
||||
}
|
||||
|
||||
public String getKeystoreFilename() {
|
||||
return keystoreFilename;
|
||||
}
|
||||
|
||||
public void setKeystoreFilename(String keystoreFilename) {
|
||||
this.keystoreFilename = keystoreFilename;
|
||||
}
|
||||
|
||||
public String getKeystoreInfo() {
|
||||
return keystoreInfo;
|
||||
}
|
||||
|
||||
public void setKeystoreInfo(String keystoreInfo) {
|
||||
this.keystoreInfo = keystoreInfo;
|
||||
}
|
||||
|
||||
public String getKeystorePassword() {
|
||||
return keystorePassword;
|
||||
}
|
||||
|
||||
public void setKeystorePassword(String keystorePassword) {
|
||||
this.keystorePassword = keystorePassword;
|
||||
}
|
||||
|
||||
public String getTruststoreFilename() {
|
||||
return truststoreFilename;
|
||||
}
|
||||
|
||||
public void setTruststoreFilename(String truststoreFilename) {
|
||||
this.truststoreFilename = truststoreFilename;
|
||||
}
|
||||
|
||||
public String getTruststoreInfo() {
|
||||
return truststoreInfo;
|
||||
}
|
||||
|
||||
public void setTruststoreInfo(String truststoreInfo) {
|
||||
this.truststoreInfo = truststoreInfo;
|
||||
}
|
||||
|
||||
public String getTruststorePassword() {
|
||||
return truststorePassword;
|
||||
}
|
||||
|
||||
public void setTruststorePassword(String truststorePassword) {
|
||||
this.truststorePassword = truststorePassword;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user