properties jasypt 암호화 적용

dev
Jonguk. Lim 6 months ago
parent 469ccbff2b
commit 9c14262418

@ -196,7 +196,11 @@
<!-- </dependency>-->
<!-- JSONArray -->
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>
</dependencies>

@ -0,0 +1,97 @@
package cokr.xit.adds.core.spring.config;
import org.jasypt.encryption.StringEncryptor;
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* <pre>
* description : properties
* packageName : cokr.xit.core.spring.config
* fileName : JasyptConfig
* author : julim
* date : 2024-05-08
* ======================================================================
*
* ----------------------------------------------------------------------
* 2024-05-08 julim
*
* </pre>
*/
//FIXME :: properties 암호화시 사용
@Configuration
public class JasyptConfig {
@Value("${app.jasypt.secretKey:none}")
private String secretKey;
@Value("${app.jasypt.alg:none}")
private String secretAlg;
@Value("${app.jasypt.type:none}")
private String secretType;
@Bean(name = "jasyptStringEncryptor")
public StringEncryptor jasyptStringEncryptor() {
SimpleStringPBEConfig config = new SimpleStringPBEConfig();
// 암/복호화 키
config.setPassword(secretKey);
// 암/복호화 알고리즘
config.setAlgorithm(secretAlg);
// 반복할 해싱 회수
config.setKeyObtentionIterations("1000");
config.setProviderName("SunJCE");
// salt 생성 클래스
config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");
// 암/복호화 인스턴스 : 0보다 커야
config.setPoolSize("1");
config.setStringOutputType(secretType);
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
encryptor.setConfig(config);
return encryptor;
}
/*
@Bean(name = "jasyptStringEncryptor")
public StringEncryptor jasyptStringEncryptor() {
SimpleStringPBEConfig config = new SimpleStringPBEConfig();
// 암/복호화 키
config.setPassword(secretKey);
// 암/복호화 알고리즘
config.setAlgorithm("PBEWithSHA256And128BitAES-CBC-BC");
// 반복할 해싱 회수
config.setKeyObtentionIterations("1000");
config.setProvider(new BouncyCastleProvider());
// salt 생성 클래스
config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");
// 암/복호화 인스턴스 : 0보다 커야
config.setPoolSize("1");
config.setStringOutputType(secretType);
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
encryptor.setConfig(config);
return encryptor;
}
*/
public static void main(String[] args) {
StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
encryptor.setAlgorithm("PBEWithMD5AndDES");
encryptor.setPassword("xit5811807!@");
String url = encryptor.encrypt("jdbc:log4jdbc:mariadb://211.119.124.9:4407/adds?useUnicode=true&characterEncoding=utf-8&rewriteBatchedStatements=true&autoReconnect=true");
String id = encryptor.encrypt("addsweb");
String passwd = encryptor.encrypt("addsweb1234");
System.out.println(url);
System.out.println(id);
System.out.println(passwd);
System.out.println(encryptor.decrypt(url));
}
}

@ -25,13 +25,13 @@ public class SpringDocsConfig {
private int SERVER_PORT;
@Value("${server.http:0}")
private int HTTP_PORT;
@Value("${app.swagger-url:}")
@Value("${app.swagger.url:}")
private String swaggerUrl;
@Bean
public OpenAPI openAPI(
@Value("${springdoc.version:v1}") String version,
@Value("${app.desc:}") String desc,
@Value("${app.swagger.desc:}") String desc,
@Value("${spring.application.name}") String name,
@Value("${spring.profiles.active}") String active) {

@ -35,10 +35,13 @@ spring:
hikari:
driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy #org.mariadb.jdbc.Driver
#driver-class-name: org.mariadb.jdbc.Driver
jdbc-url: jdbc:log4jdbc:mariadb://211.119.124.9:4407/adds?useUnicode=true&characterEncoding=utf-8&rewriteBatchedStatements=true&autoReconnect=true
#jdbc-url: jdbc:mariadb://211.119.124.9:4407/egov?useUnicode=true&characterEncoding=utf-8&rewriteBatchedStatements=true&autoReconnect=true
username: addsweb
password: addsweb1234
# jdbc-url: jdbc:log4jdbc:mariadb://211.119.124.9:4407/adds?useUnicode=true&characterEncoding=utf-8&rewriteBatchedStatements=true&autoReconnect=true
# username: addsweb
# password: addsweb1234
jdbc-url: ENC(O26qFSqrfqMEjEU6jHUqrboYIPpTnwDIHIYQg2ddL0k7VsGvDbAMd/SwDeXjan17CykVLz3Qe++xW+VqxvQpT7/+Kxhl2ry1hTElOPxRHp6OrN/8GyhaScLCcBZgpxNcEAZ3a5qWJKIyLR/+KFk6YpW77lD10jFJvscNNYvFoWQIs/K5eAa/m3JnktX9Ed2RN8ttGgBET5g=)
username: ENC(M4g3XkH/bzupKW2w4WYH3Q==)
password: ENC(fzV0zekJQ7t/QHiz75k+xqdsDUWW6+MY)
auto-commit: false
# read-only: false
@ -149,6 +152,9 @@ spring:
# read-only: false
app:
swagger:
url:
desc: 사고마약류폐기지원시스템
log:
parameter-enabled: true
response-enabled: true

@ -15,6 +15,8 @@ app:
officeinfo: /api/officeinfo.do
placeinfoV1: /api/placeinfo_v1.do
reportinfo: /api/reportinfo_ggg.do
mois:
serverId: ADM405000069
iros:
url: https://apis.data.go.kr
api-key: 0fTkYnZU6XjaAPAp6GzKW9Q6fYq8iaoSH9wKUZwz2PBjRXGM04aUgtO3a61xYGjL8nFZn4fjLGS9XErhMSXq%2Bw%3D%3D

@ -159,8 +159,6 @@ public class ExchangeDtoTest {
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.writeValue(sw, dto);
StringWriter swr = new StringWriter();
mapper.writeValue(swr, dto);
System.out.println(swr.toString());

Loading…
Cancel
Save