List of usage examples for java.security Principal getName
public String getName();
From source file:org.starfishrespect.myconsumption.server.business.controllers.UserController.java
@RequestMapping(value = "/{name}", method = RequestMethod.GET) public UserDTO get(Principal principal, @PathVariable String name) { // Check if this user can access this resource if (!(principal.getName().equals(name))) throw new NotFoundException(); User user = mUserRepository.getUser(name); if (user == null) throw new NotFoundException(); else//from ww w. ja v a 2 s . c o m return new DozerBeanMapper().map(user, UserDTO.class); }
From source file:alfio.controller.api.admin.AdminWaitingQueueApiController.java
@RequestMapping(value = "/status", method = RequestMethod.GET) public Map<String, Boolean> getStatusForEvent(@PathVariable("eventName") String eventName, Principal principal) { return optionally(() -> eventManager.getSingleEvent(eventName, principal.getName())).map(this::loadStatus) .orElse(Collections.emptyMap()); }
From source file:org.starfishrespect.myconsumption.server.business.controllers.NotifController.java
@RequestMapping(value = "/{name}/id/{registerId}", method = RequestMethod.POST) public SimpleResponseDTO registerId(Principal principal, @PathVariable String name, @PathVariable String registerId) throws DaoException { // Check if this user can access this resource if (!(principal.getName().equals(name))) return new SimpleResponseDTO(false, "you are not allowed to modify this user"); User user = mUserRepository.getUser(name); if (user == null) throw new NotFoundException(); if (registerId == null || registerId.isEmpty()) return new SimpleResponseDTO(false, "Register id invalid"); // Set or override current id user.setRegisterId(registerId);//from w w w.ja v a2 s .co m mUserRepository.updateUser(user); return new SimpleResponseDTO(true, "Register id associated to the user"); }
From source file:de.fau.amos4.web.ClientController.java
@RequestMapping(value = "/client/profile") public ModelAndView ClientProfile(Principal principal) { ModelAndView mav = new ModelAndView(); final String currentUser = principal.getName(); Client client = clientService.getClientByEmail(currentUser); mav.addObject("Client", client); mav.setViewName("client/profile"); return mav;/* w w w.java 2 s .c o m*/ }
From source file:de.fau.amos4.web.ClientController.java
@RequestMapping(value = "/client/edit") public ModelAndView ClientEdit(Principal principal) { ModelAndView mav = new ModelAndView(); final String currentUser = principal.getName(); Client client = clientService.getClientByEmail(currentUser); mav.addObject("Client", client); mav.addObject("allTitles", Title.values()); mav.setViewName("client/edit"); return mav;/*from ww w.j a va2 s .c om*/ }
From source file:com.epam.ta.reportportal.ws.controller.impl.WidgetController.java
@Override @RequestMapping(value = "/shared", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK)/* w w w . j a va 2 s. c o m*/ @ResponseBody @ApiOperation("Load shared widgets") public List<WidgetResource> getSharedWidgetsList(Principal principal, @PathVariable String projectName) { return getHandler.getSharedWidgetsList(principal.getName(), EntityUtils.normalizeProjectName(projectName)); }
From source file:runtheshow.resource.metiers.SousEvenenementMetier.java
@Override public List<SousEvenement> getSousEventById(Long id, Principal user) { return Lists.newArrayList( sousEventRepository.findByIdAndUser(id, userRepository.findUserByLogin(user.getName()))); }
From source file:com.epam.ta.reportportal.ws.controller.impl.WidgetController.java
@Override @RequestMapping(value = "/names/shared", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK)//from ww w. java 2s . c o m @ResponseBody @Deprecated @ApiIgnore public Map<String, SharedEntity> getSharedWidgets(Principal principal, @PathVariable String projectName) { return getHandler.getSharedWidgetNames(principal.getName(), EntityUtils.normalizeProjectName(projectName)); }
From source file:com.springsource.html5expense.controller.LoginController.java
@RequestMapping(value = "/", method = RequestMethod.GET) public String printWelcome(ModelMap model, Principal principal, HttpServletRequest request) { String name = principal.getName(); model.addAttribute("username", name); User user = getUserService().getUserByUserName(name); List<Expense> pendingExpenseList = getExpenseService().getExpensesByUser(user); model.addAttribute("pendingExpenseList", pendingExpenseList); request.getSession().setAttribute("user", user); return "myexpense"; }
From source file:alfio.controller.api.admin.AdminWaitingQueueApiController.java
@RequestMapping(value = "/status", method = RequestMethod.PUT) public Map<String, Boolean> setStatusForEvent(@PathVariable("eventName") String eventName, @RequestBody SetStatusForm form, Principal principal) { return optionally(() -> eventManager.getSingleEvent(eventName, principal.getName())).map(event -> { configurationManager.saveAllEventConfiguration(event.getId(), event.getOrganizationId(), singletonList(new ConfigurationModification(null, ConfigurationKeys.STOP_WAITING_QUEUE_SUBSCRIPTIONS.name(), String.valueOf(form.status))), principal.getName());//from ww w . j a va 2 s . c om return loadStatus(event); }).orElse(Collections.emptyMap()); }