public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException { User user = service.findUserByName(s); if (user == null) return null; List<GrantedAuthority> check = getGrantedAuthorities(user); return new org.springframework.security.core.userdetails.User( user.getName(), user.getPassword(), user.getState().equals("Active"), true, true, true, getGrantedAuthorities(user)); }
private List<GrantedAuthority> getGrantedAuthorities(User user) { List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(); for (UserProfile userProfile : user.getUserProfile()) { authorities.add(new SimpleGrantedAuthority("ROLE_" + userProfile.getType())); } return authorities; }