diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java index d5554fbf53f..1b0cf9ee103 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java @@ -17,6 +17,8 @@ */ package org.wso2.carbon.device.mgt.core; +import org.wso2.carbon.device.mgt.core.operation.mgt.PolicyOperation; + public final class DeviceManagementConstants { public static final class Common { @@ -47,4 +49,13 @@ public final class DeviceManagementConstants { public static final String ENROL_NOTIFICATION_TYPE = "enrol"; public static final String USER_REGISTRATION_NOTIFICATION_TYPE = "userRegistration"; } + + public static final class AuthorizationSkippedOperationCodes { + private AuthorizationSkippedOperationCodes() { + throw new AssertionError(); + } + + public static final String MONITOR_OPERATION_CODE = "MONITOR"; + public static final String POLICY_OPERATION_CODE = PolicyOperation.POLICY_OPERATION_CODE; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java index 0337a0a0795..3238fcdb322 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -28,6 +28,7 @@ import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorization 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.OperationManager; +import org.wso2.carbon.device.mgt.core.DeviceManagementConstants; import org.wso2.carbon.device.mgt.core.dao.DeviceDAO; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; @@ -83,7 +84,7 @@ public class OperationManagerImpl implements OperationManager { } try { List authorizedDeviceList; - if (operation != null && PolicyOperation.POLICY_OPERATION_CODE.equals(operation.getCode())) { + if (operation != null && isAuthenticationSkippedOperation(operation)) { authorizedDeviceList = deviceIds; } else { authorizedDeviceList = DeviceManagementDataHolder.getInstance(). @@ -618,4 +619,20 @@ public class OperationManagerImpl implements OperationManager { return CarbonContext.getThreadLocalCarbonContext().getUsername(); } + private boolean isAuthenticationSkippedOperation(Operation operation) { + boolean status; + switch (operation.getCode()) { + case DeviceManagementConstants.AuthorizationSkippedOperationCodes.POLICY_OPERATION_CODE : + status = true; + break; + case DeviceManagementConstants.AuthorizationSkippedOperationCodes.MONITOR_OPERATION_CODE : + status = true; + break; + default: + status = false; + } + + return status; + } + }