mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Added logic to skip device authorization for policy operations
This commit is contained in:
parent
6b9dc0d6a5
commit
f0471203e7
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<DeviceIdentifier> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user