aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/PermissionsManager.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-03-09 16:09:00 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-03-09 16:09:00 +1300
commitd4825d57fc27384288d9f3e1c1dd9e4bd7e29160 (patch)
tree5c13d487042303ad02ad2c47170bf2854cf3e256 /src/org/traccar/database/PermissionsManager.java
parent2879646bc58467939349c367a7763cd1eb11fde2 (diff)
downloadtrackermap-server-d4825d57fc27384288d9f3e1c1dd9e4bd7e29160.tar.gz
trackermap-server-d4825d57fc27384288d9f3e1c1dd9e4bd7e29160.tar.bz2
trackermap-server-d4825d57fc27384288d9f3e1c1dd9e4bd7e29160.zip
Implement API resource for groups
Diffstat (limited to 'src/org/traccar/database/PermissionsManager.java')
-rw-r--r--src/org/traccar/database/PermissionsManager.java14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java
index 0ed8227b4..5d6430764 100644
--- a/src/org/traccar/database/PermissionsManager.java
+++ b/src/org/traccar/database/PermissionsManager.java
@@ -38,14 +38,14 @@ public class PermissionsManager {
private final Map<Long, Set<Long>> groupPermissions = new HashMap<>();
private final Map<Long, Set<Long>> devicePermissions = new HashMap<>();
- private Set<Long> getGroupPermissions(long userId) {
+ public Set<Long> getGroupPermissions(long userId) {
if (!groupPermissions.containsKey(userId)) {
groupPermissions.put(userId, new HashSet<Long>());
}
return groupPermissions.get(userId);
}
- private Set<Long> getDevicePermissions(long userId) {
+ public Set<Long> getDevicePermissions(long userId) {
if (!devicePermissions.containsKey(userId)) {
devicePermissions.put(userId, new HashSet<Long>());
}
@@ -92,12 +92,10 @@ public class PermissionsManager {
}
}
- public Collection<Long> allowedGroups(long userId) {
- return getGroupPermissions(userId);
- }
-
- public Collection<Long> allowedDevices(long userId) {
- return getDevicePermissions(userId);
+ public void checkGroup(long userId, long groupId) throws SecurityException {
+ if (!getGroupPermissions(userId).contains(groupId)) {
+ throw new SecurityException("Group access denied");
+ }
}
public void checkDevice(long userId, long deviceId) throws SecurityException {