private String validatePassword(
     final Map<String, String> propertiesSentToClient,
     final Map<String, String> propertiesReadFromClient,
     final String clientName) {
   final DBUserController userController = new DBUserController();
   if (!userController.login(clientName, propertiesReadFromClient.get(HASHED_PASSWORD_KEY))) {
     if (userController.doesUserExist(clientName)) {
       return "Incorrect password";
     } else {
       return "Username does not exist";
     }
   } else {
     return null;
   }
 }
 private String createUser(
     final Map<String, String> propertiesReadFromClient, final String userName) {
   final String email = propertiesReadFromClient.get(EMAIL_KEY);
   final String hashedPassword = propertiesReadFromClient.get(HASHED_PASSWORD_KEY);
   final DBUserController controller = new DBUserController();
   final String error = controller.validate(userName, email, hashedPassword);
   if (error != null) {
     return error;
   }
   try {
     controller.createUser(userName, email, hashedPassword, false);
     return null;
   } catch (final IllegalStateException ise) {
     return ise.getMessage();
   }
 }
 private String anonymousLogin(
     final Map<String, String> propertiesReadFromClient, final String userName) {
   if (new DBUserController().doesUserExist(userName))
     return "Can't login anonymously, username already exists";
   if (propertiesReadFromClient.get(LOBBY_WATCHER_LOGIN) != null
       && propertiesReadFromClient
           .get(LOBBY_WATCHER_LOGIN)
           .equals(
               Boolean.TRUE
                   .toString())) // If this is a lobby watcher, use a different set of validation
   {
     if (!userName.endsWith(InGameLobbyWatcher.LOBBY_WATCHER_NAME))
       return "Lobby watcher usernames must end with 'lobby_watcher'";
     final String hostName =
         userName.substring(0, userName.indexOf(InGameLobbyWatcher.LOBBY_WATCHER_NAME));
     final String issue = DBUserController.validateUserName(hostName);
     if (issue != null) return issue;
   } else {
     final String issue = DBUserController.validateUserName(userName);
     if (issue != null) return issue;
   }
   return null;
 }