Class EnvironmentVariableLoader

java.lang.Object
com.serinity.accesscontrol.config.EnvironmentVariableLoader

public class EnvironmentVariableLoader extends Object
Utility class responsible for loading environment variables from a configuration file using the Dotenv library.

This class centralizes access to sensitive configuration values such as database credentials and JDBC driver settings.

The class uses a static initialization block to ensure that environment variables are loaded once and remain accessible throughout the application lifecycle.

Exposed configuration values:

  • DATABASE_URL – Database connection URL
  • DATABASE_USERNAME – Database authentication username
  • DATABASE_PASSWORD – Database authentication password
  • JDBC_DRIVER – Fully qualified JDBC driver class name
  • more..

If the environment file is missing or cannot be loaded, a DotenvException is thrown and wrapped in a RuntimeException.

Since:
2026-02-16 EnvironmentVariableLoader.java
Version:
1.0
Author:
@ZouariOmar (zouariomar20@gmail.com)
  • Constructor Details

    • EnvironmentVariableLoader

      public EnvironmentVariableLoader()
      Creates a new environment loader instance.
  • Method Details

    • getDatabaseUrl

      public static final String getDatabaseUrl()
      Gets the database JDBC URL.
      Returns:
      the DATABASE_URL environment variable value
    • getDatabaseUsername

      public static final String getDatabaseUsername()
      Gets the database username.
      Returns:
      the DATABASE_USERNAME environment variable value
    • getDatabasePassword

      public static final String getDatabasePassword()
      Gets the database password.
      Returns:
      the DATABASE_PASSWORD environment variable value
    • getJdbcDriver

      public static final String getJdbcDriver()
      Gets the JDBC driver class name.
      Returns:
      the fully-qualified JDBC driver class name from JDBC_DRIVER
    • getSmtpHost

      public static final String getSmtpHost()
      Gets the SMTP host name.
      Returns:
      the SMTP server hostname from SMTP_HOST
    • getSmtpPort

      public static final int getSmtpPort()
      Gets the SMTP port.
      Returns:
      the SMTP server port from SMTP_PORT
    • getSmtpPassword

      public static final String getSmtpPassword()
      Gets the SMTP password.
      Returns:
      the SMTP authentication password from SMTP_PASSWORD
    • getSmtpUsername

      public static final String getSmtpUsername()
      Gets the SMTP username.
      Returns:
      the SMTP authentication username from SMTP_USERNAME
    • getSmtpFromName

      public static final String getSmtpFromName()
      Gets the SMTP sender display name.
      Returns:
      the sender display name from SMTP_FROM_NAME
    • isSmptTls

      public static final boolean isSmptTls()
      Checks whether SMTP TLS is enabled.
      Returns:
      true if SMTP_USE_TLS is set to "true"
    • getImageRequestUrl

      public static final String getImageRequestUrl()
      Gets the FreeImage.host request URL.
      Returns:
      the FreeImage.host API request URL from IMAGE_REQUEST_URL
    • getImageApiKey

      public static final String getImageApiKey()
      Gets the FreeImage.host API key.
      Returns:
      the FreeImage.host API key from IMAGE_API_KEY