Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Wecube Platform
Commits
5be3ec4c
Commit
5be3ec4c
authored
4 years ago
by
gavin2lee
Browse files
Options
Download
Email Patches
Plain Diff
#2015 refactor aes decryption
parent
705b93a3
itsm_162_refactor
1972_fix_login_timeout
1993_plugin_list_pi
1996_bug_fix_for_out_of_memery
2046_batch_execution_update
2048_enhance_for_workflow_excution
2109_itsm_support
brankbao-patch-1
dev3_platform_refactor
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
platform-core/src/main/java/com/webank/wecube/platform/core/service/plugin/PluginInstanceService.java
+19
-16
...e/platform/core/service/plugin/PluginInstanceService.java
platform-core/src/main/java/com/webank/wecube/platform/core/service/resource/MysqlAccountManagementService.java
+10
-10
.../core/service/resource/MysqlAccountManagementService.java
platform-core/src/main/java/com/webank/wecube/platform/core/service/resource/MysqlDatabaseManagementService.java
+5
-3
...core/service/resource/MysqlDatabaseManagementService.java
platform-core/src/main/java/com/webank/wecube/platform/core/service/resource/ResourceDataQueryService.java
+5
-3
...tform/core/service/resource/ResourceDataQueryService.java
platform-core/src/main/java/com/webank/wecube/platform/core/service/resource/S3BucketManagementService.java
+10
-9
...form/core/service/resource/S3BucketManagementService.java
with
49 additions
and
41 deletions
+49
-41
platform-core/src/main/java/com/webank/wecube/platform/core/service/plugin/PluginInstanceService.java
+
19
-
16
View file @
5be3ec4c
...
...
@@ -325,10 +325,11 @@ public class PluginInstanceService {
.
getResourceServer
();
String
password
=
mysqlInstance
.
getPassword
();
if
(
password
.
startsWith
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
))
{
password
=
EncryptionUtils
.
decryptWithAes
(
password
.
substring
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
.
length
()),
resourceProperties
.
getPasswordEncryptionSeed
(),
mysqlInstance
.
getSchemaName
());
password
=
password
.
substring
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
.
length
());
}
password
=
EncryptionUtils
.
decryptWithAes
(
password
,
resourceProperties
.
getPasswordEncryptionSeed
(),
mysqlInstance
.
getSchemaName
());
DriverManagerDataSource
dataSource
=
new
DriverManagerDataSource
(
"jdbc:mysql://"
+
dbServer
.
getHost
()
+
":"
+
dbServer
.
getPort
()
+
"/"
+
mysqlInstance
.
getSchemaName
()
+
"?characterEncoding=utf8&serverTimezone=UTC"
,
...
...
@@ -567,11 +568,12 @@ public class PluginInstanceService {
String
password
=
dbInfo
.
getPassword
();
if
(
password
.
startsWith
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
))
{
password
=
EncryptionUtils
.
decryptWithAes
(
password
.
substring
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
.
length
()),
resourceProperties
.
getPasswordEncryptionSeed
(),
dbInfo
.
getSchema
());
password
=
password
.
substring
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
.
length
());
}
password
=
EncryptionUtils
.
decryptWithAes
(
password
,
resourceProperties
.
getPasswordEncryptionSeed
(),
dbInfo
.
getSchema
());
envVariablesString
=
envVariablesString
.
replace
(
"{{DB_HOST}}"
,
dbInfo
.
getHost
())
.
replace
(
"{{DB_PORT}}"
,
dbInfo
.
getPort
()).
replace
(
"{{DB_SCHEMA}}"
,
dbInfo
.
getSchema
())
...
...
@@ -656,10 +658,12 @@ public class PluginInstanceService {
String
password
=
mysqlInstance
.
getPassword
();
if
(
password
.
startsWith
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
))
{
password
=
EncryptionUtils
.
decryptWithAes
(
password
.
substring
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
.
length
()),
resourceProperties
.
getPasswordEncryptionSeed
(),
mysqlInstance
.
getSchemaName
());
password
=
password
.
substring
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
.
length
());
}
password
=
EncryptionUtils
.
decryptWithAes
(
password
,
resourceProperties
.
getPasswordEncryptionSeed
(),
mysqlInstance
.
getSchemaName
());
DriverManagerDataSource
dataSource
=
new
DriverManagerDataSource
(
"jdbc:mysql://"
+
dbServer
.
getHost
()
+
":"
+
dbServer
.
getPort
()
+
"/"
+
mysqlInstance
.
getSchemaName
()
...
...
@@ -780,15 +784,14 @@ public class PluginInstanceService {
logger
.
info
(
"scp from local:{} to remote: {}"
,
tmpFilePath
,
pluginProperties
.
getPluginDeployPath
());
try
{
String
password
=
null
;
String
dbPassword
=
hostInfo
.
getLoginPassword
();
if
(
dbPassword
.
startsWith
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
))
{
password
=
EncryptionUtils
.
decryptWithAes
(
dbPassword
.
substring
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
.
length
()),
resourceProperties
.
getPasswordEncryptionSeed
(),
hostInfo
.
getName
());
}
else
{
password
=
dbPassword
;
dbPassword
=
dbPassword
.
substring
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
.
length
());
}
String
password
=
EncryptionUtils
.
decryptWithAes
(
dbPassword
,
resourceProperties
.
getPasswordEncryptionSeed
(),
hostInfo
.
getName
());
scpService
.
put
(
hostIp
,
Integer
.
valueOf
(
hostInfo
.
getPort
()),
hostInfo
.
getLoginUsername
(),
password
,
tmpFilePath
,
pluginProperties
.
getPluginDeployPath
());
}
catch
(
Exception
e
)
{
...
...
This diff is collapsed.
Click to expand it.
platform-core/src/main/java/com/webank/wecube/platform/core/service/resource/MysqlAccountManagementService.java
+
10
-
10
View file @
5be3ec4c
...
...
@@ -59,12 +59,12 @@ public class MysqlAccountManagementService implements ResourceItemService {
log
.
info
(
"password before decrypt={}"
,
password
);
String
rawPassword
=
null
;
if
(
password
.
startsWith
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
))
{
rawPassword
=
EncryptionUtils
.
decryptWithAes
(
password
.
substring
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
.
length
()),
resourceProperties
.
getPasswordEncryptionSeed
(),
item
.
getName
());
}
else
{
rawPassword
=
password
;
password
=
password
.
substring
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
.
length
());
}
rawPassword
=
EncryptionUtils
.
decryptWithAes
(
password
,
resourceProperties
.
getPasswordEncryptionSeed
(),
item
.
getName
());
statement
.
executeUpdate
(
String
.
format
(
"CREATE USER `%s` IDENTIFIED BY '%s'"
,
username
,
rawPassword
));
statement
.
executeUpdate
(
String
.
format
(
"GRANT ALL ON %s.* TO %s@'%%' IDENTIFIED BY '%s'"
,
item
.
getName
(),
username
,
rawPassword
));
...
...
@@ -93,12 +93,12 @@ public class MysqlAccountManagementService implements ResourceItemService {
try
{
String
dbPassword
=
item
.
getResourceServer
().
getLoginPassword
();
if
(
dbPassword
.
startsWith
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
))
{
password
=
EncryptionUtils
.
decryptWithAes
(
dbPassword
.
substring
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
.
length
()),
resourceProperties
.
getPasswordEncryptionSeed
(),
item
.
getResourceServer
().
getName
());
}
else
{
password
=
dbPassword
;
dbPassword
=
dbPassword
.
substring
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
.
length
());
}
password
=
EncryptionUtils
.
decryptWithAes
(
dbPassword
,
resourceProperties
.
getPasswordEncryptionSeed
(),
item
.
getResourceServer
().
getName
());
}
catch
(
Exception
e
)
{
throw
new
WecubeCoreException
(
"3243"
,
String
.
format
(
"Failed to decrypt the login password of server [%s]."
,
item
.
getResourceServer
()),
e
);
...
...
This diff is collapsed.
Click to expand it.
platform-core/src/main/java/com/webank/wecube/platform/core/service/resource/MysqlDatabaseManagementService.java
+
5
-
3
View file @
5be3ec4c
...
...
@@ -53,10 +53,12 @@ public class MysqlDatabaseManagementService implements ResourceItemService {
private
DriverManagerDataSource
newDatasource
(
ResourceItem
item
)
{
String
password
=
item
.
getResourceServer
().
getLoginPassword
();
if
(
password
.
startsWith
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
))
{
password
=
EncryptionUtils
.
decryptWithAes
(
password
.
substring
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
.
length
()),
resourceProperties
.
getPasswordEncryptionSeed
(),
item
.
getResourceServer
().
getName
());
password
=
password
.
substring
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
.
length
());
}
password
=
EncryptionUtils
.
decryptWithAes
(
password
,
resourceProperties
.
getPasswordEncryptionSeed
(),
item
.
getResourceServer
().
getName
());
DriverManagerDataSource
dataSource
=
newMysqlDatasource
(
item
.
getResourceServer
().
getHost
(),
item
.
getResourceServer
().
getPort
(),
item
.
getResourceServer
().
getLoginUsername
(),
password
);
log
.
info
(
String
.
format
(
"Created new data source [host:%s,port:%s,username:%s]"
,
...
...
This diff is collapsed.
Click to expand it.
platform-core/src/main/java/com/webank/wecube/platform/core/service/resource/ResourceDataQueryService.java
+
5
-
3
View file @
5be3ec4c
...
...
@@ -296,10 +296,12 @@ public class ResourceDataQueryService {
String
dbUsername
=
pluginMysqlInstance
.
getUsername
();
String
password
=
pluginMysqlInstance
.
getPassword
();
if
(
password
.
startsWith
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
))
{
password
=
EncryptionUtils
.
decryptWithAes
(
password
.
substring
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
.
length
()),
resourceProperties
.
getPasswordEncryptionSeed
(),
dbUsername
);
password
=
password
.
substring
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
.
length
());
}
password
=
EncryptionUtils
.
decryptWithAes
(
password
,
resourceProperties
.
getPasswordEncryptionSeed
(),
dbUsername
);
ResourceItem
resourceItem
=
pluginMysqlInstance
.
getResourceItem
();
if
(
resourceItem
==
null
)
{
...
...
This diff is collapsed.
Click to expand it.
platform-core/src/main/java/com/webank/wecube/platform/core/service/resource/S3BucketManagementService.java
+
10
-
9
View file @
5be3ec4c
...
...
@@ -37,14 +37,13 @@ public class S3BucketManagementService implements ResourceItemService {
@Override
public
ResourceItem
createItem
(
ResourceItem
item
)
{
String
dbPassword
=
item
.
getResourceServer
().
getLoginPassword
();
String
password
=
null
;
if
(
dbPassword
.
startsWith
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
))
{
password
=
EncryptionUtils
.
decryptWithAes
(
dbPassword
.
substring
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
.
length
()),
resourceProperties
.
getPasswordEncryptionSeed
(),
item
.
getResourceServer
().
getName
());
}
else
{
password
=
dbPassword
;
dbPassword
=
dbPassword
.
substring
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
.
length
());
}
String
password
=
EncryptionUtils
.
decryptWithAes
(
dbPassword
,
resourceProperties
.
getPasswordEncryptionSeed
(),
item
.
getResourceServer
().
getName
());
AmazonS3
amazonS3
=
newS3Client
(
item
.
getResourceServer
().
getHost
(),
item
.
getResourceServer
().
getPort
(),
item
.
getResourceServer
().
getLoginUsername
(),
password
);
...
...
@@ -62,10 +61,12 @@ public class S3BucketManagementService implements ResourceItemService {
public
void
deleteItem
(
ResourceItem
item
)
{
String
password
=
item
.
getResourceServer
().
getLoginPassword
();
if
(
password
.
startsWith
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
))
{
password
=
EncryptionUtils
.
decryptWithAes
(
password
.
substring
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
.
length
()),
resourceProperties
.
getPasswordEncryptionSeed
(),
item
.
getResourceServer
().
getName
());
password
=
password
.
substring
(
ResourceManagementService
.
PASSWORD_ENCRYPT_AES_PREFIX
.
length
());
}
password
=
EncryptionUtils
.
decryptWithAes
(
password
,
resourceProperties
.
getPasswordEncryptionSeed
(),
item
.
getResourceServer
().
getName
());
AmazonS3
amazonS3
=
newS3Client
(
item
.
getResourceServer
().
getHost
(),
item
.
getResourceServer
().
getPort
(),
item
.
getResourceServer
().
getLoginUsername
(),
password
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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
Menu
Projects
Groups
Snippets
Help