class UserService {

	public Map<String, Object> login(String username, String password) {
		logger.debug("login in user: " + username);
		Map<String, Object> loginResponse = null;
		User account = user.findByUseridAndPasswd(username, password);
		if (account != null) {
			logger.debug("Found Account for user: " + username);
			account.setAuthtoken(UUID.randomUUID().toString());
			account.setLogincount(account.getLogincount() + 1);
			account.setLastlogin(new Date());
			account = user.save(account); // persist new auth token and last
											// login
			loginResponse = new HashMap<String, Object>();

			loginResponse.put("authToken", account.getAuthtoken());
			loginResponse.put("accountid", account.getId());
			// loginResponse.put("password", account.getPasswd());

			logger.info("UserService.login success for " + username
					+ " username::token=" + loginResponse.get("authToken"));

		} else {
			logger.warn("UserService.login failed to find username=" + username
					+ " password=" + password);
			throw new AuthenticationException("Login failed for user: "
					+ username);
		}
		return loginResponse;
	}

}