Class EnvironmentVariableLoader
java.lang.Object
com.serinity.accesscontrol.config.EnvironmentVariableLoader
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 URLDATABASE_USERNAME– Database authentication usernameDATABASE_PASSWORD– Database authentication passwordJDBC_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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final StringGets the database password.static final StringGets the database JDBC URL.static final StringGets the database username.static final StringGets the FreeImage.host API key.static final StringGets the FreeImage.host request URL.static final StringGets the JDBC driver class name.static final StringGets the SMTP sender display name.static final StringGets the SMTP host name.static final StringGets the SMTP password.static final intGets the SMTP port.static final StringGets the SMTP username.static final booleanChecks whether SMTP TLS is enabled.
-
Constructor Details
-
EnvironmentVariableLoader
public EnvironmentVariableLoader()Creates a new environment loader instance.
-
-
Method Details
-
getDatabaseUrl
Gets the database JDBC URL.- Returns:
- the
DATABASE_URLenvironment variable value
-
getDatabaseUsername
Gets the database username.- Returns:
- the
DATABASE_USERNAMEenvironment variable value
-
getDatabasePassword
Gets the database password.- Returns:
- the
DATABASE_PASSWORDenvironment variable value
-
getJdbcDriver
Gets the JDBC driver class name.- Returns:
- the fully-qualified JDBC driver class name from
JDBC_DRIVER
-
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
Gets the SMTP password.- Returns:
- the SMTP authentication password from
SMTP_PASSWORD
-
getSmtpUsername
Gets the SMTP username.- Returns:
- the SMTP authentication username from
SMTP_USERNAME
-
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:
trueifSMTP_USE_TLSis set to"true"
-
getImageRequestUrl
Gets the FreeImage.host request URL.- Returns:
- the FreeImage.host API request URL from
IMAGE_REQUEST_URL
-
getImageApiKey
Gets the FreeImage.host API key.- Returns:
- the FreeImage.host API key from
IMAGE_API_KEY
-