merge-requests/4/head
Dileesha Rajapakse 9 years ago
commit 8bd9295f81

@ -17,6 +17,8 @@
*/ */
package org.wso2.carbon.device.mgt.core; package org.wso2.carbon.device.mgt.core;
import org.wso2.carbon.device.mgt.core.operation.mgt.PolicyOperation;
public final class DeviceManagementConstants { public final class DeviceManagementConstants {
public static final class Common { 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 ENROL_NOTIFICATION_TYPE = "enrol";
public static final String USER_REGISTRATION_NOTIFICATION_TYPE = "userRegistration"; 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;
}
} }

@ -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.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;
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.DeviceDAO;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
@ -83,7 +84,7 @@ public class OperationManagerImpl implements OperationManager {
} }
try { try {
List<DeviceIdentifier> authorizedDeviceList; List<DeviceIdentifier> authorizedDeviceList;
if (operation != null && PolicyOperation.POLICY_OPERATION_CODE.equals(operation.getCode())) { if (operation != null && isAuthenticationSkippedOperation(operation)) {
authorizedDeviceList = deviceIds; authorizedDeviceList = deviceIds;
} else { } else {
authorizedDeviceList = DeviceManagementDataHolder.getInstance(). authorizedDeviceList = DeviceManagementDataHolder.getInstance().
@ -618,4 +619,20 @@ public class OperationManagerImpl implements OperationManager {
return CarbonContext.getThreadLocalCarbonContext().getUsername(); 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;
}
} }

Loading…
Cancel
Save