Commit a66267cb authored by Spiros Koulouzis's avatar Spiros Koulouzis

Added permissions

parent 4927b5ba
/*
* 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);
}
}
......@@ -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
......
......@@ -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();
}
......@@ -15,13 +15,13 @@
*/
package nl.uva.sne.drip.api.dao;
import nl.uva.sne.drip.commons.v1.types.UserScript;
import nl.uva.sne.drip.commons.v1.types.Script;
import org.springframework.data.mongodb.repository.MongoRepository;
/**
*
* @author S. Koulouzis
*/
public interface UserScriptDao extends MongoRepository<UserScript, String> {
public interface UserScriptDao extends MongoRepository<Script, String> {
}
/*
* 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();
}
}
/*
* 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();
}
}
......@@ -107,7 +107,7 @@ public class PlannerService {
if (t2 == null) {
throw new BadRequestException();
}
Map<String, Object> map = t2.getKvMap();
Map<String, Object> map = t2.getKeyValue();
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.getKvMap();
Map<String, Object> map = plan.getKeyValue();
Set<String> ids = plan.getLoweLevelPlanIDs();
for (String lowID : ids) {
Map<String, Object> lowLevelMap = planDao.findOne(lowID).getKvMap();
Map<String, Object> lowLevelMap = planDao.findOne(lowID).getKeyValue();
map.putAll(lowLevelMap);
}
......
......@@ -101,7 +101,7 @@ public class SimplePlannerService {
if (t2 == null) {
throw new NotFoundException();
}
Map<String, Object> map = t2.getKvMap();
Map<String, Object> map = t2.getKeyValue();
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.getKvMap();
Map<String, Object> map = plan.getKeyValue();
Set<String> ids = plan.getLoweLevelPlanIDs();
for (String lowID : ids) {
Map<String, Object> lowLevelMap = planDao.findOne(lowID).getKvMap();
Map<String, Object> lowLevelMap = planDao.findOne(lowID).getKeyValue();
map.putAll(lowLevelMap);
}
......
......@@ -43,7 +43,7 @@ public class ToscaService {
throw new NotFoundException();
}
Map<String, Object> map = tosca.getKvMap();
Map<String, Object> map = tosca.getKeyValue();
if (fromat != null && fromat.equals("yml")) {
String ymlStr = Converter.map2YmlString(map);
......
......@@ -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 {
......
......@@ -77,7 +77,8 @@ public class CloudConfigurationController0 {
}
cloudCredentials.setLogineKeys(loginKeys);
cloudCredentials.setCloudProviderName("ec2");
cloudCredentialsDao.save(cloudCredentials);
cloudCredentials = cloudCredentialsDao.save(cloudCredentials);
return "Success: " + cloudCredentials.getId();
}
......
......@@ -82,7 +82,7 @@ public class PlannerController0 {
}
e.name = p1Name;
e.content = Converter.map2YmlString(plan1.getKvMap()).replaceAll("\n", "\\n");
e.content = Converter.map2YmlString(plan1.getKeyValue()).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.getKvMap()).replaceAll("\n", "\\n");;
e.content = Converter.map2YmlString(lowPlan1.getKeyValue()).replaceAll("\n", "\\n");;
files.add(e);
}
......
......@@ -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;
......@@ -47,19 +49,19 @@ import org.springframework.web.multipart.MultipartFile;
/**
*
* This controller is responsible for handling CloudCredentials.
* CloudCredentials are a represntation of the credentials that are used by the
* provisoner to request for resources (VMs)
*
* This controller is responsible for handling CloudCredentials.
* CloudCredentials are a represntation of the credentials that are used by the
* provisoner to request for resources (VMs)
*
* @author S. Koulouzis
*/
@RestController
@RequestMapping("/user/v1.0/configuration/cloud")
@RequestMapping("/user/v1.0/credentials/cloud")
@Component
public class CloudConfigurationController {
public class CloudCredentialsController {
@Autowired
private CloudCredentialsDao cloudCredentialsDao;
private CloudCredentialsService cloudCredentialsService;
/**
* Post the cloud credentials.
......@@ -69,7 +71,7 @@ public class CloudConfigurationController {
*/
@RequestMapping(method = RequestMethod.POST)
@RolesAllowed({UserService.USER, UserService.ADMIN})
@StatusCodes({
@StatusCodes({
@ResponseCode(code = 400, condition = "Key or KeyIdAlias can't be empty")
})
public @ResponseBody
......@@ -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 = cc.getLoginKeys();
List<LoginKey> logInKeys = cloudCredentials.getLoginKeys();
if (logInKeys == null) {
logInKeys = new ArrayList<>();
}
LoginKey key = new LoginKey();
key.setKey(new String(bytes, "UTF-8"));
if (cc.getCloudProviderName().toLowerCase().equals("ec2")) {
if (cloudCredentials.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(CloudConfigurationController.class.getName()).log(Level.SEVERE, null, ex);
Logger.getLogger(CloudCredentialsController.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,20 +160,20 @@ public class CloudConfigurationController {
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
String delete(@PathVariable("id") String id) {
cloudCredentialsDao.delete(id);
cloudCredentialsService.delete(id);
return "Deleted :" + id;
}
/**
* Gets all the IDs of the stored cloud credentials
*
* @return a list of stored IDs
* @return a list of stored IDs
*/
@RequestMapping(value = "/ids", method = RequestMethod.GET)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
List<String> getIds() {
List<CloudCredentials> all = cloudCredentialsDao.findAll();
List<CloudCredentials> all = cloudCredentialsService.findAll();
List<String> ids = new ArrayList<>();
for (CloudCredentials tr : all) {
ids.add(tr.getId());
......
......@@ -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")
@Component
@Controller
public class DeployController {
@Value("${message.broker.host}")
......@@ -162,7 +163,7 @@ public class DeployController {
if (pro == null) {
throw new NotFoundException();
}
String cloudConfID = pro.getCloudConfID();
String cloudConfID = pro.getCloudcloudCredentialsID();
CloudCredentials cCred = cloudCredentialsDao.findOne(cloudConfID);
List<LoginKey> loginKeys = cCred.getLoginKeys();
List<DeployParameter> deployParams = pro.getDeployParameters();
......
......@@ -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")
@Component
@Controller
public class PlannerController {
// @Autowired
......
......@@ -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.UserScript;
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.getCloudConfID());
CloudCredentials cred = cloudCredentialsDao.findOne(pReq.getCloudcloudCredentialsID());
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.getUserScriptID();
String scriptID = pReq.getscriptID();
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.getKvMap()));
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()));
......@@ -293,7 +293,7 @@ public class ProvisionController {
Plan lowPlan = planService.getDao().findOne(lowID);
topology = new MessageParameter();
topology.setName("topology");
topology.setValue(Converter.map2YmlString(lowPlan.getKvMap()));
topology.setValue(Converter.map2YmlString(lowPlan.getKeyValue()));
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) {
UserScript script = userScriptService.getDao().findOne(userScriptID);
Script script = userScriptService.getDao().findOne(userScriptID);
if (script == null) {
throw new BadRequestException("User script: " + userScriptID + " was not found");
}
......
......@@ -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.UserScript;
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 UserScript();
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
UserScript 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) {
UserScript 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<UserScript> all = dao.findAll();
List<Script> all = dao.findAll();
List<String> ids = new ArrayList<>();
for (UserScript us : all) {
for (Script us : all) {
ids.add(us.getId());
}
return ids;
......
/*
* 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;
}
/*
* 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;
}
......@@ -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;
......
......@@ -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 getContents() {
return contents;
public String getKey() {
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;
}
}
/*
* 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;
}
}
/*
* 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;
}
}
/*
* 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;
}
}
......@@ -15,22 +15,17 @@
*/
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;
/**
*
* This class represents a plan generated by the planner.
*
* This class represents a plan generated by the planner.
*
* @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;
}
......
......@@ -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 {
@Id
private String id;
private String cloudConfID;
@Document
public class ProvisionInfo extends KeyValueHolder {
private String cloudCredentialsID;
private String planID;
private String userScriptID;
private String scriptID;
private String userKeyID;
private Map<String, Object> kvMap;
private List<DeployParameter> deployParameters;
/**
* @return the cloudConfID
* @return the cloudCredentialsID
*/
public String getCloudConfID() {
return cloudConfID;
public String getCloudcloudCredentialsID() {
return cloudCredentialsID;
}
/**
* @param cloudConfID the cloudConfID to set
* @param cloudConfID the cloudCredentialsID to set
*/
public void setCloudConfID(String cloudConfID) {
this.cloudConfID = cloudConfID;
public void setCloudcloudCredentialsID(String cloudConfID) {
this.cloudCredentialsID = cloudConfID;
}
/**
......@@ -68,17 +64,17 @@ public class ProvisionInfo {
}
/**
* @return the userScriptID
* @return the scriptID
*/
public String getUserScriptID() {
return userScriptID;
public String getscriptID() {
return scriptID;
}
/**
* @param userScriptID the userScriptID to set
* @param scriptID the scriptID to set
*/
public void setUserScriptID(String userScriptID) {
this.userScriptID = userScriptID;
public void setScriptID(String scriptID) {
this.scriptID = scriptID;
}
/**
......@@ -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;
......
......@@ -25,7 +25,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
* @author S. Koulouzis
*/
@Document
public class UserScript {
public class Script {
@Id
private String id;
......
/*
* 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;
}
}
......@@ -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
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment