List of usage examples for java.security Principal getName
public String getName();
From source file:com.epam.ta.reportportal.ws.controller.impl.LogController.java
@Override @RequestMapping(value = "/{logId}", method = RequestMethod.DELETE) @ResponseBody// www . jav a 2 s . co m @ApiOperation("Delete log") public OperationCompletionRS deleteLog(@PathVariable String projectName, @PathVariable String logId, Principal principal) { return deleteLogMessageHandler.deleteLog(logId, EntityUtils.normalizeProjectName(projectName), principal.getName()); }
From source file:alfio.controller.api.admin.ResourceController.java
private void checkAccess(Principal principal) { Validate.isTrue(userManager.isAdmin(userManager.findUserByUsername(principal.getName()))); }
From source file:alfio.controller.api.admin.ConfigurationApiController.java
@RequestMapping(value = "/configuration/organizations/{organizationId}/events/{eventId}/update", method = POST) public boolean updateEventConfiguration(@PathVariable("organizationId") int organizationId, @PathVariable("eventId") int eventId, @RequestBody Map<ConfigurationKeys.SettingCategory, List<ConfigurationModification>> input, Principal principal) { configurationManager.saveAllEventConfiguration(eventId, organizationId, input.values().stream().flatMap(Collection::stream).collect(Collectors.toList()), principal.getName()); return true;/*from w ww.j av a 2 s . c o m*/ }
From source file:com.jd.survey.web.security.GroupController.java
@Secured({ "ROLE_ADMIN" }) @RequestMapping(value = "/", params = "icreate", produces = "text/html") public String createInternalGet(Principal principal, Model uiModel, HttpServletRequest httpServletRequest) { try {/*ww w . ja v a 2 s .c o m*/ User user = userService.user_findByLogin(principal.getName()); Group group = new Group(SecurityType.I); populateEditForm(uiModel, group, user); return "security/groups/create"; } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }
From source file:com.jd.survey.web.security.GroupController.java
@Secured({ "ROLE_ADMIN" }) @RequestMapping(value = "/", params = "ecreate", produces = "text/html") public String createExternalGet(Principal principal, Model uiModel, HttpServletRequest httpServletRequest) { try {//ww w .j ava 2s . c om User user = userService.user_findByLogin(principal.getName()); Group group = new Group(SecurityType.E); populateEditForm(uiModel, group, user); return "security/groups/create"; } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }
From source file:com.jd.survey.web.settings.GlobalSettingsController.java
@Secured({ "ROLE_ADMIN" }) @RequestMapping(method = RequestMethod.PUT, produces = "text/html") public String update(@RequestParam(value = "_proceed", required = false) String proceed, @Valid GlobalSettings globalSettings, BindingResult bindingResult, Principal principal, Model uiModel, HttpServletRequest httpServletRequest) { log.info("update(): handles PUT"); try {// w ww. j a v a 2 s . co m User user = userService.user_findByLogin(principal.getName()); if (!user.isAdmin()) { log.warn("Unauthorized access to url path " + httpServletRequest.getPathInfo() + " attempted by user login:" + principal.getName() + "from IP:" + httpServletRequest.getLocalAddr()); return "accessDenied"; } if (proceed != null) { if (bindingResult.hasErrors()) { populateEditForm(uiModel, globalSettings, user); return "settings/globalSettings/update"; } uiModel.asMap().clear(); globalSettings = applicationSettingsService.globalSettings_merge(globalSettings); return "redirect:/settings/globalSettings/" + encodeUrlPathSegment(globalSettings.getId().toString(), httpServletRequest); } else { return "redirect:/settings/globalSettings/" + encodeUrlPathSegment(globalSettings.getId().toString(), httpServletRequest); } } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }
From source file:au.csiro.notify.service.NotificationServiceImpl.java
@Override @Transactional(readOnly = true)/* w w w . ja v a2 s.co m*/ public List<Notification> retrieveAll(boolean includeRead, Principal principal) { logger.trace("entering retrieveAll({}, {})", includeRead, principal); List<Notification> notifications; if (includeRead) { notifications = notificationDao.findByRecipientIncludeRead(principal.getName()); } else { notifications = notificationDao.findByRecipient(principal.getName()); } logger.trace("exiting retrieveAll={}", notifications); return notifications; }
From source file:com.jd.survey.web.settings.VelocityTemplateController.java
@Secured({ "ROLE_ADMIN" }) @RequestMapping(value = "/{id}", produces = "text/html") public String show(@PathVariable("id") Long id, Principal principal, Model uiModel) { log.info("show(): id=" + id); try {//from ww w . j a v a 2s . co m User user = userService.user_findByLogin(principal.getName()); if (!user.isAdmin()) { return "accessDenied"; } uiModel.addAttribute("velocityTemplate", surveySettingsService.velocityTemplate_findById(id)); uiModel.addAttribute("itemId", id); return "admin/templates/show"; } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }
From source file:com.jd.survey.web.security.GroupController.java
@Secured({ "ROLE_ADMIN" }) @RequestMapping(value = "/{id}", params = "form", produces = "text/html") public String updateForm(@PathVariable("id") Long id, Principal principal, Model uiModel) { log.info("updateForm(): id=" + id); try {//from w ww. j a va 2 s . c o m User user = userService.user_findByLogin(principal.getName()); populateEditForm(uiModel, userService.group_findById(id), user); return "security/groups/update"; } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }
From source file:com.jd.survey.web.settings.VelocityTemplateController.java
@Secured({ "ROLE_ADMIN" }) @RequestMapping(value = "/{id}", params = "form", produces = "text/html") public String updateForm(@PathVariable("id") Long id, Principal principal, Model uiModel) { log.info("updateForm(): id=" + id); try {/*from w ww. j a v a 2 s . co m*/ User user = userService.user_findByLogin(principal.getName()); if (!user.isAdmin()) { return "accessDenied"; } populateEditForm(uiModel, surveySettingsService.velocityTemplate_findById(id), user); return "admin/templates/update"; } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }