diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/authorization/DeviceAccessAuthorizationServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/authorization/DeviceAccessAuthorizationServiceImpl.java index d3d3ed09c00..4707bcdd4c9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/authorization/DeviceAccessAuthorizationServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/authorization/DeviceAccessAuthorizationServiceImpl.java @@ -38,6 +38,7 @@ import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -186,8 +187,12 @@ public class DeviceAccessAuthorizationServiceImpl implements DeviceAccessAuthori DeviceManagementDataHolder.getInstance().getGroupManagementProviderService() .getGroups(deviceIdentifier); for (DeviceGroup group : authorizedGroups) { - if (groupsWithDevice.contains(group)) { - return true; + Iterator groupsWithDeviceIterator = groupsWithDevice.iterator(); + while (groupsWithDeviceIterator.hasNext()) { + DeviceGroup deviceGroup = groupsWithDeviceIterator.next(); + if (deviceGroup.getId() == group.getId()) { + return true; + } } } return false;