Adding group permissions validation for operations

4.x.x
Rasika Perera 9 years ago
parent 5c680b3f65
commit 18edc21a04

@ -23,6 +23,7 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroupConstants;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
@ -88,7 +89,8 @@ public class OperationManagerImpl implements OperationManager {
authorizedDeviceList = deviceIds; authorizedDeviceList = deviceIds;
} else { } else {
authorizedDeviceList = DeviceManagementDataHolder.getInstance(). authorizedDeviceList = DeviceManagementDataHolder.getInstance().
getDeviceAccessAuthorizationService().isUserAuthorized(deviceIds).getAuthorizedDevices(); getDeviceAccessAuthorizationService().isUserAuthorized(deviceIds, DeviceGroupConstants.
Permissions.DEFAULT_OPERATOR_PERMISSIONS).getAuthorizedDevices();
} }
if (authorizedDeviceList.size() > 0) { if (authorizedDeviceList.size() > 0) {
try { try {
@ -146,7 +148,7 @@ public class OperationManagerImpl implements OperationManager {
List<Operation> operations = new ArrayList<>(); List<Operation> operations = new ArrayList<>();
try { try {
boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService(). boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
isUserAuthorized(deviceId); isUserAuthorized(deviceId, DeviceGroupConstants.Permissions.DEFAULT_OPERATOR_PERMISSIONS);
if (isUserAuthorized) { if (isUserAuthorized) {
try { try {
try { try {
@ -202,7 +204,7 @@ public class OperationManagerImpl implements OperationManager {
List<Operation> operations = new ArrayList<>(); List<Operation> operations = new ArrayList<>();
try { try {
boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService(). boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
isUserAuthorized(deviceId); isUserAuthorized(deviceId, DeviceGroupConstants.Permissions.DEFAULT_OPERATOR_PERMISSIONS);
if (isUserAuthorized) { if (isUserAuthorized) {
try { try {
try { try {
@ -266,7 +268,7 @@ public class OperationManagerImpl implements OperationManager {
List<org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation> dtoOperationList = new ArrayList<>(); List<org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation> dtoOperationList = new ArrayList<>();
try { try {
boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService(). boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
isUserAuthorized(deviceId); isUserAuthorized(deviceId, DeviceGroupConstants.Permissions.DEFAULT_OPERATOR_PERMISSIONS);
if (isUserAuthorized) { if (isUserAuthorized) {
try { try {
try { try {
@ -330,7 +332,7 @@ public class OperationManagerImpl implements OperationManager {
int enrolmentId; int enrolmentId;
try { try {
boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService(). boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
isUserAuthorized(deviceId); isUserAuthorized(deviceId, DeviceGroupConstants.Permissions.DEFAULT_OPERATOR_PERMISSIONS);
if (isUserAuthorized) { if (isUserAuthorized) {
try { try {
try { try {
@ -400,7 +402,7 @@ public class OperationManagerImpl implements OperationManager {
int enrolmentId; int enrolmentId;
try { try {
boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService(). boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
isUserAuthorized(deviceId); isUserAuthorized(deviceId, DeviceGroupConstants.Permissions.DEFAULT_OPERATOR_PERMISSIONS);
if (isUserAuthorized) { if (isUserAuthorized) {
try { try {
try { try {
@ -480,7 +482,7 @@ public class OperationManagerImpl implements OperationManager {
} }
try { try {
boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService(). boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
isUserAuthorized(deviceId); isUserAuthorized(deviceId, DeviceGroupConstants.Permissions.DEFAULT_OPERATOR_PERMISSIONS);
if (isUserAuthorized) { if (isUserAuthorized) {
try { try {
try { try {
@ -554,7 +556,7 @@ public class OperationManagerImpl implements OperationManager {
int enrolmentId; int enrolmentId;
try { try {
boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService(). boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
isUserAuthorized(deviceId); isUserAuthorized(deviceId, DeviceGroupConstants.Permissions.DEFAULT_OPERATOR_PERMISSIONS);
if (isUserAuthorized) { if (isUserAuthorized) {
try { try {
try { try {

Loading…
Cancel
Save