List of usage examples for java.security Principal getName
public String getName();
From source file:pdl.web.controller.rest.RestMainController.java
/** * Returns list of job ids for current user * @param principal user principal//w w w. j a v a 2 s . c om * @return list of jobs of current user in json format * @format curl <ip address>:<port>/pdl/r/joblist -u <user id>:<pass> */ @RequestMapping(value = "joblist", method = RequestMethod.GET) public @ResponseBody Map<String, Object> getJobList(Principal principal) { Map rtnJson = handler.getJobsForUser(principal.getName()); return rtnJson; }
From source file:pdl.web.controller.rest.RestMainController.java
/** * Returns list of files for current user * @param principal user principal/*from www . j av a 2 s .co m*/ * @return list of files that belong to current user in json format * @format curl <ip address>:<port>/pdl/r/filelist -u <user id>:<pass> */ @RequestMapping(value = "filelist", method = RequestMethod.GET) public @ResponseBody Map<String, Object> getFileList(Principal principal) { Map rtnJson = handler.getFilesForUser(principal.getName()); return rtnJson; }
From source file:mx.gob.cfe.documentos.web.DocumentoController.java
@RequestMapping public String lista(Model model, Principal principal) { String username = principal.getName(); Usuario usuario = usuarioDao.obtinePorUsername(username); model.addAttribute("documentos", instance.lista("Documento", usuario.getIniciales())); List lista = instance.lista("Documento", usuario.getIniciales()); log.error("lista{}", lista); return "documento/lista"; }
From source file:mx.gob.cfe.documentos.web.DocumentoController.java
@RequestMapping("/reporte") public String reporte(Model model, Principal principal) { String username = principal.getName(); Usuario usuario = usuarioDao.obtinePorUsername(username); model.addAttribute("documentos", instance.listaReporte(usuario.getIniciales())); List lista = instance.listaReporte(usuario.getIniciales()); log.error("lista{}", lista); return "documento/reporte"; }
From source file:mx.gob.cfe.documentos.web.DocumentoController.java
@RequestMapping("/enviados") public String listaEnviados(Model model, Principal principal) { String username = principal.getName(); Usuario usuario = usuarioDao.obtinePorUsername(username); model.addAttribute("documentos", instance.listaEnviados(usuario.getOficina())); List lista = instance.listaEnviados(usuario.getOficina()); log.error("lista{}", lista); return "documento/enviados"; }
From source file:org.ng200.openolympus.services.ContestSecurityService.java
public boolean isSuperuser(final Principal principal) { if (principal == null) { return false; }/*from ww w .ja v a2 s . c om*/ return this.isSuperuser(this.userRepository.findByUsername(principal.getName())); }
From source file:com.springsource.oauthservice.develop.AppController.java
@RequestMapping(value = "/apps/{slug}", method = RequestMethod.PUT) public String update(@PathVariable String slug, @Valid AppForm form, BindingResult bindingResult, Principal user, Model model) { if (bindingResult.hasErrors()) { model.addAttribute("slug", slug); return "develop/apps/edit"; }//from w w w. j a v a 2s. co m return "redirect:/develop/apps/" + appRepository.updateApp(user.getName(), slug, form); }
From source file:mx.gob.cfe.documentos.web.DocumentoController.java
@RequestMapping("/autorizar") public String autorizar(Model model, Principal principal) { String username = principal.getName(); Usuario usuario = usuarioDao.obtinePorUsername(username); if (!"jefe".equals(usuario.getPuesto())) { return "usuario/noAutorizado"; }//from w ww . j a va2 s . com model.addAttribute("documentos", instance.autoriza(usuario.getOficina())); List lista = instance.listaEnviados(usuario.getOficina()); log.error("lista{}", lista); return "documento/autorizar"; }
From source file:mx.gob.cfe.documentos.web.DocumentoController.java
@RequestMapping("/autoriza/{id}") public String autoriza(@PathVariable Long id, Model model, RedirectAttributes redirectAttributes, Principal principal) { String username = principal.getName(); Usuario usuario = usuarioDao.obtinePorUsername(username); if (!"jefe".equals(usuario.getPuesto())) { return "usuario/noAutorizado"; }// w ww . j a v a2 s . c om Documento documento = instance.obtiene(id); documento.setStatus("AUT"); instance.actualiza(documento); return "redirect:/documento/autorizar"; }
From source file:org.ng200.openolympus.controller.user.SolutionListController.java
@RequestMapping(value = "/user/solutions", method = RequestMethod.GET) public String showUserSolutions(@RequestParam(value = "page", defaultValue = "1") final Integer pageNumber, final Model model, final Principal principal) { final User user = this.userRepository.findByUsername(principal.getName()); final List<SolutionDTO> lst = new ArrayList<SolutionDTO>(); final Sort sort = new Sort(Direction.DESC, "timeAdded"); final PageRequest pageRequest = new PageRequest(pageNumber - 1, 10, sort); final List<Solution> solutions = new ArrayList<>(); if (this.contestService.getRunningContest() != null) { this.contestService.getRunningContest().getTasks().forEach((task) -> solutions.addAll(Optional .fromNullable(//from w w w . ja v a 2 s. c om this.solutionRepository.findByUserAndTaskOrderByTimeAddedDesc(user, task, pageRequest)) .or(new ArrayList<>()))); } else { solutions.addAll(this.solutionRepository.findByUserOrderByTimeAddedDesc(user, pageRequest)); } for (final Solution solution : solutions) { lst.add(new SolutionDTO(MessageFormat.format("/solution?id={0}", Long.toString(solution.getId())), solution.getUser().getUsername(), this.solutionService.getSolutionScore(solution), this.solutionService.getSolutionMaximumScore(solution), solution.getTask().getName(), MessageFormat.format("/task/{0}", Long.toString(solution.getTask().getId())), solution.getTimeAdded())); } SolutionListController.logger.info("Page view: {}", solutions); model.addAttribute("solutions", lst); model.addAttribute("numberOfPages", Math.max((this.getSolutionCountForUser(user) + 9) / 10, 1)); model.addAttribute("currentPage", pageNumber); model.addAttribute("pagePrefix", "/user/solutions?page="); return "tasks/solutions"; }