From cdb87723b2c3eb4b81b67d28b59ab8c8e9294e60 Mon Sep 17 00:00:00 2001 From: Dennis Turco Date: Thu, 10 Jul 2025 14:20:04 +0200 Subject: [PATCH 1/3] contributing.md --- CONTRIBUTING.md | 40 +++++++++++++++++++++++ src/main/resources/res/config/config.json | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..6f8046b --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,40 @@ +# Contributing to Backup Manager + +Thank you for your interest in contributing to **Backup Manager**! Your ideas, bug reports, improvements, and patches are very welcome. + +--- + +## How to contribute + +1. **Open an Issue** + If you find a bug or want to propose a new feature, please open an issue describing the problem or request clearly. + +2. **Fork & Clone** + Fork the repository and clone it locally: + ```bash + git clone https://github.com/DennisTurco/BackupManager.git + cd BackupManager + ``` +3. **Create a Branch** + ```bash + git checkout -b your-feature-or-fix-name + ``` +4. **Write Code** + * Follow the existing coding style. + * Write clear comments. + * Add automated tests if possible. +5. **Commit & Push** + Make clear, descriptive commits: + ```bash + git commit -m "Brief description of the change" + git push origin your-feature-or-fix-name + ``` +6. **Open a Pull Request (PR)** + Open a PR on GitHub targeting the `master` branch. Describe what you did and why. + +## Need Help? + +If you have questions about contributing, contact: dennisturco@gmail.com + +Thanks again for helping improve Backup Manager! + diff --git a/src/main/resources/res/config/config.json b/src/main/resources/res/config/config.json index 06ad97f..c9e9691 100644 --- a/src/main/resources/res/config/config.json +++ b/src/main/resources/res/config/config.json @@ -19,7 +19,7 @@ "EMAIL": "assistenza@shardpc.it", "SHARD_WEBSITE": "https://www.shardpc.it/", "LOGO_IMG": "/res/img/logo.png", - "VERSION": "2.0.5", + "VERSION": "2.0.6", "GUI_WIDTH": "982", "GUI_HEIGHT": "715", From 22477002c177bf11925e90c4cf8247fa32e4fdec Mon Sep 17 00:00:00 2001 From: Dennis Turco Date: Thu, 10 Jul 2025 15:38:21 +0200 Subject: [PATCH 2/3] email password encryption --- .gitignore | 1 - .vscode/launch.json | 14 ++ .../backupmanager/Email/DecryptPassword.java | 30 ++++ .../java/backupmanager/Email/EmailSender.java | 18 +-- .../backupmanager/Email/EncryptPassword.java | 22 +++ .../Email/EncryptedPasswordDefiner.java | 17 ++ src/main/resources/config.properties | 3 + src/main/resources/logback.xml | 9 +- src/main/resources/res/backup_list2.0.6.json | 1 + src/main/resources/res/config/config.json | 4 +- .../resources/res/config/preferences.json | 2 +- src/main/resources/res/config/user.json | 1 + .../res/logs/application-08-02-2025.log.gz | Bin 0 -> 20 bytes src/main/resources/res/logs/application.log | 153 ++++++++++++++++++ 14 files changed, 258 insertions(+), 17 deletions(-) create mode 100644 src/main/java/backupmanager/Email/DecryptPassword.java create mode 100644 src/main/java/backupmanager/Email/EncryptPassword.java create mode 100644 src/main/java/backupmanager/Email/EncryptedPasswordDefiner.java create mode 100644 src/main/resources/config.properties create mode 100644 src/main/resources/res/backup_list2.0.6.json create mode 100644 src/main/resources/res/logs/application-08-02-2025.log.gz diff --git a/.gitignore b/.gitignore index 5823597..b83d222 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ /target/ -src/main/resources/config.properties diff --git a/.vscode/launch.json b/.vscode/launch.json index e26871b..6f4e4af 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,6 +4,20 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "type": "java", + "name": "DecryptPassword", + "request": "launch", + "mainClass": "backupmanager.Email.DecryptPassword", + "projectName": "BackupManager" + }, + { + "type": "java", + "name": "EncryptPassword", + "request": "launch", + "mainClass": "backupmanager.Email.EncryptPassword", + "projectName": "BackupManager" + }, { "type": "java", "name": "Current File", diff --git a/src/main/java/backupmanager/Email/DecryptPassword.java b/src/main/java/backupmanager/Email/DecryptPassword.java new file mode 100644 index 0000000..be33c12 --- /dev/null +++ b/src/main/java/backupmanager/Email/DecryptPassword.java @@ -0,0 +1,30 @@ +package backupmanager.Email; + +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; +import java.util.Base64; + +public class DecryptPassword { + public static String decrypt(String encryptedPassword) throws Exception { + String secretKey = System.getenv("BACKUPMANAGER_AES_KEY"); + if (secretKey == null || secretKey.isEmpty()) { + throw new IllegalStateException("Secret key not set in BACKUPMANAGER_AES_KEY"); + } + + SecretKeySpec key = new SecretKeySpec(secretKey.getBytes(), "AES"); + + Cipher cipher = Cipher.getInstance("AES"); + cipher.init(Cipher.DECRYPT_MODE, key); + + byte[] decodedBytes = Base64.getDecoder().decode(encryptedPassword); + byte[] decrypted = cipher.doFinal(decodedBytes); + + return new String(decrypted); + } + + public static void main(String[] args) throws Exception { + String encryptedPassword = "password_to_decrypt"; + String decryptedPassword = decrypt(encryptedPassword); + System.out.println("\n"+decryptedPassword); + } +} diff --git a/src/main/java/backupmanager/Email/EmailSender.java b/src/main/java/backupmanager/Email/EmailSender.java index 9d9a608..fe75829 100644 --- a/src/main/java/backupmanager/Email/EmailSender.java +++ b/src/main/java/backupmanager/Email/EmailSender.java @@ -28,7 +28,7 @@ public class EmailSender { // Logger for sending critical error emails private static final Logger emailErrorLogger = LoggerFactory.getLogger("EMAIL_ERROR_LOGGER"); - + // Logger for sending informational emails private static final Logger emailInfoLogger = LoggerFactory.getLogger("EMAIL_INFO_LOGGER"); @@ -47,7 +47,7 @@ public static void sendErrorEmail(String subject, String body) { logger.warn("User is null, using a default user for the email"); user = User.getDefaultUser(); } - + int rows = 300; String emailMessage = String.format( "Subject: %s\n\nUser: %s \nEmail: %s \nLanguage: %s \n\nHas encountered the following error:\n%s \n\nLast %d rows of the application.log file:\n%s", @@ -84,21 +84,21 @@ public static void sendUserCreationEmail(User user) { */ public static void sendConfirmEmailToUser(User user) { if (user == null) throw new IllegalArgumentException("User object cannot be null"); - + String subject = TranslationCategory.USER_DIALOG.getTranslation(TranslationKey.EMAIL_CONFIRMATION_SUBJECT); String body = TranslationCategory.USER_DIALOG.getTranslation(TranslationKey.EMAIL_CONFIRMATION_BODY); - + // Assicurati di assegnare il risultato della sostituzione body = body.replace("[UserName]", user.getUserCompleteName()); body = body.replace("[SupportEmail]", ConfigKey.EMAIL.getValue()); - + String emailMessage = subject + "\n\n" + body; updateEmailRecipient(user.email); - + // Should be info, but if you change it, it doesn't work emailConfirmationLogger.error(emailMessage); // Log the message as INFO, triggering the SMTPAppender - + logger.info("Confirmation registration email sent to the user: " + user.toString()); } @@ -116,7 +116,7 @@ private static User getCurrentUser() { return null; } - + public static String getTextFromLogFile(int rows) { File file = new File(ConfigKey.LOG_DIRECTORY_STRING.getValue() + ConfigKey.LOG_FILE_STRING.getValue()); @@ -154,5 +154,5 @@ private static void updateEmailRecipient(String newRecipient) { smtpAppender.getToList().clear(); smtpAppender.addTo(newRecipient); } - } + } } diff --git a/src/main/java/backupmanager/Email/EncryptPassword.java b/src/main/java/backupmanager/Email/EncryptPassword.java new file mode 100644 index 0000000..0db2309 --- /dev/null +++ b/src/main/java/backupmanager/Email/EncryptPassword.java @@ -0,0 +1,22 @@ +package backupmanager.Email; + +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; +import java.util.Base64; + +public class EncryptPassword { + private static final String SECRET_KEY = "SecretKey16chars"; + + public static String encrypt(String password) throws Exception { + SecretKeySpec key = new SecretKeySpec(SECRET_KEY.getBytes(), "AES"); + Cipher cipher = Cipher.getInstance("AES"); + cipher.init(Cipher.ENCRYPT_MODE, key); + byte[] encrypted = cipher.doFinal(password.getBytes()); + + return Base64.getEncoder().encodeToString(encrypted); + } + + public static void main(String[] args) throws Exception { + System.out.println("\n"+encrypt("PasswordToEncrypt")); + } +} diff --git a/src/main/java/backupmanager/Email/EncryptedPasswordDefiner.java b/src/main/java/backupmanager/Email/EncryptedPasswordDefiner.java new file mode 100644 index 0000000..a7478b9 --- /dev/null +++ b/src/main/java/backupmanager/Email/EncryptedPasswordDefiner.java @@ -0,0 +1,17 @@ +package backupmanager.Email; + +import ch.qos.logback.core.PropertyDefinerBase; + +public class EncryptedPasswordDefiner extends PropertyDefinerBase { + + @Override + public String getPropertyValue() { + try { + String encryptedPassword = System.getenv("BACKUPMANAGER_SMTP_PASSWORD"); + return backupmanager.Email.DecryptPassword.decrypt(encryptedPassword); + } catch (Exception e) { + System.err.println("Error decrypting SMTP password: " + e.getMessage()); + return ""; + } + } +} \ No newline at end of file diff --git a/src/main/resources/config.properties b/src/main/resources/config.properties new file mode 100644 index 0000000..86589b7 --- /dev/null +++ b/src/main/resources/config.properties @@ -0,0 +1,3 @@ +smtp.from=backupmanager@shardpc.it +smtp.smtp=mail.shardpc.it +smtp.user=backupmanager@shardpc.it \ No newline at end of file diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 22f4b44..1f3261f 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -1,12 +1,13 @@ + + - @@ -64,7 +65,7 @@ ${EMAIL_TO} ${smtp.from} ${smtp.user} - ${smtp.password} + ${smtpPassword} ${EMAIL_ERROR_SUBJECT} %d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n @@ -82,7 +83,7 @@ ${EMAIL_TO} ${smtp.from} ${smtp.user} - ${smtp.password} + ${smtpPassword} ${EMAIL_INFO_SUBJECT} %d{yyyy-MM-dd HH:mm:ss} %logger{36} - %msg%n @@ -100,7 +101,7 @@ ${EMAIL_TO} ${smtp.from} ${smtp.user} - ${smtp.password} + ${smtpPassword} ${EMAIL_CONFIRMATION_SUBJECT} %msg%n diff --git a/src/main/resources/res/backup_list2.0.6.json b/src/main/resources/res/backup_list2.0.6.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/src/main/resources/res/backup_list2.0.6.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/src/main/resources/res/config/config.json b/src/main/resources/res/config/config.json index c9e9691..25788d9 100644 --- a/src/main/resources/res/config/config.json +++ b/src/main/resources/res/config/config.json @@ -27,10 +27,10 @@ "BugReport": true, "Preferences": true, "Clear": false, - "Donate": false, + "Donate": true, "PaypalDonate": true, "BuymeacoffeeDonate": true, - "History": false, + "History": true, "InfoPage": true, "New": true, "Quit": true, diff --git a/src/main/resources/res/config/preferences.json b/src/main/resources/res/config/preferences.json index 7ef571d..a2b51ea 100644 --- a/src/main/resources/res/config/preferences.json +++ b/src/main/resources/res/config/preferences.json @@ -1 +1 @@ -{"Language":"eng.json","Theme":"Light"} \ No newline at end of file +{"Language":"ita.json","Theme":"Light","BackupList":{"Directory":"src/main/resources/res/","File":"backup_list2.0.6.json"}} \ No newline at end of file diff --git a/src/main/resources/res/config/user.json b/src/main/resources/res/config/user.json index e69de29..0dfbf1e 100644 --- a/src/main/resources/res/config/user.json +++ b/src/main/resources/res/config/user.json @@ -0,0 +1 @@ +{"name":"gh","surname":"asd","email":"dennisturco@gmail.com"} \ No newline at end of file diff --git a/src/main/resources/res/logs/application-08-02-2025.log.gz b/src/main/resources/res/logs/application-08-02-2025.log.gz new file mode 100644 index 0000000000000000000000000000000000000000..0239669d57f6148035ad2dc4a6d54ae7db678e85 GIT binary patch literal 20 Scmb2|=3oGW|I82?NCE&DbOE&h literal 0 HcmV?d00001 diff --git a/src/main/resources/res/logs/application.log b/src/main/resources/res/logs/application.log index e69de29..e35609b 100644 --- a/src/main/resources/res/logs/application.log +++ b/src/main/resources/res/logs/application.log @@ -0,0 +1,153 @@ +10-07-2025 14:40:29.877 [main] [INFO ] backupmanager.Entities.Preferences - Preferences loaded from JSON file: language = eng.json, theme = Light +10-07-2025 14:40:29.906 [main] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = eng.json, theme = Light +10-07-2025 14:40:29.911 [main] [INFO ] backupmanager.MainApp - Application started +10-07-2025 14:40:30.426 [AWT-EventQueue-0] [INFO ] backupmanager.Json.JSONBackup - New backup list created with name: src/main/resources/res/backup_list2.0.6.json +10-07-2025 14:40:30.427 [AWT-EventQueue-0] [INFO ] backupmanager.Json.JSONBackup - File initialized with empty JSON array: [] +10-07-2025 14:40:30.434 [AWT-EventQueue-0] [INFO ] b.Services.BackupObserver - Observer for running backups started +10-07-2025 14:40:30.594 [AWT-EventQueue-0] [WARN ] backupmanager.Json.JsonUser - User file doesn't exist or is empty +10-07-2025 14:40:30.594 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Setting default language to: it +10-07-2025 14:40:30.595 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Reloading preferences +10-07-2025 14:40:30.595 [AWT-EventQueue-0] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 14:40:39.576 [AWT-EventQueue-0] [INFO ] backupmanager.Json.JsonUser - User successfully written to JSON user file with data: Dennsi asd, adsdasdsad@dasd.com, italiano (Italia) +10-07-2025 14:40:39.580 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - User creation info email sent with user: Dennsi asd, adsdasdsad@dasd.com, italiano (Italia) +10-07-2025 14:40:39.582 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - Confirmation registration email sent to the user: Dennsi asd, adsdasdsad@dasd.com, italiano (Italia) +10-07-2025 14:45:00.196 [main] [INFO ] backupmanager.Entities.Preferences - Preferences loaded from JSON file: language = ita.json, theme = Light +10-07-2025 14:45:00.214 [main] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 14:45:00.225 [main] [INFO ] backupmanager.MainApp - Application started +10-07-2025 14:45:00.743 [AWT-EventQueue-0] [INFO ] b.Services.BackupObserver - Observer for running backups started +10-07-2025 14:45:00.902 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Current user: Dennsi asd, adsdasdsad@dasd.com, italiano (Italia) +10-07-2025 14:45:03.616 [AWT-EventQueue-0] [INFO ] b.Managers.BackupManager - Event --> history +10-07-2025 14:49:49.268 [main] [INFO ] backupmanager.Entities.Preferences - Preferences loaded from JSON file: language = ita.json, theme = Light +10-07-2025 14:49:49.289 [main] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 14:49:49.298 [main] [INFO ] backupmanager.MainApp - Application started +10-07-2025 14:49:49.798 [AWT-EventQueue-0] [INFO ] b.Services.BackupObserver - Observer for running backups started +10-07-2025 14:49:49.943 [AWT-EventQueue-0] [WARN ] backupmanager.Json.JsonUser - User file doesn't exist or is empty +10-07-2025 14:49:49.943 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Setting default language to: it +10-07-2025 14:49:49.943 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Reloading preferences +10-07-2025 14:49:49.944 [AWT-EventQueue-0] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 14:49:57.822 [AWT-EventQueue-0] [INFO ] backupmanager.Json.JsonUser - User successfully written to JSON user file with data: dennis dsa, asdasd@gmail.cdss, italiano (Italia) +10-07-2025 14:49:57.826 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - User creation info email sent with user: dennis dsa, asdasd@gmail.cdss, italiano (Italia) +10-07-2025 14:49:57.827 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - Confirmation registration email sent to the user: dennis dsa, asdasd@gmail.cdss, italiano (Italia) +10-07-2025 14:51:00.293 [main] [INFO ] backupmanager.Entities.Preferences - Preferences loaded from JSON file: language = ita.json, theme = Light +10-07-2025 14:51:00.311 [main] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 14:51:00.318 [main] [INFO ] backupmanager.MainApp - Application started +10-07-2025 14:51:00.827 [AWT-EventQueue-0] [INFO ] b.Services.BackupObserver - Observer for running backups started +10-07-2025 14:51:00.988 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Current user: dennis dsa, asdasd@gmail.cdss, italiano (Italia) +10-07-2025 14:51:08.258 [main] [INFO ] backupmanager.Entities.Preferences - Preferences loaded from JSON file: language = ita.json, theme = Light +10-07-2025 14:51:08.275 [main] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 14:51:08.281 [main] [INFO ] backupmanager.MainApp - Application started +10-07-2025 14:51:08.771 [AWT-EventQueue-0] [INFO ] b.Services.BackupObserver - Observer for running backups started +10-07-2025 14:51:08.960 [AWT-EventQueue-0] [WARN ] backupmanager.Json.JsonUser - User file doesn't exist or is empty +10-07-2025 14:51:08.960 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Setting default language to: it +10-07-2025 14:51:08.960 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Reloading preferences +10-07-2025 14:51:08.961 [AWT-EventQueue-0] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 14:51:17.024 [AWT-EventQueue-0] [INFO ] backupmanager.Json.JsonUser - User successfully written to JSON user file with data: asdasd asdasd, dasda@fsdaafsd.com, italiano (Italia) +10-07-2025 14:51:17.028 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - User creation info email sent with user: asdasd asdasd, dasda@fsdaafsd.com, italiano (Italia) +10-07-2025 14:51:17.029 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - Confirmation registration email sent to the user: asdasd asdasd, dasda@fsdaafsd.com, italiano (Italia) +10-07-2025 14:59:00.560 [main] [INFO ] backupmanager.Entities.Preferences - Preferences loaded from JSON file: language = ita.json, theme = Light +10-07-2025 14:59:00.577 [main] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 14:59:00.583 [main] [INFO ] backupmanager.MainApp - Application started +10-07-2025 14:59:01.072 [AWT-EventQueue-0] [INFO ] b.Services.BackupObserver - Observer for running backups started +10-07-2025 14:59:01.229 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Current user: asdasd asdasd, dasda@fsdaafsd.com, italiano (Italia) +10-07-2025 14:59:09.090 [main] [INFO ] backupmanager.Entities.Preferences - Preferences loaded from JSON file: language = ita.json, theme = Light +10-07-2025 14:59:09.107 [main] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 14:59:09.112 [main] [INFO ] backupmanager.MainApp - Application started +10-07-2025 14:59:09.561 [AWT-EventQueue-0] [INFO ] b.Services.BackupObserver - Observer for running backups started +10-07-2025 14:59:09.715 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Current user: asdasd asdasd, dasda@fsdaafsd.com, italiano (Italia) +10-07-2025 14:59:19.738 [main] [INFO ] backupmanager.Entities.Preferences - Preferences loaded from JSON file: language = ita.json, theme = Light +10-07-2025 14:59:19.756 [main] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 14:59:19.762 [main] [INFO ] backupmanager.MainApp - Application started +10-07-2025 14:59:20.233 [AWT-EventQueue-0] [INFO ] b.Services.BackupObserver - Observer for running backups started +10-07-2025 14:59:20.414 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Current user: asdasd asdasd, dasda@fsdaafsd.com, italiano (Italia) +10-07-2025 14:59:38.975 [main] [INFO ] backupmanager.Entities.Preferences - Preferences loaded from JSON file: language = ita.json, theme = Light +10-07-2025 14:59:38.992 [main] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 14:59:38.998 [main] [INFO ] backupmanager.MainApp - Application started +10-07-2025 14:59:39.482 [AWT-EventQueue-0] [INFO ] b.Services.BackupObserver - Observer for running backups started +10-07-2025 14:59:39.641 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Current user: asdasd asdasd, dasda@fsdaafsd.com, italiano (Italia) +10-07-2025 15:00:12.118 [main] [INFO ] backupmanager.Entities.Preferences - Preferences loaded from JSON file: language = ita.json, theme = Light +10-07-2025 15:00:12.135 [main] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 15:00:12.141 [main] [INFO ] backupmanager.MainApp - Application started +10-07-2025 15:00:12.638 [AWT-EventQueue-0] [INFO ] b.Services.BackupObserver - Observer for running backups started +10-07-2025 15:00:12.782 [AWT-EventQueue-0] [WARN ] backupmanager.Json.JsonUser - User file doesn't exist or is empty +10-07-2025 15:00:12.782 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Setting default language to: it +10-07-2025 15:00:12.782 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Reloading preferences +10-07-2025 15:00:12.783 [AWT-EventQueue-0] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 15:00:22.512 [AWT-EventQueue-0] [INFO ] backupmanager.Json.JsonUser - User successfully written to JSON user file with data: dennis turco, dennisturco@gmail.com, italiano (Italia) +10-07-2025 15:00:22.518 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - User creation info email sent with user: dennis turco, dennisturco@gmail.com, italiano (Italia) +10-07-2025 15:00:22.522 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - Confirmation registration email sent to the user: dennis turco, dennisturco@gmail.com, italiano (Italia) +10-07-2025 15:06:51.507 [main] [INFO ] backupmanager.Entities.Preferences - Preferences loaded from JSON file: language = ita.json, theme = Light +10-07-2025 15:06:51.524 [main] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 15:06:51.531 [main] [INFO ] backupmanager.MainApp - Application started +10-07-2025 15:06:52.069 [AWT-EventQueue-0] [INFO ] b.Services.BackupObserver - Observer for running backups started +10-07-2025 15:06:52.224 [AWT-EventQueue-0] [WARN ] backupmanager.Json.JsonUser - User file doesn't exist or is empty +10-07-2025 15:06:52.225 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Setting default language to: it +10-07-2025 15:06:52.225 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Reloading preferences +10-07-2025 15:06:52.225 [AWT-EventQueue-0] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 15:06:58.699 [AWT-EventQueue-0] [INFO ] backupmanager.Json.JsonUser - User successfully written to JSON user file with data: sad asdasd, sadas@gmail.com, italiano (Italia) +10-07-2025 15:06:58.705 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - User creation info email sent with user: sad asdasd, sadas@gmail.com, italiano (Italia) +10-07-2025 15:06:58.707 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - Confirmation registration email sent to the user: sad asdasd, sadas@gmail.com, italiano (Italia) +10-07-2025 15:07:27.259 [main] [INFO ] backupmanager.Entities.Preferences - Preferences loaded from JSON file: language = ita.json, theme = Light +10-07-2025 15:07:27.276 [main] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 15:07:27.284 [main] [INFO ] backupmanager.MainApp - Application started +10-07-2025 15:07:27.780 [AWT-EventQueue-0] [INFO ] b.Services.BackupObserver - Observer for running backups started +10-07-2025 15:07:27.936 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Current user: sad asdasd, sadas@gmail.com, italiano (Italia) +10-07-2025 15:07:40.131 [main] [INFO ] backupmanager.Entities.Preferences - Preferences loaded from JSON file: language = ita.json, theme = Light +10-07-2025 15:07:40.148 [main] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 15:07:40.153 [main] [INFO ] backupmanager.MainApp - Application started +10-07-2025 15:07:40.637 [AWT-EventQueue-0] [INFO ] b.Services.BackupObserver - Observer for running backups started +10-07-2025 15:07:40.792 [AWT-EventQueue-0] [WARN ] backupmanager.Json.JsonUser - User file doesn't exist or is empty +10-07-2025 15:07:40.793 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Setting default language to: it +10-07-2025 15:07:40.793 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Reloading preferences +10-07-2025 15:07:40.794 [AWT-EventQueue-0] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 15:07:46.843 [AWT-EventQueue-0] [INFO ] backupmanager.Json.JsonUser - User successfully written to JSON user file with data: qwdsasd asdasdas, asdasd@gmail.com, italiano (Italia) +10-07-2025 15:07:46.849 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - User creation info email sent with user: qwdsasd asdasdas, asdasd@gmail.com, italiano (Italia) +10-07-2025 15:07:46.851 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - Confirmation registration email sent to the user: qwdsasd asdasdas, asdasd@gmail.com, italiano (Italia) +10-07-2025 15:10:28.994 [main] [INFO ] backupmanager.Entities.Preferences - Preferences loaded from JSON file: language = ita.json, theme = Light +10-07-2025 15:10:29.010 [main] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 15:10:29.017 [main] [INFO ] backupmanager.MainApp - Application started +10-07-2025 15:10:29.551 [AWT-EventQueue-0] [INFO ] b.Services.BackupObserver - Observer for running backups started +10-07-2025 15:10:29.712 [AWT-EventQueue-0] [WARN ] backupmanager.Json.JsonUser - User file doesn't exist or is empty +10-07-2025 15:10:29.712 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Setting default language to: it +10-07-2025 15:10:29.712 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Reloading preferences +10-07-2025 15:10:29.713 [AWT-EventQueue-0] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 15:10:38.479 [AWT-EventQueue-0] [INFO ] backupmanager.Json.JsonUser - User successfully written to JSON user file with data: asdas dasdasdas, dasdasd@gmail.com, italiano (Italia) +10-07-2025 15:10:38.485 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - User creation info email sent with user: asdas dasdasdas, dasdasd@gmail.com, italiano (Italia) +10-07-2025 15:10:38.488 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - Confirmation registration email sent to the user: asdas dasdasdas, dasdasd@gmail.com, italiano (Italia) +10-07-2025 15:31:50.676 [main] [INFO ] backupmanager.Entities.Preferences - Preferences loaded from JSON file: language = ita.json, theme = Light +10-07-2025 15:31:50.695 [main] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 15:31:50.702 [main] [INFO ] backupmanager.MainApp - Application started +10-07-2025 15:31:51.238 [AWT-EventQueue-0] [INFO ] b.Services.BackupObserver - Observer for running backups started +10-07-2025 15:31:51.388 [AWT-EventQueue-0] [WARN ] backupmanager.Json.JsonUser - User file doesn't exist or is empty +10-07-2025 15:31:51.388 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Setting default language to: it +10-07-2025 15:31:51.389 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Reloading preferences +10-07-2025 15:31:51.390 [AWT-EventQueue-0] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 15:32:06.180 [AWT-EventQueue-0] [INFO ] backupmanager.Json.JsonUser - User successfully written to JSON user file with data: sadasd asdasd, dennisturco@gmail.com, italiano (Italia) +10-07-2025 15:32:06.185 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - User creation info email sent with user: sadasd asdasd, dennisturco@gmail.com, italiano (Italia) +10-07-2025 15:32:06.187 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - Confirmation registration email sent to the user: sadasd asdasd, dennisturco@gmail.com, italiano (Italia) +10-07-2025 15:33:00.561 [main] [INFO ] backupmanager.Entities.Preferences - Preferences loaded from JSON file: language = ita.json, theme = Light +10-07-2025 15:33:00.577 [main] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 15:33:00.583 [main] [INFO ] backupmanager.MainApp - Application started +10-07-2025 15:33:01.084 [AWT-EventQueue-0] [INFO ] b.Services.BackupObserver - Observer for running backups started +10-07-2025 15:33:01.248 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Current user: sadasd asdasd, dennisturco@gmail.com, italiano (Italia) +10-07-2025 15:33:25.889 [main] [INFO ] backupmanager.Entities.Preferences - Preferences loaded from JSON file: language = ita.json, theme = Light +10-07-2025 15:33:25.906 [main] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 15:33:25.911 [main] [INFO ] backupmanager.MainApp - Application started +10-07-2025 15:33:26.402 [AWT-EventQueue-0] [INFO ] b.Services.BackupObserver - Observer for running backups started +10-07-2025 15:33:26.549 [AWT-EventQueue-0] [WARN ] backupmanager.Json.JsonUser - User file doesn't exist or is empty +10-07-2025 15:33:26.549 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Setting default language to: it +10-07-2025 15:33:26.550 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Reloading preferences +10-07-2025 15:33:26.550 [AWT-EventQueue-0] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 15:33:38.029 [AWT-EventQueue-0] [INFO ] backupmanager.Json.JsonUser - User successfully written to JSON user file with data: saddas saddsada, saddsasaD@gmail.com, italiano (Italia) +10-07-2025 15:33:38.033 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - User creation info email sent with user: saddas saddsada, saddsasaD@gmail.com, italiano (Italia) +10-07-2025 15:33:38.035 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - Confirmation registration email sent to the user: saddas saddsada, saddsasaD@gmail.com, italiano (Italia) +10-07-2025 15:36:44.523 [main] [INFO ] backupmanager.Entities.Preferences - Preferences loaded from JSON file: language = ita.json, theme = Light +10-07-2025 15:36:44.540 [main] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 15:36:44.545 [main] [INFO ] backupmanager.MainApp - Application started +10-07-2025 15:36:45.035 [AWT-EventQueue-0] [INFO ] b.Services.BackupObserver - Observer for running backups started +10-07-2025 15:36:45.179 [AWT-EventQueue-0] [WARN ] backupmanager.Json.JsonUser - User file doesn't exist or is empty +10-07-2025 15:36:45.179 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Setting default language to: it +10-07-2025 15:36:45.180 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Reloading preferences +10-07-2025 15:36:45.180 [AWT-EventQueue-0] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 15:36:53.398 [AWT-EventQueue-0] [INFO ] backupmanager.Json.JsonUser - User successfully written to JSON user file with data: gh asd, dennisturco@gmail.com, italiano (Italia) +10-07-2025 15:36:53.403 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - User creation info email sent with user: gh asd, dennisturco@gmail.com, italiano (Italia) +10-07-2025 15:36:53.409 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - Confirmation registration email sent to the user: gh asd, dennisturco@gmail.com, italiano (Italia) From 8f2e3c6c2870190ed78251b900d225c575d42c36 Mon Sep 17 00:00:00 2001 From: Dennis Turco Date: Thu, 10 Jul 2025 16:07:34 +0200 Subject: [PATCH 3/3] version program inside the emails --- .../Dialogs/PreferencesDialog.java | 2 +- .../java/backupmanager/Email/EmailSender.java | 5 +-- src/main/resources/logback.xml | 4 +-- src/main/resources/res/config/user.json | 2 +- src/main/resources/res/logs/application.log | 33 +++++++++++++++++++ 5 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/main/java/backupmanager/Dialogs/PreferencesDialog.java b/src/main/java/backupmanager/Dialogs/PreferencesDialog.java index 85826c5..cdcc4a1 100644 --- a/src/main/java/backupmanager/Dialogs/PreferencesDialog.java +++ b/src/main/java/backupmanager/Dialogs/PreferencesDialog.java @@ -129,7 +129,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { }// //GEN-END:initComponents private void themesComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_themesComboBoxActionPerformed - + }//GEN-LAST:event_themesComboBoxActionPerformed private void applyBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_applyBtnActionPerformed diff --git a/src/main/java/backupmanager/Email/EmailSender.java b/src/main/java/backupmanager/Email/EmailSender.java index fe75829..89bc761 100644 --- a/src/main/java/backupmanager/Email/EmailSender.java +++ b/src/main/java/backupmanager/Email/EmailSender.java @@ -50,11 +50,12 @@ public static void sendErrorEmail(String subject, String body) { int rows = 300; String emailMessage = String.format( - "Subject: %s\n\nUser: %s \nEmail: %s \nLanguage: %s \n\nHas encountered the following error:\n%s \n\nLast %d rows of the application.log file:\n%s", + "Subject: %s\n\nUser: %s \nEmail: %s \nLanguage: %s \nInstalled Version: %s \n\nHas encountered the following error:\n%s \n\nLast %d rows of the application.log file:\n%s", subject, user.getUserCompleteName(), user.email, user.language, + ConfigKey.VERSION.getValue(), body, rows, getTextFromLogFile(rows) @@ -69,7 +70,7 @@ public static void sendErrorEmail(String subject, String body) { * Sends an informational email. */ public static void sendUserCreationEmail(User user) { - String userDetails = "New user registered. \n\nName: " + user.getUserCompleteName()+ "\nEmail: " + user.email + "\nLanguage: " + user.language; + String userDetails = "New user registered. \n\nName: " + user.getUserCompleteName()+ "\nEmail: " + user.email + "\nLanguage: " + user.language + "\nInstalled version: " + ConfigKey.VERSION.getValue(); String emailMessage = "\n\n" + userDetails; diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 1f3261f..21a8a07 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -1,9 +1,9 @@ - - + + diff --git a/src/main/resources/res/config/user.json b/src/main/resources/res/config/user.json index 0dfbf1e..feecf03 100644 --- a/src/main/resources/res/config/user.json +++ b/src/main/resources/res/config/user.json @@ -1 +1 @@ -{"name":"gh","surname":"asd","email":"dennisturco@gmail.com"} \ No newline at end of file +{"name":"dsasd","surname":"asdasd","email":"dsadas@gmail.comn"} \ No newline at end of file diff --git a/src/main/resources/res/logs/application.log b/src/main/resources/res/logs/application.log index e35609b..b9d3a37 100644 --- a/src/main/resources/res/logs/application.log +++ b/src/main/resources/res/logs/application.log @@ -151,3 +151,36 @@ 10-07-2025 15:36:53.398 [AWT-EventQueue-0] [INFO ] backupmanager.Json.JsonUser - User successfully written to JSON user file with data: gh asd, dennisturco@gmail.com, italiano (Italia) 10-07-2025 15:36:53.403 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - User creation info email sent with user: gh asd, dennisturco@gmail.com, italiano (Italia) 10-07-2025 15:36:53.409 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - Confirmation registration email sent to the user: gh asd, dennisturco@gmail.com, italiano (Italia) +10-07-2025 16:02:11.830 [main] [INFO ] backupmanager.Entities.Preferences - Preferences loaded from JSON file: language = ita.json, theme = Light +10-07-2025 16:02:11.852 [main] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 16:02:11.859 [main] [INFO ] backupmanager.MainApp - Application started +10-07-2025 16:02:12.432 [AWT-EventQueue-0] [INFO ] b.Services.BackupObserver - Observer for running backups started +10-07-2025 16:02:12.614 [AWT-EventQueue-0] [WARN ] backupmanager.Json.JsonUser - User file doesn't exist or is empty +10-07-2025 16:02:12.614 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Setting default language to: it +10-07-2025 16:02:12.614 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Reloading preferences +10-07-2025 16:02:12.615 [AWT-EventQueue-0] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 16:02:18.019 [AWT-EventQueue-0] [INFO ] backupmanager.Json.JsonUser - User successfully written to JSON user file with data: asd asd, asdasd@gmail.com, italiano (Italia) +10-07-2025 16:02:18.023 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - User creation info email sent with user: asd asd, asdasd@gmail.com, italiano (Italia) +10-07-2025 16:02:18.025 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - Confirmation registration email sent to the user: asd asd, asdasd@gmail.com, italiano (Italia) +10-07-2025 16:04:00.971 [main] [INFO ] backupmanager.Entities.Preferences - Preferences loaded from JSON file: language = ita.json, theme = Light +10-07-2025 16:04:00.990 [main] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 16:04:00.994 [main] [INFO ] backupmanager.MainApp - Application started +10-07-2025 16:04:01.491 [AWT-EventQueue-0] [INFO ] b.Services.BackupObserver - Observer for running backups started +10-07-2025 16:04:01.646 [AWT-EventQueue-0] [WARN ] backupmanager.Json.JsonUser - User file doesn't exist or is empty +10-07-2025 16:04:01.646 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Setting default language to: it +10-07-2025 16:04:01.646 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Reloading preferences +10-07-2025 16:04:01.647 [AWT-EventQueue-0] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 16:04:06.435 [AWT-EventQueue-0] [INFO ] backupmanager.Json.JsonUser - User successfully written to JSON user file with data: asd asd, asdasd@gmail.com, italiano (Italia) +10-07-2025 16:04:06.438 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - User creation info email sent with user: asd asd, asdasd@gmail.com, italiano (Italia) +10-07-2025 16:04:06.439 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - Confirmation registration email sent to the user: asd asd, asdasd@gmail.com, italiano (Italia) +10-07-2025 16:06:02.301 [main] [INFO ] backupmanager.Entities.Preferences - Preferences loaded from JSON file: language = ita.json, theme = Light +10-07-2025 16:06:02.318 [main] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 16:06:02.323 [main] [INFO ] backupmanager.MainApp - Application started +10-07-2025 16:06:02.837 [AWT-EventQueue-0] [INFO ] b.Services.BackupObserver - Observer for running backups started +10-07-2025 16:06:02.985 [AWT-EventQueue-0] [WARN ] backupmanager.Json.JsonUser - User file doesn't exist or is empty +10-07-2025 16:06:02.985 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Setting default language to: it +10-07-2025 16:06:02.986 [AWT-EventQueue-0] [INFO ] backupmanager.GUI.BackupManagerGUI - Reloading preferences +10-07-2025 16:06:02.987 [AWT-EventQueue-0] [INFO ] backupmanager.Entities.Preferences - Preferences updated to JSON file: language = ita.json, theme = Light +10-07-2025 16:06:09.123 [AWT-EventQueue-0] [INFO ] backupmanager.Json.JsonUser - User successfully written to JSON user file with data: dsasd asdasd, dsadas@gmail.comn, italiano (Italia) +10-07-2025 16:06:09.127 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - User creation info email sent with user: dsasd asdasd, dsadas@gmail.comn, italiano (Italia) +10-07-2025 16:06:09.130 [AWT-EventQueue-0] [INFO ] backupmanager.Email.EmailSender - Confirmation registration email sent to the user: dsasd asdasd, dsadas@gmail.comn, italiano (Italia)