List of usage examples for org.springframework.security.core Authentication getName
public String getName();
From source file:cz.fi.muni.pa036.airticketbooking.service.SecurityServiceImpl.java
public UserDto getCurrentlyLoggedUser() { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String name = auth.getName(); //get logged in username return userService.findByNick(name); //get user by login name }
From source file:cz.fi.muni.pa165.mushroomhunter.service.SecurityServiceImpl.java
public HunterDto getCurrentlyLoggedUser() { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String name = auth.getName(); //get logged in username return hunterService.findByNick(name); //get hunter by login name }
From source file:it.f2informatica.webapp.security.CustomAuthenticationSuccessHandler.java
@Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException { String username = authentication.getName(); Optional<UserModel> user = userService.findByUsername(username); if (user.isPresent()) { request.getSession(true).setAttribute("user", user.get()); log.info("User in session: [username: " + user.get().getUsername() + ", id: " + user.get().getUserId() + "]"); }//from ww w .j a v a2s. c om super.handle(request, response, authentication); }
From source file:nz.net.orcon.kanban.security.NullAuthenticationProvider.java
@Override public Authentication authenticate(Authentication authIn) throws AuthenticationException { String username = authIn.getName(); String password = authIn.getCredentials().toString(); try {/*from www . j a v a2 s . c o m*/ List<GrantedAuthority> grantedAuths = this.securityTool.getRoles(username); Authentication auth = new UsernamePasswordAuthenticationToken(username, password, grantedAuths); logger.info("Authenticated User: " + username); return auth; } catch (Exception e) { logger.error("Authentication Exception: " + username, e); } return null; }
From source file:de.blizzy.documentr.web.filter.AuthenticationCreationTimeFilter.java
private int getHashCode(Authentication authentication) { int result = StringUtils.defaultString(authentication.getName()).hashCode(); for (GrantedAuthority authority : authentication.getAuthorities()) { result ^= authority.hashCode();/* www.ja v a 2s. c o m*/ } return result; }
From source file:com.epam.ta.reportportal.auth.permissions.ProjectWorkerPermission.java
/** * Validates this is {@link ProjectRole#MEMBER} or higher authority in the * authentication context// ww w . j a v a2s .com */ @Override protected boolean checkAllowed(@NotNull Authentication authentication, @NotNull Project project) { return project.getUsers().get(authentication.getName()).getProjectRole().compareTo(ProjectRole.MEMBER) >= 0; }
From source file:net.triptech.buildulator.service.OpenIdAuthenticationSuccessHandler.java
public final void onAuthenticationSuccess(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException { Person person = Person.findByOpenIdIdentifier(authentication.getName()); if (person != null) { // Transfer any previous projects to the authenticated user transferProjects(request, person); }//from w ww. j a v a 2 s.co m response.sendRedirect(request.getContextPath() + "/projects"); }
From source file:org.callistasoftware.netcare.video.web.security.AuthenticationProvider.java
@Override public Authentication authenticate(final Authentication auth) throws AuthenticationException { log.info("Authenticating {}", auth.getName()); try {/*from w ww . jav a 2s .c o m*/ final UserDetails details = this.service.loadUserByUsername(auth.getName()); return new UsernamePasswordAuthenticationToken(details, null, details.getAuthorities()); } catch (final UsernameNotFoundException e) { } throw new AuthenticationServiceException("Bad credentials"); }
From source file:com.ignite.controller.ClientController.java
@RequestMapping(value = "/client", method = RequestMethod.GET) public ModelAndView client() { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String name = auth.getName(); List<Account> accounts = accountDao.getAccountsForClient(clientDao.getClient(name)); return new ModelAndView("client", "accountList", accounts); }
From source file:io.smalldata.ohmageomh.dsu.controller.AccountController.java
@RequestMapping(value = "/", method = RequestMethod.GET) public String home(Authentication auth, Model model) { Optional<EndUser> user = endUserRepo.findOne(auth.getName()); model.addAttribute("user", user.get()); List<Study> studies = studyService.getStudiesByUsername(user.get().getUsername()); model.addAttribute("studies", studies); return "home"; }