Answers for "A granted authority textual representation is required"

0

A granted authority textual representation is required

@Service
public class UserDetailsServiceImpl implements UserDetailsService {

    @Autowired
    private UserInfoService userInfoDAO;

    @Override
    public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException {
        UserInfo userInfo = userInfoDAO.getUserInfoByUserName();
        GrantedAuthority authority = new SimpleGrantedAuthority(userInfo.getRole());
        return new User(userInfo.getUserName(), userInfo.getPassword(), Arrays.asList(authority));
    }
}


@Service
public class UserInfoService {

    @Value("${auth.username}")
    private String username;

    @Value("${auth.password}")
    private String password;

    //setting the system user
    public UserInfo getUserInfoByUserName(){
        UserInfo userInfo =new UserInfo();
        userInfo.setUserName(username);
        userInfo.setPassword(password);
        userInfo.setRole("USER");
        return userInfo;
    }
}
Posted by: Guest on October-07-2021

Code answers related to "A granted authority textual representation is required"

Browse Popular Code Answers by Language