November 2017
Intermediate to advanced
542 pages
14h 24m
English
Now that we are able to add new users to the system, we need to indicate that the user is authenticated. Update SpringSecurityUserContext to set the current user on the SecurityContextHolder object of Spring Security, as follows:
//src/main/java/com/packtpub/springsecurity/service/ SpringSecurityUserContext.java public void setCurrentUser(CalendarUser user) { UserDetails userDetails = userDetailsService. loadUserByUsername(user.getEmail()); Authentication authentication = new UsernamePasswordAuthenticationToken(userDetails, user.getPassword(), userDetails.getAuthorities()); SecurityContextHolder.getContext(). setAuthentication(authentication); }
The first step we perform is to convert our CalendarUser ...
Read now
Unlock full access