From 22f45bd129f275b930ab2166a6b76713ca972abf Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 18 Jan 2024 07:06:46 -0800 Subject: Option to disable device sharing --- src/main/java/org/traccar/api/resource/DeviceResource.java | 3 +++ src/main/java/org/traccar/config/Keys.java | 7 +++++++ 2 files changed, 10 insertions(+) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/api/resource/DeviceResource.java b/src/main/java/org/traccar/api/resource/DeviceResource.java index 00a3fc5b9..c3ced9b84 100644 --- a/src/main/java/org/traccar/api/resource/DeviceResource.java +++ b/src/main/java/org/traccar/api/resource/DeviceResource.java @@ -204,6 +204,9 @@ public class DeviceResource extends BaseObjectResource { @FormParam("expiration") Date expiration) throws StorageException, GeneralSecurityException, IOException { User user = permissionsService.getUser(getUserId()); + if (permissionsService.getServer().getBoolean(Keys.DEVICE_SHARE_DISABLE.getKey())) { + throw new SecurityException("Sharing is disabled"); + } if (user.getTemporary()) { throw new SecurityException("Temporary user"); } diff --git a/src/main/java/org/traccar/config/Keys.java b/src/main/java/org/traccar/config/Keys.java index e79264908..02e684875 100644 --- a/src/main/java/org/traccar/config/Keys.java +++ b/src/main/java/org/traccar/config/Keys.java @@ -340,6 +340,13 @@ public final class Keys { List.of(KeyType.SERVER, KeyType.DEVICE), 0.0); + /** + * Disable device sharing on the server. + */ + public static final ConfigKey DEVICE_SHARE_DISABLE = new BooleanConfigKey( + "disableShare", + List.of(KeyType.SERVER)); + /** * Speed limit threshold multiplier. For example, if the speed limit is 100, but we only want to generate an event * if the speed is higher than 105, this parameter can be set to 1.05. Default multiplier is 1.0. -- cgit v1.2.3