List of usage examples for org.springframework.security.core Authentication getName
public String getName();
From source file:com.crimelab.controller.AssignmentController.java
@RequestMapping(value = "/assignmentList", method = RequestMethod.GET) public String assignmentList(Model model) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String username = auth.getName(); //get logged in username model.addAttribute("assignments", assignmentService.getAssignments(username)); return "assignmentList"; }
From source file:com.crimelab.controller.AssignmentController.java
@RequestMapping(value = "/getAssignments", method = RequestMethod.GET, produces = "application/json") public @ResponseBody String getAssignments() throws IOException { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String username = auth.getName(); //get logged in username ObjectMapper mapper = new ObjectMapper(); return mapper.writeValueAsString(assignmentService.getAssignments(username)); }
From source file:com.crimelab.controller.AssignmentController.java
@RequestMapping(value = "/getUserTasks", method = RequestMethod.GET, produces = "application/json") public @ResponseBody String getUserTasks() throws IOException { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String username = auth.getName(); //get logged in username ObjectMapper mapper = new ObjectMapper(); return mapper.writeValueAsString(assignmentService.getUserTasks(username)); }
From source file:fr.univrouen.poste.web.candidat.CandidatAddPosteCandidatureController.java
@RequestMapping(method = RequestMethod.POST, produces = "text/html") @PreAuthorize("hasRole('ROLE_CANDIDAT')") public String addCandidature(@RequestParam(required = false) List<Long> posteIds, Model uiModel) { if (!AppliConfig.getCacheCandidatCanSignup()) { return "redirect:/postecandidatures"; }//from w w w . j av a 2 s .c o m if (posteIds != null) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String emailAddress = auth.getName(); User candidat = User.findUsersByEmailAddress(emailAddress, null, null).getSingleResult(); log.info("Candidatures sur les postes : " + posteIds + " pour le candidat " + candidat); posteAPourvoirService.updateCandidatures(candidat, posteIds); } return "redirect:/addpostecandidatures"; }
From source file:org.agatom.springatom.data.hades.model.revision.AuditingRevisionEntity.java
/** {@inheritDoc} */ @Override/*from w w w. j a v a 2 s. co m*/ public void newRevision(final Object revisionEntity) { final AuditedRevisionEntity auditedRevisionEntity = (AuditedRevisionEntity) revisionEntity; final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication != null) { final String userName = authentication.getName(); auditedRevisionEntity.setUser(userName); } else { auditedRevisionEntity.setUser("SYSTEM"); } }
From source file:pl.java.scalatech.audit.SpringSecurityAuditorAware.java
@Override public User getCurrentAuditor() { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String login = ANONYMOUS;/* www . j a v a 2 s .c om*/ if (auth != null) { login = auth.getName(); } log.info("+++++++++++++++++++ +++++++++++++++++++++++++++++ login from security context : {}", login); Optional<User> user = userRepository.findByLogin(login); User loaded = user.orElseThrow(() -> new IllegalArgumentException("user not exists")); log.info("+++++++++++++++++ +++++++++++++++++++++++++++++ {}", loaded); return loaded; }
From source file:org.cloudfoundry.identity.uaa.security.DefaultSecurityContextAccessor.java
@Override public String getUserName() { Authentication a = SecurityContextHolder.getContext().getAuthentication(); return a == null ? null : a.getName(); }
From source file:org.ff4j.security.SpringSecurityAuthorisationManager.java
/** {@inheritDoc} */ public String getCurrentUserName() { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if (!(auth instanceof AnonymousAuthenticationToken)) { return auth.getName(); }/*from w w w . j a v a 2s . c om*/ return "anonymous"; }
From source file:com.mec.Security.JWTLoginFilter.java
@Override protected void successfulAuthentication(HttpServletRequest req, HttpServletResponse res, FilterChain chain, Authentication auth) throws IOException, ServletException { //System.out.println("JWTLoginFilter - successfullAuth"); tokenAuth.addAuthentication(res, auth.getName()); }
From source file:com.wisemapping.security.AuthenticationProvider.java
@Override() public Authentication authenticate(@NotNull final Authentication auth) throws AuthenticationException { // All your user authentication needs final String email = auth.getName(); final UserDetails userDetails = getUserDetailsService().loadUserByUsername(email); final User user = userDetails.getUser(); final String credentials = (String) auth.getCredentials(); if (user == null || credentials == null || !encoder.isPasswordValid(user.getPassword(), credentials, null)) { throw new BadCredentialsException("Username/Password does not match for " + auth.getPrincipal()); }/*from w ww . j a v a 2 s. c o m*/ userDetailsService.getUserService().auditLogin(user); return new UsernamePasswordAuthenticationToken(userDetails, credentials, userDetails.getAuthorities()); }