aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/helper/model
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-18 10:08:52 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-18 10:08:52 -0700
commit22bd8bcc80b850dc2308be50cf2886c39b0655da (patch)
tree01f98cf67e21f06f94f85b8cc38ae63b8ec39df9 /src/main/java/org/traccar/helper/model
parentc248ed30047a0525bf792730a0fbd4de0c89ad8e (diff)
downloadtrackermap-server-22bd8bcc80b850dc2308be50cf2886c39b0655da.tar.gz
trackermap-server-22bd8bcc80b850dc2308be50cf2886c39b0655da.tar.bz2
trackermap-server-22bd8bcc80b850dc2308be50cf2886c39b0655da.zip
Refactor device password
Diffstat (limited to 'src/main/java/org/traccar/helper/model')
-rw-r--r--src/main/java/org/traccar/helper/model/AttributeUtil.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/helper/model/AttributeUtil.java b/src/main/java/org/traccar/helper/model/AttributeUtil.java
index 5b3fc1cbe..225089d5c 100644
--- a/src/main/java/org/traccar/helper/model/AttributeUtil.java
+++ b/src/main/java/org/traccar/helper/model/AttributeUtil.java
@@ -15,8 +15,11 @@
*/
package org.traccar.helper.model;
+import org.traccar.Context;
import org.traccar.config.ConfigKey;
import org.traccar.config.KeyType;
+import org.traccar.config.Keys;
+import org.traccar.model.Command;
import org.traccar.model.Device;
import org.traccar.model.Group;
import org.traccar.session.cache.CacheManager;
@@ -69,4 +72,22 @@ public final class AttributeUtil {
return key.getDefaultValue();
}
+ public static String getDevicePassword(
+ CacheManager cacheManager, long deviceId, String protocol, String defaultPassword) {
+
+ String password = lookup(cacheManager, Keys.DEVICE_PASSWORD, deviceId);
+ if (password != null) {
+ return password;
+ }
+
+ if (protocol != null) {
+ password = cacheManager.getConfig().getString(Keys.PROTOCOL_DEVICE_PASSWORD.withPrefix(protocol));
+ if (password != null) {
+ return password;
+ }
+ }
+
+ return defaultPassword;
+ }
+
}