shjung před 3 roky
rodič
revize
b1c14b72a3

+ 1 - 0
pom.xml

@@ -308,6 +308,7 @@
             <version>0.97-incubator</version>
             <scope>compile</scope>
         </dependency>
+
         <dependency>
             <groupId>com.github.ulisesbocchio</groupId>
             <artifactId>jasypt-spring-boot-starter</artifactId>

+ 63 - 0
src/main/java/com/its/op/config/JasyptConfig.java

@@ -0,0 +1,63 @@
+package com.its.op.config;
+
+import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
+import org.jasypt.encryption.StringEncryptor;
+import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
+import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
+import org.jasypt.salt.StringFixedSaltGenerator;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@EnableEncryptableProperties
+public class JasyptConfig {
+
+    @Value("${jasypt.encryptor.password:asdkjfaslkjflkajslfjkajlkf}")
+    private final String encKey = "asdkjfaslkjflkajslfjkajlkf";
+
+    @Bean("jasyptStringEncryptor")
+    public StringEncryptor stringEncryptor() {
+
+        PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
+        SimpleStringPBEConfig config = new SimpleStringPBEConfig();
+
+        // ==> SimpleStringPBEConfig 사용시 아래 3개 반드시 설정해야함
+        config.setPassword(encKey);                                         // 암호화에 사용할 키
+        config.setPoolSize(1);                                              // Pool Size
+        config.setSaltGenerator(new StringFixedSaltGenerator("fixedSalt")); // 고정으로 암호화(Default: Random)
+        //config.setAlgorithm("PBEWithMD5AndTripleDES");
+        //config.setAlgorithm("PBEWithMD5AndDES"); // Jasypt 를 이용한 암호화 알고리즘
+        //config.setProviderName("SunJCE");
+        config.setKeyObtentionIterations("10000");
+        config.setStringOutputType("base64");
+        /*private Boolean proxyPropertySources = false;
+        private String bean = "jasyptStringEncryptor";
+        private String password;
+        private String algorithm = "PBEWithMD5AndDES";
+        private String keyObtentionIterations = "1000";
+        private String poolSize = "1";
+        private String providerName = null;
+        //config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");
+        private String saltGeneratorClassname = "org.jasypt.salt.RandomSaltGenerator";
+        private String stringOutputType = "base64";*/
+        encryptor.setConfig(config);
+
+        return encryptor;
+    }
+
+    public String getKey() {
+        return this.encKey;
+    }
+
+    public String encrypt(String string) {
+        StringEncryptor encrypt = stringEncryptor();
+        return encrypt.encrypt(string);
+    }
+
+    public String decrypt(String string) {
+        StringEncryptor decrypt = stringEncryptor();
+        return decrypt.decrypt(string);
+    }
+
+}

+ 1 - 1
src/main/java/com/its/op/config/ThreadPoolTaskExecutorConfig.java

@@ -11,10 +11,10 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import javax.annotation.PostConstruct;
 import java.util.concurrent.Executor;
 
-@EqualsAndHashCode(callSuper = true)
 @Slf4j
 @Data
 @Configuration
+@EqualsAndHashCode(callSuper = true)
 public class ThreadPoolTaskExecutorConfig extends AsyncConfigurerSupport {
 
     private int poolCore = 0;

+ 18 - 1
src/main/java/com/its/op/controller/its/LoginController.java

@@ -1,10 +1,13 @@
 package com.its.op.controller.its;
 
+import com.its.op.config.AppUtils;
+import com.its.op.config.JasyptConfig;
 import com.its.op.dto.its.LoginDto;
-import com.its.op.service.its.LoginService;
 import com.its.op.security.WebMvcConfig;
+import com.its.op.service.its.LoginService;
 import com.its.utils.CookieUtils;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.security.core.Authentication;
@@ -116,4 +119,18 @@ public class LoginController {
         response.addCookie(cookie);
     }
 
+    @ApiOperation(value = "ENCRYPT", response = String.class)
+    @GetMapping(value = "/encrypt/{string}", produces = {"application/json; charset=utf8"})
+    public String encrypt(@PathVariable("string") String string) {
+        JasyptConfig jasyptConfig = (JasyptConfig) AppUtils.getBean(JasyptConfig.class);
+        return jasyptConfig.encrypt(string);
+    }
+
+    @ApiOperation(value = "DECRYPT", response = String.class)
+    @GetMapping(value = "/decrypt/{string}", produces = {"application/json; charset=utf8"})
+    public String decrypt(@PathVariable("string") String string) {
+        JasyptConfig jasyptConfig = (JasyptConfig) AppUtils.getBean(JasyptConfig.class);
+        return jasyptConfig.decrypt(string);
+    }
+
 }

+ 5 - 6
src/main/java/com/its/op/dto/its/vms/TbVmsFormObjectDetlDto.java

@@ -6,7 +6,6 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Builder;
 import lombok.Data;
 
-import javax.persistence.Column;
 import java.io.Serializable;
 
 /**
@@ -14,7 +13,7 @@ import java.io.Serializable;
  */
 @Data
 @Builder
