October 2018
Intermediate to advanced
590 pages
15h 5m
English
As mentioned earlier, the UserDetails object will be saved in the Authentication object, which will be saved into HttpSession. So, it is important that we keep less data inside of UserDetails. The following is SimpleUser, which implements UserDetails:
...public class SimpleUser implements UserDetails, Serializable { ... private long userId; private String username; private String password; public SimpleUser(User user) { this.userId = user.getId(); this.username = user.getUsername(); this.password = user.getPassword(); } // Getters of the three properties ... public Collection<? extends GrantedAuthority> getAuthorities() { return Collections.singleton(new SimpleGrantedAuthority("ROLE_USER")); } public boolean isAccountNonExpired() ...Read now
Unlock full access