Skip to content

Commit

Permalink
Rename method to get permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
tananaev committed Jan 11, 2016
1 parent 887eace commit 751569a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/org/traccar/database/PermissionsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class PermissionsManager {

private final Map<Long, Set<Long>> permissions = new HashMap<>();

private Set<Long> getNotNull(long userId) {
private Set<Long> getPermissions(long userId) {
if (!permissions.containsKey(userId)) {
permissions.put(userId, new HashSet<Long>());
}
Expand All @@ -57,7 +57,7 @@ public final void refresh() {
users.put(user.getId(), user);
}
for (Permission permission : dataManager.getPermissions()) {
getNotNull(permission.getUserId()).add(permission.getDeviceId());
getPermissions(permission.getUserId()).add(permission.getDeviceId());
}
} catch (SQLException error) {
Log.warning(error);
Expand All @@ -81,11 +81,11 @@ public void checkUser(long userId, long otherUserId) throws SecurityException {
}

public Collection<Long> allowedDevices(long userId) {
return getNotNull(userId);
return getPermissions(userId);
}

public void checkDevice(long userId, long deviceId) throws SecurityException {
if (!getNotNull(userId).contains(deviceId)) {
if (!getPermissions(userId).contains(deviceId)) {
throw new SecurityException("Device access denied");
}
}
Expand Down

0 comments on commit 751569a

Please sign in to comment.