List of usage examples for java.security Principal getName
public String getName();
From source file:com.lixiaocong.rest.CommentController.java
@RequestMapping(method = RequestMethod.GET) public Map<String, Object> get(@RequestParam(required = false, defaultValue = "1") int page, @RequestParam(required = false, defaultValue = "10") int size, Principal principal) { User user = userService.getByUsername(principal.getName()); if (user.isAdmin()) return ResponseMsgFactory.createSuccessResponse("comments", commentService.get(page - 1, size)); else/* w w w .ja v a2s . co m*/ return ResponseMsgFactory.createSuccessResponse("comments", commentService.getByUser(page - 1, size, user.getId())); }
From source file:jipdbs.web.processors.ContactProcessor.java
@Override public String doProcess(ResolverContext context) throws ProcessorException { if (context.isPost()) { HttpServletRequest req = context.getRequest(); String mail = req.getParameter("m"); String text = req.getParameter("text"); if (StringUtils.isEmpty(mail) || StringUtils.isEmpty(text)) { Flash.error(req, MessageResource.getMessage("fields_required")); return null; }//from ww w .j av a 2 s .c om if (!Validator.isValidEmail(mail)) { Flash.error(req, MessageResource.getMessage("invalid_email")); return null; } IDDBService app = (IDDBService) context.getServletContext().getAttribute("jipdbs"); if (!app.isRecaptchaValid(req.getRemoteAddr(), req.getParameter("recaptcha_challenge_field"), req.getParameter("recaptcha_response_field"))) { Flash.error(req, MessageResource.getMessage("invalid_captcha")); return null; } Principal user = req.getUserPrincipal(); app.sendAdminMail(user != null ? user.getName() : null, mail, text); Flash.ok(req, MessageResource.getMessage("mail_sent")); } return null; }
From source file:com.lixiaocong.rest.UserController.java
@RequestMapping(value = "/info", method = RequestMethod.GET) public Map<String, Object> info(Principal principal) { User user = userService.getByUsername(principal.getName()); Map<String, Object> ret = ResponseMsgFactory.createSuccessResponse("user", user); ConnectionRepository connectionRepository = connectionRepositoryProvider.get(); Connection<Facebook> facebookConnection = connectionRepository.findPrimaryConnection(Facebook.class); ret.put("facebook", facebookConnection != null); Connection<QQ> qqConnection = connectionRepository.findPrimaryConnection(QQ.class); ret.put("qq", qqConnection != null); return ret;//from w ww. j a v a 2s. c o m }
From source file:com.epam.reportportal.auth.SsoEndpoint.java
@RequestMapping(value = { "/sso/me/apitoken" }, method = RequestMethod.GET) public OAuth2AccessToken getApiToken(Principal user) { Optional<OAuth2AccessToken> tokens = tokenServicesFacade.getTokens(user.getName(), ReportPortalClient.api) .findAny();/*from www .jav a 2 s .com*/ BusinessRule.expect(tokens, Preconditions.IS_PRESENT).verify(ErrorType.USER_NOT_FOUND, user.getName()); return tokens.get(); }
From source file:org.mitre.oauth2.web.RefreshTokenAPI.java
@RequestMapping(value = "", method = RequestMethod.GET, produces = "application/json") public String getAll(ModelMap m, Principal p) { Set<OAuth2RefreshTokenEntity> allTokens = tokenService.getAllRefreshTokensForUser(p.getName()); m.put("entity", allTokens); return "jsonEntityView"; }
From source file:runtheshow.resource.metiers.EventMetier.java
@Override public List<Evenement> getAllEvent(Principal user) { return Lists.newArrayList(eventRepository.findByCreateur(userRepository.findUserByLogin(user.getName()))); }
From source file:sample.U2fController.java
@RequestMapping("/u2f/register") public String registerForm(Principal principal, Map<String, Object> model) { String username = principal.getName(); RegisterRequestData registerRequestData = u2f.startRegistration(SERVER_ADDRESS, getRegistrations(username)); requestStorage.save(registerRequestData); model.put("data", registerRequestData.toJson()); return "u2f/register"; }
From source file:alfio.controller.api.AttendeeApiController.java
@RequestMapping(value = "/sponsor-scan/bulk", method = RequestMethod.POST) public ResponseEntity<List<TicketAndCheckInResult>> scanBadges(@RequestBody List<SponsorScanRequest> requests, Principal principal) { String username = principal.getName(); return ResponseEntity .ok(requests.stream().map(request -> attendeeManager.registerSponsorScan(request.eventName, request.ticketIdentifier, username)).collect(Collectors.toList())); }
From source file:com.github.jguaneri.notifications.web.controller.AccountManagementController.java
/** * //w w w. ja v a2 s . c o m * @param model * @return */ @RequestMapping(method = RequestMethod.GET) public String getAdmin(Model model, Principal principal) { final List<Channel> channels = channelService.getChannelsForUsername(principal.getName()); //final Collection<Broadcaster> broadcasters = notificationService.getAllBroadcasters(); //model.addAttribute("broadcasters", broadcasters); model.addAttribute("channels", channels); return "manage/channels"; }
From source file:com.tamnd.app.rest.controller.AccountController.java
@RequestMapping(value = "/current", method = RequestMethod.GET) public ResponseEntity<AccountResource> getUserInfo(Principal user) { Account account = accountService.findByAccountName(user.getName()); if (account != null) { AccountResource res = new AccountResourceAsm().toResource(account); return new ResponseEntity<>(res, HttpStatus.OK); }/*w w w .j a v a2s .c o m*/ return new ResponseEntity<>(HttpStatus.NOT_FOUND); }