Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
7ac714b8
Commit
7ac714b8
authored
Jun 05, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added encryption
parent
c89d2adb
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
4 deletions
+52
-4
Converter.java
...rc/main/java/nl/uva/sne/drip/commons/utils/Converter.java
+35
-0
deployer-deployment.yaml
k8s/CONF/deployer-deployment.yaml
+3
-1
manager-deployment.yaml
k8s/CONF/manager-deployment.yaml
+2
-0
Dockerfile
provisioner/Dockerfile
+1
-0
CloudStormService.java
...n/java/nl/uva/sne/drip/provisioner/CloudStormService.java
+9
-2
application.properties
provisioner/src/main/resources/application.properties
+2
-1
No files found.
commons/src/main/java/nl/uva/sne/drip/commons/utils/Converter.java
View file @
7ac714b8
...
...
@@ -41,6 +41,7 @@ import java.util.Enumeration;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipFile
;
import
java.util.zip.ZipOutputStream
;
...
...
@@ -49,6 +50,7 @@ import javax.crypto.Cipher;
import
javax.crypto.IllegalBlockSizeException
;
import
javax.crypto.NoSuchPaddingException
;
import
javax.crypto.spec.SecretKeySpec
;
import
nl.uva.sne.drip.model.tosca.Credential
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.springframework.web.multipart.MultipartFile
;
...
...
@@ -191,4 +193,37 @@ public class Converter {
return
new
SecretKeySpec
(
key
,
"AES"
);
}
public
static
Credential
encryptCredential
(
Credential
credential
,
String
credentialSecret
)
throws
UnsupportedEncodingException
,
NoSuchAlgorithmException
,
NoSuchPaddingException
,
InvalidKeyException
,
IllegalBlockSizeException
,
BadPaddingException
{
Map
<
String
,
String
>
credKeys
=
credential
.
getKeys
();
Set
<
String
>
keySet
=
credKeys
.
keySet
();
for
(
String
key
:
keySet
)
{
String
credKey
=
credKeys
.
get
(
key
);
if
(
credKey
!=
null
)
{
credKeys
.
put
(
key
,
encryptString
(
credKey
,
credentialSecret
));
}
}
String
token
=
credential
.
getToken
();
if
(
token
!=
null
)
{
credential
.
setToken
(
encryptString
(
token
,
credentialSecret
));
}
return
credential
;
}
public
static
Credential
dencryptCredential
(
Credential
credential
,
String
credentialSecret
)
throws
UnsupportedEncodingException
,
NoSuchAlgorithmException
,
NoSuchPaddingException
,
InvalidKeyException
,
IllegalBlockSizeException
,
BadPaddingException
{
Map
<
String
,
String
>
credKeys
=
credential
.
getKeys
();
Set
<
String
>
keySet
=
credKeys
.
keySet
();
for
(
String
key
:
keySet
)
{
String
credKey
=
credKeys
.
get
(
key
);
if
(
credKey
!=
null
)
{
credKeys
.
put
(
key
,
decryptString
(
credKey
,
credentialSecret
));
}
}
String
token
=
credential
.
getToken
();
if
(
token
!=
null
)
{
credential
.
setToken
(
decryptString
(
token
,
credentialSecret
));
}
return
credential
;
}
}
k8s/CONF/deployer-deployment.yaml
View file @
7ac714b8
...
...
@@ -35,6 +35,8 @@ spec:
value
:
http://sure-tosca:8081/tosca-sure/1.0.0
-
name
:
SEMAPHORE_BASE_PATH
value
:
http://semaphore:3000/api
-
name
:
CREDENTIAL_SECRET
value
:
top_secret
image
:
qcdis/deployer:3.0.0
name
:
deployer
imagePullPolicy
:
Always
...
...
k8s/CONF/manager-deployment.yaml
View file @
7ac714b8
...
...
@@ -35,6 +35,8 @@ spec:
value
:
rabbit
-
name
:
SURE_TOSCA_BASE_PATH
value
:
http://sure-tosca:8081/tosca-sure/1.0.0
-
name
:
CREDENTIAL_SECRET
value
:
top_secret
image
:
qcdis/manager:3.0.0
name
:
manager
imagePullPolicy
:
Always
...
...
provisioner/Dockerfile
View file @
7ac714b8
...
...
@@ -10,6 +10,7 @@ CMD jar -xf provisioner-3.0.0-jar-with-dependencies.jar application.properties &
ENCRYPTION_PASSWORD=`date +%s | sha256sum | base64 | head -c 32 ; echo` && \
echo "cloud.storm.secret=$ENCRYPTION_PASSWORD" >> application.properties && \
echo "cloud.storm.db.path=/etc/UD" >> application.properties && \
echo "credential.secret=$CREDENTIAL_SECRET" >> application.properties && \
cat application.properties && \
jar -uf provisioner-3.0.0-jar-with-dependencies.jar application.properties && \
sleep 5 && \
...
...
provisioner/src/main/java/nl/uva/sne/drip/provisioner/CloudStormService.java
View file @
7ac714b8
...
...
@@ -69,6 +69,7 @@ import topology.analysis.TopologyAnalysisMain;
class
CloudStormService
{
private
String
secret
;
private
String
credentialSecret
;
/**
* @return the helper
...
...
@@ -117,6 +118,11 @@ class CloudStormService {
if
(
secret
==
null
)
{
throw
new
NullPointerException
(
"secret cannot be null"
);
}
credentialSecret
=
properties
.
getProperty
(
"credential.secret"
);
if
(
credentialSecret
==
null
)
{
throw
new
NullPointerException
(
"secret cannot be null"
);
}
Logger
.
getLogger
(
CloudStormService
.
class
.
getName
()).
log
(
Level
.
FINE
,
"sureToscaBasePath: {0}"
,
sureToscaBasePath
);
this
.
helper
=
new
ToscaHelper
(
sureToscaBasePath
);
this
.
helper
.
uploadToscaTemplate
(
toscaTemplate
);
...
...
@@ -138,7 +144,7 @@ class CloudStormService {
String
encryptedFileContents
=
(
String
)
provisionedFiles
.
get
(
"file_contents"
);
if
(
encryptedFileContents
!=
null
)
{
File
zipFile
=
new
File
(
tempInputDir
.
getParent
()
+
File
.
separator
+
Long
.
toString
(
System
.
nanoTime
())
+
"-"
+
CLOUD_STORM_FILES_ZIP_SUFIX
);
String
fileContentsBase64
=
Converter
.
decryptString
(
encryptedFileContents
,
secret
);
String
fileContentsBase64
=
Converter
.
decryptString
(
encryptedFileContents
,
secret
);
Converter
.
decodeBase64BToFile
(
fileContentsBase64
,
zipFile
.
getAbsolutePath
());
Converter
.
unzipFolder
(
zipFile
.
getAbsolutePath
(),
tempInputDir
.
getAbsolutePath
());
...
...
@@ -295,6 +301,7 @@ class CloudStormService {
int
i
=
0
;
for
(
NodeTemplateMap
vmTopologyMap
:
vmTopologiesMaps
)
{
Credential
toscaCredentials
=
getHelper
().
getCredentialsFromVMTopology
(
vmTopologyMap
);
toscaCredentials
=
Converter
.
dencryptCredential
(
toscaCredentials
,
credentialSecret
);
CloudCred
cloudStormCredential
=
new
CloudCred
();
cloudStormCredential
.
setCloudProvider
(
toscaCredentials
.
getCloudProviderName
());
String
credInfoFile
=
toscaCredentials
.
getCloudProviderName
()
+
i
+
".yml"
;
...
...
@@ -429,7 +436,7 @@ class CloudStormService {
Logger
.
getLogger
(
CloudStormService
.
class
.
getName
()).
log
(
Level
.
FINE
,
"Created zip at: {0}"
,
zipPath
);
String
cloudStormZipFileContentsAsBase64
=
Converter
.
encodeFileToBase64Binary
(
zipPath
);
String
encryptedCloudStormZipFileContents
=
Converter
.
encryptString
(
cloudStormZipFileContentsAsBase64
,
secret
);
String
encryptedCloudStormZipFileContents
=
Converter
.
encryptString
(
cloudStormZipFileContentsAsBase64
,
secret
);
provisionedFiles
.
put
(
"file_contents"
,
encryptedCloudStormZipFileContents
);
provisionedFiles
.
put
(
"encoding"
,
"base64"
);
provisionedFiles
.
put
(
"file_ext"
,
"zip"
);
...
...
provisioner/src/main/resources/application.properties
View file @
7ac714b8
...
...
@@ -7,3 +7,4 @@ message.broker.queue.deployer=deployer
sure-tosca.base.path
=
http://localhost:8081/tosca-sure/1.0.0
cloud.storm.db.path
=
etc/UD
cloud.storm.secret
=
top_secret
credential.secret
=
top_secret
\ No newline at end of file
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