-@ApiModel("TbVmsFormObjectDtoDetl(VMS FORM OBJECT)")
+@ApiModel("TbVmsFormObjectDetlDto(VMS FORM OBJECT)")
 public class TbVmsFormObjectDetlDto implements Serializable {
     private static final long serialVersionUID = 1L;
 
@@ -140,19 +139,19 @@ public class TbVmsFormObjectDetlDto implements Serializable {
     private String symbExpl;
 
     @ApiModelProperty("VMS 유형 코드")  // Y VARCHAR(7)
-    @Column(name = "VMS_TYPE_CD", length = 7)
+    @JsonProperty("vms_type_cd")
     private String vmsTypeCd;
 
     @ApiModelProperty("VMS FORM 유형 코드")  // N NUMBER(3)
-    @Column(name = "VMS_FORM_TYPE_CD", nullable = false, columnDefinition = "NUMBER", length = 3)
+    @JsonProperty("vms_form_type_cd")
     private Integer vmsFormTypeCd;
 
     @ApiModelProperty("VMS FORM 배경 색상 코드")  // N NUMBER(10)
-    @Column(name = "VMS_FORM_BCKG_HUE_CD", nullable = false, columnDefinition = "NUMBER", length = 10)
+    @JsonProperty("vms_form_bckg_hue_cd")
     private Long vmsFormBckgHueCd;
 
     @ApiModelProperty("VMS FORM 명")  // Y VARCHAR(60)
-    @Column(name = "VMS_FORM_NM", length = 60)
+    @JsonProperty("vms_form_nm")
     private String vmsFormNm;
 
 }

+ 6 - 6
src/main/resources/application-dev.yml

@@ -9,8 +9,8 @@ spring:
       driver-class-name: com.tmax.tibero.jdbc.TbDriver
       #jdbc-url: jdbc:tibero:thin:@115.91.94.42:8629:tibero
       jdbc-url: jdbc:tibero:thin:@192.168.20.99:8629:tibero
-      username: yiits
-      password: yiits
+      username: ENC(07xt40GoahE=)
+      password: ENC(07xt40GoahE=)
       minimumIdle: 5
       maximumIdle: 10
       maximumPoolSize: 20
@@ -27,8 +27,8 @@ spring:
       driver-class-name: com.tmax.tibero.jdbc.TbDriver
       #jdbc-url: jdbc:tibero:thin:@115.91.94.42:8629:tibero
       jdbc-url: jdbc:tibero:thin:@192.168.20.99:8629:tibero
-      username: rutis
-      password: rutis
+      username: ENC(SDpa2UMdPqw=)
+      password: ENC(SDpa2UMdPqw=)
       minimumIdle: 3
       maximumIdle: 10
       maximumPoolSize: 20
@@ -45,8 +45,8 @@ spring:
       driver-class-name: com.tmax.tibero.jdbc.TbDriver
       #jdbc-url: jdbc:tibero:thin:@115.91.94.42:8629:tibero
       jdbc-url: jdbc:tibero:thin:@192.168.20.99:8629:tibero
-      username: yiits
-      password: yiits
+      username: ENC(07xt40GoahE=)
+      password: ENC(07xt40GoahE=)
       minimumIdle: 3
       maximumIdle: 10
       maximumPoolSize: 20

+ 8 - 1
src/main/resources/application.yml

@@ -90,4 +90,11 @@ logging:
         type:
           descriptor:
             sql:
-              BasicBinder: TRACE
+              BasicBinder: TRACE
+
+jasypt:
+  encryptor:
+    bean: jasyptStringEncryptor
+    property:
+      prefix: ENC(
+      suffix: )

+ 36 - 0
src/test/java/com/its/op/ItsOpServerApplicationTests.java

@@ -1,6 +1,9 @@
 package com.its.op;
 
 import lombok.extern.slf4j.Slf4j;
+import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
+import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
+import org.junit.jupiter.api.Test;
 import org.springframework.boot.test.context.SpringBootTest;
 
 @Slf4j
@@ -26,4 +29,37 @@ public class ItsOpServerApplicationTests {
     }
 
 
+    @Test
+    void jasypt() {
+        String encKey = "asdkjfaslkjflkajslfjkajlkf";
+        PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
+        SimpleStringPBEConfig config = new SimpleStringPBEConfig();
+
+        // ==> SimpleStringPBEConfig 사용시 아래 3개 반드시 설정해야함
+        config.setPassword(encKey);                                         // 암호화에 사용할 키
+        config.setPoolSize(1);                                              // Pool Size
+        //config.setSaltGenerator(new StringFixedSaltGenerator("fixedSalt")); // 고정으로 암호화(Default: Random)
+        config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");
+        //config.setAlgorithm("PBEWithMD5AndTripleDES");
+        config.setAlgorithm("PBEWithMD5AndDES"); // Jasypt 를 이용한 암호화 알고리즘
+        config.setProviderName("SunJCE");
+        config.setKeyObtentionIterations("10000");
+        config.setStringOutputType("base64");
+        /*private Boolean proxyPropertySources = false;
+        private String bean = "jasyptStringEncryptor";
+        private String password;
+        private String algorithm = "PBEWithMD5AndDES";
+        private String keyObtentionIterations = "1000";
+        private String poolSize = "1";
+        private String providerName = null;
+        //config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");
+        private String saltGeneratorClassname = "org.jasypt.salt.RandomSaltGenerator";
+        private String stringOutputType = "base64";*/
+        encryptor.setConfig(config);
+
+        String yiits = encryptor.encrypt("yiits");
+        String rutis = encryptor.encrypt("rutis");
+        log.info("{}", yiits);
+        log.info("{}", rutis);
+    }
 }