Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gjjapp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhfwpt
gjjapp
Commits
94572fe8
Commit
94572fe8
authored
Nov 13, 2022
by
张俊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
数据库信息加密处理
parent
2ea9ff57
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
116 additions
and
13 deletions
+116
-13
gjjapp-web/pom.xml
gjjapp-web/pom.xml
+8
-0
gjjapp-web/src/main/java/com/changda/gjjapp/encryptor/EncryptController.java
.../java/com/changda/gjjapp/encryptor/EncryptController.java
+40
-0
gjjapp-web/src/main/java/com/changda/gjjapp/encryptor/EncryptorConfig.java
...in/java/com/changda/gjjapp/encryptor/EncryptorConfig.java
+59
-0
gjjapp-web/src/main/resources/gjj.properties
gjjapp-web/src/main/resources/gjj.properties
+6
-7
gjjapp-web/src/main/resources/spring-context.xml
gjjapp-web/src/main/resources/spring-context.xml
+3
-6
No files found.
gjjapp-web/pom.xml
View file @
94572fe8
...
...
@@ -506,6 +506,14 @@
<artifactId>
junit
</artifactId>
<scope>
test
</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jasypt/jasypt-spring4 -->
<dependency>
<groupId>
org.jasypt
</groupId>
<artifactId>
jasypt-spring4
</artifactId>
<version>
1.9.3
</version>
</dependency>
</dependencies>
<dependencyManagement>
...
...
gjjapp-web/src/main/java/com/changda/gjjapp/encryptor/EncryptController.java
0 → 100644
View file @
94572fe8
package
com.changda.gjjapp.encryptor
;
import
com.changda.cd4j.foundation.core.dto.ResultDto
;
import
com.changda.gjjapp.zhfwpt.service.qdyxzb.ZhfwptTest
;
import
org.jasypt.encryption.StringEncryptor
;
import
org.jasypt.encryption.pbe.StandardPBEStringEncryptor
;
import
org.jasypt.properties.PropertyValueEncryptionUtils
;
import
org.jasypt.spring4.properties.EncryptablePropertyPlaceholderConfigurer
;
import
org.jasypt.util.text.BasicTextEncryptor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
@Controller
()
@RequestMapping
(
value
=
"/encrypt"
)
public
class
EncryptController
{
@Autowired
private
StringEncryptor
stringEncryptor
;
@ResponseBody
@RequestMapping
(
"/jasyptEnc"
)
public
ResultDto
encrypt
(
String
encStr
)
{
ResultDto
resultDto
=
new
ResultDto
();
resultDto
.
setData
(
stringEncryptor
.
encrypt
(
encStr
));
resultDto
.
setSuccess
(
true
);
return
resultDto
;
}
@ResponseBody
@RequestMapping
(
"/jasyptDec"
)
public
ResultDto
decrypt
(
String
decStr
)
{
ResultDto
resultDto
=
new
ResultDto
();
resultDto
.
setData
(
stringEncryptor
.
decrypt
(
decStr
));
resultDto
.
setSuccess
(
true
);
return
resultDto
;
}
}
gjjapp-web/src/main/java/com/changda/gjjapp/encryptor/EncryptorConfig.java
0 → 100644
View file @
94572fe8
package
com.changda.gjjapp.encryptor
;
import
org.jasypt.encryption.StringEncryptor
;
import
org.jasypt.encryption.pbe.PooledPBEStringEncryptor
;
import
org.jasypt.encryption.pbe.StandardPBEByteEncryptor
;
import
org.jasypt.encryption.pbe.StandardPBEStringEncryptor
;
import
org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig
;
import
org.jasypt.encryption.pbe.config.SimpleStringPBEConfig
;
import
org.jasypt.spring4.properties.EncryptablePropertyPlaceholderConfigurer
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.io.DefaultResourceLoader
;
@Configuration
public
class
EncryptorConfig
{
/*@Bean
public StandardPBEStringEncryptor standardPBEStringEncryptor() {
EnvironmentStringPBEConfig stringPBEConfig = new EnvironmentStringPBEConfig();
stringPBEConfig.setAlgorithm("PBEWithMD5AndDES");
stringPBEConfig.setPassword("root");
StandardPBEStringEncryptor pbeStringEncryptor = new StandardPBEStringEncryptor();
pbeStringEncryptor.setConfig(stringPBEConfig);
return pbeStringEncryptor;
}*/
@Bean
public
EncryptablePropertyPlaceholderConfigurer
propertyConfigurer
(
StringEncryptor
pbeStringEncryptor
)
{
EncryptablePropertyPlaceholderConfigurer
placeholderConfigurer
=
new
EncryptablePropertyPlaceholderConfigurer
(
pbeStringEncryptor
);
DefaultResourceLoader
defaultResourceLoader
=
new
DefaultResourceLoader
();
placeholderConfigurer
.
setLocations
(
defaultResourceLoader
.
getResource
(
"classpath:gjj.properties"
));
return
placeholderConfigurer
;
}
@Bean
public
StringEncryptor
stringEncryptor
()
{
PooledPBEStringEncryptor
encryptor
=
new
PooledPBEStringEncryptor
();
SimpleStringPBEConfig
config
=
new
SimpleStringPBEConfig
();
// 加密盐值
config
.
setPassword
(
"gjjcdgs856177110"
);
// 加密算法
config
.
setAlgorithm
(
StandardPBEByteEncryptor
.
DEFAULT_ALGORITHM
);
// key迭代次数
config
.
setKeyObtentionIterations
(
"1000"
);
// 池大小
config
.
setPoolSize
(
"1"
);
config
.
setProviderName
(
"SunJCE"
);
// 随机盐生成器
config
.
setSaltGeneratorClassName
(
"org.jasypt.salt.RandomSaltGenerator"
);
config
.
setIvGeneratorClassName
(
"org.jasypt.iv.RandomIvGenerator"
);
// 加密后输出字符串编码方式
config
.
setStringOutputType
(
"base64"
);
encryptor
.
setConfig
(
config
);
return
encryptor
;
}
}
gjjapp-web/src/main/resources/gjj.properties
View file @
94572fe8
...
...
@@ -15,16 +15,15 @@ FileTemplatPath=D:\\JavaFileDir
jdbc.type
=
oracle
jdbc.driver
=
oracle.jdbc.driver.OracleDriver
jdbc.url
=
jdbc:oracle:thin:@192.168.101.194:1521:zfgjj
jdbc.username
=
ZHFW80
jdbc.password
=
ZHFW80
jdbc.url
=
ENC(O/MRgz1LcC4g+4JLVPeEEQYSJQ8MNNvUJ6ri4Izl5IdK1NEkMhRvmi+54sNI/HmoOOxZpcZY/64vTaXZvKBNQg==)
jdbc.username
=
ENC(v/urlgt6tqaEsE717EpUf0dTSg4VVPru)
jdbc.password
=
ENC(v/urlgt6tqaEsE717EpUf0dTSg4VVPru)
jdbc.type.ss
=
oracle
jdbc.driver.ss
=
oracle.jdbc.driver.OracleDriver
jdbc.url.ss
=
jdbc:oracle:thin:@192.168.101.194:1521:zfgjj
jdbc.username.ss
=
ZHFW80
jdbc.password.ss
=
ZHFW80
jdbc.url.ss
=
ENC(O/MRgz1LcC4g+4JLVPeEEQYSJQ8MNNvUJ6ri4Izl5IdK1NEkMhRvmi+54sNI/HmoOOxZpcZY/64vTaXZvKBNQg==)
jdbc.username.ss
=
ENC(v/urlgt6tqaEsE717EpUf0dTSg4VVPru)
jdbc.password.ss
=
ENC(v/urlgt6tqaEsE717EpUf0dTSg4VVPru)
#jdbc.type=oracle
#jdbc.driver=oracle.jdbc.driver.OracleDriver
...
...
gjjapp-web/src/main/resources/spring-context.xml
View file @
94572fe8
...
...
@@ -27,15 +27,12 @@
<aop:aspectj-autoproxy
proxy-target-class=
"true"
>
</aop:aspectj-autoproxy>
<!-- 加载配置属性文件 -->
<context:property-placeholder
ignore-unresolvable=
"true"
location=
"classpath:gjj.properties"
/>
<context:property-placeholder
ignore-unresolvable=
"true"
location=
"classpath:gjj_bussiness.property"
/>
<!--<context:property-placeholder ignore-unresolvable="true" location="classpath:gjj.properties" />-->
<context:property-placeholder
ignore-unresolvable=
"true"
location=
"classpath:gjj_bussiness.property"
/>
<!-- 加载应用属性实例,可通过 @Value("#{APP_PROP['jdbc.driver']}") String jdbcDriver
方式引用 -->
<util:properties
id=
"APP_PROP"
location=
"classpath:gjj.properties"
local-override=
"true"
/>
<util:properties
id=
"APP_PROP"
location=
"classpath:gjj.properties"
local-override=
"true"
/>
<!-- 使用Annotation自动注册Bean,解决事物失效问题:在主容器中不扫描@Controller注解,在SpringMvc中只扫描@Controller注解。 -->
<context:component-scan
base-package=
"com.changda"
>
<!-- base-package
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment