aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/database
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/database')
-rw-r--r--src/main/java/org/traccar/database/DeviceManager.java11
-rw-r--r--src/main/java/org/traccar/database/IdentityManager.java2
2 files changed, 10 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/database/DeviceManager.java b/src/main/java/org/traccar/database/DeviceManager.java
index d5b1c8c0d..51f35b3db 100644
--- a/src/main/java/org/traccar/database/DeviceManager.java
+++ b/src/main/java/org/traccar/database/DeviceManager.java
@@ -116,13 +116,20 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
}
@Override
- public String getDevicePassword(long id, String defaultPassword) {
+ public String getDevicePassword(long id, String protocol, String defaultPassword) {
- String password = getById(id).getString(Command.KEY_DEVICE_PASSWORD);
+ String password = lookupAttributeString(id, Command.KEY_DEVICE_PASSWORD, null, false);
if (password != null) {
return password;
}
+ if (protocol != null) {
+ password = Context.getConfig().getString(protocol + "." + Command.KEY_DEVICE_PASSWORD);
+ if (password != null) {
+ return password;
+ }
+ }
+
return defaultPassword;
}
diff --git a/src/main/java/org/traccar/database/IdentityManager.java b/src/main/java/org/traccar/database/IdentityManager.java
index b30537f4f..af6a6ce71 100644
--- a/src/main/java/org/traccar/database/IdentityManager.java
+++ b/src/main/java/org/traccar/database/IdentityManager.java
@@ -26,7 +26,7 @@ public interface IdentityManager {
Device getByUniqueId(String uniqueId) throws Exception;
- String getDevicePassword(long id, String defaultPassword);
+ String getDevicePassword(long id, String protocol, String defaultPassword);
Position getLastPosition(long deviceId);