List of usage examples for java.security Principal getName
public String getName();
From source file:org.magnum.mobilecloud.video.VideoSvcCtrl.java
@PreAuthorize("hasRole(USER)") @RequestMapping(method = RequestMethod.POST, value = VideoSvcApi.VIDEO_SVC_PATH + "/{id}/like") public @ResponseBody void likeVideo(@PathVariable("id") long id, Principal principal, HttpServletResponse response) {/* www . j av a2s.com*/ Video v = videoRepo.findOne(id); if (v != null) { HashSet<String> likers = v.getLikers(); if (likers.contains(principal.getName())) response.setStatus(HttpServletResponse.SC_BAD_REQUEST); else { likers.add(principal.getName()); videoRepo.save(v); response.setStatus(HttpServletResponse.SC_OK); } } else response.setStatus(HttpServletResponse.SC_NOT_FOUND); }
From source file:org.magnum.mobilecloud.video.VideoController.java
@RequestMapping(value = VideoSvcApi.VIDEO_SVC_PATH + "/{id}/like", method = RequestMethod.POST) public void likeVideo(@PathVariable long id, Principal principal, HttpServletResponse response) { Video v = _videoRepository.findOne(id); if (v == null) { response.setStatus(HttpStatus.SC_NOT_FOUND); return;/*from ww w . ja v a 2 s . co m*/ } String username = principal.getName(); if (!v.like(username)) response.setStatus(HttpStatus.SC_BAD_REQUEST); _videoRepository.save(v); }
From source file:org.davidmendoza.esu.web.admin.ArticuloController.java
@RequestMapping(value = "/nuevo", method = RequestMethod.GET) public String nuevo(Model model, Principal principal) { Usuario autor = usuarioService.obtiene(principal.getName()); Articulo articulo = new Articulo(); articulo.setAutor(autor);/*from w w w . j a v a 2 s . co m*/ model.addAttribute("articulo", articulo); return "admin/articulo/nuevo"; }
From source file:org.geosdi.geoplatform.experimental.dropwizard.resources.secure.viewport.GPSecureViewportResource.java
@DELETE @Path(value = GPServiceRSPathConfig.DELETE_VIEWPORT_PATH) @Override/*from www . j a va 2 s .co m*/ public Boolean deleteViewport(@Auth Principal principal, @QueryParam(value = "viewportID") Long viewportID) throws Exception { logger.debug("\n\n@@@@@@@@@@@@@@Executing secure deleteViewport - " + "Principal : {}\n\n", principal.getName()); return super.deleteViewport(viewportID); }
From source file:org.geosdi.geoplatform.experimental.dropwizard.resources.secure.viewport.GPSecureViewportResource.java
@GET @Path(value = GPServiceRSPathConfig.GET_VIEWPORT_BY_ID_PATH) @Override// w w w . j a va 2s. co m public GPViewport getViewportById(@Auth Principal principal, @QueryParam(value = "idViewport") Long idViewport) throws Exception { logger.debug("\n\n@@@@@@@@@@@@@@Executing secure getViewportById - " + "Principal : {}\n\n", principal.getName()); return super.getViewportById(idViewport); }
From source file:org.magnum.mobilecloud.video.VideoService.java
@RequestMapping(value = VideoSvcApi.VIDEO_SVC_PATH + "/{id}/like", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.OK)/*from w ww. j a v a 2 s. co m*/ public void likeVideo(@PathVariable("id") long id, HttpServletResponse response, Principal p) { Video v = videos.findOne(id); if (v == null) { sendError(response, HttpServletResponse.SC_NOT_FOUND, "Video not found"); return; } if (!v.likeVideo(p.getName())) { sendError(response, HttpServletResponse.SC_BAD_REQUEST, "Video already liked by user"); return; } videos.save(v); }
From source file:com.epam.ta.reportportal.ws.controller.impl.TestItemController.java
@Override @PutMapping("/{item}/update") @ResponseBody/* w ww . j a v a 2 s. co m*/ @ResponseStatus(OK) @PreAuthorize(ASSIGNED_TO_PROJECT) @ApiOperation("Update test item") public OperationCompletionRS updateTestItem(@PathVariable String projectName, @PathVariable String item, @RequestBody @Validated UpdateTestItemRQ rq, Principal principal) { return updateTestItemHandler.updateTestItem(normalizeProjectName(projectName), item, rq, principal.getName()); }
From source file:alfio.controller.api.admin.CheckInApiController.java
@RequestMapping(value = "/check-in/{eventId}/tickets", method = POST) public List<FullTicketInfo> findAllTicketsForAdminCheckIn(@PathVariable("eventId") int eventId, @RequestBody List<Integer> ids, Principal principal) { validateIdList(ids);// w w w .ja va 2s. c o m return checkInManager.getAttendeesInformation(eventId, ids, principal.getName()); }
From source file:org.geosdi.geoplatform.experimental.dropwizard.resources.secure.message.GPSecureMessageResource.java
@DELETE @Path(value = GPServiceRSPathConfig.DELETE_MESSAGE_PATH) @Override// w ww .ja va 2s . co m public Boolean deleteMessage(@Auth Principal principal, @PathParam(value = "messageID") Long messageID) throws Exception { logger.debug("\n\n@@@@@@@@@@@@@@Executing secure deleteMessage - " + "Principal : {}\n\n", principal.getName()); return super.deleteMessage(messageID); }
From source file:alfio.controller.api.AdminApiController.java
@RequestMapping(value = "/events/{name}", method = GET) public Map<String, Object> getSingleEvent(@PathVariable("name") String eventName, Principal principal) { Map<String, Object> out = new HashMap<>(); final String username = principal.getName(); final EventWithStatistics event = eventManager.getSingleEventWithStatistics(eventName, username); out.put("event", event); out.put("organization", eventManager.loadOrganizer(event.getEvent(), username)); return out;/*from w ww .jav a 2 s . com*/ }