로그인
메뉴
HOME
STUDY
SCS FOOD
DRAWING
MEMO
GS
DIARY
CRIZEL SLM
카테고리1
카테고리1 선택
프로그래밍
카테고리2
카테고리2 선택
AI
CSS
DB
Git
JAVA
JAVASCRIPT
MCP
mysql
NESTJS
REMIX
도커
리액트
리액트 네이티브
미들웨어
브라우저
서버
스벨트킷
스프링
스프링부트
오라클
자바
자바스크립트
플러터
제목
작성자
[context-crypto.xml] <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:egov-crypto="http://www.egovframe.go.kr/schema/egov-crypto" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.egovframe.go.kr/schema/egov-crypto http://www.egovframe.go.kr/schema/egov-crypto/egov-crypto-3.8.xsd"> <bean name="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="useCodeAsDefaultMessage"> <value>true</value> </property> <property name="basenames"> <list> <value>classpath:/egovframework/prop/config.properties</value> </list> </property> </bean> <egov-crypto:config id="egovCryptoConfig" initial="true" crypto="true" algorithm="SHA-256" algorithmKey="egovframe" algorithmKeyHash="gdyYs/IZqY86VcWhT8emCYfqY1ahw2vtLG+/FzNqtrQ=" cryptoBlockSize="1024" cryptoPropertyLocation="classpath:/egovframework/prop/config.properties" /> </beans> [context-dataSource.xml] <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd "> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:/egovframework/prop/config.properties</value> </list> </property> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${config.dbClass}"/> <property name="url" value="${config.dbUrl}"/> <property name="username" value="${config.dbId}"/> <!-- <property name="password" value="${config.dbPW}"/> --> <property name="password" value="#{egovEnvCryptoService.decrypt('${config.dbPW}')}"/> <property name="validationQuery" value="SELECT 1 FROM DUAL" /> <property name="testWhileIdle" value="true" /> </bean> </beans> [EgovEnvCryptoUserTest.java] 암호화 확인 public class EgovEnvCryptoUserTest { private static final Logger LOGGER = LoggerFactory.getLogger(EgovEnvCryptoUserTest.class); public static void main(String[] args) { String[] arrCryptoString = { "ksh", //데이터베이스 접속 계정 설정 "1234", //데이터베이스 접속 패드워드 설정 "jdbc:mysql://localhost:13306/ksh?useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true", //데이터베이스 접속 주소 설정 "com.mysql.cj.jdbc.Driver" //데이터베이스 드라이버 }; LOGGER.info("------------------------------------------------------"); ApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"classpath:/egovframework/spring/context-crypto.xml"}); EgovEnvCryptoService cryptoService = context.getBean(EgovEnvCryptoServiceImpl.class); LOGGER.info("------------------------------------------------------"); String label = ""; try { for(int i=0; i < arrCryptoString.length; i++) { if(i==0)label = "사용자 아이디"; if(i==1)label = "사용자 비밀번호"; if(i==2)label = "접속 주소"; if(i==3)label = "데이터 베이스 드라이버"; LOGGER.info(label+" 원본(orignal):" + arrCryptoString[i]); LOGGER.info(label+" 인코딩(encrypted):" + cryptoService.encrypt(arrCryptoString[i])); LOGGER.info("------------------------------------------------------"); } } catch (IllegalArgumentException e) { LOGGER.error("["+e.getClass()+"] IllegalArgumentException : " + e.getMessage()); } catch (Exception e) { LOGGER.error("["+e.getClass()+"] Exception : " + e.getMessage()); } } }
저장
뒤로가기