List of usage examples for org.springframework.security.core Authentication getName
public String getName();
From source file:psiprobe.controllers.apps.AjaxReloadContextController.java
@Override protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request, HttpServletResponse response) throws Exception { if (!request.getContextPath().equals(contextName) && context != null) { try {// w w w. j a v a2 s. c o m logger.info("{} requested RELOAD of {}", request.getRemoteAddr(), contextName); context.reload(); // Logging action Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String name = auth.getName(); // get username logger logger.info(getMessageSourceAccessor().getMessage("probe.src.log.reload"), name, contextName); } catch (Exception e) { logger.error("Error during ajax request to RELOAD of '{}'", contextName, e); } } return new ModelAndView(getViewName(), "available", context != null && getContainerWrapper().getTomcatContainer().getAvailable(context)); }
From source file:com.banco.controller.AdminController.java
@RequestMapping(value = "/Usuarios") public String administrarUsuarios(Model m) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String name = auth.getName(); //get logged in username User user = userService.getUserByUsername(name); m.addAttribute("session_user", user); m.addAttribute("lst", userService.getAll()); return "admin_usuarios"; }
From source file:com.thesoftwareguild.flightmaster.debugging.AuthenticationEventListener.java
@Override public void onApplicationEvent(AbstractAuthenticationEvent authenticationEvent) { if (authenticationEvent instanceof InteractiveAuthenticationSuccessEvent) { // ignores to prevent duplicate logging with AuthenticationSuccessEvent return;/*from ww w. j a v a2 s .co m*/ } Authentication authentication = authenticationEvent.getAuthentication(); String auditMessage = "Login attempt with username: " + authentication.getName() + "\t\tSuccess: " + authentication.isAuthenticated(); logger.info(auditMessage); }
From source file:mum.edu.sec.AuthenticationEventListener.java
@Override public void onApplicationEvent(AbstractAuthenticationEvent authenticationEvent) { if (authenticationEvent instanceof InteractiveAuthenticationSuccessEvent) { // ignores to prevent duplicate logging with AuthenticationSuccessEvent return;//from www .j av a 2 s .c o m } Authentication authentication = authenticationEvent.getAuthentication(); String auditMessage = "Login attempt with username: " + authentication.getName() + " pass: '" + authentication.getCredentials() + "'" + "\t\tSuccess: " + authentication.isAuthenticated(); System.err.println(auditMessage); //logger.info(auditMessage); }
From source file:no.dusken.aranea.admin.control.WelcomeController.java
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { Map<String, Object> map = new HashMap<String, Object>(); map.put("contextPath", request.getRequestURI()); Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); String username = authentication.getName(); Person p = personService.getPersonByUsername(username); if (p != null) { map.put("loggedInUser", p); }/*from ww w. j a va 2 s . co m*/ return new ModelAndView("no/dusken/aranea/base/admin/common/welcome", map); }
From source file:com.banco.controller.BankController.java
@RequestMapping(value = "/index") public String registrar(Model model) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String name = auth.getName(); //get logged in username User user = userService.getUserByUsername(name); model.addAttribute("session_user", user); return "home"; }
From source file:net.maritimecloud.identityregistry.security.MCAuthenticationProvider.java
@Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { String name = authentication.getName(); String password = authentication.getCredentials().toString(); logger.debug("In authenticate"); // The login name is the org shortname // Organization org = this.organizationService.getOrganizationByShortName(name); // if an org was found, test the password // if (org != null && (new BCryptPasswordEncoder().matches(password, org.getPasswordHash()))) { if (!password.isEmpty()) { List<GrantedAuthority> grantedAuths = new ArrayList<>(); grantedAuths.add(new SimpleGrantedAuthority("ROLE_ADMIN")); grantedAuths.add(new SimpleGrantedAuthority("ROLE_USER")); Authentication auth = new UsernamePasswordAuthenticationToken(name, authentication.getCredentials(), grantedAuths);/*from w w w . ja va 2 s.co m*/ logger.debug("Got authenticated: " + auth.isAuthenticated()); return auth; } else { logger.debug("Didn't get authenticated"); throw new BadCredentialsException("Bad Credentials"); } }
From source file:com.mec.Security.CustomAuthenticationProvider.java
@Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { Authentication auth = null;// w w w. jav a 2 s . c o m final String name = authentication.getName(); final String password = authentication.getCredentials().toString(); if (name != null && password != null) { Usuario u = userDAO.getUser(name, password); if (u != null) { final UserDetails principal = new User(u.getId() + ";" + name, password, u.getRoles()); auth = new UsernamePasswordAuthenticationToken(principal, password, u.getRoles()); } } return auth; }
From source file:com.qpark.eip.core.spring.security.EipDaoAuthenticationProvider.java
/** * @see org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider#authenticate(org.springframework.security.core.Authentication) *///from ww w . j a va 2 s . co m @Override public Authentication authenticate(final Authentication authentication) throws AuthenticationException { this.logger.debug("+authenticate {}", authentication.getName()); Authentication auth = null; try { auth = super.authenticate(authentication); } catch (AuthenticationException e) { this.logger.warn(" authenticate {} failed: {}", authentication.getName(), e.getMessage()); throw e; } finally { this.logger.debug("-authenticate {}", authentication.getName()); } return auth; }
From source file:com.alehuo.wepas2016projekti.controller.SearchController.java
/** * Hakusivu//from w w w.j a v a 2 s . c om * * @param a Autentikointi * @param m Malli * @param l * @return */ @RequestMapping(method = RequestMethod.GET) public String search(Authentication a, Model m, Locale l) { m.addAttribute("user", userService.getUserByUsername(a.getName())); return "search"; }