# HG changeset patch # User ymh # Date 1382356700 -7200 # Node ID 6ac00231ee3481bd080d78698d2d2f381e62a7e9 # Parent a392390de1a76c9e388dde4d9ee410f8efc9fef6 Manage users. (not passwords) diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/java/org/iri_research/renkan/controller/RenkanController.java --- a/server/src/main/java/org/iri_research/renkan/controller/RenkanController.java Wed Oct 16 23:26:28 2013 +0200 +++ b/server/src/main/java/org/iri_research/renkan/controller/RenkanController.java Mon Oct 21 13:58:20 2013 +0200 @@ -27,104 +27,116 @@ import org.springframework.web.client.HttpServerErrorException; import org.springframework.web.servlet.ModelAndView; - @Controller @RequestMapping("/p") public class RenkanController { - private final Logger logger = LoggerFactory.getLogger(RenkanController.class); - - @Autowired - private ProjectsRepository projectsRepository; - - @Autowired - private SpacesRepository spacesRepository; - - private void checkCowebkey(String cowebkey, Project project, Constants.EditMode editMode) { - if(cowebkey == null || cowebkey.isEmpty()) { - throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Cowebkey missing"); - } - try { - if(!project.checkKey(cowebkey, editMode)) { - throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Bad cowebkey"); - } - } catch (RenkanException e) { - throw new HttpServerErrorException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage()); - } - } - - @RequestMapping(value="/copy", method = RequestMethod.POST, produces={"application/json;charset=UTF-8"}) - public @ResponseBody Project copyProject(@RequestParam(value="project_id") String projectId ) { - - if(projectId == null || projectId.length() == 0) { - throw new IllegalArgumentException("RenkanContoller.renkanProject.copyProject: Project id is null or empty."); - } - Project project = this.projectsRepository.findOne(projectId); - if(project == null) { - throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "Project " + projectId + " not found for copyProject."); - } + private final Logger logger = LoggerFactory + .getLogger(RenkanController.class); + + @Autowired + private ProjectsRepository projectsRepository; + + @Autowired + private SpacesRepository spacesRepository; + + private void checkCowebkey(String cowebkey, Project project, + Constants.EditMode editMode) { + if (cowebkey == null || cowebkey.isEmpty()) { + throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, + "Cowebkey missing"); + } + try { + if (!project.checkKey(cowebkey, editMode)) { + throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, + "Bad cowebkey"); + } + } catch (RenkanException e) { + throw new HttpServerErrorException( + HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage()); + } + } - Project newProject = this.projectsRepository.copy(project, project.getTitle() + " (copy)"); - - return newProject; - } + @RequestMapping(value = "/copy", method = RequestMethod.POST, produces = { "application/json;charset=UTF-8" }) + public @ResponseBody + Project copyProject(@RequestParam(value = "project_id") String projectId) { + + if (projectId == null || projectId.length() == 0) { + throw new IllegalArgumentException( + "RenkanContoller.renkanProject.copyProject: Project id is null or empty."); + } + Project project = this.projectsRepository.findOne(projectId); + if (project == null) { + throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "Project " + + projectId + " not found for copyProject."); + } - - @RequestMapping(value="/{project_id}", method = RequestMethod.GET, produces={"text/html;charset=UTF-8", "!image/*"}) - public ModelAndView renkanProject( - @PathVariable(value="project_id") String project_id, - @RequestHeader(value="Accept") String accept_header, - @RequestParam(value="cowebkey") String cowebkey - ) throws HttpMediaTypeNotSupportedException - { + Project newProject = this.projectsRepository.copy(project, + project.getTitle() + " (copy)"); + + return newProject; + } + + @RequestMapping(value = "/{project_id}", method = RequestMethod.GET, produces = { + "text/html;charset=UTF-8", "!image/*" }) + public ModelAndView renkanProject( + @PathVariable(value = "project_id") String project_id, + @RequestHeader(value = "Accept") String accept_header, + @RequestParam(value = "cowebkey") String cowebkey) + throws HttpMediaTypeNotSupportedException { - this.logger.debug("renkanProject : " + project_id + " Accept : " + accept_header!=null?accept_header:"" + ", cowebkey: "+ cowebkey!=null?cowebkey:""); - - - if(project_id == null || project_id.length() == 0) { - throw new IllegalArgumentException("RenkanContoller.renkanProject: Project id is null or empty."); - } - - Project project = this.projectsRepository.findOne(project_id); - - if(project == null) { - throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "Project " + project_id + " not found."); - } - - this.checkCowebkey(cowebkey, project, EditMode.EDITION); - - Map model = new HashMap(); - model.put("coweb_debug", Boolean.parseBoolean(RenkanProperties.getInstance().getProperty("renkan.coweb.debug","false"))); - model.put("coweb_websockets", Boolean.parseBoolean(RenkanProperties.getInstance().getProperty("renkan.coweb.websocket", "true"))); - model.put("project", project); - model.put("space", spacesRepository.findOne(project.getSpaceId())); - - return new ModelAndView("renkanProjectEdit", model); - } - - @RequestMapping(value="/pub/{project_id}", method = RequestMethod.GET, produces={"text/html;charset=UTF-8", "!image/*"}) - public String renkanPublishProject( - Model model, - @PathVariable(value="project_id") String project_id, - @RequestParam(value="cowebkey") String cowebkey - ) - { - if(project_id == null || project_id.length() == 0) { - throw new IllegalArgumentException("RenkanContoller.renkanProject: Project id is null or empty."); - } - - Project project = this.projectsRepository.findOne(project_id); - if(project == null) { - throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "Project " + project_id + " not found."); - } + this.logger.debug("renkanProject : " + project_id + " Accept : " + + accept_header != null ? accept_header : "" + ", cowebkey: " + + cowebkey != null ? cowebkey : ""); + + if (project_id == null || project_id.length() == 0) { + throw new IllegalArgumentException( + "RenkanContoller.renkanProject: Project id is null or empty."); + } + + Project project = this.projectsRepository.findOne(project_id); + + if (project == null) { + throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "Project " + + project_id + " not found."); + } + + this.checkCowebkey(cowebkey, project, EditMode.EDITION); + + Map model = new HashMap(); + model.put("coweb_debug", Boolean.parseBoolean(RenkanProperties + .getInstance().getProperty("renkan.coweb.debug", "false"))); + model.put("coweb_websockets", Boolean.parseBoolean(RenkanProperties + .getInstance().getProperty("renkan.coweb.websocket", "true"))); + model.put("project", project); + model.put("space", spacesRepository.findOne(project.getSpaceId())); - this.checkCowebkey(cowebkey, project, EditMode.READ_ONLY); - - model.addAttribute("project", project); - model.addAttribute("space", spacesRepository.findOne(project.getSpaceId())); - - return "renkanProjectPublish"; - } - - + return new ModelAndView("renkanProjectEdit", model); + } + + @RequestMapping(value = "/pub/{project_id}", method = RequestMethod.GET, produces = { + "text/html;charset=UTF-8", "!image/*" }) + public String renkanPublishProject(Model model, + @PathVariable(value = "project_id") String project_id, + @RequestParam(value = "cowebkey") String cowebkey) { + if (project_id == null || project_id.length() == 0) { + throw new IllegalArgumentException( + "RenkanContoller.renkanProject: Project id is null or empty."); + } + + Project project = this.projectsRepository.findOne(project_id); + if (project == null) { + throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "Project " + + project_id + " not found."); + } + + this.checkCowebkey(cowebkey, project, EditMode.READ_ONLY); + + model.addAttribute("project", project); + model.addAttribute("space", + spacesRepository.findOne(project.getSpaceId())); + + return "renkanProjectPublish"; + } + } diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/java/org/iri_research/renkan/controller/admin/AdminController.java --- a/server/src/main/java/org/iri_research/renkan/controller/admin/AdminController.java Wed Oct 16 23:26:28 2013 +0200 +++ b/server/src/main/java/org/iri_research/renkan/controller/admin/AdminController.java Mon Oct 21 13:58:20 2013 +0200 @@ -10,14 +10,13 @@ @RequestMapping("/admin") public class AdminController { - - @SuppressWarnings("unused") - private final Logger logger = LoggerFactory.getLogger(AdminController.class); - - @RequestMapping(value="", method = RequestMethod.GET, produces={"text/html;charset=UTF-8"}) - public String adminIndex() { - - return "admin/adminIndex"; - } - + @SuppressWarnings("unused") + private final Logger logger = LoggerFactory + .getLogger(AdminController.class); + + @RequestMapping(value = "", method = RequestMethod.GET, produces = { "text/html;charset=UTF-8" }) + public String adminIndex() { + return "admin/adminIndex"; + } + } diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/java/org/iri_research/renkan/controller/admin/SpacesAdminController.java --- a/server/src/main/java/org/iri_research/renkan/controller/admin/SpacesAdminController.java Wed Oct 16 23:26:28 2013 +0200 +++ b/server/src/main/java/org/iri_research/renkan/controller/admin/SpacesAdminController.java Mon Oct 21 13:58:20 2013 +0200 @@ -40,145 +40,151 @@ @Controller @RequestMapping("/admin/spaces") public class SpacesAdminController { - - private final Logger logger = LoggerFactory.getLogger(SpacesAdminController.class); + + private final Logger logger = LoggerFactory + .getLogger(SpacesAdminController.class); - @Autowired - private SpacesRepository spacesRepository; - @Autowired - private ProjectsRepository projectsRepository; - - @InitBinder(value={"space"}) + @Autowired + private SpacesRepository spacesRepository; + @Autowired + private ProjectsRepository projectsRepository; + + @InitBinder(value = { "space" }) protected void initBinder(WebDataBinder binder) { binder.setValidator(new SpaceFormValidator()); } - @RequestMapping(value="/", method = RequestMethod.GET, produces={"text/html;charset=UTF-8"}) - public String spacesList( - Model model, - @PageableDefaults(sort={"created"}, sortDir=Direction.DESC, pageNumber=0, value=Constants.PAGINATION_SIZE) Pageable p, - HttpServletRequest request) { - - Page page = this.spacesRepository.findAll(p); - - model.addAttribute("page", page); - model.addAttribute("baseUrl", Utils.buildBaseUrl(request)); - model.addAttribute("projectsCount", this.projectsRepository.getCountBySpace()); - - return "admin/spacesList"; - } - - @RequestMapping(value="/edit/", method = RequestMethod.GET, produces={"text/html;charset=UTF-8"}) - public String editSpace(Model model) { - return editSpace(model, null); - } - - @RequestMapping(value="/edit/{spaceId}", method = RequestMethod.GET, produces={"text/html;charset=UTF-8"}) - public String editSpace(Model model, @PathVariable(value="spaceId") String spaceId) { - - SpaceForm spaceForm = null; - - if(spaceId == null || spaceId.length() == 0 || "_".equals(spaceId)) { - spaceForm = new SpaceForm(); - } - else { - Space space = this.spacesRepository.findOne(spaceId); - if(space == null) { - throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "space " + spaceId + " not found"); - } - spaceForm = new SpaceForm(space); - } - - model.addAttribute("space", spaceForm); - - return "admin/spaceEdit"; - } - - - @RequestMapping(value="/save", method = RequestMethod.POST) - public String saveSpace(Model model, @ModelAttribute("space") @Valid SpaceForm spaceForm, BindingResult bindingResult) { + @RequestMapping(value = "", method = RequestMethod.GET, produces = { "text/html;charset=UTF-8" }) + public String spacesList( + Model model, + @PageableDefaults(sort = { "created" }, sortDir = Direction.DESC, pageNumber = 0, value = Constants.PAGINATION_SIZE) Pageable p, + HttpServletRequest request) { + + Page page = this.spacesRepository.findAll(p); + + model.addAttribute("page", page); + model.addAttribute("baseUrl", Utils.buildBaseUrl(request)); + model.addAttribute("projectsCount", + this.projectsRepository.getCountBySpace()); + + return "admin/spacesList"; + } + + @RequestMapping(value = "/edit/", method = RequestMethod.GET, produces = { "text/html;charset=UTF-8" }) + public String editSpace(Model model) { + return editSpace(model, null); + } + + @RequestMapping(value = "/edit/{spaceId}", method = RequestMethod.GET, produces = { "text/html;charset=UTF-8" }) + public String editSpace(Model model, + @PathVariable(value = "spaceId") String spaceId) { + + SpaceForm spaceForm = null; + + if (spaceId == null || spaceId.length() == 0 || "_".equals(spaceId)) { + spaceForm = new SpaceForm(); + } else { + Space space = this.spacesRepository.findOne(spaceId); + if (space == null) { + throw new HttpClientErrorException(HttpStatus.NOT_FOUND, + "space " + spaceId + " not found"); + } + spaceForm = new SpaceForm(space); + } + + model.addAttribute("space", spaceForm); + + return "admin/spaceEdit"; + } + + @RequestMapping(value = "/save", method = RequestMethod.POST) + public String saveSpace(Model model, + @ModelAttribute("space") @Valid SpaceForm spaceForm, + BindingResult bindingResult) { + + logger.debug("space title " + spaceForm.getTitle()); + logger.debug("space description " + spaceForm.getDescription()); + + if (bindingResult.hasErrors()) { + return "admin/spaceEdit"; + } + + spaceForm.setSpacesRepository(spacesRepository); + + try { + spaceForm.save(); + } catch (RenkanException e) { + throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "space " + + spaceForm.getId() + " not found"); + } + + return "redirect:/admin/spaces"; + } - logger.debug("space title " + spaceForm.getTitle()); - logger.debug("space description " + spaceForm.getDescription()); - - if(bindingResult.hasErrors()) { - return "admin/spaceEdit"; - } - - spaceForm.setSpacesRepository(spacesRepository); - - try { - spaceForm.save(); - } catch (RenkanException e) { - throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "space " + spaceForm.getId() + " not found"); - } - - return "redirect:/admin/spaces"; - } - - @RequestMapping(value="/delete/{spaceId}") - public String deleteSpace( - HttpServletRequest request, - Model model, - @PathVariable(value="spaceId") String spaceId, - @RequestParam(value="key", required=false) String key, - @RequestParam(value="salt", required=false) String salt) throws NoSuchAlgorithmException, RenkanException - { + @RequestMapping(value = "/delete/{spaceId}") + public String deleteSpace(HttpServletRequest request, Model model, + @PathVariable(value = "spaceId") String spaceId, + @RequestParam(value = "key", required = false) String key, + @RequestParam(value = "salt", required = false) String salt) + throws NoSuchAlgorithmException, RenkanException { + + if (spaceId == null || spaceId.length() == 0) { + throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, + "Null or empty space id"); + } + + RequestMethod method = RequestMethod.valueOf(request.getMethod()); - if(spaceId == null || spaceId.length() == 0) { - throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Null or empty space id"); - } - - RequestMethod method = RequestMethod.valueOf(request.getMethod()); - - Map nbProj = this.projectsRepository.getCountBySpace(Arrays.asList(spaceId)); - if(nbProj.containsKey(spaceId) && nbProj.get(spaceId).intValue()>0) { - throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "This space have projects"); - } - - if(RequestMethod.GET.equals(method)) { + Map nbProj = this.projectsRepository + .getCountBySpace(Arrays.asList(spaceId)); + if (nbProj.containsKey(spaceId) && nbProj.get(spaceId).intValue() > 0) { + throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, + "This space have projects"); + } + + if (RequestMethod.GET.equals(method)) { + + Space space = this.spacesRepository.findOne(spaceId); + + if (space == null) { + throw new HttpClientErrorException(HttpStatus.NOT_FOUND, + "space " + spaceId + " not found"); + } - Space space = this.spacesRepository.findOne(spaceId); - - if(space == null) { - throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "space " + spaceId + " not found"); - } - - SecureRandom rand = SecureRandom.getInstance("SHA1PRNG"); - rand.setSeed(System.currentTimeMillis()); - byte[] rawSalt = new byte[50]; - rand.nextBytes(rawSalt); - String newSalt = Hex.encodeHexString(rawSalt); - - - model.addAttribute("spaceObj", space); - model.addAttribute("salt", newSalt); - model.addAttribute("key", space.getKey(newSalt)); - - return "admin/spaceDeleteConfirm"; - } - else if (RequestMethod.POST.equals(method) && key != null && !key.isEmpty() && salt != null && !salt.isEmpty()) { - - if(spaceId != null && spaceId.length() > 0) { - - Space space = this.spacesRepository.findOne(spaceId); - if(space != null) { - if(space.checkKey(key, salt)) { - this.spacesRepository.delete(spaceId); - } - else { - throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Key not ckecked"); - } - } - - } - return "redirect:/admin/spaces"; - - } - else { - throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Bad request method or parameters"); - } - - } - + SecureRandom rand = SecureRandom.getInstance("SHA1PRNG"); + rand.setSeed(System.currentTimeMillis()); + byte[] rawSalt = new byte[50]; + rand.nextBytes(rawSalt); + String newSalt = Hex.encodeHexString(rawSalt); + + model.addAttribute("spaceObj", space); + model.addAttribute("salt", newSalt); + model.addAttribute("key", space.getKey(newSalt)); + + return "admin/spaceDeleteConfirm"; + } else if (RequestMethod.POST.equals(method) && key != null + && !key.isEmpty() && salt != null && !salt.isEmpty()) { + + if (spaceId != null && spaceId.length() > 0) { + + Space space = this.spacesRepository.findOne(spaceId); + if (space != null) { + if (space.checkKey(key, salt)) { + this.spacesRepository.delete(spaceId); + } else { + throw new HttpClientErrorException( + HttpStatus.BAD_REQUEST, "Key not ckecked"); + } + } + + } + return "redirect:/admin/spaces"; + + } else { + throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, + "Bad request method or parameters"); + } + + } + } diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/java/org/iri_research/renkan/controller/admin/UsersAdminController.java --- a/server/src/main/java/org/iri_research/renkan/controller/admin/UsersAdminController.java Wed Oct 16 23:26:28 2013 +0200 +++ b/server/src/main/java/org/iri_research/renkan/controller/admin/UsersAdminController.java Mon Oct 21 13:58:20 2013 +0200 @@ -1,9 +1,18 @@ package org.iri_research.renkan.controller.admin; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.util.Arrays; +import java.util.Map; + import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import org.apache.commons.codec.binary.Hex; import org.iri_research.renkan.Constants; +import org.iri_research.renkan.RenkanException; import org.iri_research.renkan.controller.Utils; +import org.iri_research.renkan.forms.UserForm; import org.iri_research.renkan.models.User; import org.iri_research.renkan.repositories.ProjectsRepository; import org.iri_research.renkan.repositories.UsersRepository; @@ -14,37 +23,161 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort.Direction; import org.springframework.data.web.PageableDefaults; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.client.HttpClientErrorException; @Controller @RequestMapping("/admin/users") public class UsersAdminController { - - @SuppressWarnings("unused") - private final Logger logger = LoggerFactory.getLogger(UsersAdminController.class); - - @Autowired - private UsersRepository usersRepository; - - @Autowired - private ProjectsRepository projectsRepository; - - @RequestMapping(value="/", method = RequestMethod.GET, produces={"text/html;charset=UTF-8"}) - public String usersList( - Model model, - @PageableDefaults(sort={"username"}, sortDir=Direction.DESC, pageNumber=0, value=Constants.PAGINATION_SIZE) Pageable p, - HttpServletRequest request) { - - Page page = this.usersRepository.findAll(p); - - model.addAttribute("page", page); - model.addAttribute("baseUrl", Utils.buildBaseUrl(request)); - model.addAttribute("projectsCount", this.projectsRepository.getCountByUser()); - - return "admin/usersList"; - } + + private final Logger logger = LoggerFactory + .getLogger(UsersAdminController.class); + + @Autowired + private UsersRepository usersRepository; + + @Autowired + private ProjectsRepository projectsRepository; + + @RequestMapping(value = "", method = RequestMethod.GET, produces = { "text/html;charset=UTF-8" }) + public String usersList( + Model model, + @PageableDefaults(sort = { "username" }, sortDir = Direction.DESC, pageNumber = 0, value = Constants.PAGINATION_SIZE) Pageable p, + HttpServletRequest request) { + + Page page = this.usersRepository.findAll(p); + + model.addAttribute("page", page); + model.addAttribute("baseUrl", Utils.buildBaseUrl(request)); + model.addAttribute("projectsCount", + this.projectsRepository.getCountByUser()); + + return "admin/usersList"; + } + + @RequestMapping(value = "/edit/", method = RequestMethod.GET, produces = { "text/html;charset=UTF-8" }) + public String editUser(Model model) { + return editUser(model, null); + } + + @RequestMapping(value = "/edit/{userId}", method = RequestMethod.GET, produces = { "text/html;charset=UTF-8" }) + public String editUser(Model model, + @PathVariable(value = "userId") String userId) { + + UserForm userForm = null; + User user = null; + + if (userId != null && userId.length() > 0 && !"_".equals(userId)) { + user = this.usersRepository.findOne(userId); + if (user == null) { + throw new HttpClientErrorException(HttpStatus.NOT_FOUND, + "user " + userId + " not found"); + } + } + userForm = new UserForm(user); + + model.addAttribute("user", userForm); + + return "admin/userEdit"; + } + + @RequestMapping(value = "/save", method = RequestMethod.POST) + public String saveUser(Model model, + @ModelAttribute("user") @Valid UserForm userForm, + BindingResult bindingResult) { + + logger.debug("user title " + userForm.getTitle()); + logger.debug("user description " + userForm.getDescription()); + + if (bindingResult.hasErrors()) { + return "admin/userEdit"; + } + + userForm.setUsersRepository(usersRepository); + + try { + userForm.save(); + } catch (RenkanException e) { + throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "space " + + userForm.getId() + " not found"); + } + + return "redirect:/admin/users"; + } + + @RequestMapping(value = "/delete/{userId}") + public String deleteSpace(HttpServletRequest request, Model model, + @PathVariable(value = "userId") String userId, + @RequestParam(value = "key", required = false) String key, + @RequestParam(value = "salt", required = false) String salt) + throws NoSuchAlgorithmException, RenkanException { + + if (userId == null || userId.length() == 0) { + throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, + "Null or empty user id"); + } + + RequestMethod method = RequestMethod.valueOf(request.getMethod()); + + Map nbProj = this.projectsRepository + .getCountByUser(Arrays.asList(userId)); + if (nbProj.containsKey(userId) && nbProj.get(userId).intValue() > 0) { + throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, + "This user have projects"); + } + + if (RequestMethod.GET.equals(method)) { + + User user = this.usersRepository.findOne(userId); + + if (user == null) { + throw new HttpClientErrorException(HttpStatus.NOT_FOUND, + "user " + userId + " not found"); + } + + SecureRandom rand = SecureRandom.getInstance("SHA1PRNG"); + rand.setSeed(System.currentTimeMillis()); + byte[] rawSalt = new byte[50]; + rand.nextBytes(rawSalt); + String newSalt = Hex.encodeHexString(rawSalt); + + model.addAttribute("userObj", user); + model.addAttribute("salt", newSalt); + model.addAttribute("key", user.getKey(newSalt)); + + return "admin/userDeleteConfirm"; + + } else if (RequestMethod.POST.equals(method) && key != null + && !key.isEmpty() && salt != null && !salt.isEmpty()) { + + if (userId != null && userId.length() > 0) { + + User user = this.usersRepository.findOne(userId); + if (user != null) { + if (user.checkKey(key, salt)) { + this.usersRepository.delete(userId); + } else { + throw new HttpClientErrorException( + HttpStatus.BAD_REQUEST, "Key not ckecked"); + } + } + + } + return "redirect:/admin/users"; + + } else { + throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, + "Bad request method or parameters"); + } + + } } diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/java/org/iri_research/renkan/forms/RenkanForm.java --- a/server/src/main/java/org/iri_research/renkan/forms/RenkanForm.java Wed Oct 16 23:26:28 2013 +0200 +++ b/server/src/main/java/org/iri_research/renkan/forms/RenkanForm.java Mon Oct 21 13:58:20 2013 +0200 @@ -6,99 +6,111 @@ import org.iri_research.renkan.models.IRenkanModel; import org.iri_research.renkan.repositories.IRenkanRepository; -public abstract class RenkanForm > { - - protected RM model; - - private ID id; - private String title; - private String description; - private String uri; - private String color; - - protected abstract void saveToModel(); - protected abstract IRenkanRepository getRepository(); - protected abstract RM getModelInstance(); - - public RenkanForm() {} - - public RenkanForm(RM model) { - this.model = model; - this.id = model.getId(); - this.title = model.getTitle(); - this.description = model.getDescription(); - this.color = model.getColor(); - this.uri = model.getUri(); - } - - public ID getId() { - return id; - } - public void setId(ID id) { - this.id = id; - } - public String getTitle() { - return title; - } - public void setTitle(String title) { - this.title = title; - } - public String getDescription() { - return description; - } - public void setDescription(String description) { - this.description = description; - } - public String getUri() { - return uri; - } - public void setUri(String uri) { - this.uri = uri; - } - public String getColor() { - return color; - } - public void setColor(String color) { - this.color = color; - } - - public void setModel(RM model) { - this.model = model; - } - - private void saveToRenkanModel() { - - this.model.setTitle(title); - this.model.setDescription(description); - this.model.setColor(color); - this.model.setUri(uri); - } - - - public RM save() throws RenkanException { +public abstract class RenkanForm> { + + protected RM model; + + private ID id; + private String title; + private String description; + private String uri; + private String color; + + protected abstract void saveToModel(); + + protected abstract IRenkanRepository getRepository(); + + protected abstract RM getModelInstance(); + + public RenkanForm() { + } + + public RenkanForm(RM model) { + if(model == null) { + return; + } + this.model = model; + this.id = model.getId(); + this.title = model.getTitle(); + this.description = model.getDescription(); + this.color = model.getColor(); + this.uri = model.getUri(); + } + + public ID getId() { + return id; + } + + public void setId(ID id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } - if(this.model == null) { - - if(this.getId() != null) { - this.model = this.getRepository().findOne(this.getId()); - if(this.model == null) { - throw new RenkanException("Model id " + this.getId().toString() + " not found"); - } - } - else { - this.model = this.getModelInstance(); - } - } - - this.saveToRenkanModel(); - this.saveToModel(); - - this.model = this.getRepository().save(this.model); - - return this.model; - - } - - + public void setDescription(String description) { + this.description = description; + } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public void setModel(RM model) { + this.model = model; + } + + private void saveToRenkanModel() { + + this.model.setTitle(title); + this.model.setDescription(description); + this.model.setColor(color); + this.model.setUri(uri); + } + + public RM save() throws RenkanException { + + if (this.model == null) { + + if (this.getId() != null) { + this.model = this.getRepository().findOne(this.getId()); + if (this.model == null) { + throw new RenkanException("Model id " + + this.getId().toString() + " not found"); + } + } else { + this.model = this.getModelInstance(); + } + } + + this.saveToRenkanModel(); + this.saveToModel(); + + this.model = this.getRepository().save(this.model); + + return this.model; + + } } diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/java/org/iri_research/renkan/forms/SpaceForm.java --- a/server/src/main/java/org/iri_research/renkan/forms/SpaceForm.java Wed Oct 16 23:26:28 2013 +0200 +++ b/server/src/main/java/org/iri_research/renkan/forms/SpaceForm.java Mon Oct 21 13:58:20 2013 +0200 @@ -11,59 +11,62 @@ @Component public class SpaceForm extends RenkanForm { - - @Autowired - private SpacesRepository spacesRepository; - - public SpaceForm() { - super(); - } - - public SpaceForm(Space model) { - super(model); - this.binConfig = model.getBinConfig(); - this.image = model.getImage(); - } - - private String binConfig; - private String image; + + @Autowired + private SpacesRepository spacesRepository; + + public SpaceForm() { + super(); + } + + public SpaceForm(Space model) { + super(model); + this.binConfig = model.getBinConfig(); + this.image = model.getImage(); + } + + private String binConfig; + private String image; + + public String getBinConfig() { + return binConfig; + } + + public void setBinConfig(String binConfig) { + this.binConfig = binConfig; + } + + public String getImage() { + return image; + } - public String getBinConfig() { - return binConfig; - } - public void setBinConfig(String binConfig) { - this.binConfig = binConfig; - } - public String getImage() { - return image; - } - public void setImage(String image) { - this.image = image; - } + public void setImage(String image) { + this.image = image; + } + + @Override + protected void saveToModel() { + if (this.getId() == null || this.getId().length() == 0) { + this.model.setId(Constants.UUID_GENERATOR.generate().toString()); + this.model.setCreated(new Date()); + } + this.model.setBinConfig(binConfig); + this.model.setImage(image); + } - @Override - protected void saveToModel() { - if(this.getId() == null || this.getId().length() == 0) { - this.model.setId(Constants.UUID_GENERATOR.generate().toString()); - this.model.setCreated(new Date()); - } - this.model.setBinConfig(binConfig); - this.model.setImage(image); - } + @Override + protected IRenkanRepository getRepository() { + return this.spacesRepository; + } - @Override - protected IRenkanRepository getRepository() { - return this.spacesRepository; - } + @Override + protected Space getModelInstance() { + return new Space(); + } - @Override - protected Space getModelInstance() { - return new Space(); - } + @Autowired + public void setSpacesRepository(SpacesRepository spacesRepository) { + this.spacesRepository = spacesRepository; + } - @Autowired - public void setSpacesRepository(SpacesRepository spacesRepository) { - this.spacesRepository = spacesRepository; - } - } diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/java/org/iri_research/renkan/forms/SpaceFormValidator.java --- a/server/src/main/java/org/iri_research/renkan/forms/SpaceFormValidator.java Wed Oct 16 23:26:28 2013 +0200 +++ b/server/src/main/java/org/iri_research/renkan/forms/SpaceFormValidator.java Mon Oct 21 13:58:20 2013 +0200 @@ -14,35 +14,40 @@ @Component public class SpaceFormValidator implements Validator { - - private Logger logger = LoggerFactory.getLogger(SpaceFormValidator.class); + + private Logger logger = LoggerFactory.getLogger(SpaceFormValidator.class); - @Override - public boolean supports(Class clazz) { - return SpaceForm.class.equals(clazz); - } + @Override + public boolean supports(Class clazz) { + return SpaceForm.class.equals(clazz); + } - @Override - public void validate(Object target, Errors errors) { - SpaceForm space = (SpaceForm)target; + @Override + public void validate(Object target, Errors errors) { + SpaceForm space = (SpaceForm) target; + + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "title", + "renkan.error.title.empty"); - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "title", "renkan.error.title.empty"); - - if(space.getBinConfig() != null && space.getBinConfig().length()>0) { - boolean valid = false; - ObjectMapper mapper = new ObjectMapper(); - try { - mapper.readTree(space.getBinConfig()); - valid = true; - } catch (JsonProcessingException e) { - logger.debug("SpaceValidator JsonProcessingException error validating bin config", e); - } catch (IOException e) { - logger.debug("SpaceValidator IOException error validating bin config", e); - } - if(!valid) { - errors.rejectValue("binConfig", "renkan.error.bin_config.json"); - } - } - } + if (space.getBinConfig() != null && space.getBinConfig().length() > 0) { + boolean valid = false; + ObjectMapper mapper = new ObjectMapper(); + try { + mapper.readTree(space.getBinConfig()); + valid = true; + } catch (JsonProcessingException e) { + logger.debug( + "SpaceValidator JsonProcessingException error validating bin config", + e); + } catch (IOException e) { + logger.debug( + "SpaceValidator IOException error validating bin config", + e); + } + if (!valid) { + errors.rejectValue("binConfig", "renkan.error.bin_config.json"); + } + } + } } diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/java/org/iri_research/renkan/forms/UserForm.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/main/java/org/iri_research/renkan/forms/UserForm.java Mon Oct 21 13:58:20 2013 +0200 @@ -0,0 +1,126 @@ +package org.iri_research.renkan.forms; + +import java.util.Date; + +import org.iri_research.renkan.Constants; +import org.iri_research.renkan.models.User; +import org.iri_research.renkan.repositories.IRenkanRepository; +import org.iri_research.renkan.repositories.UsersRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class UserForm extends RenkanForm { + + @Autowired + private UsersRepository usersRepository; + + public UserForm() { + super(); + } + + public UserForm(User model) { + super(model); + if(model != null) { + this.avatar = model.getAvatar(); + this.credentialExpirationDate = model.getCredentialExpirationDate(); + this.email = model.getEmail(); + this.expirationDate = model.getExpirationDate(); + this.enabled = model.isEnabled(); + this.locked = model.isLocked(); + } + } + + private String avatar; + private String email; + private Date credentialExpirationDate; + private Date expirationDate; + private boolean enabled; + private boolean locked; + + + + public String getAvatar() { + return avatar; + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public Date getCredentialExpirationDate() { + return credentialExpirationDate; + } + + public void setCredentialExpirationDate(Date credentialExpirationDate) { + this.credentialExpirationDate = credentialExpirationDate; + } + + public Date getExpirationDate() { + return expirationDate; + } + + public void setExpirationDate(Date expirationDate) { + this.expirationDate = expirationDate; + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public boolean isLocked() { + return locked; + } + + public void setLocked(boolean locked) { + this.locked = locked; + } + + public UsersRepository getUsersRepository() { + return usersRepository; + } + + @Override + protected void saveToModel() { + if (this.getId() == null || this.getId().length() == 0) { + this.model.setId(Constants.UUID_GENERATOR.generate().toString()); + } + this.model.setAvatar(this.avatar); + this.model.setEmail(this.email); + this.model.setCredentialExpirationDate(this.credentialExpirationDate); + this.model.setExpirationDate(this.expirationDate); + this.model.setEnabled(this.enabled); + this.model.setLocked(this.locked); + + } + + @Override + protected IRenkanRepository getRepository() { + return this.usersRepository; + } + + @Override + protected User getModelInstance() { + return new User(); + } + + @Autowired + public void setUsersRepository(UsersRepository usersRepository) { + this.usersRepository = usersRepository; + } + + + +} diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/java/org/iri_research/renkan/models/AbstractRenkanModel.java --- a/server/src/main/java/org/iri_research/renkan/models/AbstractRenkanModel.java Wed Oct 16 23:26:28 2013 +0200 +++ b/server/src/main/java/org/iri_research/renkan/models/AbstractRenkanModel.java Mon Oct 21 13:58:20 2013 +0200 @@ -1,82 +1,139 @@ package org.iri_research.renkan.models; import java.io.Serializable; +import java.io.UnsupportedEncodingException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import javax.crypto.spec.SecretKeySpec; + +import org.apache.commons.codec.binary.Hex; +import org.iri_research.renkan.Constants; +import org.iri_research.renkan.RenkanException; import org.iri_research.renkan.RenkanRuntimeException; +public abstract class AbstractRenkanModel implements + IRenkanModel { -public abstract class AbstractRenkanModel implements IRenkanModel { - - public AbstractRenkanModel(ID id, String title, String description, String uri, String color) { - super(); - this.id = id; - this.title = title; - this.description = description; - this.uri = uri; - this.color = color; - } - - protected AbstractRenkanModel() { - } + public AbstractRenkanModel(ID id, String title, String description, + String uri, String color) { + super(); + this.id = id; + this.title = title; + this.description = description; + this.uri = uri; + this.color = color; + } + + protected AbstractRenkanModel() { + } + + protected ID id; + protected String title; + protected String description; + protected String uri; + protected String color; + + @Override + public String getTitle() { + return this.title; + } - protected ID id; - protected String title; - protected String description; - protected String uri; - protected String color; - - @Override - public String getTitle() { - return this.title; - } + @Override + public String getDescription() { + return this.description; + } + + @Override + public String getUri() { + return this.uri; + } + + @Override + public String getColor() { + return this.color; + } - @Override - public String getDescription() { - return this.description; - } + @Override + public ID getId() { + return this.id; + } + + @Override + public void setId(ID id) throws RenkanRuntimeException { + if (this.id != null) { + throw new RenkanRuntimeException( + "Current id is not null, can not change object id"); + } + this.id = id; + } + + @Override + public void setTitle(String title) { + this.title = title; + } - @Override - public String getUri() { - return this.uri; - } - - @Override - public String getColor() { - return this.color; - } - - @Override - public ID getId() { - return this.id; - } - - @Override - public void setId(ID id) throws RenkanRuntimeException { - if(this.id != null) { - throw new RenkanRuntimeException("Current id is not null, can not change object id"); - } - this.id = id; - } + @Override + public void setDescription(String description) { + this.description = description; + } + + @Override + public void setUri(String uri) { + this.uri = uri; + } + + @Override + public void setColor(String color) { + this.color = color; + } + + abstract protected String getRawKeyPart(); + + private String getRawKey(String salt) { + StringBuffer key = new StringBuffer(salt != null ? salt + "|" : ""); + key.append(this.getId()); + key.append('|'); + key.append(this.getRawKeyPart()); + return key.toString(); + } + + public String getKey(String salt) throws RenkanException { + + String rawKey = this.getRawKey(salt); - @Override - public void setTitle(String title) { - this.title = title; - } - - @Override - public void setDescription(String description) { - this.description = description; - } + MessageDigest md; + try { + md = MessageDigest.getInstance("SHA-256"); + } catch (NoSuchAlgorithmException e) { + throw new RenkanException("NoSuchAlgorithmException digest: " + + e.getMessage(), e); + } + String key; + final SecretKeySpec secret_key = new SecretKeySpec( + Constants.KEYHEX.getBytes(), "HmacSHA256"); + md.update(secret_key.getEncoded()); + try { + key = Hex.encodeHexString(md.digest(rawKey.getBytes("UTF-8"))); + } catch (UnsupportedEncodingException e) { + throw new RenkanException("UnsupportedEncodingException digest: " + + e.getMessage(), e); + } - @Override - public void setUri(String uri) { - this.uri = uri; - } + return key; + } + + public boolean checkKey(String key, String salt) throws RenkanException { + + if (key == null || key.isEmpty()) { + return false; + } - @Override - public void setColor(String color) { - this.color = color; - } - - + String signature = key; + + String new_key = this.getKey(salt); + + return new_key.equals(signature); + } + } diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/java/org/iri_research/renkan/models/Edge.java --- a/server/src/main/java/org/iri_research/renkan/models/Edge.java Wed Oct 16 23:26:28 2013 +0200 +++ b/server/src/main/java/org/iri_research/renkan/models/Edge.java Mon Oct 21 13:58:20 2013 +0200 @@ -9,82 +9,86 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; - -@Document(collection="edges") +@Document(collection = "edges") public class Edge extends AbstractRenkanModel { - @DBRef - private Node from; - - @DBRef - private Node to; - - @Field("project_id") - @JsonProperty("project_id") - private String projectId; - - @Field("created_by") - @JsonProperty("created_by") - private String createdBy; - - @SuppressWarnings("unused") - private Edge() { - } - - public Edge(Edge edge, Node from, Node to, String projectId) { - this(Constants.UUID_GENERATOR.generate().toString(), edge.title, edge.description, edge.uri, edge.color, from, to, edge.createdBy, projectId); - } + @DBRef + private Node from; + + @DBRef + private Node to; + + @Field("project_id") + @JsonProperty("project_id") + private String projectId; + + @Field("created_by") + @JsonProperty("created_by") + private String createdBy; + + @SuppressWarnings("unused") + private Edge() { + } - public Edge(Edge edge) { - this(edge, edge.from, edge.to, edge.projectId); - } + public Edge(Edge edge, Node from, Node to, String projectId) { + this(Constants.UUID_GENERATOR.generate().toString(), edge.title, + edge.description, edge.uri, edge.color, from, to, + edge.createdBy, projectId); + } + + public Edge(Edge edge) { + this(edge, edge.from, edge.to, edge.projectId); + } - @Autowired(required=true) - public Edge(String id, String title, String description, String uri, String color, Node from, Node to, String createdBy, String projectId) { - super(id,title, description, uri, color); - this.from = from; - this.to = to; - this.createdBy = createdBy; - this.projectId = projectId; - } - + @Autowired(required = true) + public Edge(String id, String title, String description, String uri, + String color, Node from, Node to, String createdBy, String projectId) { + super(id, title, description, uri, color); + this.from = from; + this.to = to; + this.createdBy = createdBy; + this.projectId = projectId; + } - @JsonProperty("project_id") - public String getProjectId() { - return projectId; - } + @JsonProperty("project_id") + public String getProjectId() { + return projectId; + } + public String getCreatedBy() { + return createdBy; + } + + @JsonIgnore + public Node getFromNode() { + return this.from; + } - public String getCreatedBy() { - return createdBy; - } - - @JsonIgnore - public Node getFromNode() { - return this.from; - } - - public String getFrom() { - if(this.from != null) { - return this.from.id; - } - else { - return null; - } - } + public String getFrom() { + if (this.from != null) { + return this.from.id; + } else { + return null; + } + } + + @JsonIgnore + public Node getToNode() { + return this.to; + } - @JsonIgnore - public Node getToNode() { - return this.to; - } - - public String getTo() { - if(this.to != null) { - return this.to.id; - } - else { - return null; - } - } - + public String getTo() { + if (this.to != null) { + return this.to.id; + } else { + return null; + } + } + + @Override + protected String getRawKeyPart() { + // TODO Auto-generated method stub + return this.createdBy; + } + } diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/java/org/iri_research/renkan/models/Group.java --- a/server/src/main/java/org/iri_research/renkan/models/Group.java Wed Oct 16 23:26:28 2013 +0200 +++ b/server/src/main/java/org/iri_research/renkan/models/Group.java Mon Oct 21 13:58:20 2013 +0200 @@ -2,13 +2,17 @@ import org.springframework.data.mongodb.core.mapping.Document; -@Document(collection="groups") +@Document(collection = "groups") public class Group extends AbstractRenkanModel { - - public String getGroupName() { - return this.getTitle(); - } - - + + public String getGroupName() { + return this.getTitle(); + } + + @Override + protected String getRawKeyPart() { + // TODO Auto-generated method stub + return ""; + } } diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/java/org/iri_research/renkan/models/IRenkanModel.java --- a/server/src/main/java/org/iri_research/renkan/models/IRenkanModel.java Wed Oct 16 23:26:28 2013 +0200 +++ b/server/src/main/java/org/iri_research/renkan/models/IRenkanModel.java Mon Oct 21 13:58:20 2013 +0200 @@ -2,6 +2,7 @@ import java.io.Serializable; +import org.iri_research.renkan.RenkanException; import org.iri_research.renkan.RenkanRuntimeException; @@ -24,6 +25,8 @@ public void setDescription(String description); public void setUri(String uri); public void setColor(String color); + public String getKey(String salt) throws RenkanException; + public boolean checkKey(String key, String salt) throws RenkanException; } diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/java/org/iri_research/renkan/models/Node.java --- a/server/src/main/java/org/iri_research/renkan/models/Node.java Wed Oct 16 23:26:28 2013 +0200 +++ b/server/src/main/java/org/iri_research/renkan/models/Node.java Mon Oct 21 13:58:20 2013 +0200 @@ -8,66 +8,75 @@ import com.fasterxml.jackson.annotation.JsonProperty; -@Document(collection="nodes") +@Document(collection = "nodes") public class Node extends AbstractRenkanModel { - public Node(Node node, String projectId) { - this(Constants.UUID_GENERATOR.generate().toString(), node.title, node.description, node.uri, node.color, node.createdBy, node.position, node.image, node.size, projectId); - } - - public Node(Node node) { - this(node, node.projectId); - } - - @SuppressWarnings("unused") - private Node() { - } + public Node(Node node, String projectId) { + this(Constants.UUID_GENERATOR.generate().toString(), node.title, + node.description, node.uri, node.color, node.createdBy, + node.position, node.image, node.size, projectId); + } + + public Node(Node node) { + this(node, node.projectId); + } + + @SuppressWarnings("unused") + private Node() { + } - @Autowired(required=true) - public Node(String id, String title, String description, String uri, String color, String createdBy, Point position, String image, Integer size, String projectId) { - super(id, title, description, uri, color); - - this.projectId = projectId; - this.createdBy = createdBy; - this.position = position; - this.image = image; - this.size = (size == null) ? 0 : size.intValue(); - } + @Autowired(required = true) + public Node(String id, String title, String description, String uri, + String color, String createdBy, Point position, String image, + Integer size, String projectId) { + super(id, title, description, uri, color); - @Field("project_id") - @JsonProperty("project_id") - private String projectId = null; + this.projectId = projectId; + this.createdBy = createdBy; + this.position = position; + this.image = image; + this.size = (size == null) ? 0 : size.intValue(); + } + + @Field("project_id") + @JsonProperty("project_id") + private String projectId = null; + + @Field("created_by") + @JsonProperty("created_by") + private String createdBy = null; - @Field("created_by") - @JsonProperty("created_by") - private String createdBy = null; - - private Point position = null; + private Point position = null; + + private String image; + + private int size; - private String image; - - private int size; - - public Point getPosition() { - return position; - } + public Point getPosition() { + return position; + } + + public String getImage() { + return image; + } - public String getImage() { - return image; - } + @JsonProperty("project_id") + public String getProjectId() { + return projectId; + } - @JsonProperty("project_id") - public String getProjectId() { - return projectId; - } + @JsonProperty("created_by") + public String getCreatedBy() { + return createdBy; + } - @JsonProperty("created_by") - public String getCreatedBy() { - return createdBy; - } + public int getSize() { + return size; + } - public int getSize() { - return size; - } - + @Override + protected String getRawKeyPart() { + return this.createdBy; + } + } diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/java/org/iri_research/renkan/models/Project.java --- a/server/src/main/java/org/iri_research/renkan/models/Project.java Wed Oct 16 23:26:28 2013 +0200 +++ b/server/src/main/java/org/iri_research/renkan/models/Project.java Mon Oct 21 13:58:20 2013 +0200 @@ -26,224 +26,237 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; -@Document(collection="projects") +@Document(collection = "projects") public class Project extends AbstractRenkanModel { - - @SuppressWarnings("unused") - private static Logger logger = LoggerFactory.getLogger(Project.class); - - @Field("rev_counter") - private int revCounter = 1; - - @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone="GMT") - private Date created; - @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone="GMT") - private Date updated; - - // Space - @Field("space_id") - @JsonProperty("space_id") - private String spaceId = null; - - // Nodes - @DBRef - private List nodes = new ArrayList(); - - // edges - @DBRef - private List edges = new ArrayList(); + + @SuppressWarnings("unused") + private static Logger logger = LoggerFactory.getLogger(Project.class); + + @Field("rev_counter") + private int revCounter = 1; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT") + private Date created; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT") + private Date updated; + + // Space + @Field("space_id") + @JsonProperty("space_id") + private String spaceId = null; + + // Nodes + @DBRef + private List nodes = new ArrayList(); - // Users - private List users = new ArrayList(); - - - public Project(Project project) { - this(project.spaceId, Constants.UUID_GENERATOR.generate().toString(), project.title, project.description, project.uri, new Date()); - - Map nodeCloneMap = new HashMap(project.nodes.size()); - for (Node node : project.nodes) { - Node newNode = new Node(node,this.id); - this.nodes.add(newNode); - nodeCloneMap.put(node.id, newNode); - } + // edges + @DBRef + private List edges = new ArrayList(); + + // Users + private List users = new ArrayList(); + + public Project(Project project) { + this(project.spaceId, Constants.UUID_GENERATOR.generate().toString(), + project.title, project.description, project.uri, new Date()); + + Map nodeCloneMap = new HashMap( + project.nodes.size()); + for (Node node : project.nodes) { + Node newNode = new Node(node, this.id); + this.nodes.add(newNode); + nodeCloneMap.put(node.id, newNode); + } + + for (Edge edge : project.edges) { + this.edges.add(new Edge(edge, nodeCloneMap.get(edge.getFrom()), + nodeCloneMap.get(edge.getTo()), this.id)); + } + for (RenkanUser user : project.users) { + this.users.add(new RenkanUser(user)); + } + } - for (Edge edge : project.edges) { - this.edges.add(new Edge(edge, nodeCloneMap.get(edge.getFrom()), nodeCloneMap.get(edge.getTo()), this.id)); - } - for(RenkanUser user : project.users) { - this.users.add(new RenkanUser(user)); - } - } - - public Project(String spaceId, String id, String title, String description, String uri, Date created, - int revCounter) { - super(id,title, description, uri, null); - this.revCounter = revCounter; - this.spaceId = spaceId; - this.created = created; - if(this.created == null) { - this.created = new Date(); - } - this.setUpdated(new Date()); - } + public Project(String spaceId, String id, String title, String description, + String uri, Date created, int revCounter) { + super(id, title, description, uri, null); + this.revCounter = revCounter; + this.spaceId = spaceId; + this.created = created; + if (this.created == null) { + this.created = new Date(); + } + this.setUpdated(new Date()); + } + + @Autowired(required = true) + public Project(String spaceId, String id, String title, String description, + String uri, Date created) { + this(spaceId, id, title, description, uri, created, 1); + } + + @SuppressWarnings("unused") + private Project() { + } + + public int getRevCounter() { + return this.revCounter; + } + + public List getNodes() { + return this.nodes; + } - @Autowired(required=true) - public Project(String spaceId, String id, String title, String description, String uri, Date created) { - this(spaceId, id,title, description, uri, created, 1); - } - - @SuppressWarnings("unused") - private Project() { - } - - public int getRevCounter() { - return this.revCounter; - } - - public List getNodes() { - return this.nodes; - } + public List getEdges() { + return this.edges; + } + + public List getUsers() { + return this.users; + } + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT") + public Date getCreated() { + return created; + } + + public void setCreated(Date date) { + this.created = date; - public List getEdges() { - return this.edges; - } - - public List getUsers() { - return this.users; - } + } + + @JsonProperty("space_id") + public String getSpaceId() { + return spaceId; + } - @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone="GMT") - public Date getCreated() { - return created; - } - - public void setCreated(Date date) { - this.created = date; - - } - - @JsonProperty("space_id") - public String getSpaceId() { - return spaceId; - } + private String getRawKey(String prefix, Constants.EditMode editMode) { + StringBuffer key = new StringBuffer(prefix != null ? prefix + "|" : ""); + key.append(this.getId()); + key.append('|'); + key.append(this.getSpaceId()); + key.append('|'); + key.append(this.getCreated().getTime()); + key.append('|'); + key.append(editMode.toString()); + return key.toString(); + } - private String getRawKey(String prefix, Constants.EditMode editMode) { - StringBuffer key = new StringBuffer(prefix!=null?prefix+"|":""); - key.append(this.getId()); - key.append('|'); - key.append(this.getSpaceId()); - key.append('|'); - key.append(this.getCreated().getTime()); - key.append('|'); - key.append(editMode.toString()); - return key.toString(); - } - - public String getKey(int editMode) throws RenkanException { - return this.getKey(EditMode.fromInt(editMode)); - } - - public String getKey(Constants.EditMode editMode) throws RenkanException { - - String rawKey = this.getRawKey("", editMode); - - MessageDigest md; - try { - md = MessageDigest.getInstance("SHA-256"); - } catch (NoSuchAlgorithmException e) { - throw new RenkanException("NoSuchAlgorithmException digest: " + e.getMessage(), e); - } - String key; - final SecretKeySpec secret_key = new SecretKeySpec(Constants.KEYHEX.getBytes(), "HmacSHA256"); - md.update(secret_key.getEncoded()); - try { - key = Hex.encodeHexString(md.digest(rawKey.getBytes("UTF-8"))); - } catch (UnsupportedEncodingException e) { - throw new RenkanException("UnsupportedEncodingException digest: " + e.getMessage(), e); - } - - return key; - } - - public boolean checkKey(String key, Constants.EditMode editMode) throws RenkanException { - + public String getKey(int editMode) throws RenkanException { + return this.getKey(EditMode.fromInt(editMode)); + } + + public String getKey(Constants.EditMode editMode) throws RenkanException { + + String rawKey = this.getRawKey("", editMode); + + MessageDigest md; + try { + md = MessageDigest.getInstance("SHA-256"); + } catch (NoSuchAlgorithmException e) { + throw new RenkanException("NoSuchAlgorithmException digest: " + + e.getMessage(), e); + } + String key; + final SecretKeySpec secret_key = new SecretKeySpec( + Constants.KEYHEX.getBytes(), "HmacSHA256"); + md.update(secret_key.getEncoded()); + try { + key = Hex.encodeHexString(md.digest(rawKey.getBytes("UTF-8"))); + } catch (UnsupportedEncodingException e) { + throw new RenkanException("UnsupportedEncodingException digest: " + + e.getMessage(), e); + } - if(key == null || key.isEmpty()) { - return false; - } - - String signature = key; - - String new_key = this.getKey(editMode); - - return new_key.equals(signature); - } + return key; + } + + public boolean checkKey(String key, Constants.EditMode editMode) + throws RenkanException { + + if (key == null || key.isEmpty()) { + return false; + } + + String signature = key; + + String new_key = this.getKey(editMode); - @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone="GMT") - public Date getUpdated() { - return updated; - } + return new_key.equals(signature); + } + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT") + public Date getUpdated() { + return updated; + } + + public void setUpdated(Date updated) { + this.updated = updated; + } + + public void addUser(User user) { - public void setUpdated(Date updated) { - this.updated = updated; - } - - public void addUser(User user) { - - if(user == null) { - // we add an anonymous user - // find an unique user name - this.addUser(null, null); - } - else { - // if user is already in list do nothing - for (RenkanUser renkanUser : this.users) { - if(renkanUser.getUserId() != null && renkanUser.getUserId().equals(user.getId())) { - return; - } - } - // user not found - this.users.add(new RenkanUser(this.getId(), user.getId(), user.getColor(), user.getUsername())); - - } - - } - - public void addUser(String username, String color) { - - if(username == null) { - //find a new username - int i = 0; - boolean usernameFound = true; - while(i++<1000000 && usernameFound) { - username = String.format("%s-%s", Constants.ANONYMOUS_USER_BASE_NAME, i); - usernameFound = false; - for(RenkanUser renkanUser : this.users) { - if(username.equals(renkanUser.getUsername())) { - usernameFound = true; - break; - } - } - } - } - - if(color == null) { - int i=0; - boolean colorFound = true; - while(i++<10000000 && colorFound) { - color = "#" + ColorGenerator.randomColorHex(); - colorFound = false; - for(RenkanUser renkanUser : this.users) { - if(username.equals(renkanUser.getUsername())) { - colorFound = true; - break; - } - } - } - } - - RenkanUser ruser = new RenkanUser(this.getId(), null, color, username); - this.users.add(ruser); - } - + if (user == null) { + // we add an anonymous user + // find an unique user name + this.addUser(null, null); + } else { + // if user is already in list do nothing + for (RenkanUser renkanUser : this.users) { + if (renkanUser.getUserId() != null + && renkanUser.getUserId().equals(user.getId())) { + return; + } + } + // user not found + this.users.add(new RenkanUser(this.getId(), user.getId(), user + .getColor(), user.getUsername())); + + } + + } + + public void addUser(String username, String color) { + + if (username == null) { + // find a new username + int i = 0; + boolean usernameFound = true; + while (i++ < 1000000 && usernameFound) { + username = String.format("%s-%s", + Constants.ANONYMOUS_USER_BASE_NAME, i); + usernameFound = false; + for (RenkanUser renkanUser : this.users) { + if (username.equals(renkanUser.getUsername())) { + usernameFound = true; + break; + } + } + } + } + + if (color == null) { + int i = 0; + boolean colorFound = true; + while (i++ < 10000000 && colorFound) { + color = "#" + ColorGenerator.randomColorHex(); + colorFound = false; + for (RenkanUser renkanUser : this.users) { + if (username.equals(renkanUser.getUsername())) { + colorFound = true; + break; + } + } + } + } + + RenkanUser ruser = new RenkanUser(this.getId(), null, color, username); + this.users.add(ruser); + } + + @Override + protected String getRawKeyPart() { + return Long.toString(this.getCreated().getTime()); + } + } diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/java/org/iri_research/renkan/models/ProjectRevision.java --- a/server/src/main/java/org/iri_research/renkan/models/ProjectRevision.java Wed Oct 16 23:26:28 2013 +0200 +++ b/server/src/main/java/org/iri_research/renkan/models/ProjectRevision.java Mon Oct 21 13:58:20 2013 +0200 @@ -12,66 +12,71 @@ import com.fasterxml.jackson.annotation.JsonFormat; -@Document(collection="projectRevisions") +@Document(collection = "projectRevisions") public class ProjectRevision extends AbstractRenkanModel { - @SuppressWarnings("unused") - private static Logger logger = LoggerFactory.getLogger(ProjectRevision.class); - - private int revision; - - @DBRef - private Project project; - - @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone="GMT") - private Date created; - - // Nodes - private List nodes = new ArrayList(); - - // Edgess - private List edges = new ArrayList(); + @SuppressWarnings("unused") + private static Logger logger = LoggerFactory + .getLogger(ProjectRevision.class); + + private int revision; + + @DBRef + private Project project; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT") + private Date created; + // Nodes + private List nodes = new ArrayList(); - @SuppressWarnings("unused") - private ProjectRevision() { - super(); - } + // Edgess + private List edges = new ArrayList(); + + @SuppressWarnings("unused") + private ProjectRevision() { + super(); + } + + public ProjectRevision(String title, String description, String uri, + Project project, int revision, Date created) { + this(null, title, description, uri, project, revision, created); + } - public ProjectRevision(String title, String description, - String uri, Project project, int revision, Date created) { - this(null, title, description, uri, project, revision,created); - } - - public ProjectRevision(ObjectId id, String title, String description, - String uri, Project project, int revision, Date created) { - super(id, title, description, uri, null); - this.project = project; - this.revision = revision; - if(created == null) { - this.created = new Date(System.currentTimeMillis()); - } - } + public ProjectRevision(ObjectId id, String title, String description, + String uri, Project project, int revision, Date created) { + super(id, title, description, uri, null); + this.project = project; + this.revision = revision; + if (created == null) { + this.created = new Date(System.currentTimeMillis()); + } + } + + public int getRevision() { + return revision; + } + + public Project getProject() { + return project; + } - public int getRevision() { - return revision; - } - - public Project getProject() { - return project; - } - - public List getNodes() { - return nodes; - } + public List getNodes() { + return nodes; + } + + public List getEgdes() { + return edges; + } - public List getEgdes() { - return edges; - } + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT") + public Date getCreated() { + return created; + } - @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone="GMT") - public Date getCreated() { - return created; - } - + @Override + protected String getRawKeyPart() { + return Long.toString(this.getCreated().getTime()); + } + } diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/java/org/iri_research/renkan/models/RosterUser.java --- a/server/src/main/java/org/iri_research/renkan/models/RosterUser.java Wed Oct 16 23:26:28 2013 +0200 +++ b/server/src/main/java/org/iri_research/renkan/models/RosterUser.java Mon Oct 21 13:58:20 2013 +0200 @@ -3,49 +3,54 @@ import com.fasterxml.jackson.annotation.JsonProperty; public class RosterUser extends AbstractRenkanModel { - - private String projectId; - private Long siteId; - private String clientId; + + private String projectId; + private Long siteId; + private String clientId; + + public RosterUser(String id, String title, String description, String uri, + String color, String project_id, Long site_id, String client_id) { + super(id, title, description, uri, color); - public RosterUser(String id, String title, String description, String uri, String color, String project_id, Long site_id, String client_id) { - super(id, title, description, uri, color); - - this.projectId = project_id; - this.siteId = site_id; - this.clientId = client_id; - } - - public void setTitle(String title) { - this.title = title; - } + this.projectId = project_id; + this.siteId = site_id; + this.clientId = client_id; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setUri(String uri) { + this.uri = uri; + } - public void setDescription(String description) { - this.description = description; - } - - public void setUri(String uri) { - this.uri = uri; - } - - public void setColor(String color) { - this.color = color; - } + public void setColor(String color) { + this.color = color; + } + + @JsonProperty(value = "project_id") + public String getProjectId() { + return projectId; + } - @JsonProperty(value="project_id") - public String getProjectId() { - return projectId; - } + @JsonProperty(value = "site_id") + public Long getSiteId() { + return siteId; + } - @JsonProperty(value="site_id") - public Long getSiteId() { - return siteId; - } - - @JsonProperty(value="client_id") - public String getClientId() { - return clientId; - } + @JsonProperty(value = "client_id") + public String getClientId() { + return clientId; + } - + @Override + protected String getRawKeyPart() { + return ""; + } + } diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/java/org/iri_research/renkan/models/Space.java --- a/server/src/main/java/org/iri_research/renkan/models/Space.java Wed Oct 16 23:26:28 2013 +0200 +++ b/server/src/main/java/org/iri_research/renkan/models/Space.java Mon Oct 21 13:58:20 2013 +0200 @@ -1,15 +1,7 @@ package org.iri_research.renkan.models; -import java.io.UnsupportedEncodingException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; import java.util.Date; -import javax.crypto.spec.SecretKeySpec; - -import org.apache.commons.codec.binary.Hex; -import org.iri_research.renkan.Constants; -import org.iri_research.renkan.RenkanException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Field; @@ -17,112 +9,75 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; -@Document(collection="spaces") +@Document(collection = "spaces") public class Space extends AbstractRenkanModel { - - @Autowired - public Space(String id, String title, String description, String binConfig, String uri, String color, String createdBy, String image, Date created) { - super(id, title, description, uri, color); - - this.binConfig = binConfig; - this.createdBy = createdBy; - this.setImage(image); - this.created = created; - if(this.created == null) { - this.created = new Date(); - } - } - - public Space() { - } + + @Autowired + public Space(String id, String title, String description, String binConfig, + String uri, String color, String createdBy, String image, + Date created) { + super(id, title, description, uri, color); - @Field("bin_config") - @JsonProperty("bin_config") - private String binConfig; - - @Field("created_by") - @JsonProperty("created_by") - private String createdBy = null; - private String image; - - @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone="GMT") - private Date created; - - public String getImage() { - return image; - } + this.binConfig = binConfig; + this.createdBy = createdBy; + this.setImage(image); + this.created = created; + if (this.created == null) { + this.created = new Date(); + } + } + + public Space() { + } - @JsonProperty("created_by") - public String getCreatedBy() { - return createdBy; - } - - @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone="GMT") - public Date getCreated() { - return created; - } - - public void setCreated(Date date) { - this.created = date; - - } + @Field("bin_config") + @JsonProperty("bin_config") + private String binConfig; - @JsonProperty("bin_config") - public String getBinConfig() { - return binConfig; - } + @Field("created_by") + @JsonProperty("created_by") + private String createdBy = null; + private String image; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT") + private Date created; - @JsonProperty("bin_config") - public void setBinConfig(String bin_config) { - this.binConfig = bin_config; - } + public String getImage() { + return image; + } + + @JsonProperty("created_by") + public String getCreatedBy() { + return createdBy; + } + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT") + public Date getCreated() { + return created; + } + + public void setCreated(Date date) { + this.created = date; + + } - public void setImage(String image) { - this.image = image; - } - - private String getRawKey(String salt) { - StringBuffer key = new StringBuffer(salt!=null?salt+"|":""); - key.append(this.getId()); - key.append('|'); - key.append(this.getCreated().getTime()); - return key.toString(); - } - - public String getKey(String salt) throws RenkanException { - - String rawKey = this.getRawKey(salt); - - MessageDigest md; - try { - md = MessageDigest.getInstance("SHA-256"); - } catch (NoSuchAlgorithmException e) { - throw new RenkanException("NoSuchAlgorithmException digest: " + e.getMessage(), e); - } - String key; - final SecretKeySpec secret_key = new SecretKeySpec(Constants.KEYHEX.getBytes(), "HmacSHA256"); - md.update(secret_key.getEncoded()); - try { - key = Hex.encodeHexString(md.digest(rawKey.getBytes("UTF-8"))); - } catch (UnsupportedEncodingException e) { - throw new RenkanException("UnsupportedEncodingException digest: " + e.getMessage(), e); - } - - return key; - } - - public boolean checkKey(String key, String salt) throws RenkanException { - + @JsonProperty("bin_config") + public String getBinConfig() { + return binConfig; + } + + @JsonProperty("bin_config") + public void setBinConfig(String bin_config) { + this.binConfig = bin_config; + } - if(key == null || key.isEmpty()) { - return false; - } - - String signature = key; - - String new_key = this.getKey(salt); - - return new_key.equals(signature); - } - + public void setImage(String image) { + this.image = image; + } + + @Override + protected String getRawKeyPart() { + return Long.toString(this.getCreated().getTime()); + } + } \ No newline at end of file diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/java/org/iri_research/renkan/models/User.java --- a/server/src/main/java/org/iri_research/renkan/models/User.java Wed Oct 16 23:26:28 2013 +0200 +++ b/server/src/main/java/org/iri_research/renkan/models/User.java Mon Oct 21 13:58:20 2013 +0200 @@ -11,78 +11,122 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; -@Document(collection="users") +@Document(collection = "users") public class User extends AbstractRenkanModel implements UserDetails { - - private static final long serialVersionUID = 6972038893086220548L; - - private String email; - private String password; - private String salt; - private String avatar; - private boolean enabled; - private boolean locked; - - @Field("expiration_date") - @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone="GMT") - private Date expirationDate; - - @Field("credentials_expiration_date") - @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone="GMT") - private Date credentialExpirationDate; + + private static final long serialVersionUID = 6972038893086220548L; + + private String avatar; + @Field("credentials_expiration_date") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT") + private Date credentialExpirationDate; + private String email; + private boolean enabled; + @Field("expiration_date") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", timezone = "GMT") + private Date expirationDate; + + private boolean locked; + + private String password; + + private String salt; - public User(String id, String title, String description, String uri, String color) { - super(id, title, description, uri, color); - } - - public String getColor() { - return this.color; - } + public User() { + } + public User(String id, String title, String description, String uri, + String color) { + super(id, title, description, uri, color); + } + @Override + public Collection getAuthorities() { + // TODO Auto-generated method stub + return null; + } - @Override - public Collection getAuthorities() { - // TODO Auto-generated method stub - return null; - } + public String getAvatar() { + return avatar; + } + public String getColor() { + return this.color; + } + + public Date getCredentialExpirationDate() { + return credentialExpirationDate; + } + + public String getEmail() { + return email; + } + + public Date getExpirationDate() { + return expirationDate; + } - @Override - @JsonIgnore - public String getPassword() { - return this.password; - } + @Override + @JsonIgnore + public String getPassword() { + return this.password; + } + + @Override + @JsonIgnore + public String getUsername() { + return this.title; + } - @Override - @JsonIgnore - public String getUsername() { - return this.title; - } + @Override + public boolean isAccountNonExpired() { + return this.expirationDate == null + || this.expirationDate.after(new Date()); + } + + @Override + public boolean isAccountNonLocked() { + return !this.locked; + } - @Override - public boolean isAccountNonExpired() { - return this.expirationDate == null || this.expirationDate.after(new Date()); - } + @Override + public boolean isCredentialsNonExpired() { + return this.credentialExpirationDate == null + || this.credentialExpirationDate.after(new Date()); + } + + @Override + public boolean isEnabled() { + return this.enabled; + } - @Override - public boolean isAccountNonLocked() { - return !this.locked; - } + public boolean isLocked() { + return locked; + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } - @Override - public boolean isCredentialsNonExpired() { - return this.credentialExpirationDate == null || this.credentialExpirationDate.after(new Date()); - } + public void setCredentialExpirationDate(Date credentialExpirationDate) { + this.credentialExpirationDate = credentialExpirationDate; + } + + public void setEmail(String email) { + this.email = email; + } - @Override - public boolean isEnabled() { - return this.enabled; - } + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public void setExpirationDate(Date expirationDate) { + this.expirationDate = expirationDate; + } - public String getEmail() { - return email; - } + public void setLocked(boolean locked) { + this.locked = locked; + } + @Override + protected String getRawKeyPart() { + return ""; + } - public String getAvatar() { - return avatar; - } - } diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/webapp/WEB-INF/i18n/messages.properties --- a/server/src/main/webapp/WEB-INF/i18n/messages.properties Wed Oct 16 23:26:28 2013 +0200 +++ b/server/src/main/webapp/WEB-INF/i18n/messages.properties Mon Oct 21 13:58:20 2013 +0200 @@ -47,6 +47,7 @@ renkanAdmin.space_delete = Delete space renkanIndex.space_url = Url renkanAdmin.space_confirm_delete = Do you want to delete the space entitled "{0}" ? +renkanAdmin.space_proj_count = Nb. Proj. renkanAdmin.object_name = Name renkanAdmin.object_edit = Edit @@ -64,6 +65,14 @@ renkanAdmin.form.space.format = Format renkanAdmin.form.space.compact = Compact +renkanAdmin.form.avatar = Avatar +renkanAdmin.form.credentialExpirationDate = Cred. exp. date +renkanAdmin.form.expirationDate = Exp. date +renkanAdmin.form.email = Email +renkanAdmin.form.enabled = Enabled +renkanAdmin.form.locked = Locked +renkanAdmin.form.user.submit = Ok + renkan.error.title.empty = Title must not be empty or null renkan.error.bin_config.json = bin config field must contain a valid json diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/webapp/WEB-INF/i18n/messages_en.properties --- a/server/src/main/webapp/WEB-INF/i18n/messages_en.properties Wed Oct 16 23:26:28 2013 +0200 +++ b/server/src/main/webapp/WEB-INF/i18n/messages_en.properties Mon Oct 21 13:58:20 2013 +0200 @@ -47,6 +47,7 @@ renkanAdmin.space_delete = Del. space renkanIndex.space_url = Url renkanAdmin.space_confirm_delete = Do you want to delete the space entitled "{0}" ? +renkanAdmin.space_proj_count = Nb. Proj. renkanAdmin.object_name = Name renkanAdmin.object_created = Created @@ -74,6 +75,14 @@ renkanIndex.user_url = Url renkanAdmin.user_confirm_delete = Do you want to delete the user with username "{0}" ? +renkanAdmin.form.avatar = Avatar +renkanAdmin.form.credentialExpirationDate = Cred. exp. date +renkanAdmin.form.expirationDate = Exp. date +renkanAdmin.form.email = Email +renkanAdmin.form.enabled = Enabled +renkanAdmin.form.locked = Locked +renkanAdmin.form.user.submit = Ok + renkan.error.title.empty = Title must not be empty or null renkan.error.bin_config.json = bin config field must contain a valid json diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/webapp/WEB-INF/i18n/messages_fr.properties --- a/server/src/main/webapp/WEB-INF/i18n/messages_fr.properties Wed Oct 16 23:26:28 2013 +0200 +++ b/server/src/main/webapp/WEB-INF/i18n/messages_fr.properties Mon Oct 21 13:58:20 2013 +0200 @@ -46,6 +46,7 @@ renkanAdmin.space_delete = Supression espace renkanIndex.space_url = Url renkanAdmin.space_confirm_delete = Confirmez-vous l'effacement de l'espace intitulé "{0}" ? +renkanAdmin.space_proj_count = Nb. Proj. renkanAdmin.object_name = Nom renkanAdmin.object_created = Date Crea. @@ -72,7 +73,13 @@ renkanIndex.user_url = Url renkanAdmin.user_confirm_delete = Do you want to delete the user with username "{0}" ? - +renkanAdmin.form.avatar = Avatar +renkanAdmin.form.credentialExpirationDate = Date exp. mdp. +renkanAdmin.form.expirationDate = Date exp. +renkanAdmin.form.email = Email +renkanAdmin.form.enabled = Actif +renkanAdmin.form.locked = Verrouillé +renkanAdmin.form.user.submit = Ok renkan.error.title.empty = Le champ titre ne doit pas être vide diff -r a392390de1a7 -r 6ac00231ee34 server/src/main/webapp/WEB-INF/templates/admin/spaceDeleteConfirm.html --- a/server/src/main/webapp/WEB-INF/templates/admin/spaceDeleteConfirm.html Wed Oct 16 23:26:28 2013 +0200 +++ b/server/src/main/webapp/WEB-INF/templates/admin/spaceDeleteConfirm.html Mon Oct 21 13:58:20 2013 +0200 @@ -1,7 +1,7 @@ - Renkan Admin - edit space + Renkan Admin - delete space @@ -22,9 +22,9 @@

Spaces List / Delete space

-
-
Do you want to delete space with title
-
+
+
Do you want to delete space with title
+