<file_sep>package com.cg.ecom.dao;

import com.cg.ecom.dto.Login;
import com.cg.ecom.exception.LoginException;
import com.cg.ecom.repo.LoginRepository;

public class LoginDaoImpl implements LoginDao{

	/*Checks if the User ID passed in the method is present in the repository
	 *if yes then values mapped with the ID(type Login) are returned
	 *if no then LoginException is raised*/
	@Override
	public Login getLoginDetails(String userid) throws LoginException {
		if(LoginRepository.cmap.containsKey(userid)) {
			return LoginRepository.cmap.get(userid);
		}
		else throw new LoginException("Invalid User ID");
	}  

}
<file_sep>package com.cg.ecom.repo;

import java.util.HashMap;
import java.util.Map;

import com.cg.ecom.dto.Login;

public class LoginRepository{
	
	/***************Repository of existing users****************/
		public static Map<String, Login> cmap = new HashMap<>();
		
	    static {
	    	//ID of the user is key and values are of type Login having id, password, user name, role
	    	cmap.put("Poorva123", new Login("Poorva123", "Poorva$123", "Poorva", "admin"));    
	    	cmap.put("Keshav123", new Login("Keshav123", "Keshav$123", "Keshav", "user"));
	    	cmap.put("Pritam123", new Login("Pritam123", "Pritam$123", "Pritam", "user"));
	    	cmap.put("Rahhi123", new Login("Rahhi123", "Rahhi$123", "Rahhi", "user"));
	    	cmap.put("Sudheer123", new Login("Sudheer123", "Sudheer$123", "Sudheer", "user"));
	    	cmap.put("Sohail123", new Login("Sohail123", "Sohail$123", "Sohail", "user"));
	    }
	    
}
