Instead of hardcoding the user details inside the security model, we will implement a service layer that will programmatically generate a username and password for the application:
- Let us create the UserService interface, as follows that will generate hardcoded data for the UserDetails:
public interface UserService { public String getUserCredentials(String username); public Set<String> getuserRoles(String username); }
- Save this file in our org.secured.mvc.service since this is just an application-based native service.
- Then, implement the interface through UserServiceImpl as follows:
@Service("userService") public class UserServiceImpl implements UserService{ @Override public String getUserCredentials(String username) ...