|
|
|
@ -31,7 +31,7 @@ public class CustomerUserPermissions extends AbstractPermissions { |
|
|
|
|
|
|
|
public CustomerUserPermissions() { |
|
|
|
super(); |
|
|
|
put(Resource.ALARM, TenantAdminPermissions.tenantEntityPermissionChecker); |
|
|
|
put(Resource.ALARM, customerAlarmPermissionChecker); |
|
|
|
put(Resource.ASSET, customerEntityPermissionChecker); |
|
|
|
put(Resource.DEVICE, customerEntityPermissionChecker); |
|
|
|
put(Resource.CUSTOMER, customerPermissionChecker); |
|
|
|
@ -44,6 +44,19 @@ public class CustomerUserPermissions extends AbstractPermissions { |
|
|
|
put(Resource.RPC, rpcPermissionChecker); |
|
|
|
} |
|
|
|
|
|
|
|
private static final PermissionChecker customerAlarmPermissionChecker = new PermissionChecker() { |
|
|
|
@Override |
|
|
|
public boolean hasPermission(SecurityUser user, Operation operation, EntityId entityId, HasTenantId entity) { |
|
|
|
if (!user.getTenantId().equals(entity.getTenantId())) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
if (!(entity instanceof HasCustomerId)) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
return user.getCustomerId().equals(((HasCustomerId) entity).getCustomerId()); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
private static final PermissionChecker customerEntityPermissionChecker = |
|
|
|
new PermissionChecker.GenericPermissionChecker(Operation.READ, Operation.READ_CREDENTIALS, |
|
|
|
Operation.READ_ATTRIBUTES, Operation.READ_TELEMETRY, Operation.RPC_CALL, Operation.CLAIM_DEVICES, |
|
|
|
|