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
a66267cb
Commit
a66267cb
authored
8 years ago
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added permissions
parent
4927b5ba
Changes
30
Show whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
801 additions
and
176 deletions
+801
-176
PermissionChecker.java
...main/java/nl/uva/sne/drip/api/auth/PermissionChecker.java
+37
-0
SecurityConfig.java
...rc/main/java/nl/uva/sne/drip/api/conf/SecurityConfig.java
+2
-1
CloudCredentialsDao.java
...ain/java/nl/uva/sne/drip/api/dao/CloudCredentialsDao.java
+11
-0
UserScriptDao.java
.../src/main/java/nl/uva/sne/drip/api/dao/UserScriptDao.java
+2
-2
UnauthorizedExeption.java
...a/nl/uva/sne/drip/api/exception/UnauthorizedExeption.java
+35
-0
CloudCredentialsService.java
.../nl/uva/sne/drip/api/service/CloudCredentialsService.java
+71
-0
PlannerService.java
...main/java/nl/uva/sne/drip/api/service/PlannerService.java
+3
-3
SimplePlannerService.java
...ava/nl/uva/sne/drip/api/service/SimplePlannerService.java
+3
-3
ToscaService.java
...c/main/java/nl/uva/sne/drip/api/service/ToscaService.java
+1
-1
UserService.java
...rc/main/java/nl/uva/sne/drip/api/service/UserService.java
+1
-4
CloudConfigurationController0.java
...a/sne/drip/api/v0/rest/CloudConfigurationController0.java
+2
-1
PlannerController0.java
.../java/nl/uva/sne/drip/api/v0/rest/PlannerController0.java
+2
-2
ProvisionController0.java
...ava/nl/uva/sne/drip/api/v0/rest/ProvisionController0.java
+279
-0
CloudCredentialsController.java
.../uva/sne/drip/api/v1/rest/CloudCredentialsController.java
+28
-22
DeployController.java
...in/java/nl/uva/sne/drip/api/v1/rest/DeployController.java
+3
-2
PlannerController.java
...n/java/nl/uva/sne/drip/api/v1/rest/PlannerController.java
+2
-1
ProvisionController.java
...java/nl/uva/sne/drip/api/v1/rest/ProvisionController.java
+6
-6
UserScriptController.java
...ava/nl/uva/sne/drip/api/v1/rest/UserScriptController.java
+6
-6
Execute.java
...c/main/java/nl/uva/sne/drip/commons/v0/types/Execute.java
+28
-0
Upload.java
...rc/main/java/nl/uva/sne/drip/commons/v0/types/Upload.java
+31
-0
CloudCredentials.java
...va/nl/uva/sne/drip/commons/v1/types/CloudCredentials.java
+1
-1
ClusterCredentials.java
.../nl/uva/sne/drip/commons/v1/types/ClusterCredentials.java
+7
-7
KeyValueHolder.java
...java/nl/uva/sne/drip/commons/v1/types/KeyValueHolder.java
+62
-0
OwnedObject.java
...in/java/nl/uva/sne/drip/commons/v1/types/OwnedObject.java
+63
-0
Permissions.java
...in/java/nl/uva/sne/drip/commons/v1/types/Permissions.java
+61
-0
Plan.java
.../src/main/java/nl/uva/sne/drip/commons/v1/types/Plan.java
+3
-36
ProvisionInfo.java
.../java/nl/uva/sne/drip/commons/v1/types/ProvisionInfo.java
+19
-49
Script.java
...rc/main/java/nl/uva/sne/drip/commons/v1/types/Script.java
+1
-1
TestBean.java
.../main/java/nl/uva/sne/drip/commons/v1/types/TestBean.java
+30
-0
ToscaRepresentation.java
...nl/uva/sne/drip/commons/v1/types/ToscaRepresentation.java
+1
-28
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/auth/PermissionChecker.java
0 → 100644
View file @
a66267cb
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
auth
;
import
nl.uva.sne.drip.commons.v1.types.OwnedObject
;
import
nl.uva.sne.drip.commons.v1.types.User
;
import
org.springframework.stereotype.Component
;
/**
*
* @author S. Koulouzis
*/
@Component
(
"PermissionChecker"
)
public
class
PermissionChecker
{
public
boolean
canRead
(
OwnedObject
obj
,
User
user
)
{
return
false
;
}
public
boolean
isOwner
(
OwnedObject
obj
,
User
user
)
{
String
ownerid
=
obj
.
getOwner
();
return
user
.
getId
().
equals
(
ownerid
);
}
}
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/conf/SecurityConfig.java
View file @
a66267cb
...
...
@@ -36,7 +36,8 @@ import org.springframework.security.web.authentication.www.BasicAuthenticationFi
*/
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity
(
jsr250Enabled
=
true
)
//@EnableGlobalMethodSecurity(jsr250Enabled = true, prePostEnabled = true)
@EnableGlobalMethodSecurity
(
prePostEnabled
=
true
)
public
class
SecurityConfig
extends
WebSecurityConfigurerAdapter
{
@Autowired
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/dao/CloudCredentialsDao.java
View file @
a66267cb
...
...
@@ -24,4 +24,15 @@ import org.springframework.data.mongodb.repository.MongoRepository;
*/
public
interface
CloudCredentialsDao
extends
MongoRepository
<
CloudCredentials
,
String
>
{
@Override
CloudCredentials
findOne
(
String
id
);
//
// @PreAuthorize(ALLOWED_FOR_ADMINISTRATOR)
// @Override
// void delete(String id);
//
// @PreAuthorize(ALLOWED_FOR_OWNER + " or " + ALLOWED_FOR_ADMINISTRATOR)
// @Override
// List<CloudCredentials> findAll();
}
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/dao/UserScriptDao.java
View file @
a66267cb
...
...
@@ -15,13 +15,13 @@
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
dao
;
import
nl.uva.sne.drip.commons.v1.types.
User
Script
;
import
nl.uva.sne.drip.commons.v1.types.Script
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
/**
*
* @author S. Koulouzis
*/
public
interface
UserScriptDao
extends
MongoRepository
<
User
Script
,
String
>
{
public
interface
UserScriptDao
extends
MongoRepository
<
Script
,
String
>
{
}
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/exception/UnauthorizedExeption.java
0 → 100644
View file @
a66267cb
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
exception
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
/**
*
* @author S. Koulouzis
*/
@ResponseStatus
(
value
=
HttpStatus
.
UNAUTHORIZED
)
public
class
UnauthorizedExeption
extends
RuntimeException
{
public
UnauthorizedExeption
(
String
string
)
{
super
(
string
);
}
public
UnauthorizedExeption
()
{
super
();
}
}
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/service/CloudCredentialsService.java
0 → 100644
View file @
a66267cb
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
service
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
nl.uva.sne.drip.api.dao.CloudCredentialsDao
;
import
nl.uva.sne.drip.commons.v1.types.CloudCredentials
;
import
nl.uva.sne.drip.commons.v1.types.Permissions
;
import
nl.uva.sne.drip.commons.v1.types.User
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PostAuthorize
;
import
org.springframework.security.access.prepost.PostFilter
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreFilter
;
import
org.springframework.stereotype.Service
;
/**
*
* @author S. Koulouzis
*/
@Service
public
class
CloudCredentialsService
{
@Autowired
private
CloudCredentialsDao
dao
;
@PreFilter
(
"(filterObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))"
)
public
CloudCredentials
save
(
CloudCredentials
cloudCredentials
)
{
Permissions
permissions
=
new
Permissions
();
// String owner = user.getUsername();
// cloudCredentials.setOwner(owner);
System
.
err
.
println
(
cloudCredentials
.
getOwner
());
Set
<
String
>
read
=
new
HashSet
<>();
permissions
.
setRead
(
read
);
Set
<
String
>
write
=
new
HashSet
<>();
permissions
.
setWrite
(
write
);
cloudCredentials
.
setPermissions
(
permissions
);
return
dao
.
save
(
cloudCredentials
);
}
@PreAuthorize
(
"(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))"
)
public
CloudCredentials
findOne
(
String
id
)
{
CloudCredentials
creds
=
dao
.
findOne
(
id
);
return
creds
;
}
public
void
delete
(
String
id
)
{
dao
.
delete
(
id
);
}
@PreAuthorize
(
" (hasRole('ROLE_ADMIN')) or (hasRole('ROLE_USER'))"
)
@PostFilter
(
"(filterObject.owner == authentication.name)"
)
public
List
<
CloudCredentials
>
findAll
()
{
return
dao
.
findAll
();
}
}
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/service/PlannerService.java
View file @
a66267cb
...
...
@@ -107,7 +107,7 @@ public class PlannerService {
if
(
t2
==
null
)
{
throw
new
BadRequestException
();
}
Map
<
String
,
Object
>
map
=
t2
.
getK
vMap
();
Map
<
String
,
Object
>
map
=
t2
.
getK
eyValue
();
String
json
=
Converter
.
map2JsonString
(
map
);
json
=
json
.
replaceAll
(
"\\uff0E"
,
"\\."
);
byte
[]
bytes
=
json
.
getBytes
();
...
...
@@ -132,10 +132,10 @@ public class PlannerService {
throw
new
NotFoundException
();
}
Map
<
String
,
Object
>
map
=
plan
.
getK
vMap
();
Map
<
String
,
Object
>
map
=
plan
.
getK
eyValue
();
Set
<
String
>
ids
=
plan
.
getLoweLevelPlanIDs
();
for
(
String
lowID
:
ids
)
{
Map
<
String
,
Object
>
lowLevelMap
=
planDao
.
findOne
(
lowID
).
getK
vMap
();
Map
<
String
,
Object
>
lowLevelMap
=
planDao
.
findOne
(
lowID
).
getK
eyValue
();
map
.
putAll
(
lowLevelMap
);
}
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/service/SimplePlannerService.java
View file @
a66267cb
...
...
@@ -101,7 +101,7 @@ public class SimplePlannerService {
if
(
t2
==
null
)
{
throw
new
NotFoundException
();
}
Map
<
String
,
Object
>
map
=
t2
.
getK
vMap
();
Map
<
String
,
Object
>
map
=
t2
.
getK
eyValue
();
String
ymlStr
=
Converter
.
map2YmlString
(
map
);
ymlStr
=
ymlStr
.
replaceAll
(
"\\uff0E"
,
"\\."
);
byte
[]
bytes
=
ymlStr
.
getBytes
();
...
...
@@ -134,10 +134,10 @@ public class SimplePlannerService {
throw
new
NotFoundException
();
}
Map
<
String
,
Object
>
map
=
plan
.
getK
vMap
();
Map
<
String
,
Object
>
map
=
plan
.
getK
eyValue
();
Set
<
String
>
ids
=
plan
.
getLoweLevelPlanIDs
();
for
(
String
lowID
:
ids
)
{
Map
<
String
,
Object
>
lowLevelMap
=
planDao
.
findOne
(
lowID
).
getK
vMap
();
Map
<
String
,
Object
>
lowLevelMap
=
planDao
.
findOne
(
lowID
).
getK
eyValue
();
map
.
putAll
(
lowLevelMap
);
}
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/service/ToscaService.java
View file @
a66267cb
...
...
@@ -43,7 +43,7 @@ public class ToscaService {
throw
new
NotFoundException
();
}
Map
<
String
,
Object
>
map
=
tosca
.
getK
vMap
();
Map
<
String
,
Object
>
map
=
tosca
.
getK
eyValue
();
if
(
fromat
!=
null
&&
fromat
.
equals
(
"yml"
))
{
String
ymlStr
=
Converter
.
map2YmlString
(
map
);
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/service/UserService.java
View file @
a66267cb
...
...
@@ -15,8 +15,6 @@
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
service
;
import
java.util.Collection
;
import
java.util.HashSet
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
nl.uva.sne.drip.api.dao.UserDao
;
...
...
@@ -25,7 +23,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.stereotype.Service
;
/**
...
...
@@ -39,7 +36,7 @@ public class UserService implements UserDetailsService {
public
static
final
String
USER
=
"USER"
;
@Autowired
UserDao
dao
;
private
UserDao
dao
;
@Override
public
UserDetails
loadUserByUsername
(
String
username
)
throws
UsernameNotFoundException
{
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/v0/rest/CloudConfigurationController0.java
View file @
a66267cb
...
...
@@ -77,7 +77,8 @@ public class CloudConfigurationController0 {
}
cloudCredentials
.
setLogineKeys
(
loginKeys
);
cloudCredentials
.
setCloudProviderName
(
"ec2"
);
cloudCredentialsDao
.
save
(
cloudCredentials
);
cloudCredentials
=
cloudCredentialsDao
.
save
(
cloudCredentials
);
return
"Success: "
+
cloudCredentials
.
getId
();
}
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/v0/rest/PlannerController0.java
View file @
a66267cb
...
...
@@ -82,7 +82,7 @@ public class PlannerController0 {
}
e
.
name
=
p1Name
;
e
.
content
=
Converter
.
map2YmlString
(
plan1
.
getK
vMap
()).
replaceAll
(
"\n"
,
"\\n"
);
e
.
content
=
Converter
.
map2YmlString
(
plan1
.
getK
eyValue
()).
replaceAll
(
"\n"
,
"\\n"
);
files
.
add
(
e
);
for
(
String
lowiID
:
plan1
.
getLoweLevelPlanIDs
())
{
...
...
@@ -97,7 +97,7 @@ public class PlannerController0 {
}
e
.
name
=
p1Name
;
e
.
content
=
Converter
.
map2YmlString
(
lowPlan1
.
getK
vMap
()).
replaceAll
(
"\n"
,
"\\n"
);;
e
.
content
=
Converter
.
map2YmlString
(
lowPlan1
.
getK
eyValue
()).
replaceAll
(
"\n"
,
"\\n"
);;
files
.
add
(
e
);
}
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/v0/rest/ProvisionController0.java
0 → 100644
View file @
a66267cb
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
v0
.
rest
;
import
com.fasterxml.jackson.core.JsonParser
;
import
nl.uva.sne.drip.commons.v1.types.ProvisionInfo
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.Set
;
import
java.util.concurrent.TimeoutException
;
import
javax.annotation.security.RolesAllowed
;
import
nl.uva.sne.drip.api.dao.CloudCredentialsDao
;
import
nl.uva.sne.drip.commons.v1.types.Message
;
import
nl.uva.sne.drip.commons.v1.types.MessageParameter
;
import
nl.uva.sne.drip.commons.utils.Converter
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
nl.uva.sne.drip.api.exception.BadRequestException
;
import
nl.uva.sne.drip.api.exception.CloudCredentialsNotFoundException
;
import
nl.uva.sne.drip.api.exception.PlanNotFoundException
;
import
nl.uva.sne.drip.api.service.ProvisionService
;
import
nl.uva.sne.drip.api.service.SimplePlannerService
;
import
nl.uva.sne.drip.api.service.UserKeyService
;
import
nl.uva.sne.drip.api.service.UserScriptService
;
import
nl.uva.sne.drip.api.service.UserService
;
import
nl.uva.sne.drip.commons.v0.types.Upload
;
import
nl.uva.sne.drip.commons.v1.types.CloudCredentials
;
import
nl.uva.sne.drip.commons.v1.types.LoginKey
;
import
nl.uva.sne.drip.commons.v1.types.Plan
;
import
nl.uva.sne.drip.commons.v1.types.Script
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FilenameUtils
;
import
org.json.JSONException
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.RequestBody
;
/**
* This controller is responsible for obtaining resources from cloud providers
* based the plan generated by the planner and uploaded by the user
*
* @author S. Koulouzis
*/
@RestController
@RequestMapping
(
"/user/v0.0/switch/provision/"
)
@Component
public
class
ProvisionController0
{
@Value
(
"${message.broker.host}"
)
private
String
messageBrokerHost
;
@Autowired
private
UserScriptService
userScriptService
;
@Autowired
private
UserKeyService
userKeysService
;
@Autowired
private
CloudCredentialsDao
cloudCredentialsDao
;
@Autowired
private
ProvisionService
provisionService
;
@Autowired
private
SimplePlannerService
planService
;
@RequestMapping
(
value
=
"/upload"
,
method
=
RequestMethod
.
POST
,
consumes
=
MediaType
.
TEXT_XML_VALUE
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
String
provision
(
@RequestBody
Upload
upload
)
{
ProvisionInfo
provInfo
=
new
ProvisionInfo
();
String
cloudCredID
=
null
;
provInfo
.
setCloudcloudCredentialsID
(
cloudCredID
);
String
planID
=
null
;
provInfo
.
setPlanID
(
planID
);
String
userKeyID
=
null
;
provInfo
.
setUserKeyID
(
userKeyID
);
String
scriptID
=
null
;
provInfo
.
setScriptID
(
scriptID
);
provisionService
.
getDao
().
save
(
provInfo
);
return
"Success: Infrastructure files are uploaded! Action number: "
+
provInfo
.
getId
();
}
private
Message
buildProvisionerMessage
(
ProvisionInfo
pReq
)
throws
JSONException
,
IOException
{
Message
invokationMessage
=
new
Message
();
List
<
MessageParameter
>
parameters
=
new
ArrayList
();
CloudCredentials
cred
=
cloudCredentialsDao
.
findOne
(
pReq
.
getCloudcloudCredentialsID
());
if
(
cred
==
null
)
{
throw
new
CloudCredentialsNotFoundException
();
}
MessageParameter
conf
=
buildCloudConfParam
(
cred
);
parameters
.
add
(
conf
);
List
<
MessageParameter
>
certs
=
buildCertificatesParam
(
cred
);
parameters
.
addAll
(
certs
);
List
<
MessageParameter
>
topologies
=
buildTopologyParams
(
pReq
.
getPlanID
());
parameters
.
addAll
(
topologies
);
String
scriptID
=
pReq
.
getscriptID
();
if
(
scriptID
!=
null
)
{
List
<
MessageParameter
>
userScripts
=
buildScriptParams
(
scriptID
);
parameters
.
addAll
(
userScripts
);
}
String
userKeyID
=
pReq
.
getUserKeyID
();
if
(
userKeyID
!=
null
)
{
List
<
MessageParameter
>
userKeys
=
buildKeysParams
(
userKeyID
);
parameters
.
addAll
(
userKeys
);
}
invokationMessage
.
setParameters
(
parameters
);
invokationMessage
.
setCreationDate
((
System
.
currentTimeMillis
()));
return
invokationMessage
;
}
private
MessageParameter
buildCloudConfParam
(
CloudCredentials
cred
)
throws
JsonProcessingException
,
JSONException
,
IOException
{
MessageParameter
conf
=
null
;
String
provider
=
cred
.
getCloudProviderName
();
if
(
provider
==
null
)
{
throw
new
BadRequestException
(
"Provider name can't be null. Check the cloud credentials: "
+
cred
.
getId
());
}
switch
(
cred
.
getCloudProviderName
().
toLowerCase
())
{
case
"ec2"
:
conf
=
buildEC2Conf
(
cred
);
break
;
}
return
conf
;
}
private
List
<
MessageParameter
>
buildCertificatesParam
(
CloudCredentials
cred
)
{
List
<
LoginKey
>
loginKeys
=
cred
.
getLoginKeys
();
if
(
loginKeys
==
null
||
loginKeys
.
isEmpty
())
{
throw
new
BadRequestException
(
"Log in keys can't be empty"
);
}
List
<
MessageParameter
>
parameters
=
new
ArrayList
<>();
for
(
LoginKey
lk
:
loginKeys
)
{
String
domainName
=
lk
.
getAttributes
().
get
(
"domain_name"
);
if
(
domainName
==
null
)
{
domainName
=
lk
.
getAttributes
().
get
(
"domain_name "
);
}
MessageParameter
cert
=
new
MessageParameter
();
cert
.
setName
(
"certificate"
);
cert
.
setValue
(
lk
.
getKey
());
Map
<
String
,
String
>
attributes
=
new
HashMap
<>();
attributes
.
put
(
"filename"
,
domainName
);
cert
.
setAttributes
(
attributes
);
parameters
.
add
(
cert
);
}
return
parameters
;
}
private
List
<
MessageParameter
>
buildTopologyParams
(
String
planID
)
throws
JSONException
{
Plan
plan
=
planService
.
getDao
().
findOne
(
planID
);
if
(
plan
==
null
)
{
throw
new
PlanNotFoundException
();
}
List
<
MessageParameter
>
parameters
=
new
ArrayList
();
MessageParameter
topology
=
new
MessageParameter
();
topology
.
setName
(
"topology"
);
topology
.
setValue
(
Converter
.
map2YmlString
(
plan
.
getKeyValue
()));
Map
<
String
,
String
>
attributes
=
new
HashMap
<>();
attributes
.
put
(
"level"
,
String
.
valueOf
(
plan
.
getLevel
()));
attributes
.
put
(
"filename"
,
FilenameUtils
.
removeExtension
(
plan
.
getName
()));
topology
.
setAttributes
(
attributes
);
parameters
.
add
(
topology
);
Set
<
String
>
ids
=
plan
.
getLoweLevelPlanIDs
();
for
(
String
lowID
:
ids
)
{
Plan
lowPlan
=
planService
.
getDao
().
findOne
(
lowID
);
topology
=
new
MessageParameter
();
topology
.
setName
(
"topology"
);
topology
.
setValue
(
Converter
.
map2YmlString
(
lowPlan
.
getKeyValue
()));
attributes
=
new
HashMap
<>();
attributes
.
put
(
"level"
,
String
.
valueOf
(
lowPlan
.
getLevel
()));
attributes
.
put
(
"filename"
,
FilenameUtils
.
removeExtension
(
lowPlan
.
getName
()));
topology
.
setAttributes
(
attributes
);
parameters
.
add
(
topology
);
}
return
parameters
;
}
private
MessageParameter
buildEC2Conf
(
CloudCredentials
cred
)
throws
JsonProcessingException
,
JSONException
,
IOException
{
Properties
prop
=
Converter
.
getEC2Properties
(
cred
);
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
prop
.
store
(
baos
,
null
);
byte
[]
bytes
=
baos
.
toByteArray
();
MessageParameter
conf
=
new
MessageParameter
();
conf
.
setName
(
"ec2.conf"
);
String
charset
=
"UTF-8"
;
conf
.
setValue
(
new
String
(
bytes
,
charset
));
return
conf
;
}
private
List
<
MessageParameter
>
buildScriptParams
(
String
userScriptID
)
{
Script
script
=
userScriptService
.
getDao
().
findOne
(
userScriptID
);
if
(
script
==
null
)
{
throw
new
BadRequestException
(
"User script: "
+
userScriptID
+
" was not found"
);
}
List
<
MessageParameter
>
parameters
=
new
ArrayList
();
MessageParameter
scriptParameter
=
new
MessageParameter
();
scriptParameter
.
setName
(
"guiscript"
);
scriptParameter
.
setValue
(
script
.
getContents
());
scriptParameter
.
setEncoding
(
"UTF-8"
);
parameters
.
add
(
scriptParameter
);
return
parameters
;
}
private
List
<
MessageParameter
>
buildKeysParams
(
String
userKeyID
)
{
LoginKey
key
=
userKeysService
.
get
(
userKeyID
,
LoginKey
.
Type
.
PUBLIC
);
if
(
key
==
null
)
{
throw
new
BadRequestException
(
"User key: "
+
userKeyID
+
" was not found"
);
}
List
<
MessageParameter
>
parameters
=
new
ArrayList
();
MessageParameter
keyParameter
=
new
MessageParameter
();
keyParameter
.
setName
(
"sshkey"
);
keyParameter
.
setValue
(
key
.
getKey
());
keyParameter
.
setEncoding
(
"UTF-8"
);
parameters
.
add
(
keyParameter
);
return
parameters
;
}
private
Message
generateFakeResponse
(
String
path
)
throws
IOException
,
TimeoutException
,
InterruptedException
,
JSONException
{
// String strResponse = "{\"creationDate\":1488368936945,\"parameters\":["
// + "{\"name\":\"f293ff03-4b82-49e2-871a-899aadf821ce\","
// + "\"encoding\":\"UTF-8\",\"value\":"
// + "\"publicKeyPath: /tmp/Input-4007028381500/user.pem\\nuserName: "
// + "zh9314\\nsubnets:\\n- {name: s1, subnet: 192.168.10.0, "
// + "netmask: 255.255.255.0}\\ncomponents:\\n- "
// + "name: faab6756-61b6-4800-bffa-ae9d859a9d6c\\n "
// + "type: Switch.nodes.Compute\\n nodetype: t2.medium\\n "
// + "OStype: Ubuntu 16.04\\n domain: ec2.us-east-1.amazonaws.com\\n "
// + "script: /tmp/Input-4007028381500/guiscipt.sh\\n "
// + "installation: null\\n role: master\\n "
// + "dockers: mogswitch/InputDistributor\\n "
// + "public_address: 54.144.0.91\\n instanceId: i-0e78cbf853328b820\\n "
// + "ethernet_port:\\n - {name: p1, subnet_name: s1, "
// + "address: 192.168.10.10}\\n- name: 1c75eedf-8497-46fe-aeb8-dab6a62154cb\\n "
// + "type: Switch.nodes.Compute\\n nodetype: t2.medium\\n OStype: Ubuntu 16.04\\n domain: ec2.us-east-1.amazonaws.com\\n script: /tmp/Input-4007028381500/guiscipt.sh\\n installation: null\\n role: slave\\n dockers: mogswitch/ProxyTranscoder\\n public_address: 34.207.254.160\\n instanceId: i-0a99ea18fcc77ed7a\\n ethernet_port:\\n - {name: p1, subnet_name: s1, address: 192.168.10.11}\\n\"},{\"name\":\"kubernetes\",\"encoding\":\"UTF-8\",\"value\":\"54.144.0.91 ubuntu /tmp/Input-4007028381500/Virginia.pem master\\n34.207.254.160 ubuntu /tmp/Input-4007028381500/Virginia.pem slave\\n\"}]}";
// String strResponse = "{\"creationDate\":1488805337447,\"parameters\":[{\"name\":\"2e5dafb6-5a1c-4a66-9dca-5841f99ea735\",\"encoding\":\"UTF-8\",\"value\":\"publicKeyPath: /tmp/Input-11594765342486/user.pem\\nuserName: zh9314\\nsubnets:\\n- {name: s1, subnet: 192.168.10.0, netmask: 255.255.255.0}\\ncomponents:\\n- name: 8fcc1788d9ee462c826572c79fdb2a6a\\n type: Switch.nodes.Compute\\n nodeType: t2.medium\\n OStype: Ubuntu 16.04\\n script: /tmp/Input-11594765342486/guiscipt.sh\\n domain: ec2.us-east-1.amazonaws.com\\n installation: null\\n clusterType: swarm\\n role: master\\n dockers: mogswitch/ProxyTranscoder:1.0\\n public_address: 34.207.73.18\\n instanceId: i-0e82b5624a0df99b1\\n ethernet_port:\\n - {name: p1, subnet_name: s1, address: 192.168.10.10}\\n- name: 8fcc1788d9ee462c826572c79fdb2a6a\\n type: Switch.nodes.Compute\\n nodeType: t2.medium\\n OStype: Ubuntu 16.04\\n script: /tmp/Input-11594765342486/guiscipt.sh\\n domain: ec2.us-east-1.amazonaws.com\\n installation: null\\n clusterType: swarm\\n role: slave\\n dockers: mogswitch/ProxyTranscoder:1.0\\n public_address: 34.207.73.18\\n instanceId: i-0e82b5624a0df99b1\\n ethernet_port:\\n - {name: p1, subnet_name: s1, address: 192.168.10.11}\\n\"},{\"name\":\"kubernetes\",\"encoding\":\"UTF-8\",\"value\":\"34.207.73.18 ubuntu /tmp/Input-11594765342486/Virginia.pem master\\n34.207.73.18 ubuntu /tmp/Input-11594765342486/Virginia.pem slave\\n\"}]}";
String
strResponse
=
FileUtils
.
readFileToString
(
new
File
(
path
));
ObjectMapper
mapper
=
new
ObjectMapper
();
mapper
.
configure
(
JsonParser
.
Feature
.
ALLOW_SINGLE_QUOTES
,
true
);
return
mapper
.
readValue
(
strResponse
,
Message
.
class
);
}
}
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/v1/rest/CloudC
onfiguration
Controller.java
→
drip-api/src/main/java/nl/uva/sne/drip/api/v1/rest/CloudC
redentials
Controller.java
View file @
a66267cb
...
...
@@ -32,14 +32,16 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
nl.uva.sne.drip.api.dao.CloudCredentialsDao
;
import
nl.uva.sne.drip.api.exception.BadRequestException
;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.api.exception.NullKeyException
;
import
nl.uva.sne.drip.api.exception.NullKeyIDException
;
import
nl.uva.sne.drip.api.service.CloudCredentialsService
;
import
nl.uva.sne.drip.api.service.UserService
;
import
nl.uva.sne.drip.commons.v1.types.LoginKey
;
import
nl.uva.sne.drip.commons.v1.types.User
;
import
org.apache.commons.io.FilenameUtils
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestParam
;
...
...
@@ -54,12 +56,12 @@ import org.springframework.web.multipart.MultipartFile;
* @author S. Koulouzis
*/
@RestController
@RequestMapping
(
"/user/v1.0/c
onfiguration
/cloud"
)
@RequestMapping
(
"/user/v1.0/c
redentials
/cloud"
)
@Component
public
class
CloudC
onfiguration
Controller
{
public
class
CloudC
redentials
Controller
{
@Autowired
private
CloudCredentials
Dao
cloudCredentialsDao
;
private
CloudCredentials
Service
cloudCredentialsService
;
/**
* Post the cloud credentials.
...
...
@@ -80,7 +82,8 @@ public class CloudConfigurationController {
if
(
cloudCredentials
.
getKeyIdAlias
()
==
null
)
{
throw
new
NullKeyIDException
();
}
cloudCredentialsDao
.
save
(
cloudCredentials
);
// User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
cloudCredentials
=
cloudCredentialsService
.
save
(
cloudCredentials
);
return
cloudCredentials
.
getId
();
}
...
...
@@ -97,8 +100,9 @@ public class CloudConfigurationController {
public
@ResponseBody
String
addLogineKey
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@PathVariable
(
"id"
)
String
id
)
{
try
{
CloudCredentials
cc
=
cloudCredentialsDao
.
findOne
(
id
);
if
(
cc
==
null
)
{
CloudCredentials
cloudCredentials
=
cloudCredentialsService
.
findOne
(
id
);
if
(
cloudCredentials
==
null
)
{
throw
new
NotFoundException
();
}
if
(
file
.
isEmpty
())
{
...
...
@@ -106,23 +110,24 @@ public class CloudConfigurationController {
}
String
originalFileName
=
file
.
getOriginalFilename
();
byte
[]
bytes
=
file
.
getBytes
();
List
<
LoginKey
>
logInKeys
=
c
c
.
getLoginKeys
();
List
<
LoginKey
>
logInKeys
=
c
loudCredentials
.
getLoginKeys
();
if
(
logInKeys
==
null
)
{
logInKeys
=
new
ArrayList
<>();
}
LoginKey
key
=
new
LoginKey
();
key
.
setKey
(
new
String
(
bytes
,
"UTF-8"
));
if
(
c
c
.
getCloudProviderName
().
toLowerCase
().
equals
(
"ec2"
))
{
if
(
c
loudCredentials
.
getCloudProviderName
().
toLowerCase
().
equals
(
"ec2"
))
{
Map
<
String
,
String
>
attributes
=
new
HashMap
<>();
attributes
.
put
(
"domain_name"
,
FilenameUtils
.
removeExtension
(
originalFileName
));
key
.
setAttributes
(
attributes
);
}
logInKeys
.
add
(
key
);
cc
.
setLogineKeys
(
logInKeys
);
cloudCredentialsDao
.
save
(
cc
);
return
cloudCredentialsDao
.
findOne
(
id
).
getId
();
cloudCredentials
.
setLogineKeys
(
logInKeys
);
// User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
cloudCredentials
=
cloudCredentialsService
.
save
(
cloudCredentials
);
return
cloudCredentials
.
getId
();
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
CloudC
onfiguration
Controller
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
Logger
.
getLogger
(
CloudC
redentials
Controller
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
return
null
;
}
...
...
@@ -137,7 +142,8 @@ public class CloudConfigurationController {
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
CloudCredentials
get
(
@PathVariable
(
"id"
)
String
id
)
{
CloudCredentials
cc
=
cloudCredentialsDao
.
findOne
(
id
);
// User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
CloudCredentials
cc
=
cloudCredentialsService
.
findOne
(
id
);
if
(
cc
==
null
)
{
throw
new
NotFoundException
();
}
...
...
@@ -154,7 +160,7 @@ public class CloudConfigurationController {
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
String
delete
(
@PathVariable
(
"id"
)
String
id
)
{
cloudCredentials
Dao
.
delete
(
id
);
cloudCredentials
Service
.
delete
(
id
);
return
"Deleted :"
+
id
;
}
...
...
@@ -167,7 +173,7 @@ public class CloudConfigurationController {
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
List
<
String
>
getIds
()
{
List
<
CloudCredentials
>
all
=
cloudCredentials
Dao
.
findAll
();
List
<
CloudCredentials
>
all
=
cloudCredentials
Service
.
findAll
();
List
<
String
>
ids
=
new
ArrayList
<>();
for
(
CloudCredentials
tr
:
all
)
{
ids
.
add
(
tr
.
getId
());
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/v1/rest/DeployController.java
View file @
a66267cb
...
...
@@ -49,6 +49,7 @@ import nl.uva.sne.drip.commons.v1.types.ClusterCredentials;
import
nl.uva.sne.drip.commons.v1.types.DeployParameter
;
import
nl.uva.sne.drip.commons.v1.types.LoginKey
;
import
nl.uva.sne.drip.commons.v1.types.ProvisionInfo
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestParam
;
...
...
@@ -59,7 +60,7 @@ import org.springframework.web.bind.annotation.RequestParam;
*/
@RestController
@RequestMapping
(
"/user/v1.0/deployer"
)
@Co
mponent
@Co
ntroller
public
class
DeployController
{
@Value
(
"${message.broker.host}"
)
...
...
@@ -162,7 +163,7 @@ public class DeployController {
if
(
pro
==
null
)
{
throw
new
NotFoundException
();
}
String
cloudConfID
=
pro
.
getCloud
Conf
ID
();
String
cloudConfID
=
pro
.
getCloud
cloudCredentials
ID
();
CloudCredentials
cCred
=
cloudCredentialsDao
.
findOne
(
cloudConfID
);
List
<
LoginKey
>
loginKeys
=
cCred
.
getLoginKeys
();
List
<
DeployParameter
>
deployParams
=
pro
.
getDeployParameters
();
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/v1/rest/PlannerController.java
View file @
a66267cb
...
...
@@ -34,6 +34,7 @@ import org.springframework.web.bind.annotation.RestController;
import
nl.uva.sne.drip.api.service.PlannerService
;
import
nl.uva.sne.drip.api.service.UserService
;
import
nl.uva.sne.drip.commons.v1.types.Plan
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestParam
;
/**
...
...
@@ -44,7 +45,7 @@ import org.springframework.web.bind.annotation.RequestParam;
*/
@RestController
@RequestMapping
(
"/user/v1.0/planner"
)
@Co
mponent
@Co
ntroller
public
class
PlannerController
{
// @Autowired
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/v1/rest/ProvisionController.java
View file @
a66267cb
...
...
@@ -59,7 +59,7 @@ import nl.uva.sne.drip.commons.v1.types.CloudCredentials;
import
nl.uva.sne.drip.commons.v1.types.DeployParameter
;
import
nl.uva.sne.drip.commons.v1.types.LoginKey
;
import
nl.uva.sne.drip.commons.v1.types.Plan
;
import
nl.uva.sne.drip.commons.v1.types.
User
Script
;
import
nl.uva.sne.drip.commons.v1.types.Script
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FilenameUtils
;
import
org.json.JSONException
;
...
...
@@ -207,7 +207,7 @@ public class ProvisionController {
private
Message
buildProvisionerMessage
(
ProvisionInfo
pReq
)
throws
JSONException
,
IOException
{
Message
invokationMessage
=
new
Message
();
List
<
MessageParameter
>
parameters
=
new
ArrayList
();
CloudCredentials
cred
=
cloudCredentialsDao
.
findOne
(
pReq
.
getCloud
Conf
ID
());
CloudCredentials
cred
=
cloudCredentialsDao
.
findOne
(
pReq
.
getCloud
cloudCredentials
ID
());
if
(
cred
==
null
)
{
throw
new
CloudCredentialsNotFoundException
();
}
...
...
@@ -220,7 +220,7 @@ public class ProvisionController {
List
<
MessageParameter
>
topologies
=
buildTopologyParams
(
pReq
.
getPlanID
());
parameters
.
addAll
(
topologies
);
String
scriptID
=
pReq
.
get
UserS
criptID
();
String
scriptID
=
pReq
.
get
s
criptID
();
if
(
scriptID
!=
null
)
{
List
<
MessageParameter
>
userScripts
=
buildScriptParams
(
scriptID
);
parameters
.
addAll
(
userScripts
);
...
...
@@ -281,7 +281,7 @@ public class ProvisionController {
List
<
MessageParameter
>
parameters
=
new
ArrayList
();
MessageParameter
topology
=
new
MessageParameter
();
topology
.
setName
(
"topology"
);
topology
.
setValue
(
Converter
.
map2YmlString
(
plan
.
getK
vMap
()));
topology
.
setValue
(
Converter
.
map2YmlString
(
plan
.
getK
eyValue
()));
Map
<
String
,
String
>
attributes
=
new
HashMap
<>();
attributes
.
put
(
"level"
,
String
.
valueOf
(
plan
.
getLevel
()));
attributes
.
put
(
"filename"
,
FilenameUtils
.
removeExtension
(
plan
.
getName
()));
...
...
@@ -293,7 +293,7 @@ public class ProvisionController {
Plan
lowPlan
=
planService
.
getDao
().
findOne
(
lowID
);
topology
=
new
MessageParameter
();
topology
.
setName
(
"topology"
);
topology
.
setValue
(
Converter
.
map2YmlString
(
lowPlan
.
getK
vMap
()));
topology
.
setValue
(
Converter
.
map2YmlString
(
lowPlan
.
getK
eyValue
()));
attributes
=
new
HashMap
<>();
attributes
.
put
(
"level"
,
String
.
valueOf
(
lowPlan
.
getLevel
()));
attributes
.
put
(
"filename"
,
FilenameUtils
.
removeExtension
(
lowPlan
.
getName
()));
...
...
@@ -318,7 +318,7 @@ public class ProvisionController {
}
private
List
<
MessageParameter
>
buildScriptParams
(
String
userScriptID
)
{
User
Script
script
=
userScriptService
.
getDao
().
findOne
(
userScriptID
);
Script
script
=
userScriptService
.
getDao
().
findOne
(
userScriptID
);
if
(
script
==
null
)
{
throw
new
BadRequestException
(
"User script: "
+
userScriptID
+
" was not found"
);
}
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/v1/rest/UserScriptController.java
View file @
a66267cb
...
...
@@ -30,7 +30,7 @@ import org.springframework.web.bind.annotation.RestController;
import
org.springframework.web.multipart.MultipartFile
;
import
nl.uva.sne.drip.api.dao.UserScriptDao
;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.commons.v1.types.
User
Script
;
import
nl.uva.sne.drip.commons.v1.types.Script
;
import
org.springframework.web.bind.annotation.PathVariable
;
/**
...
...
@@ -64,7 +64,7 @@ public class UserScriptController {
byte
[]
bytes
=
file
.
getBytes
();
String
conents
=
new
String
(
bytes
,
"UTF-8"
);
UserScript
us
=
new
User
Script
();
Script
us
=
new
Script
();
us
.
setContents
(
conents
);
us
.
setName
(
name
);
...
...
@@ -86,13 +86,13 @@ public class UserScriptController {
*/
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
public
@ResponseBody
User
Script
get
(
@PathVariable
(
"id"
)
String
id
)
{
Script
get
(
@PathVariable
(
"id"
)
String
id
)
{
return
dao
.
findOne
(
id
);
}
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
DELETE
)
public
String
delete
(
@PathVariable
(
"id"
)
String
id
)
{
User
Script
script
=
dao
.
findOne
(
id
);
Script
script
=
dao
.
findOne
(
id
);
if
(
script
==
null
)
{
throw
new
NotFoundException
();
}
...
...
@@ -108,9 +108,9 @@ public class UserScriptController {
@RequestMapping
(
value
=
"/ids"
,
method
=
RequestMethod
.
GET
)
public
@ResponseBody
List
<
String
>
getIds
()
{
List
<
User
Script
>
all
=
dao
.
findAll
();
List
<
Script
>
all
=
dao
.
findAll
();
List
<
String
>
ids
=
new
ArrayList
<>();
for
(
User
Script
us
:
all
)
{
for
(
Script
us
:
all
)
{
ids
.
add
(
us
.
getId
());
}
return
ids
;
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/commons/v0/types/Execute.java
0 → 100644
View file @
a66267cb
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
commons
.
v0
.
types
;
/**
*
* @author S. Koulouzis
*/
public
class
Execute
{
public
String
user
;
public
String
pwd
;
public
String
action
;
}
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/commons/v0/types/Upload.java
0 → 100644
View file @
a66267cb
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
commons
.
v0
.
types
;
import
java.util.List
;
/**
*
* @author S. Koulouzis
*/
public
class
Upload
{
public
String
user
;
public
String
pwd
;
List
<
File
>
file
;
}
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/commons/v1/types/CloudCredentials.java
View file @
a66267cb
...
...
@@ -27,7 +27,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
* @author S. Koulouzis
*/
@Document
public
class
CloudCredentials
{
public
class
CloudCredentials
extends
OwnedObject
{
@Id
private
String
id
;
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/commons/v1/types/ClusterCredentials.java
View file @
a66267cb
...
...
@@ -29,7 +29,7 @@ public class ClusterCredentials {
@Id
private
String
id
;
private
String
contents
;
private
String
key
;
public
String
getId
()
{
return
id
;
...
...
@@ -43,19 +43,19 @@ public class ClusterCredentials {
}
/**
* The
contents
of the login key.
* @return the
contents
* The
key
of the login key.
* @return the
key
*/
@DocumentationExample
(
"BEGINRSAPRIVATEKEY-----\\nMIIEogIBAAKCAQEAm6AALYxkJFNzD3fVJ4+hMY5j0/kqM9CURLKXMlYuAysnvoG8wZKx9Bedefm\\neNSse4zTg798ZA2kDMZFIrwp1AseTwtj8DDu5fhG5DjyI3g6iJltS5zFQdMXneDlHXBX8cncSzNY\\nRx0NdjEMAe7YttvI8FNlxL0VnMFli/HB/ftzYMe5+AmkSROncVGHiwoiUpj+vtobCFOYtXsCf6ri\\nd4lgWA5wv6DZT/JKCYymiBqgSXu3ueFcEzw5SAukARWVjn1xccjZkokFfBbO/FpYY00TrUTBw9S6\\nD3iM+gj8RT6EKILOmhrt71D21S95WAWIT7h2YBsy1KAvMixhNf9VaQIDAQABAoIBAHhVYK3Xl3tr\\nN1Xm0ctJTQg3ijxhR2qsUBgGUokqezpdOoD2zbbOz7XvTYsX1GLr967U9pwxzUpELexexwiTvDgk\\nnLv8D7ui6qbRsmc4DSsWBRSophVIVFKQmftO8Xow6x+fuYJAYmsicM1KIYHBILtL+PSzV8anenWq\\nKQ3r0tfCiQhEzKEk4b1uT3SJWQyHE++JAhVkO7lIeb6S9Dg1jAaAeMnJ/NiMxTarpPRnxe6hsTsH\\ngG1iKWo+Skcl4SknOc+CMEfyDjG4FL7MGhKduahsO8vMUrgGsDD7EH3NiX/FweB8La6qpDYAwFpC\\nycrooyhiyzw8Wb5gGaYnmvr9l70CgYEAx74O8JleXaHpxEAmh4h7VbLmJ3mOylfBmOdzcHeedJQw\\nack2SAv65WBI9S9MEQ7J/vFuyw5HNk3C/mcWgzDQXSNIhHLvl/Z9sux/Qpm3SQWLz0RBxKV3dJ4r\\nwcAxzVA93+/L1Nee+VOKnlyRumvVa6+XLsLagpap2AVcTqlerMcCgYEAx3T2pXtqkCE9eU/ov22r\\npdaKjgHoGOUg1CMEfWi/Ch6sYIIRyrHz6dhy+yR1pXNgPbLWdrn8l88F3+IsmbaMupMgRmqwEC3G\\n9Y2FglGIVvRdZaagvRxLzRCcvcN4v6OYs9ST4o1xlv7Qxphld+0XDKv7VSCv/rASuK8BqlFL3E8C\\ngYArMXJRnRjG7qh6g9TRIjZphdI3XxX9s5Rt2D8iZvuhAhqmBZjzY4PR7kxYmO2+EpCjzNnEl0XW\\n/GHaWbiIjhnAykx4N9KP7gGom3O5lzwHUme1XnFKcO2wDjQwJbufRmba8iQF1srN577mF+Z7ha4V\\nJ1duCTzvWF1KFX6sk/uhKQKBgAcDFai7rgNjJ8YcCRKxyFcMM9LKPl6hr4XFtWKzTAQPEABUkkuN\\n9gVClsg9f+VRKRECOIf0Ae1UWeCFEwxUXp4wjfHrzkTDVztKvmbWdvSXorDwKrZ7SC7tZpVFSfly\\nxuuLjadpUZT9YFmbAfY1X5oSccOMYqORjRbxEB3svb4BAoGAGTgFuq9Zojh/KIqY8b4HpEfmh6CQ\\nhLVfD98Nqd6GDbxgvIM0v4mFXE92x2jn35Ia0JdFyh3B8Vkl7sqQZfxDFXI9O9pte2mPJxY9ICaY\\n55+X/SN1pd53BH+gaPZJy/R+Vpvs5MN48howjUKy5UKpoFeUWrS5QArjtvNCm4SGlXw=\\n-----ENDRSAPRIVATEKEY-----\\n"
)
public
String
get
Contents
()
{
return
contents
;
public
String
get
Key
()
{
return
key
;
}
/**
* @param contents the
contents
to set
* @param contents the
key
to set
*/
public
void
setContents
(
String
contents
)
{
this
.
contents
=
contents
;
this
.
key
=
contents
;
}
}
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/commons/v1/types/KeyValueHolder.java
0 → 100644
View file @
a66267cb
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
commons
.
v1
.
types
;
import
java.util.Map
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
/**
*
* @author S. Koulouzis
*/
@Document
public
class
KeyValueHolder
{
@Id
private
String
id
;
private
Map
<
String
,
Object
>
keyValue
;
/**
* @return the keyValue
*/
public
Map
<
String
,
Object
>
getKeyValue
()
{
return
keyValue
;
}
/**
* @param keyValue the keyValue to set
*/
public
void
setKvMap
(
Map
<
String
,
Object
>
keyValue
)
{
this
.
keyValue
=
keyValue
;
}
/**
* @return the id
*/
public
String
getId
()
{
return
id
;
}
/**
* @param id the id to set
*/
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
}
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/commons/v1/types/OwnedObject.java
0 → 100644
View file @
a66267cb
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
commons
.
v1
.
types
;
import
javax.validation.constraints.NotNull
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.stereotype.Component
;
/**
*
* @author S. Koulouzis
*/
@Document
public
class
OwnedObject
{
@NotNull
private
String
owner
;
@NotNull
private
Permissions
permissions
;
/**
* @return the permissions
*/
public
Permissions
getPermissions
()
{
return
permissions
;
}
/**
* @param permissions the permissions to set
*/
public
void
setPermissions
(
Permissions
permissions
)
{
this
.
permissions
=
permissions
;
}
/**
* @return the owner
*/
public
String
getOwner
()
{
return
owner
;
}
/**
* @param owner the ownerID to set
*/
public
void
setOwner
(
String
owner
)
{
this
.
owner
=
owner
;
}
}
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/commons/v1/types/Permissions.java
0 → 100644
View file @
a66267cb
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
commons
.
v1
.
types
;
import
java.util.Set
;
import
javax.validation.constraints.NotNull
;
import
org.springframework.data.mongodb.core.mapping.Document
;
/**
*
* @author S. Koulouzis
*/
@Document
public
class
Permissions
{
private
Set
<
String
>
read
;
private
Set
<
String
>
write
;
/**
* @return the read
*/
public
Set
<
String
>
getRead
()
{
return
read
;
}
/**
* @param read the read to set
*/
public
void
setRead
(
Set
<
String
>
read
)
{
this
.
read
=
read
;
}
/**
* @return the write
*/
public
Set
<
String
>
getWrite
()
{
return
write
;
}
/**
* @param write the write to set
*/
public
void
setWrite
(
Set
<
String
>
write
)
{
this
.
write
=
write
;
}
}
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/commons/v1/types/Plan.java
View file @
a66267cb
...
...
@@ -15,9 +15,7 @@
*/
package
nl
.
uva
.
sne
.
drip
.
commons
.
v1
.
types
;
import
java.util.Map
;
import
java.util.Set
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
/**
...
...
@@ -27,10 +25,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
* @author S. Koulouzis
*/
@Document
public
class
Plan
{
@Id
private
String
id
;
public
class
Plan
extends
KeyValueHolder
{
private
String
toscaID
;
...
...
@@ -40,31 +35,6 @@ public class Plan {
private
Set
<
String
>
loweLevelPlansIDs
;
private
Map
<
String
,
Object
>
kvMap
;
public
final
String
getId
()
{
return
id
;
}
public
final
void
setId
(
final
String
id
)
{
this
.
id
=
id
;
}
/**
*
* @return the kvMap
*/
public
Map
<
String
,
Object
>
getKvMap
()
{
return
kvMap
;
}
/**
* @param kvMap the kvMap to set
*/
public
void
setKvMap
(
Map
<
String
,
Object
>
kvMap
)
{
this
.
kvMap
=
kvMap
;
}
/**
* @return the name
*/
...
...
@@ -114,9 +84,6 @@ public class Plan {
return
loweLevelPlansIDs
;
}
/**
* @param loweLevelPlans the loweLevelPlansIDs to set
*/
public
void
setLoweLevelPlansIDs
(
Set
<
String
>
loweLevelPlansIDs
)
{
this
.
loweLevelPlansIDs
=
loweLevelPlansIDs
;
}
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/commons/v1/types/ProvisionInfo.java
View file @
a66267cb
...
...
@@ -16,41 +16,37 @@
package
nl
.
uva
.
sne
.
drip
.
commons
.
v1
.
types
;
import
java.util.List
;
import
java.util.Map
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
/**
*
* @author S. Koulouzis
*/
public
class
ProvisionInfo
{
@Document
public
class
ProvisionInfo
extends
KeyValueHolder
{
@Id
private
String
id
;
private
String
cloudConfID
;
private
String
cloudCredentialsID
;
private
String
planID
;
private
String
userS
criptID
;
private
String
s
criptID
;
private
String
userKeyID
;
private
Map
<
String
,
Object
>
kvMap
;
private
List
<
DeployParameter
>
deployParameters
;
/**
* @return the cloudC
onf
ID
* @return the cloudC
redentials
ID
*/
public
String
getCloud
Conf
ID
()
{
return
cloudC
onf
ID
;
public
String
getCloud
cloudCredentials
ID
()
{
return
cloudC
redentials
ID
;
}
/**
* @param cloudConfID the cloudC
onf
ID to set
* @param cloudConfID the cloudC
redentials
ID to set
*/
public
void
setCloud
Conf
ID
(
String
cloudConfID
)
{
this
.
cloudC
onf
ID
=
cloudConfID
;
public
void
setCloud
cloudCredentials
ID
(
String
cloudConfID
)
{
this
.
cloudC
redentials
ID
=
cloudConfID
;
}
/**
...
...
@@ -68,17 +64,17 @@ public class ProvisionInfo {
}
/**
* @return the
userS
criptID
* @return the
s
criptID
*/
public
String
get
UserS
criptID
()
{
return
userS
criptID
;
public
String
get
s
criptID
()
{
return
s
criptID
;
}
/**
* @param
userScriptID the userS
criptID to set
* @param
scriptID the s
criptID to set
*/
public
void
set
UserScriptID
(
String
userS
criptID
)
{
this
.
userScriptID
=
userS
criptID
;
public
void
set
ScriptID
(
String
s
criptID
)
{
this
.
scriptID
=
s
criptID
;
}
/**
...
...
@@ -95,33 +91,7 @@ public class ProvisionInfo {
this
.
userKeyID
=
userKeyID
;
}
/**
* @return the id
*/
public
String
getId
()
{
return
id
;
}
/**
* @param id the id to set
*/
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
/**
* @return the kvMap
*/
public
Map
<
String
,
Object
>
getKvMap
()
{
return
kvMap
;
}
/**
* @param kvMap the kvMap to set
*/
public
void
setKvMap
(
Map
<
String
,
Object
>
kvMap
)
{
this
.
kvMap
=
kvMap
;
}
public
void
setDeployParameters
(
List
<
DeployParameter
>
deployParameters
)
{
this
.
deployParameters
=
deployParameters
;
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/commons/v1/types/
User
Script.java
→
drip-api/src/main/java/nl/uva/sne/drip/commons/v1/types/Script.java
View file @
a66267cb
...
...
@@ -25,7 +25,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
* @author S. Koulouzis
*/
@Document
public
class
User
Script
{
public
class
Script
{
@Id
private
String
id
;
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/commons/v1/types/TestBean.java
0 → 100644
View file @
a66267cb
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
commons
.
v1
.
types
;
import
org.springframework.stereotype.Component
;
/**
*
* @author S. Koulouzis
*/
@Component
public
class
TestBean
{
public
boolean
getTestBoolean
()
{
return
false
;
}
}
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/commons/v1/types/ToscaRepresentation.java
View file @
a66267cb
...
...
@@ -24,37 +24,10 @@ import org.springframework.data.mongodb.core.mapping.Document;
* @author S. Koulouzis
*/
@Document
public
class
ToscaRepresentation
{
@Id
private
String
id
;
public
class
ToscaRepresentation
extends
KeyValueHolder
{
private
String
name
;
private
Map
<
String
,
Object
>
kvMap
;
public
final
String
getId
()
{
return
id
;
}
public
final
void
setId
(
final
String
id
)
{
this
.
id
=
id
;
}
/**
* @return the kvMap
*/
public
Map
<
String
,
Object
>
getKvMap
()
{
return
kvMap
;
}
/**
* @param kvMap the kvMap to set
*/
public
void
setKvMap
(
Map
<
String
,
Object
>
kvMap
)
{
this
.
kvMap
=
kvMap
;
}
/**
* @return the name
*/
...
...
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