| 카테고리1 | 프로그래밍 |
|---|---|
| 카테고리2 | JAVA |
| 제목 | 전자정부프레임워크 프로퍼티 암호화 |
| 작성자 | 고성훈 |
| 작성일 | 2024-11-26 |
[context-crypto.xml]
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"> algorithmKey="egovframe" algorithmKeyHash="gdyYs/IZqY86VcWhT8emCYfqY1ahw2vtLG+/FzNqtrQ=" cryptoBlockSize="1024" cryptoPropertyLocation="classpath:/egovframework/prop/config.properties" /> [context-dataSource.xml] 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 "> [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()); } } } | |