/**
   * This method check if the passed directory (as path through the String directory parameter)
   * exists and if it doesn't then tries to create it. Once it is sure the directory exists (if not
   * throws Exception) the next step is to create the file one_auth with the received login data.
   *
   * @param directory Directory's path where the file is going to be located
   * @param login Data relative to the login (user and pass)
   * @throws Exception UserResouce.public Message userRegister(Login login) understands how to
   *     manage the thrown exception
   */
  private void dumpLoginToFile(String directory, Login login) throws Exception {
    // Directory
    File dir = new File(directory);
    if (!dir.exists())
      if (!dir.mkdirs()) throw new Exception("Couldn't create directory to allocate login file.");

    // File
    // File file = new File(dir.getAbsolutePath()+File.separator+"login_"+login.getUser());
    File file = new File(dir.getAbsolutePath() + File.separator + "one_auth");

    // Output
    PrintWriter out = new PrintWriter(file);
    out.println(login.getUser() + ":" + login.getPasswd());
    out.close();
  }