Skip to content

m-rusu-st/Med_Tracker

Repository files navigation

Med Tracker

A JavaFX Application that can be used in a doctor-patient interaction using the following technologies:

Our application intends to make everyone's life easier, by creating a direct line between patients and doctors.

Prerequisites

To be able to install and run this project, please make sure you have installed Java 15 or higher. Otherwise, the setup will not work! To check your java version, please run java -version in the command line.

To install a newer version of Java, you can go to Oracle or OpenJDK.

It would be good if you also installed Gradle to your system. To check if you have Gradle installed run gradle -version.

If you need to install, please refer to official Gradle docs.

Make sure you install JavaFX SDK on your machine, using the instructions provided in the Official Documentation. Make sure to export the PATH_TO_FX environment variable, or to replace it in every command you will find in this documentation from now on, with the path/to/javafx-sdk-15.0.1/lib.

Note: you can download version 15 of the javafx-sdk, by replacing in the download link for version 16 the 16 with 15.

Setup & Run

To set up and run the project locally on your machine, please follow the next steps.

Clone the repository

Clone the repository using:

git clone https://github.com/m-rusu-st/Med_Tracker.git

Run the project with Gradle

To start and run the project use one of the following commands:

  • gradle run or ./gradlew run (to start the run task of the org.openjfx.javafxplugin plugin)

Database

Behind the scenes, the app actually saved the users in the database, encrypting the password. To see that it actually worked, we need to inspect the database that was created in the $HOME/.registration-example/registration-example.db (for Linux and MacOS) and %USERPROFILE%/.registration-example/registration-example.db file, using the nitrite-explorer-3.4.3.jar, provided by Nitrite Java. Download the jar and run java --module-path $PATH_TO_FX --add-modules javafx.controls,javafx.fxml $PATH_TO_NITRITE\nitrite-explorer-3.4.3.jar . You should see a window like this open:

Choose the $HOME/.registration-example/registration-example.db and add test as both the username, and the password to access the database, then click Open.

You should be able to see that there is a single database entry for the Users Collection, namely the one you just added. Also, please notice that the password is saved encrypted!

Technical Details

Encrypting Passwords

Encrypting the passwords is done via the following 2 Java functions, found in UserService.java:

    private static String encodePassword(String salt, String password) {
        MessageDigest md = getMessageDigest();
        md.update(salt.getBytes(StandardCharsets.UTF_8));

        byte[] hashedPassword = md.digest(password.getBytes(StandardCharsets.UTF_8));

        // This is the way a password should be encoded when checking the credentials
        return new String(hashedPassword, StandardCharsets.UTF_8)
                .replace("\"", ""); //to be able to save in JSON format
    }

    private static MessageDigest getMessageDigest() {
        MessageDigest md;
        try {
            md = MessageDigest.getInstance("SHA-512");
        } catch (NoSuchAlgorithmException e) {
            throw new IllegalStateException("SHA-512 does not exist!");
        }
        return md;
    }

Nitrite Java

Nitrite Java was used in the UserService.java file, where we initialized a database, and a Repository of User objects:

    private static ObjectRepository<User> userRepository;

    public static void initDatabase() {
        Nitrite database = Nitrite.builder()
                .filePath(getPathToFile("MedTracker.db").toFile())
                .openOrCreate("test", "test");

        userRepository = database.getRepository(User.class);
    }

Resources

To understand and learn more about JavaFX, you can take a look at some of the following links:

To better understand how to use Nitrite Java, use the following links:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages