Esempio n. 1
0
  private static void createXML() {
    Scanner input = new Scanner(System.in);
    String secret;
    String username;
    String password;

    System.out.println("Secret must be exactly 16 characters long.");
    System.out.println("The secret will be used to encrypt your email & password");
    System.out.println();
    System.out.print("Enter secret: ");
    secret = input.next();

    EncryptText encrypter = new EncryptText(secret);

    System.out.print("Enter email address: ");
    username = input.next();
    System.out.print("Enter password: ");
    password = input.next();
    System.out.println();

    username = encrypter.encryptString(username);
    password = encrypter.encryptString(password);

    WriteUserXML writer = new WriteUserXML(USER_XML_PATH);
    try {
      writer.WriteUserInfo(username, password);
    } catch (FileNotFoundException | XMLStreamException e) {
      logger.error(e);
    }
  }
Esempio n. 2
0
  private static void updateFromUtorrent(
      String logFilePath, String label, String title, String secret) {
    XBMCUpdate updateServer = new XBMCUpdate("xbmc", "xbmc", "10.0.0.5", "8081");
    updateServer.sendUpdateRequest();

    DownloadLog log = new DownloadLog(label, title);
    String toEmail = null;
    String password = null;

    ReadUserXML reader;
    try {
      reader = new ReadUserXML(USER_XML_PATH);
      reader.parseXML();
      EncryptText encrypter = new EncryptText(secret);
      toEmail = encrypter.decryptString(reader.getUsername());
      password = encrypter.decryptString(reader.getPassword());

    } catch (FileNotFoundException | XMLStreamException e) {
      logger.error(e);
    }
    Emailer emailer = new Emailer();
    emailer.setCredentials(toEmail, password);
    String fromEmail = "*****@*****.**";
    emailer.setToAddress(toEmail);
    emailer.setFromAddress(fromEmail);
    emailer.setMessageSubject("New Torrent Downloaded");
    emailer.setMessageBody(log.toString());
    emailer.sendEmail("true", "smtp.gmail.com", "587", false);

    File logFile = new File(logFilePath);
    if (logFile.exists()) {
      try (FileWriter writer = new FileWriter(logFile, true)) {
        writer.write(log.toString());
        writer.write("\n");
        System.out.println("Added to log: \n\t" + log.toString());
      } catch (IOException e) {
        logger.info("logFilePath invalid");

        logger.error("Could not find log file", e);
      }
    } else {
      System.out.printf("Directory %s does not exist%n", logFile.getAbsolutePath());
    }
  }
Esempio n. 3
0
 private static void decryptText(String text, String secret) {
   EncryptText encrypter = new EncryptText(secret);
   System.out.println(encrypter.decryptString(text));
 }