aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/config
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/config')
-rw-r--r--src/main/java/org/traccar/config/Config.java31
-rw-r--r--src/main/java/org/traccar/config/Keys.java96
2 files changed, 103 insertions, 24 deletions
diff --git a/src/main/java/org/traccar/config/Config.java b/src/main/java/org/traccar/config/Config.java
index 5f95c16d9..c73be6475 100644
--- a/src/main/java/org/traccar/config/Config.java
+++ b/src/main/java/org/traccar/config/Config.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2020 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2022 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.InvalidPropertiesFormatException;
+import java.util.Objects;
import java.util.Properties;
@Singleton
@@ -71,8 +72,7 @@ public class Config {
return hasKey(key.getKey());
}
- @Deprecated
- public boolean hasKey(String key) {
+ private boolean hasKey(String key) {
return useEnvironmentVariables && System.getenv().containsKey(getEnvironmentVariableName(key))
|| properties.containsKey(key);
}
@@ -102,12 +102,7 @@ public class Config {
}
public boolean getBoolean(ConfigKey<Boolean> key) {
- return getBoolean(key.getKey());
- }
-
- @Deprecated
- public boolean getBoolean(String key) {
- return Boolean.parseBoolean(getString(key));
+ return Boolean.parseBoolean(getString(key.getKey()));
}
public int getInteger(ConfigKey<Integer> key) {
@@ -116,11 +111,7 @@ public class Config {
return Integer.parseInt(value);
} else {
Integer defaultValue = key.getDefaultValue();
- if (defaultValue != null) {
- return defaultValue;
- } else {
- return 0;
- }
+ return Objects.requireNonNullElse(defaultValue, 0);
}
}
@@ -139,11 +130,7 @@ public class Config {
return Long.parseLong(value);
} else {
Long defaultValue = key.getDefaultValue();
- if (defaultValue != null) {
- return defaultValue;
- } else {
- return 0;
- }
+ return Objects.requireNonNullElse(defaultValue, 0L);
}
}
@@ -153,11 +140,7 @@ public class Config {
return Double.parseDouble(value);
} else {
Double defaultValue = key.getDefaultValue();
- if (defaultValue != null) {
- return defaultValue;
- } else {
- return 0;
- }
+ return Objects.requireNonNullElse(defaultValue, 0.0);
}
}
diff --git a/src/main/java/org/traccar/config/Keys.java b/src/main/java/org/traccar/config/Keys.java
index 2e1a14eaf..7ab45312f 100644
--- a/src/main/java/org/traccar/config/Keys.java
+++ b/src/main/java/org/traccar/config/Keys.java
@@ -801,6 +801,102 @@ public final class Keys {
"templates");
/**
+ * Force SMTP settings from the config file and ignore user attributes.
+ */
+ public static final ConfigKey<Boolean> MAIL_SMTP_IGNORE_USER_CONFIG = new BooleanConfigKey(
+ "mail.smtp.ignoreUserConfig",
+ List.of(KeyType.CONFIG));
+
+ /**
+ * The SMTP server to connect to.
+ */
+ public static final ConfigKey<String> MAIL_SMTP_HOST = new StringConfigKey(
+ "mail.smtp.host",
+ List.of(KeyType.CONFIG, KeyType.USER));
+
+ /**
+ * The SMTP server port to connect. Defaults to 25.
+ */
+ public static final ConfigKey<Integer> MAIL_SMTP_PORT = new IntegerConfigKey(
+ "mail.smtp.port",
+ List.of(KeyType.CONFIG, KeyType.USER),
+ 25);
+
+ /**
+ * Email transport protocol. Default value is "smtp".
+ */
+ public static final ConfigKey<String> MAIL_TRANSPORT_PROTOCOL = new StringConfigKey(
+ "mail.transport.protocol",
+ List.of(KeyType.CONFIG, KeyType.USER),
+ "smtp");
+
+ /**
+ * If true, enables the use of the STARTTLS command (if supported by the server) to switch the connection to a
+ * TLS-protected connection before issuing any login commands.
+ */
+ public static final ConfigKey<Boolean> MAIL_SMTP_STARTTLS_ENABLE = new BooleanConfigKey(
+ "mail.smtp.starttls.enable",
+ List.of(KeyType.CONFIG, KeyType.USER));
+
+ /**
+ * If true, requires the use of the STARTTLS command. If the server doesn't support the STARTTLS command, or the
+ * command fails, the connect method will fail.
+ */
+ public static final ConfigKey<Boolean> MAIL_SMTP_STARTTLS_REQUIRED = new BooleanConfigKey(
+ "mail.smtp.starttls.required",
+ List.of(KeyType.CONFIG, KeyType.USER));
+
+ /**
+ * If set to true, use SSL to connect and use the SSL port by default.
+ */
+ public static final ConfigKey<Boolean> MAIL_SMTP_SSL_ENABLE = new BooleanConfigKey(
+ "mail.smtp.ssl.enable",
+ List.of(KeyType.CONFIG, KeyType.USER));
+
+ /**
+ * If set to "*", all hosts are trusted. If set to a whitespace separated list of hosts, those hosts are trusted.
+ * Otherwise, trust depends on the certificate the server presents.
+ */
+ public static final ConfigKey<String> MAIL_SMTP_SSL_TRUST = new StringConfigKey(
+ "mail.smtp.ssl.trust",
+ List.of(KeyType.CONFIG, KeyType.USER));
+
+ /**
+ * Specifies the SSL protocols that will be enabled for SSL connections.
+ */
+ public static final ConfigKey<String> MAIL_SMTP_SSL_PROTOCOLS = new StringConfigKey(
+ "mail.smtp.ssl.protocols",
+ List.of(KeyType.CONFIG, KeyType.USER));
+
+ /**
+ * SMTP connection username.
+ */
+ public static final ConfigKey<String> MAIL_SMTP_USERNAME = new StringConfigKey(
+ "mail.smtp.username",
+ List.of(KeyType.CONFIG, KeyType.USER));
+
+ /**
+ * SMTP connection password.
+ */
+ public static final ConfigKey<String> MAIL_SMTP_PASSWORD = new StringConfigKey(
+ "mail.smtp.password",
+ List.of(KeyType.CONFIG, KeyType.USER));
+
+ /**
+ * Email address to use for SMTP MAIL command.
+ */
+ public static final ConfigKey<String> MAIL_SMTP_FROM = new StringConfigKey(
+ "mail.smtp.from",
+ List.of(KeyType.CONFIG, KeyType.USER));
+
+ /**
+ * The personal name for the email from address.
+ */
+ public static final ConfigKey<String> MAIL_SMTP_FROM_NAME = new StringConfigKey(
+ "mail.smtp.fromName",
+ List.of(KeyType.CONFIG, KeyType.USER));
+
+ /**
* SMS API service full URL. Enables SMS commands and notifications.
*/
public static final ConfigKey<String> SMS_HTTP_URL = new StringConfigKey(