aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/PermissionsManager.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-04 13:20:46 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-04 13:20:46 +1300
commitd4dbf85d9536bfec85252a58fc552e2bad42ff17 (patch)
tree4a849426c2cd60538b152138b147abef47b40966 /src/org/traccar/database/PermissionsManager.java
parent9218bc65b9673b24d2866aae3d5bbe1a5388bab0 (diff)
downloadtrackermap-server-d4dbf85d9536bfec85252a58fc552e2bad42ff17.tar.gz
trackermap-server-d4dbf85d9536bfec85252a58fc552e2bad42ff17.tar.bz2
trackermap-server-d4dbf85d9536bfec85252a58fc552e2bad42ff17.zip
Remove trailing whitespaces from code
Diffstat (limited to 'src/org/traccar/database/PermissionsManager.java')
-rw-r--r--src/org/traccar/database/PermissionsManager.java22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java
index cfbbb9a39..a38a29c32 100644
--- a/src/org/traccar/database/PermissionsManager.java
+++ b/src/org/traccar/database/PermissionsManager.java
@@ -26,25 +26,25 @@ import org.traccar.model.Permission;
import org.traccar.model.User;
public class PermissionsManager {
-
+
private final DataManager dataManager;
-
+
private final Map<Long, User> users = new HashMap<>();
-
+
private final Map<Long, Set<Long>> permissions = new HashMap<>();
-
+
private Set<Long> getNotNull(long userId) {
if (!permissions.containsKey(userId)) {
permissions.put(userId, new HashSet<Long>());
}
return permissions.get(userId);
}
-
+
public PermissionsManager(DataManager dataManager) {
this.dataManager = dataManager;
refresh();
}
-
+
public final void refresh() {
users.clear();
permissions.clear();
@@ -59,27 +59,27 @@ public class PermissionsManager {
Log.warning(error);
}
}
-
+
public void checkAdmin(long userId) throws SecurityException {
if (!users.containsKey(userId) || !users.get(userId).getAdmin()) {
throw new SecurityException("Admin access required");
}
}
-
+
public void checkUser(long userId, long otherUserId) throws SecurityException {
if (userId != otherUserId) {
checkAdmin(userId);
}
}
-
+
public Collection<Long> allowedDevices(long userId) {
return getNotNull(userId);
}
-
+
public void checkDevice(long userId, long deviceId) throws SecurityException {
if (!getNotNull(userId).contains(deviceId)) {
throw new SecurityException("Device access denied");
}
}
-
+
}