aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-02-27 22:17:56 +1300
committerGitHub <noreply@github.com>2017-02-27 22:17:56 +1300
commit39452c3e0af164e6d63696afaf874c13c7ee8b5f (patch)
treed884f4065c7a9ef4291ad590a117ee7b22cc679c
parent61a1bae779f876bcdb9b83a8f950e678a170afb0 (diff)
parentbb0a5ccd64ab8fa7c33ad9a6c37c695f2c3eef7e (diff)
downloadtraccar-server-39452c3e0af164e6d63696afaf874c13c7ee8b5f.tar.gz
traccar-server-39452c3e0af164e6d63696afaf874c13c7ee8b5f.tar.bz2
traccar-server-39452c3e0af164e6d63696afaf874c13c7ee8b5f.zip
Merge pull request #2960 from Abyss777/server_devicereadonly
Server-wide "device readonly" flag
-rw-r--r--schema/changelog-3.11.xml4
-rw-r--r--setup/default.xml1
-rw-r--r--src/org/traccar/api/resource/CommandResource.java1
-rw-r--r--src/org/traccar/database/PermissionsManager.java2
-rw-r--r--src/org/traccar/model/Server.java10
5 files changed, 16 insertions, 2 deletions
diff --git a/schema/changelog-3.11.xml b/schema/changelog-3.11.xml
index a8deb0295..c169e1146 100644
--- a/schema/changelog-3.11.xml
+++ b/schema/changelog-3.11.xml
@@ -16,6 +16,10 @@
<column name="sms" type="BOOLEAN" defaultValueBoolean="false" />
</addColumn>
+ <addColumn tableName="server">
+ <column name="devicereadonly" type="BOOLEAN" defaultValueBoolean="false" />
+ </addColumn>
+
</changeSet>
</databaseChangeLog>
diff --git a/setup/default.xml b/setup/default.xml
index b5bc4202a..80351f6a6 100644
--- a/setup/default.xml
+++ b/setup/default.xml
@@ -41,6 +41,7 @@
UPDATE server SET
registration = :registration,
readonly = :readonly,
+ deviceReadonly = :deviceReadonly,
map = :map,
bingKey = :bingKey,
mapUrl = :mapUrl,
diff --git a/src/org/traccar/api/resource/CommandResource.java b/src/org/traccar/api/resource/CommandResource.java
index e13ae9de8..41b263bf9 100644
--- a/src/org/traccar/api/resource/CommandResource.java
+++ b/src/org/traccar/api/resource/CommandResource.java
@@ -34,7 +34,6 @@ public class CommandResource extends BaseResource {
@POST
public Response add(Command entity) {
Context.getPermissionsManager().checkReadonly(getUserId());
- Context.getPermissionsManager().checkDeviceReadonly(getUserId());
Context.getPermissionsManager().checkDevice(getUserId(), entity.getDeviceId());
Context.getConnectionManager().getActiveDevice(entity.getDeviceId()).sendCommand(entity);
return Response.ok(entity).build();
diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java
index 78589ad88..5313859df 100644
--- a/src/org/traccar/database/PermissionsManager.java
+++ b/src/org/traccar/database/PermissionsManager.java
@@ -223,7 +223,7 @@ public class PermissionsManager {
}
public void checkDeviceReadonly(long userId) throws SecurityException {
- if (!isAdmin(userId) && isDeviceReadonly(userId)) {
+ if (!isAdmin(userId) && (server.getDeviceReadonly() || isDeviceReadonly(userId))) {
throw new SecurityException("Account is device readonly");
}
}
diff --git a/src/org/traccar/model/Server.java b/src/org/traccar/model/Server.java
index 5cf26f7f2..b588a4de0 100644
--- a/src/org/traccar/model/Server.java
+++ b/src/org/traccar/model/Server.java
@@ -46,6 +46,16 @@ public class Server extends Extensible {
this.readonly = readonly;
}
+ private boolean deviceReadonly;
+
+ public boolean getDeviceReadonly() {
+ return deviceReadonly;
+ }
+
+ public void setDeviceReadonly(boolean deviceReadonly) {
+ this.deviceReadonly = deviceReadonly;
+ }
+
private String map;
public String getMap() {