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
c89d2adb
Commit
c89d2adb
authored
4 years ago
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added encryption
parent
e902d50b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
19 deletions
+15
-19
Dockerfile
manager/Dockerfile
+1
-0
CredentialApiController.java
...ain/java/nl/uva/sne/drip/api/CredentialApiController.java
+13
-2
CredentialService.java
.../main/java/nl/uva/sne/drip/service/CredentialService.java
+1
-17
No files found.
manager/Dockerfile
View file @
c89d2adb
...
@@ -5,6 +5,7 @@ CMD jar -xf manager-3.0.0.jar BOOT-INF/classes/application.properties && \
...
@@ -5,6 +5,7 @@ CMD jar -xf manager-3.0.0.jar BOOT-INF/classes/application.properties && \
sed -ie "s
#^message.broker.host=.*#message.broker.host=$RABBITMQ_HOST#" BOOT-INF/classes/application.properties && \
sed -ie "s
#^message.broker.host=.*#message.broker.host=$RABBITMQ_HOST#" BOOT-INF/classes/application.properties && \
sed -ie "s
#^db.host=.*#db.host=$MONGO_HOST#" BOOT-INF/classes/application.properties && \
sed -ie "s
#^db.host=.*#db.host=$MONGO_HOST#" BOOT-INF/classes/application.properties && \
sed -ie "s
#^sure-tosca.base.path=.*#sure-tosca.base.path=$SURE_TOSCA_BASE_PATH#" BOOT-INF/classes/application.properties && \
sed -ie "s
#^sure-tosca.base.path=.*#sure-tosca.base.path=$SURE_TOSCA_BASE_PATH#" BOOT-INF/classes/application.properties && \
echo "credential.secret=$CREDENTIAL_SECRET" >> application.properties && \
cat BOOT-INF/classes/application.properties && \
cat BOOT-INF/classes/application.properties && \
jar -uf manager-3.0.0.jar BOOT-INF/classes/application.properties && \
jar -uf manager-3.0.0.jar BOOT-INF/classes/application.properties && \
java -jar manager-3.0.0.jar
java -jar manager-3.0.0.jar
This diff is collapsed.
Click to expand it.
manager/src/main/java/nl/uva/sne/drip/api/CredentialApiController.java
View file @
c89d2adb
...
@@ -3,6 +3,9 @@ package nl.uva.sne.drip.api;
...
@@ -3,6 +3,9 @@ package nl.uva.sne.drip.api;
import
nl.uva.sne.drip.model.tosca.Credential
;
import
nl.uva.sne.drip.model.tosca.Credential
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
io.swagger.annotations.*
;
import
io.swagger.annotations.*
;
import
java.io.UnsupportedEncodingException
;
import
java.security.InvalidKeyException
;
import
java.security.NoSuchAlgorithmException
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
...
@@ -12,6 +15,10 @@ import org.springframework.web.bind.annotation.RequestBody;
...
@@ -12,6 +15,10 @@ import org.springframework.web.bind.annotation.RequestBody;
import
javax.validation.Valid
;
import
javax.validation.Valid
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
import
java.util.List
;
import
java.util.logging.Level
;
import
javax.crypto.BadPaddingException
;
import
javax.crypto.IllegalBlockSizeException
;
import
javax.crypto.NoSuchPaddingException
;
import
nl.uva.sne.drip.service.CredentialService
;
import
nl.uva.sne.drip.service.CredentialService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -41,8 +48,12 @@ public class CredentialApiController implements CredentialApi {
...
@@ -41,8 +48,12 @@ public class CredentialApiController implements CredentialApi {
@Valid
@RequestBody
Credential
body
)
{
@Valid
@RequestBody
Credential
body
)
{
String
accept
=
request
.
getHeader
(
"Accept"
);
String
accept
=
request
.
getHeader
(
"Accept"
);
if
(
accept
!=
null
&&
accept
.
contains
(
"application/json"
))
{
if
(
accept
!=
null
&&
accept
.
contains
(
"application/json"
))
{
String
id
=
credentialService
.
save
(
body
);
try
{
return
new
ResponseEntity
<>(
id
,
HttpStatus
.
OK
);
String
id
=
credentialService
.
save
(
body
);
return
new
ResponseEntity
<>(
id
,
HttpStatus
.
OK
);
}
catch
(
UnsupportedEncodingException
|
NoSuchAlgorithmException
|
NoSuchPaddingException
|
InvalidKeyException
|
IllegalBlockSizeException
|
BadPaddingException
ex
)
{
return
new
ResponseEntity
<>(
HttpStatus
.
INTERNAL_SERVER_ERROR
);
}
}
else
{
}
else
{
return
new
ResponseEntity
<>(
HttpStatus
.
NOT_ACCEPTABLE
);
return
new
ResponseEntity
<>(
HttpStatus
.
NOT_ACCEPTABLE
);
}
}
...
...
This diff is collapsed.
Click to expand it.
manager/src/main/java/nl/uva/sne/drip/service/CredentialService.java
View file @
c89d2adb
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
*/
*/
package
nl
.
uva
.
sne
.
drip
.
service
;
package
nl
.
uva
.
sne
.
drip
.
service
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
java.io.UnsupportedEncodingException
;
import
java.io.UnsupportedEncodingException
;
import
java.security.InvalidKeyException
;
import
java.security.InvalidKeyException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.NoSuchAlgorithmException
;
...
@@ -38,7 +37,7 @@ public class CredentialService {
...
@@ -38,7 +37,7 @@ public class CredentialService {
public
String
save
(
Credential
document
)
throws
UnsupportedEncodingException
,
NoSuchAlgorithmException
,
NoSuchPaddingException
,
InvalidKeyException
,
IllegalBlockSizeException
,
BadPaddingException
{
public
String
save
(
Credential
document
)
throws
UnsupportedEncodingException
,
NoSuchAlgorithmException
,
NoSuchPaddingException
,
InvalidKeyException
,
IllegalBlockSizeException
,
BadPaddingException
{
dao
.
save
(
encryptCredential
(
documen
t
));
dao
.
save
(
Converter
.
encryptCredential
(
document
,
credentialSecre
t
));
return
document
.
getId
();
return
document
.
getId
();
}
}
...
@@ -68,21 +67,6 @@ public class CredentialService {
...
@@ -68,21 +67,6 @@ public class CredentialService {
return
dao
.
findBycloudProviderName
(
provider
);
return
dao
.
findBycloudProviderName
(
provider
);
}
}
private
Credential
encryptCredential
(
Credential
credential
)
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
,
Converter
.
encryptString
(
credKey
,
credentialSecret
));
}
}
String
token
=
credential
.
getToken
();
if
(
token
!=
null
)
{
credential
.
setToken
(
Converter
.
encryptString
(
token
,
credentialSecret
));
}
return
credential
;
}
}
}
This diff is collapsed.
Click to expand it.
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