diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-16 07:18:33 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-16 07:18:33 -0700 |
commit | cc342a9ba371b0dca8d87ca9e74c5907ccb58bc6 (patch) | |
tree | 6d0354e4a357eb314eeaad044ad9591f9f98f867 /src/main/java/org/traccar/database | |
parent | d3e83f9fa0d066e5a15fde225599cc43071c031a (diff) | |
download | trackermap-server-cc342a9ba371b0dca8d87ca9e74c5907ccb58bc6.tar.gz trackermap-server-cc342a9ba371b0dca8d87ca9e74c5907ccb58bc6.tar.bz2 trackermap-server-cc342a9ba371b0dca8d87ca9e74c5907ccb58bc6.zip |
Permissions manager refactor
Diffstat (limited to 'src/main/java/org/traccar/database')
-rw-r--r-- | src/main/java/org/traccar/database/DeviceManager.java | 2 | ||||
-rw-r--r-- | src/main/java/org/traccar/database/PermissionsManager.java | 27 |
2 files changed, 1 insertions, 28 deletions
diff --git a/src/main/java/org/traccar/database/DeviceManager.java b/src/main/java/org/traccar/database/DeviceManager.java index 29c17c41f..bd100245c 100644 --- a/src/main/java/org/traccar/database/DeviceManager.java +++ b/src/main/java/org/traccar/database/DeviceManager.java @@ -368,7 +368,7 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity } } if (result == null && lookupServer) { - Server server = Context.getPermissionsManager().getServer(); + Server server = cacheManager.getServer(); result = server.getAttributes().get(attributeName); } if (result == null && lookupConfig) { diff --git a/src/main/java/org/traccar/database/PermissionsManager.java b/src/main/java/org/traccar/database/PermissionsManager.java index 595e236fa..3d4e6425a 100644 --- a/src/main/java/org/traccar/database/PermissionsManager.java +++ b/src/main/java/org/traccar/database/PermissionsManager.java @@ -22,7 +22,6 @@ import org.traccar.api.security.PermissionsService; import org.traccar.model.Device; import org.traccar.model.Group; import org.traccar.model.Permission; -import org.traccar.model.Server; import org.traccar.model.User; import org.traccar.storage.Storage; import org.traccar.storage.StorageException; @@ -44,8 +43,6 @@ public class PermissionsManager { private final DataManager dataManager; private final Storage storage; - private volatile Server server; - private final ReadWriteLock lock = new ReentrantReadWriteLock(); private final Map<Long, Set<Long>> groupPermissions = new HashMap<>(); @@ -56,7 +53,6 @@ public class PermissionsManager { public PermissionsManager(DataManager dataManager, Storage storage) { this.dataManager = dataManager; this.storage = storage; - refreshServer(); refreshDeviceAndGroupPermissions(); } @@ -148,14 +144,6 @@ public class PermissionsManager { } } - public void refreshServer() { - try { - server = dataManager.getServer(); - } catch (StorageException error) { - LOGGER.warn("Refresh server config error", error); - } - } - public final void refreshDeviceAndGroupPermissions() { writeLock(); try { @@ -229,12 +217,6 @@ public class PermissionsManager { return user != null && user.getReadonly(); } - public void checkReadonly(long userId) throws SecurityException { - if (!getUserAdmin(userId) && (server.getReadonly() || getUserReadonly(userId))) { - throw new SecurityException("Account is readonly"); - } - } - public void checkUserEnabled(long userId) throws SecurityException { User user = getUser(userId); if (user == null) { @@ -265,15 +247,6 @@ public class PermissionsManager { } } - public Server getServer() { - return server; - } - - public void updateServer(Server server) throws StorageException { - dataManager.updateObject(server); - this.server = server; - } - public User login(String email, String password) throws StorageException { User user = dataManager.login(email, password); if (user != null) { |