-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jasypt 라이브러리 추가 및 설정파일 생성. key는 gitignore에 추가했습니다.
- Loading branch information
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,5 @@ out/ | |
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
application-key.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
backEnd/src/main/java/com/quiz/ourClass/global/config/JasyptConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.quiz.ourClass.global.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.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.key}") | ||
String key; | ||
|
||
@Bean(name = "jasyptStringEncryptor") | ||
public StringEncryptor stringEncryptor() { | ||
|
||
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor(); | ||
SimpleStringPBEConfig config = new SimpleStringPBEConfig(); | ||
config.setPassword(key); | ||
config.setAlgorithm("PBEWithMD5AndDES"); | ||
config.setKeyObtentionIterations("1000"); | ||
config.setPoolSize("1"); | ||
config.setProviderName("SunJCE"); | ||
config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator"); | ||
config.setStringOutputType("base64"); | ||
encryptor.setConfig(config); | ||
return encryptor; | ||
} | ||
} |