aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/BaseProtocolEncoder.java
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/BaseProtocolEncoder.java
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/BaseProtocolEncoder.java')
-rw-r--r--src/main/java/org/traccar/BaseProtocolEncoder.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/BaseProtocolEncoder.java b/src/main/java/org/traccar/BaseProtocolEncoder.java
index 10b780fc8..612d91c57 100644
--- a/src/main/java/org/traccar/BaseProtocolEncoder.java
+++ b/src/main/java/org/traccar/BaseProtocolEncoder.java
@@ -15,7 +15,6 @@
*/
package org.traccar;
-import com.google.inject.Inject;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
@@ -24,7 +23,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.traccar.database.IdentityManager;
import org.traccar.helper.NetworkUtil;
+import org.traccar.helper.model.AttributeUtil;
import org.traccar.model.Command;
+import org.traccar.session.cache.CacheManager;
+
+import javax.inject.Inject;
public abstract class BaseProtocolEncoder extends ChannelOutboundHandlerAdapter {
@@ -34,12 +37,23 @@ public abstract class BaseProtocolEncoder extends ChannelOutboundHandlerAdapter
private final Protocol protocol;
+ private CacheManager cacheManager;
+
private IdentityManager identityManager;
public BaseProtocolEncoder(Protocol protocol) {
this.protocol = protocol;
}
+ public CacheManager getCacheManager() {
+ return cacheManager;
+ }
+
+ @Inject
+ public void setCacheManager(CacheManager cacheManager) {
+ this.cacheManager = cacheManager;
+ }
+
public IdentityManager getIdentityManager() {
return identityManager;
}
@@ -59,8 +73,8 @@ public abstract class BaseProtocolEncoder extends ChannelOutboundHandlerAdapter
protected void initDevicePassword(Command command, String defaultPassword) {
if (!command.getAttributes().containsKey(Command.KEY_DEVICE_PASSWORD)) {
- String password = identityManager
- .getDevicePassword(command.getDeviceId(), getProtocolName(), defaultPassword);
+ String password = AttributeUtil.getDevicePassword(
+ cacheManager, command.getDeviceId(), getProtocolName(), defaultPassword);
command.set(Command.KEY_DEVICE_PASSWORD, password);
}
}