package com.crap.sms.controllers;

import java.util.Scanner;

import com.crap.sms.service.UserManagement;

public class Login {
	public static boolean login() {
		// handle login or creation of users
		Scanner sc = new Scanner(System.in);

		if (false) {
			setNewMasterpassword();
		} else {
			System.out.println("Please enter the master password!");
			int hashedMasterPassword = (sc.nextLine()).hashCode();
		}
		System.out.println("Access granted");
		boolean active = true;
		while (active) {
			System.out.println("What do you want to do next?\n" + " (0) end Application\n" + " (1) add a new user\n"
					+ " (2) login\n");
			String input = sc.nextLine();
			if (!input.equals("0") && !input.equals("1") && !input.equals("2"))
				System.out.println("Input not valid");
			else {
				if (input.equals(0))
					active = false;
				if (input.equals(1))
					createNewUser();
				if (input.equals(2)) {
					System.out.println("Please enter your user name!");
					String userName = sc.nextLine();
					System.out.println("Please enter your password!");
					int hashedPassword = (sc.nextLine()).hashCode();
					UserManagement userManagement= new UserManagement();
				}
			}
		}
		return false;
	}

	public static void createNewUser() {

	}

	public static void setNewMasterpassword() {
		Scanner sc = new Scanner(System.in);
		String newMasterPassword = null;
		boolean isCorrect = false;
		while (!isCorrect) {
			System.out.println("Please set a master password! It should have between 8 and 32 characters.");
			newMasterPassword = sc.nextLine();

			if (newMasterPassword.length() < 8)
				System.out.println("Your password is to short, you have to do it again.");
			else if (newMasterPassword.length() > 32)
				System.out.println("Your password is to long, you have to do it again.");
			else
				isCorrect = true;
		}
		int hashedMasterPassword = newMasterPassword.hashCode();

		System.out.println("The master password has been set.");
	}

}

@@ -55,16 +55,55 @@
 anner;%0A%0A
+import com.crap.sms.domain.model.User;%0A
 import c
@@ -1158,72 +1158,293 @@
 User
-Management userManagement= new UserManagement(
+ user = UserManagement.findUser(userName);%0A%09%09%09%09%09if (hashedPassword == user.getPasswordHash()) %7B%0A%09%09%09%09%09%09System.out.println(%22Access granted. Welcome, %22 + userName);%0A%09%09%09%09%09%09return true;%0A%09%09%09%09%09%7D else %7B%0A%09%09%09%09%09%09System.out.println(%22Access denied. Wrong name or password.%22
 );%0A%09%09%09%09
+%09
 %7D%0A
+%09
 %09%09%09%7D%0A
+%09
 %09%09%7D%0A
+%09%09%7D%0A
 %09%09re
@@ -1497,16 +1497,250 @@
 ser() %7B%0A
+%09%09Scanner sc = new Scanner(System.in);%0A%09%09System.out.println(%22Please enter a new user name!%22);%0A%09%09String userName = sc.nextLine();%0A%09%09if (UserManagement.findUser(userName) != null) %7B%0A%09%09%09System.out.println(%22User name not available.%22);%0A%09%09%7D
 %0A%09%7D%0A%0A%09pu

Update Login