List of usage examples for org.springframework.security.core Authentication getName
public String getName();
From source file:com.ericpol.notifier.web.MainController.java
@RequestMapping(value = "/save-events", method = RequestMethod.POST) public String saveEvents(@RequestParam Map<String, String> allRequestParams, Model model) throws IOException, SchedulerException { LOGGER.info("save events"); Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String name = auth.getName(); final User user = userDAO.getUser(name); userDAO.setEventsSettings(user, allRequestParams); return "redirect:/"; }
From source file:org.mitre.uma.web.ClaimsAPI.java
@RequestMapping(value = "", method = RequestMethod.GET, produces = MimeTypeUtils.APPLICATION_JSON_VALUE) public String getResourceSetsForCurrentUser(Model m, Authentication auth) { Collection<ResourceSet> resourceSets = resourceSetService.getAllForOwner(auth.getName()); m.addAttribute(JsonEntityView.ENTITY, resourceSets); return JsonEntityView.VIEWNAME; }
From source file:org.xaloon.wicket.security.spring.external.ExternalAuthenticationProvider.java
private Authentication createExternalAuthenticationToken(Authentication authentication, AuthenticationToken initialToken) { User user = userDao.newUser();//from ww w. j a v a 2 s . c om user.setUsername(authentication.getName()); user.setExternal(true); externalParameterResolver.resolve(initialToken, user); Collection<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(); authorities.add(new SimpleGrantedAuthority(SecurityAuthorities.AUTHENTICATED_USER)); UsernamePasswordAuthenticationToken result = new UsernamePasswordAuthenticationToken( authentication.getPrincipal(), authentication.getCredentials(), authorities); result.setDetails(user); return result; }
From source file:cherry.sqlapp.controller.sqltool.load.SqltoolLoadControllerImpl.java
@Override public SqltoolLoadForm getForm(Integer ref, Authentication auth) { if (ref != null) { SqltoolMetadata md = metadataService.findById(ref, auth.getName()); if (md != null) { SqltoolLoad record = loadService.findById(ref); if (record != null) { return formUtil.getForm(record); }//w w w.ja va 2s.c om } } SqltoolLoadForm form = new SqltoolLoadForm(); form.setDatabaseName(dataSourceDef.getDefaultName()); return form; }
From source file:com.ericpol.notifier.web.MainController.java
@RequestMapping(value = "/settings", method = RequestMethod.POST) public String settings(@RequestParam(value = "sip-number", defaultValue = "none") String aSipNumber, @RequestParam(value = "notified", defaultValue = "false") boolean notified, Map<String, Object> model) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String name = auth.getName(); LOGGER.info("settings controller for {}, sip is {}, notified is {}", name, aSipNumber, notified); final User user = userDAO.getUser(name); user.setSipNumber(Integer.parseInt(aSipNumber)); user.setNotified(notified);// ww w. j a va 2 s . co m userDAO.updateUser(user); return "redirect:/"; }
From source file:org.duracloud.account.app.controller.AbstractAccountController.java
/** * @return/*from w w w .j ava2 s . c om*/ */ protected DuracloudUser getUser() throws DBNotFoundException { SecurityContext securityContext = SecurityContextHolder.getContext(); Authentication authentication = securityContext.getAuthentication(); String username = authentication.getName(); return this.userService.loadDuracloudUserByUsername(username); }
From source file:uk.co.caprica.bootlace.data.UsernameAuditor.java
@Override public String getCurrentAuditor() { logger.debug("getCurrentAuditor()"); Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); String result;/*from ww w . jav a2 s .c o m*/ if (authentication != null && authentication.isAuthenticated()) { result = authentication.getName(); } else { result = null; } logger.debug("result={}", result); return result; }
From source file:org.magnum.mobilecloud.video.AppController.java
@RequestMapping(value = VideoSvcApi.VIDEO_SVC_PATH + "/{id}/unlike", method = RequestMethod.POST) public void setUnlike(@PathVariable("id") Long id, HttpServletResponse response) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String name = auth.getName(); //get logged in username Video v = videos.findOne(id);/*w ww . ja va2 s.c om*/ if (null == v) { response.setStatus(404); return; } else if (!v.isUserAleadySetLike(name)) { response.setStatus(400); return; } // add the user who likes this video. v.removeUserFromLikes(name); videos.save(v); response.setStatus(200); }
From source file:org.magnum.mobilecloud.video.AppController.java
@RequestMapping(value = VideoSvcApi.VIDEO_SVC_PATH + "/{id}/like", method = RequestMethod.POST) public void setLike(@PathVariable("id") Long id, HttpServletResponse response) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String name = auth.getName(); //get logged in username Video v = videos.findOne(id);/*from w w w . j a v a2s .c o m*/ if (null == v) { response.setStatus(404); return; } else if (v.isUserAleadySetLike(name)) { response.setStatus(400); return; } // add the user who likes this video. v.addUserToLikes(name); videos.save(v); response.setStatus(200); }
From source file:controller.PackagesCustomer.java
@RequestMapping(value = "/delete/{id}", method = RequestMethod.GET) public ModelAndView deletePackage(@PathVariable int id, HttpServletRequest req, Authentication authen) { ModelAndView model = new ModelAndView(); try {/* w ww. j a v a 2s. c om*/ model.setViewName("deletePackage"); Customer cus = cusModel.find(authen.getName(), "username", false).get(0); int orderID = orderModel.getOrderIDByCustomer(cus.getCustomerId()); OderDetail orderDetail = orderDetailModel.getByID(new OderDetailId(orderID, id)); if (orderDetail.getQuantity() > 1) { orderDetail.setQuantity(orderDetail.getQuantity() - 1); model.addObject("check", orderDetailModel.addOrUpdate(orderDetail)); } else { model.addObject("check", orderDetailModel.delete(orderDetail)); } model.addObject("alert", "Deleted"); model.addObject("link", req.getContextPath() + "/customer/packagesCustomer.html"); } catch (Exception ex) { ex.printStackTrace(); model.addObject("alert", "Error: " + ex.getMessage()); } return model; }