diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml index a1423e285e..434c4a6775 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml @@ -22,13 +22,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.annotations - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT bundle WSO2 Carbon - API Management Annotations WSO2 Carbon - API Management Custom Annotation Module diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml index 3c320381bb..2ee4c6430e 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml @@ -21,12 +21,12 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT org.wso2.carbon.apimgt.application.extension.api war WSO2 Carbon - API Application Management API diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml index 405ffaf903..6e4284f173 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml @@ -22,12 +22,12 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT org.wso2.carbon.apimgt.application.extension bundle WSO2 Carbon - API Application Management diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml index e8f4b4173a..3c3f3bbedb 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml @@ -21,13 +21,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.handlers - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT bundle WSO2 Carbon - API Security Handler Component WSO2 Carbon - API Management Security Handler Module diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml index 3c9db88b63..38746a00d4 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml @@ -22,13 +22,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.webapp.publisher - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT bundle WSO2 Carbon - API Management Webapp Publisher WSO2 Carbon - API Management Webapp Publisher diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index c13a83faea..1211393c47 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../../pom.xml 4.0.0 apimgt-extensions - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT pom WSO2 Carbon - API Management Extensions Component http://wso2.org diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml index 227be0c61e..2d6af3f10c 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml index 3c2e4bd255..39f83e6a14 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml index 33947cc973..5ba6836fa1 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml @@ -21,13 +21,13 @@ org.wso2.carbon.devicemgt certificate-mgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.certificate.mgt.core - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT bundle WSO2 Carbon - Certificate Management Core WSO2 Carbon - Certificate Management Core diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 520b63f674..30b0186238 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt certificate-mgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT pom WSO2 Carbon - Certificate Management Component http://wso2.org diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml index 545377a929..0fdf348315 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/pom.xml index 8fc1785bce..ea9f8c173f 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 35e32e2219..0ac6ea57a3 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index f4e3a2d21f..fb4e62bb66 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index c944f3716f..8f3b451be7 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml index 8f3729bc54..4f96da0d4a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml @@ -3,7 +3,7 @@ org.wso2.carbon.devicemgt device-mgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml @@ -62,6 +62,7 @@ org.wso2.carbon.device.mgt.analytics.dashboard, + org.wso2.carbon.device.mgt.analytics.dashboard.util, org.wso2.carbon.device.mgt.analytics.dashboard.exception, org.wso2.carbon.device.mgt.analytics.dashboard.bean diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/GadgetDataService.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/GadgetDataService.java index c2b1b55a75..5a251fc9c2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/GadgetDataService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/GadgetDataService.java @@ -47,7 +47,7 @@ public interface GadgetDataService { * executing SQL query and retrieving data. */ @SuppressWarnings("unused") - DeviceCountByGroup getDeviceCount(ExtendedFilterSet extendedFilterSet) + DeviceCountByGroup getDeviceCount(ExtendedFilterSet extendedFilterSet, String userName) throws InvalidPotentialVulnerabilityValueException, DataAccessLayerException; /** @@ -64,7 +64,7 @@ public interface GadgetDataService { * executing SQL query and retrieving data. */ @SuppressWarnings("unused") - DeviceCountByGroup getFeatureNonCompliantDeviceCount(String featureCode, BasicFilterSet basicFilterSet) + DeviceCountByGroup getFeatureNonCompliantDeviceCount(String featureCode, BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, DataAccessLayerException; /** @@ -74,7 +74,7 @@ public interface GadgetDataService { * executing SQL query and retrieving data. */ @SuppressWarnings("unused") - DeviceCountByGroup getTotalDeviceCount() throws DataAccessLayerException; + DeviceCountByGroup getTotalDeviceCount(String userName) throws DataAccessLayerException; /** * This method is used to get device counts classified by connectivity statuses. @@ -83,7 +83,7 @@ public interface GadgetDataService { * executing SQL query and retrieving data. */ @SuppressWarnings("unused") - List getDeviceCountsByConnectivityStatuses() throws DataAccessLayerException; + List getDeviceCountsByConnectivityStatuses(String userName) throws DataAccessLayerException; /** * This method is used to get device counts classified by potential vulnerabilities. @@ -92,7 +92,7 @@ public interface GadgetDataService { * executing SQL query and retrieving data. */ @SuppressWarnings("unused") - List getDeviceCountsByPotentialVulnerabilities() throws DataAccessLayerException; + List getDeviceCountsByPotentialVulnerabilities(String userName) throws DataAccessLayerException; /** * This method is used to get non-compliant device counts classified by individual features. @@ -105,7 +105,7 @@ public interface GadgetDataService { * executing SQL query and retrieving data. */ @SuppressWarnings("unused") - PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount) throws + PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount, String userName) throws InvalidStartIndexValueException, InvalidResultCountValueException, DataAccessLayerException; /** @@ -122,7 +122,7 @@ public interface GadgetDataService { * executing SQL query and retrieving data. */ @SuppressWarnings("unused") - List getDeviceCountsByPlatforms(ExtendedFilterSet extendedFilterSet) + List getDeviceCountsByPlatforms(ExtendedFilterSet extendedFilterSet, String userName) throws InvalidPotentialVulnerabilityValueException, DataAccessLayerException; /** @@ -139,7 +139,7 @@ public interface GadgetDataService { */ @SuppressWarnings("unused") List getFeatureNonCompliantDeviceCountsByPlatforms(String featureCode, - BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException, + BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, DataAccessLayerException; /** @@ -156,7 +156,7 @@ public interface GadgetDataService { * executing SQL query and retrieving data. */ @SuppressWarnings("unused") - List getDeviceCountsByOwnershipTypes(ExtendedFilterSet extendedFilterSet) + List getDeviceCountsByOwnershipTypes(ExtendedFilterSet extendedFilterSet, String userName) throws InvalidPotentialVulnerabilityValueException, DataAccessLayerException; /** @@ -174,7 +174,7 @@ public interface GadgetDataService { */ @SuppressWarnings("unused") List getFeatureNonCompliantDeviceCountsByOwnershipTypes(String featureCode, - BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException, + BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, DataAccessLayerException; /** @@ -196,7 +196,7 @@ public interface GadgetDataService { * @throws InvalidResultCountValueException This can occur if resultCount value is lesser than its minimum (5). */ @SuppressWarnings("unused") - PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount) + PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount, String userName) throws InvalidPotentialVulnerabilityValueException, DataAccessLayerException, InvalidStartIndexValueException, InvalidResultCountValueException; @@ -220,7 +220,7 @@ public interface GadgetDataService { */ @SuppressWarnings("unused") PaginationResult getFeatureNonCompliantDevicesWithDetails(String featureCode, BasicFilterSet basicFilterSet, - int startIndex, int resultCount) throws InvalidFeatureCodeValueException, + int startIndex, int resultCount, String userName) throws InvalidFeatureCodeValueException, DataAccessLayerException, InvalidStartIndexValueException, InvalidResultCountValueException; @@ -238,7 +238,7 @@ public interface GadgetDataService { * executing SQL query and retrieving data. */ @SuppressWarnings("unused") - List getDevicesWithDetails(ExtendedFilterSet extendedFilterSet) + List getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, String userName) throws InvalidPotentialVulnerabilityValueException, DataAccessLayerException; /** @@ -255,7 +255,7 @@ public interface GadgetDataService { */ @SuppressWarnings("unused") List getFeatureNonCompliantDevicesWithDetails(String featureCode, - BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException, + BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, DataAccessLayerException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/AbstractGadgetDataServiceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/AbstractGadgetDataServiceDAO.java index 9781512064..4cad3f2201 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/AbstractGadgetDataServiceDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/AbstractGadgetDataServiceDAO.java @@ -18,13 +18,16 @@ package org.wso2.carbon.device.mgt.analytics.dashboard.dao; -import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.analytics.dashboard.bean.BasicFilterSet; import org.wso2.carbon.device.mgt.analytics.dashboard.bean.DeviceWithDetails; import org.wso2.carbon.device.mgt.analytics.dashboard.bean.DeviceCountByGroup; import org.wso2.carbon.device.mgt.analytics.dashboard.bean.ExtendedFilterSet; import org.wso2.carbon.device.mgt.analytics.dashboard.exception.InvalidFeatureCodeValueException; import org.wso2.carbon.device.mgt.analytics.dashboard.exception.InvalidPotentialVulnerabilityValueException; +import org.wso2.carbon.device.mgt.analytics.dashboard.util.APIUtil; +import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; import java.sql.Connection; @@ -36,40 +39,39 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import static org.wso2.carbon.device.mgt.analytics.dashboard.util.APIUtil.getAuthenticatedUser; +import static org.wso2.carbon.device.mgt.analytics.dashboard.util.APIUtil.getAuthenticatedUserTenantDomainId; + public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceDAO { + private static final Log log = LogFactory.getLog(AbstractGadgetDataServiceDAO.class); @Override - public DeviceCountByGroup getTotalDeviceCount() throws SQLException { + public DeviceCountByGroup getTotalDeviceCount(String userName) throws SQLException { int totalDeviceCount; try { - totalDeviceCount = this.getFilteredDeviceCount(null); + totalDeviceCount = this.getFilteredDeviceCount(null, userName); } catch (InvalidPotentialVulnerabilityValueException e) { throw new AssertionError(e); } - DeviceCountByGroup deviceCountByGroup = new DeviceCountByGroup(); deviceCountByGroup.setGroup("total"); deviceCountByGroup.setDisplayNameForGroup("Total"); deviceCountByGroup.setDeviceCount(totalDeviceCount); - return deviceCountByGroup; } @Override - public DeviceCountByGroup getDeviceCount(ExtendedFilterSet extendedFilterSet) + public DeviceCountByGroup getDeviceCount(ExtendedFilterSet extendedFilterSet, String userName) throws InvalidPotentialVulnerabilityValueException, SQLException { - - int filteredDeviceCount = this.getFilteredDeviceCount(extendedFilterSet); - + int filteredDeviceCount = this.getFilteredDeviceCount(extendedFilterSet, userName); DeviceCountByGroup deviceCountByGroup = new DeviceCountByGroup(); deviceCountByGroup.setGroup("filtered"); deviceCountByGroup.setDisplayNameForGroup("Filtered"); deviceCountByGroup.setDeviceCount(filteredDeviceCount); - return deviceCountByGroup; } - private int getFilteredDeviceCount(ExtendedFilterSet extendedFilterSet) + private int getFilteredDeviceCount(ExtendedFilterSet extendedFilterSet, String userName) throws InvalidPotentialVulnerabilityValueException, SQLException { Map filters = this.extractDatabaseFiltersFromBean(extendedFilterSet); @@ -77,24 +79,37 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD Connection con; PreparedStatement stmt = null; ResultSet rs = null; - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + int tenantId = getAuthenticatedUserTenantDomainId(); int filteredDeviceCount = 0; try { + String sql; con = this.getConnection(); - String sql = "SELECT COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + - GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " WHERE TENANT_ID = ?"; + if (APIUtil.isDeviceAdminUser()) { + sql = "SELECT COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + + GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " POLICY__INFO WHERE TENANT_ID = ?"; + } else { + sql = "SELECT COUNT(POLICY__INFO.DEVICE_ID) AS DEVICE_COUNT FROM " + + GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " POLICY__INFO INNER JOIN" + + " DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = POLICY__INFO.DEVICE_ID AND " + + " POLICY__INFO.TENANT_ID = ? AND ENR_DB.OWNER = ? "; + } // appending filters to support advanced filtering options // [1] appending filter columns if (filters != null && filters.size() > 0) { for (String column : filters.keySet()) { - sql = sql + " AND " + column + " = ?"; + sql = sql + " AND POLICY__INFO." + column + " = ? "; } } - stmt = con.prepareStatement(sql); // [2] appending filter column values, if exist + stmt = con.prepareStatement(sql); stmt.setInt(1, tenantId); + int index = 2; + if (!APIUtil.isDeviceAdminUser()) { + stmt.setString(2, userName); + index = 3; + } if (filters != null && filters.values().size() > 0) { - int i = 2; + int i = index; for (Object value : filters.values()) { if (value instanceof Integer) { stmt.setInt(i, (Integer) value); @@ -110,6 +125,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD while (rs.next()) { filteredDeviceCount = rs.getInt("DEVICE_COUNT"); } + } catch (DeviceAccessAuthorizationException e) { + String msg = "Error occurred while checking device access authorization"; + log.error(msg, e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, rs); } @@ -118,7 +136,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD @Override public DeviceCountByGroup getFeatureNonCompliantDeviceCount(String featureCode, - BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException, SQLException { + BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, SQLException { if (featureCode == null || featureCode.isEmpty()) { throw new InvalidFeatureCodeValueException("Feature code should not be either null or empty."); @@ -129,25 +147,39 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD Connection con; PreparedStatement stmt = null; ResultSet rs = null; - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + int tenantId = getAuthenticatedUserTenantDomainId(); int filteredDeviceCount = 0; try { + String sql; con = this.getConnection(); - String sql = "SELECT COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + - GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 + " WHERE TENANT_ID = ? AND FEATURE_CODE = ?"; + if (APIUtil.isDeviceAdminUser()) { + sql = "SELECT COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + + GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 + " FEATURE_INFO WHERE TENANT_ID =" + + " ? AND FEATURE_CODE = ?"; + } else { + sql = "SELECT COUNT(FEATURE_INFO.DEVICE_ID) AS DEVICE_COUNT FROM " + + GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 + " FEATURE_INFO INNER JOIN " + + "DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = FEATURE_INFO.DEVICE_ID AND " + + "FEATURE_INFO.TENANT_ID = ? AND FEATURE_INFO.FEATURE_CODE = ? AND ENR_DB.OWNER = ? "; + } // appending filters to support advanced filtering options // [1] appending filter columns if (filters != null && filters.size() > 0) { for (String column : filters.keySet()) { - sql = sql + " AND " + column + " = ?"; + sql = sql + " AND FEATURE_INFO." + column + " = ?"; } } stmt = con.prepareStatement(sql); // [2] appending filter column values, if exist stmt.setInt(1, tenantId); stmt.setString(2, featureCode); + int index = 3; + if (!APIUtil.isDeviceAdminUser()) { + stmt.setString(3, userName); + index = 4; + } if (filters != null && filters.values().size() > 0) { - int i = 3; + int i = index; for (Object value : filters.values()) { if (value instanceof Integer) { stmt.setInt(i, (Integer) value); @@ -163,6 +195,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD while (rs.next()) { filteredDeviceCount = rs.getInt("DEVICE_COUNT"); } + } catch (DeviceAccessAuthorizationException e) { + String msg = "Error occurred while checking device access authorization"; + log.error(msg, e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, rs); } @@ -176,20 +211,32 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD } @Override - public List getDeviceCountsByConnectivityStatuses() throws SQLException { + public List getDeviceCountsByConnectivityStatuses(String userName) throws SQLException { Connection con; PreparedStatement stmt = null; ResultSet rs = null; - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + int tenantId = getAuthenticatedUserTenantDomainId(); List deviceCountsByConnectivityStatuses = new ArrayList<>(); try { + String sql; con = this.getConnection(); - String sql = "SELECT CONNECTIVITY_STATUS, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + - GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + - " WHERE TENANT_ID = ? GROUP BY CONNECTIVITY_STATUS"; + if (APIUtil.isDeviceAdminUser()) { + sql = "SELECT CONNECTIVITY_STATUS, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + + GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + + " WHERE TENANT_ID = ? GROUP BY CONNECTIVITY_STATUS"; + } else { + sql = "SELECT POLICY__INFO.CONNECTIVITY_STATUS AS CONNECTIVITY_STATUS, " + + "COUNT(POLICY__INFO.DEVICE_ID) AS DEVICE_COUNT FROM " + + GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " POLICY__INFO " + + "INNER JOIN DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = POLICY__INFO.DEVICE_ID " + + " AND POLICY__INFO.TENANT_ID = ? AND ENR_DB.OWNER = ? GROUP BY POLICY__INFO.CONNECTIVITY_STATUS"; + } stmt = con.prepareStatement(sql); // [2] appending filter column values, if exist stmt.setInt(1, tenantId); + if(!APIUtil.isDeviceAdminUser()){ + stmt.setString(2, userName); + } // executing query rs = stmt.executeQuery(); // fetching query results @@ -201,6 +248,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD deviceCountByConnectivityStatus.setDeviceCount(rs.getInt("DEVICE_COUNT")); deviceCountsByConnectivityStatuses.add(deviceCountByConnectivityStatus); } + } catch (DeviceAccessAuthorizationException e) { + String msg = "Error occurred while checking device access authorization"; + log.error(msg, e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, rs); } @@ -208,7 +258,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD } @Override - public List getDeviceCountsByPotentialVulnerabilities() throws SQLException { + public List getDeviceCountsByPotentialVulnerabilities(String userName) throws SQLException { // getting non-compliant device count DeviceCountByGroup nonCompliantDeviceCount = new DeviceCountByGroup(); nonCompliantDeviceCount.setGroup(GadgetDataServiceDAOConstants.PotentialVulnerability.NON_COMPLIANT); @@ -230,10 +280,10 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD private int getNonCompliantDeviceCount() throws SQLException { ExtendedFilterSet extendedFilterSet = new ExtendedFilterSet(); - extendedFilterSet.setPotentialVulnerability(GadgetDataServiceDAOConstants. - PotentialVulnerability.NON_COMPLIANT); + extendedFilterSet.setPotentialVulnerability(GadgetDataServiceDAOConstants.PotentialVulnerability.NON_COMPLIANT); try { - return this.getFilteredDeviceCount(extendedFilterSet); + String userName = getAuthenticatedUser(); + return this.getFilteredDeviceCount(extendedFilterSet, userName); } catch (InvalidPotentialVulnerabilityValueException e) { throw new AssertionError(e); } @@ -244,14 +294,15 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD extendedFilterSet.setPotentialVulnerability(GadgetDataServiceDAOConstants. PotentialVulnerability.UNMONITORED); try { - return this.getFilteredDeviceCount(extendedFilterSet); + String userName = getAuthenticatedUser(); + return this.getFilteredDeviceCount(extendedFilterSet, userName); } catch (InvalidPotentialVulnerabilityValueException e) { throw new AssertionError(e); } } @Override - public List getDeviceCountsByPlatforms(ExtendedFilterSet extendedFilterSet) + public List getDeviceCountsByPlatforms(ExtendedFilterSet extendedFilterSet, String userName) throws InvalidPotentialVulnerabilityValueException, SQLException { Map filters = this.extractDatabaseFiltersFromBean(extendedFilterSet); @@ -259,7 +310,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD Connection con; PreparedStatement stmt = null; ResultSet rs = null; - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + int tenantId = getAuthenticatedUserTenantDomainId(); List filteredDeviceCountsByPlatforms = new ArrayList<>(); try { con = this.getConnection(); @@ -268,16 +319,30 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD // [1] appending filter columns, if exist if (filters != null && filters.size() > 0) { for (String column : filters.keySet()) { - advancedSqlFiltering = advancedSqlFiltering + "AND " + column + " = ? "; + advancedSqlFiltering = advancedSqlFiltering + " AND POLICY__INFO." + column + " = ? "; } } - sql = "SELECT PLATFORM, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants. - DatabaseView.DEVICES_VIEW_1 + " WHERE TENANT_ID = ? " + advancedSqlFiltering + "GROUP BY PLATFORM"; + if (APIUtil.isDeviceAdminUser()) { + sql = "SELECT PLATFORM, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants. + DatabaseView.DEVICES_VIEW_1 + " POLICY__INFO WHERE TENANT_ID = ? " + advancedSqlFiltering + + " GROUP BY PLATFORM"; + } else { + sql = "SELECT POLICY__INFO.PLATFORM, COUNT(POLICY__INFO.DEVICE_ID) AS DEVICE_COUNT FROM " + + GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " POLICY__INFO INNER JOIN " + + "DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = POLICY__INFO.DEVICE_ID AND " + + "POLICY__INFO.TENANT_ID = ? AND ENR_DB.OWNER = ? " + advancedSqlFiltering + " GROUP BY " + + "POLICY__INFO.PLATFORM"; + } stmt = con.prepareStatement(sql); // [2] appending filter column values, if exist stmt.setInt(1, tenantId); + int index = 2; + if (!APIUtil.isDeviceAdminUser()) { + stmt.setString(2, userName); + index = 3; + } if (filters != null && filters.values().size() > 0) { - int i = 2; + int i = index; for (Object value : filters.values()) { if (value instanceof Integer) { stmt.setInt(i, (Integer) value); @@ -298,6 +363,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD filteredDeviceCountByPlatform.setDeviceCount(rs.getInt("DEVICE_COUNT")); filteredDeviceCountsByPlatforms.add(filteredDeviceCountByPlatform); } + } catch (DeviceAccessAuthorizationException e) { + String msg = "Error occurred while checking device access authorization"; + log.error(msg, e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, rs); } @@ -307,7 +375,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD @Override public List getFeatureNonCompliantDeviceCountsByPlatforms(String featureCode, - BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException, SQLException { + BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, SQLException { if (featureCode == null || featureCode.isEmpty()) { throw new InvalidFeatureCodeValueException("Feature code should not be either null or empty."); @@ -318,7 +386,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD Connection con; PreparedStatement stmt = null; ResultSet rs = null; - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + int tenantId = getAuthenticatedUserTenantDomainId(); List filteredDeviceCountsByPlatforms = new ArrayList<>(); try { con = this.getConnection(); @@ -327,18 +395,32 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD // [1] appending filter columns, if exist if (filters != null && filters.size() > 0) { for (String column : filters.keySet()) { - advancedSqlFiltering = advancedSqlFiltering + "AND " + column + " = ? "; + advancedSqlFiltering = advancedSqlFiltering + " AND FEATURE_INFO." + column + " = ? "; } } - sql = "SELECT PLATFORM, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants. - DatabaseView.DEVICES_VIEW_2 + " WHERE TENANT_ID = ? AND FEATURE_CODE = ? " + - advancedSqlFiltering + "GROUP BY PLATFORM"; + if (APIUtil.isDeviceAdminUser()) { + sql = "SELECT PLATFORM, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants. + DatabaseView.DEVICES_VIEW_2 + " FEATURE_INFO WHERE TENANT_ID = ? AND FEATURE_CODE = ? " + + advancedSqlFiltering + " GROUP BY PLATFORM"; + } else { + sql = "SELECT FEATURE_INFO.PLATFORM, COUNT(FEATURE_INFO.DEVICE_ID) AS DEVICE_COUNT FROM " + + GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 + " FEATURE_INFO INNER JOIN " + + "DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = FEATURE_INFO.DEVICE_ID " + + " AND FEATURE_INFO.TENANT_ID = ? AND FEATURE_INFO.FEATURE_CODE = ? AND ENR_DB.OWNER = ? " + + advancedSqlFiltering + " GROUP BY FEATURE_INFO.PLATFORM"; + } + stmt = con.prepareStatement(sql); // [2] appending filter column values, if exist stmt.setInt(1, tenantId); stmt.setString(2, featureCode); + int index = 3; + if (!APIUtil.isDeviceAdminUser()) { + stmt.setString(3, userName); + index = 4; + } if (filters != null && filters.values().size() > 0) { - int i = 3; + int i = index; for (Object value : filters.values()) { if (value instanceof Integer) { stmt.setInt(i, (Integer) value); @@ -359,6 +441,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD filteredDeviceCountByPlatform.setDeviceCount(rs.getInt("DEVICE_COUNT")); filteredDeviceCountsByPlatforms.add(filteredDeviceCountByPlatform); } + } catch (DeviceAccessAuthorizationException e) { + String msg = "Error occurred while checking device access authorization"; + log.error(msg, e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, rs); } @@ -366,7 +451,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD } @Override - public List getDeviceCountsByOwnershipTypes(ExtendedFilterSet extendedFilterSet) + public List getDeviceCountsByOwnershipTypes(ExtendedFilterSet extendedFilterSet, String userName) throws InvalidPotentialVulnerabilityValueException, SQLException { Map filters = this.extractDatabaseFiltersFromBean(extendedFilterSet); @@ -374,7 +459,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD Connection con; PreparedStatement stmt = null; ResultSet rs = null; - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + int tenantId = getAuthenticatedUserTenantDomainId(); List filteredDeviceCountsByOwnershipTypes = new ArrayList<>(); try { con = this.getConnection(); @@ -383,17 +468,29 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD // [1] appending filter columns, if exist if (filters != null && filters.size() > 0) { for (String column : filters.keySet()) { - advancedSqlFiltering = advancedSqlFiltering + "AND " + column + " = ? "; + advancedSqlFiltering = advancedSqlFiltering + " AND POLICY__INFO." + column + " = ? "; } } - sql = "SELECT OWNERSHIP, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants. - DatabaseView.DEVICES_VIEW_1 + " WHERE TENANT_ID = ? " + - advancedSqlFiltering + "GROUP BY OWNERSHIP"; + if(APIUtil.isDeviceAdminUser()){ + sql = "SELECT OWNERSHIP, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants. + DatabaseView.DEVICES_VIEW_1 + " POLICY__INFO WHERE TENANT_ID = ? " + + advancedSqlFiltering + "GROUP BY OWNERSHIP"; + }else{ + sql = "SELECT POLICY__INFO.OWNERSHIP, COUNT(POLICY__INFO.DEVICE_ID) AS DEVICE_COUNT FROM " + + GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " POLICY__INFO INNER JOIN " + + "DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = POLICY__INFO.DEVICE_ID AND POLICY__INFO.TENANT_ID" + + " = ? AND ENR_DB.OWNER = ? " + advancedSqlFiltering + " GROUP BY POLICY__INFO.OWNERSHIP"; + } stmt = con.prepareStatement(sql); // [2] appending filter column values, if exist stmt.setInt(1, tenantId); + int index = 2; + if(!APIUtil.isDeviceAdminUser()){ + stmt.setString(2, userName); + index = 3; + } if (filters != null && filters.values().size() > 0) { - int i = 2; + int i = index; for (Object value : filters.values()) { if (value instanceof Integer) { stmt.setInt(i, (Integer) value); @@ -414,6 +511,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD filteredDeviceCountByOwnershipType.setDeviceCount(rs.getInt("DEVICE_COUNT")); filteredDeviceCountsByOwnershipTypes.add(filteredDeviceCountByOwnershipType); } + } catch (DeviceAccessAuthorizationException e) { + String msg = "Error occurred while checking device access authorization"; + log.error(msg, e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, rs); } @@ -423,7 +523,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD @Override public List getFeatureNonCompliantDeviceCountsByOwnershipTypes(String featureCode, - BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException, SQLException { + BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, SQLException { if (featureCode == null || featureCode.isEmpty()) { throw new InvalidFeatureCodeValueException("Feature code should not be either null or empty."); @@ -434,7 +534,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD Connection con; PreparedStatement stmt = null; ResultSet rs = null; - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + int tenantId = getAuthenticatedUserTenantDomainId(); List filteredDeviceCountsByOwnershipTypes = new ArrayList<>(); try { con = this.getConnection(); @@ -443,18 +543,31 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD // [1] appending filter columns, if exist if (filters != null && filters.size() > 0) { for (String column : filters.keySet()) { - advancedSqlFiltering = advancedSqlFiltering + "AND " + column + " = ? "; + advancedSqlFiltering = advancedSqlFiltering + " AND FEATURE_INFO." + column + " = ? "; } } - sql = "SELECT OWNERSHIP, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants. - DatabaseView.DEVICES_VIEW_2 + " WHERE TENANT_ID = ? AND FEATURE_CODE = ? " + - advancedSqlFiltering + "GROUP BY OWNERSHIP"; + if(APIUtil.isDeviceAdminUser()){ + sql = "SELECT OWNERSHIP, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants. + DatabaseView.DEVICES_VIEW_2 + " FEATURE_INFO WHERE TENANT_ID = ? AND FEATURE_CODE = ? " + + advancedSqlFiltering + "GROUP BY OWNERSHIP"; + }else{ + sql = "SELECT FEATURE_INFO.OWNERSHIP, COUNT(FEATURE_INFO.DEVICE_ID) AS DEVICE_COUNT FROM " + + GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 + " FEATURE_INFO INNER JOIN " + + "DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = FEATURE_INFO.DEVICE_ID AND FEATURE_INFO.TENANT_ID " + + "= ? AND FEATURE_INFO.FEATURE_CODE = ? AND ENR_DB.OWNER = ? " + advancedSqlFiltering + + " GROUP BY FEATURE_INFO.OWNERSHIP"; + } stmt = con.prepareStatement(sql); // [2] appending filter column values, if exist stmt.setInt(1, tenantId); stmt.setString(2, featureCode); + int index = 3; + if(!APIUtil.isDeviceAdminUser()){ + stmt.setString(3, userName); + index = 4; + } if (filters != null && filters.values().size() > 0) { - int i = 3; + int i = index; for (Object value : filters.values()) { if (value instanceof Integer) { stmt.setInt(i, (Integer) value); @@ -475,6 +588,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD filteredDeviceCountByOwnershipType.setDeviceCount(rs.getInt("DEVICE_COUNT")); filteredDeviceCountsByOwnershipTypes.add(filteredDeviceCountByOwnershipType); } + } catch (DeviceAccessAuthorizationException e) { + String msg = "Error occurred while checking device access authorization"; + log.error(msg, e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, rs); } @@ -482,7 +598,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD } @Override - public List getDevicesWithDetails(ExtendedFilterSet extendedFilterSet) + public List getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, String userName) throws InvalidPotentialVulnerabilityValueException, SQLException { Map filters = this.extractDatabaseFiltersFromBean(extendedFilterSet); @@ -490,25 +606,38 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD Connection con; PreparedStatement stmt = null; ResultSet rs = null; - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + int tenantId = getAuthenticatedUserTenantDomainId(); List filteredDevicesWithDetails = new ArrayList<>(); try { con = this.getConnection(); String sql; - sql = "SELECT DEVICE_ID, DEVICE_IDENTIFICATION, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM " + - GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " WHERE TENANT_ID = ?"; + if(APIUtil.isDeviceAdminUser()){ + sql = "SELECT DEVICE_ID, DEVICE_IDENTIFICATION, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM " + + GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " POLICY__INFO WHERE TENANT_ID = ?"; + }else{ + sql = "SELECT POLICY__INFO.DEVICE_ID, POLICY__INFO.DEVICE_IDENTIFICATION, POLICY__INFO.PLATFORM," + + " POLICY__INFO.OWNERSHIP, POLICY__INFO.CONNECTIVITY_STATUS FROM "+ + GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1+" POLICY__INFO INNER JOIN " + + "DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = POLICY__INFO.DEVICE_ID AND " + + "POLICY__INFO.TENANT_ID = ? AND ENR_DB.OWNER = ?"; + } // appending filters to support advanced filtering options // [1] appending filter columns, if exist if (filters != null && filters.size() > 0) { for (String column : filters.keySet()) { - sql = sql + " AND " + column + " = ?"; + sql = sql + " AND POLICY__INFO." + column + " = ?"; } } stmt = con.prepareStatement(sql); // [2] appending filter column values, if exist stmt.setInt(1, tenantId); + int index = 2; + if(!APIUtil.isDeviceAdminUser()){ + stmt.setString(2, userName); + index = 3; + } if (filters != null && filters.values().size() > 0) { - int i = 2; + int i = index; for (Object value : filters.values()) { if (value instanceof Integer) { stmt.setInt(i, (Integer) value); @@ -531,6 +660,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD filteredDeviceWithDetails.setConnectivityStatus(rs.getString("CONNECTIVITY_STATUS")); filteredDevicesWithDetails.add(filteredDeviceWithDetails); } + } catch (DeviceAccessAuthorizationException e) { + String msg = "Error occurred while checking device access authorization"; + log.error(msg, e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, rs); } @@ -539,7 +671,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD @Override public List getFeatureNonCompliantDevicesWithDetails(String featureCode, - BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException, SQLException { + BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, SQLException { if (featureCode == null || featureCode.isEmpty()) { throw new InvalidFeatureCodeValueException("Feature code should not be either null or empty."); @@ -550,27 +682,40 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD Connection con; PreparedStatement stmt = null; ResultSet rs = null; - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + int tenantId = getAuthenticatedUserTenantDomainId(); List filteredDevicesWithDetails = new ArrayList<>(); try { con = this.getConnection(); String sql; - sql = "SELECT DEVICE_ID, DEVICE_IDENTIFICATION, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM " + - GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 + - " WHERE TENANT_ID = ? AND FEATURE_CODE = ?"; + if(APIUtil.isDeviceAdminUser()){ + sql = "SELECT DEVICE_ID, DEVICE_IDENTIFICATION, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM " + + GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 + + " WHERE TENANT_ID = ? AND FEATURE_CODE = ?"; + }else{ + sql = "SELECT FEATURE_INFO.DEVICE_ID, FEATURE_INFO.DEVICE_IDENTIFICATION, FEATURE_INFO.PLATFORM, " + + "FEATURE_INFO.OWNERSHIP, FEATURE_INFO.CONNECTIVITY_STATUS FROM "+ + GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2+" FEATURE_INFO INNER JOIN " + + "DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = FEATURE_INFO.DEVICE_ID AND FEATURE_INFO.TENANT_ID" + + " = ? AND FEATURE_INFO.FEATURE_CODE = ? AND ENR_DB.OWNER = ? "; + } // appending filters to support advanced filtering options // [1] appending filter columns, if exist if (filters != null && filters.size() > 0) { for (String column : filters.keySet()) { - sql = sql + " AND " + column + " = ?"; + sql = sql + " AND FEATURE_INFO." + column + " = ?"; } } stmt = con.prepareStatement(sql); // [2] appending filter column values, if exist stmt.setInt(1, tenantId); stmt.setString(2, featureCode); + int index = 3; + if(!APIUtil.isDeviceAdminUser()){ + stmt.setString(3, userName); + index = 4; + } if (filters != null && filters.values().size() > 0) { - int i = 3; + int i = index; for (Object value : filters.values()) { if (value instanceof Integer) { stmt.setInt(i, (Integer) value); @@ -593,6 +738,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD filteredDeviceWithDetails.setConnectivityStatus(rs.getString("CONNECTIVITY_STATUS")); filteredDevicesWithDetails.add(filteredDeviceWithDetails); } + } catch (DeviceAccessAuthorizationException e) { + String msg = "Error occurred while checking device access authorization"; + log.error(msg, e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, rs); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/GadgetDataServiceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/GadgetDataServiceDAO.java index c5c1638fba..0033f19327 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/GadgetDataServiceDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/GadgetDataServiceDAO.java @@ -30,45 +30,45 @@ import java.util.List; public interface GadgetDataServiceDAO { - DeviceCountByGroup getDeviceCount(ExtendedFilterSet extendedFilterSet) + DeviceCountByGroup getDeviceCount(ExtendedFilterSet extendedFilterSet, String userName) throws InvalidPotentialVulnerabilityValueException, SQLException; - DeviceCountByGroup getFeatureNonCompliantDeviceCount(String featureCode, BasicFilterSet basicFilterSet) + DeviceCountByGroup getFeatureNonCompliantDeviceCount(String featureCode, BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, SQLException; - DeviceCountByGroup getTotalDeviceCount() throws SQLException; + DeviceCountByGroup getTotalDeviceCount(String userName) throws SQLException; - List getDeviceCountsByConnectivityStatuses() throws SQLException; + List getDeviceCountsByConnectivityStatuses(String userName) throws SQLException; - List getDeviceCountsByPotentialVulnerabilities() throws SQLException; + List getDeviceCountsByPotentialVulnerabilities(String userName) throws SQLException; - PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount) throws + PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount, String userName) throws InvalidStartIndexValueException, InvalidResultCountValueException, SQLException; - List getDeviceCountsByPlatforms(ExtendedFilterSet extendedFilterSet) + List getDeviceCountsByPlatforms(ExtendedFilterSet extendedFilterSet, String userName) throws InvalidPotentialVulnerabilityValueException, SQLException; List getFeatureNonCompliantDeviceCountsByPlatforms(String featureCode, - BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException, SQLException; + BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, SQLException; - List getDeviceCountsByOwnershipTypes(ExtendedFilterSet extendedFilterSet) + List getDeviceCountsByOwnershipTypes(ExtendedFilterSet extendedFilterSet, String userName) throws InvalidPotentialVulnerabilityValueException, SQLException; List getFeatureNonCompliantDeviceCountsByOwnershipTypes(String featureCode, - BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException, SQLException; + BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, SQLException; - PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount) + PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount, String userName) throws InvalidPotentialVulnerabilityValueException, InvalidStartIndexValueException, InvalidResultCountValueException, SQLException; PaginationResult getFeatureNonCompliantDevicesWithDetails(String featureCode, BasicFilterSet basicFilterSet, - int startIndex, int resultCount) throws InvalidFeatureCodeValueException, + int startIndex, int resultCount, String userName) throws InvalidFeatureCodeValueException, InvalidStartIndexValueException, InvalidResultCountValueException, SQLException; - List getDevicesWithDetails(ExtendedFilterSet extendedFilterSet) + List getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, String userName) throws InvalidPotentialVulnerabilityValueException, SQLException; List getFeatureNonCompliantDevicesWithDetails(String featureCode, - BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException, SQLException; + BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, SQLException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/GenericGadgetDataServiceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/GenericGadgetDataServiceDAOImpl.java index 4a0deb7d24..68defcc788 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/GenericGadgetDataServiceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/GenericGadgetDataServiceDAOImpl.java @@ -18,7 +18,8 @@ package org.wso2.carbon.device.mgt.analytics.dashboard.dao.impl; -import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.analytics.dashboard.bean.DeviceWithDetails; import org.wso2.carbon.device.mgt.analytics.dashboard.bean.DeviceCountByGroup; import org.wso2.carbon.device.mgt.analytics.dashboard.bean.BasicFilterSet; @@ -26,7 +27,9 @@ import org.wso2.carbon.device.mgt.analytics.dashboard.bean.ExtendedFilterSet; import org.wso2.carbon.device.mgt.analytics.dashboard.dao.AbstractGadgetDataServiceDAO; import org.wso2.carbon.device.mgt.analytics.dashboard.dao.GadgetDataServiceDAOConstants; import org.wso2.carbon.device.mgt.analytics.dashboard.exception.*; +import org.wso2.carbon.device.mgt.analytics.dashboard.util.APIUtil; import org.wso2.carbon.device.mgt.common.PaginationResult; +import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; import java.sql.Connection; @@ -37,10 +40,14 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import static org.wso2.carbon.device.mgt.analytics.dashboard.util.APIUtil.getAuthenticatedUserTenantDomainId; + public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO { + private static final Log log = LogFactory.getLog(GenericGadgetDataServiceDAOImpl.class); + @Override - public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount) + public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount, String userName) throws InvalidStartIndexValueException, InvalidResultCountValueException, SQLException { if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) { @@ -56,19 +63,33 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA Connection con; PreparedStatement stmt = null; ResultSet rs = null; - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + int tenantId = getAuthenticatedUserTenantDomainId(); List filteredNonCompliantDeviceCountsByFeatures = new ArrayList<>(); int totalRecordsCount = 0; try { + String sql; con = this.getConnection(); - String sql = "SELECT FEATURE_CODE, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants. - DatabaseView.DEVICES_VIEW_2 + " WHERE TENANT_ID = ? GROUP BY FEATURE_CODE " + - "ORDER BY DEVICE_COUNT DESC LIMIT ?, ?"; + if(APIUtil.isDeviceAdminUser()){ + sql = "SELECT FEATURE_CODE, COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants. + DatabaseView.DEVICES_VIEW_2 + " WHERE TENANT_ID = ? GROUP BY FEATURE_CODE " + + "ORDER BY DEVICE_COUNT DESC LIMIT ?, ?"; + }else{ + sql = "SELECT FEATURE_INFO.FEATURE_CODE, COUNT(FEATURE_INFO.DEVICE_ID) AS DEVICE_COUNT " + + "FROM "+GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2+" FEATURE_INFO INNER JOIN " + + "DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = FEATURE_INFO.DEVICE_ID AND " + + "FEATURE_INFO.TENANT_ID = ? AND ENR_DB.OWNER = ? GROUP BY FEATURE_INFO.FEATURE_CODE ORDER BY" + + " DEVICE_COUNT DESC LIMIT ?, ?"; + } stmt = con.prepareStatement(sql); stmt.setInt(1, tenantId); - stmt.setInt(2, startIndex); - stmt.setInt(3, resultCount); - + if(!APIUtil.isDeviceAdminUser()){ + stmt.setString(2, userName); + stmt.setInt(3, startIndex); + stmt.setInt(4, resultCount); + }else{ + stmt.setInt(2, startIndex); + stmt.setInt(3, resultCount); + } // executing query rs = stmt.executeQuery(); // fetching query results @@ -81,19 +102,30 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA filteredNonCompliantDeviceCountsByFeatures.add(filteredNonCompliantDeviceCountByFeature); } // fetching total records count - sql = "SELECT COUNT(FEATURE_CODE) AS NON_COMPLIANT_FEATURE_COUNT FROM (SELECT DISTINCT FEATURE_CODE FROM " + - GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 + " WHERE TENANT_ID = ?) " + - "NON_COMPLIANT_FEATURE_CODE"; - + if(APIUtil.isDeviceAdminUser()){ + sql = "SELECT COUNT(FEATURE_CODE) AS NON_COMPLIANT_FEATURE_COUNT FROM (SELECT DISTINCT FEATURE_CODE FROM " + + GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 + " WHERE TENANT_ID = ?) " + + "NON_COMPLIANT_FEATURE_CODE"; + }else{ + sql = "SELECT COUNT(FEATURE_CODE) AS NON_COMPLIANT_FEATURE_COUNT FROM (SELECT DISTINCT " + + "FEATURE_INFO.FEATURE_CODE FROM "+GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 + +" FEATURE_INFO INNER JOIN DM_ENROLMENT ENR_DB ON ENR_DB.DEVICE_ID = FEATURE_INFO.DEVICE_ID " + + "AND FEATURE_INFO.TENANT_ID = ? AND ENR_DB.OWNER = ? ) NON_COMPLIANT_FEATURE_CODE"; + } stmt = con.prepareStatement(sql); stmt.setInt(1, tenantId); - + if(!APIUtil.isDeviceAdminUser()){ + stmt.setString(2, userName); + } // executing query rs = stmt.executeQuery(); // fetching query results while (rs.next()) { totalRecordsCount = rs.getInt("NON_COMPLIANT_FEATURE_COUNT"); } + } catch (DeviceAccessAuthorizationException e) { + String msg = "Error occurred while checking device access authorization"; + log.error(msg, e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, rs); } @@ -105,7 +137,7 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA @Override public PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, - int resultCount) throws InvalidPotentialVulnerabilityValueException, + int resultCount, String userName) throws InvalidPotentialVulnerabilityValueException, InvalidStartIndexValueException, InvalidResultCountValueException, SQLException { if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) { @@ -123,7 +155,7 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA Connection con; PreparedStatement stmt = null; ResultSet rs = null; - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + int tenantId = getAuthenticatedUserTenantDomainId(); List filteredDevicesWithDetails = new ArrayList<>(); int totalRecordsCount = 0; try { @@ -133,17 +165,31 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA // [1] appending filter columns, if exist if (filters != null && filters.size() > 0) { for (String column : filters.keySet()) { - advancedSqlFiltering = advancedSqlFiltering + "AND " + column + " = ? "; + advancedSqlFiltering = advancedSqlFiltering + " AND POLICY__INFO." + column + " = ? "; } } - sql = "SELECT DEVICE_ID, DEVICE_IDENTIFICATION, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM " + - GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " WHERE TENANT_ID = ? " + - advancedSqlFiltering + "ORDER BY DEVICE_ID ASC LIMIT ?, ?"; + if(APIUtil.isDeviceAdminUser()){ + sql = "SELECT DEVICE_ID, DEVICE_IDENTIFICATION, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM " + + GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " POLICY__INFO WHERE TENANT_ID = ? " + + advancedSqlFiltering + "ORDER BY DEVICE_ID ASC LIMIT ?, ?"; + }else{ + sql = "SELECT POLICY__INFO.DEVICE_ID, POLICY__INFO.DEVICE_IDENTIFICATION, POLICY__INFO.PLATFORM, " + + "POLICY__INFO.OWNERSHIP, POLICY__INFO.CONNECTIVITY_STATUS FROM " + + GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_1 + " POLICY__INFO INNER JOIN DM_ENROLMENT " + + "ENR_DB ON ENR_DB.DEVICE_ID = POLICY__INFO.DEVICE_ID AND " + + "POLICY__INFO.TENANT_ID = ? AND ENR_DB.OWNER = ? " + advancedSqlFiltering + " ORDER BY " + + "POLICY__INFO.DEVICE_ID ASC LIMIT ?,?"; + } stmt = con.prepareStatement(sql); // [2] appending filter column values, if exist stmt.setInt(1, tenantId); + int index = 2; + if(!APIUtil.isDeviceAdminUser()){ + stmt.setString(2, userName); + index = 3; + } if (filters != null && filters.values().size() > 0) { - int i = 2; + int i = index; for (Object value : filters.values()) { if (value instanceof Integer) { stmt.setInt(i, (Integer) value); @@ -155,8 +201,8 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA stmt.setInt(i, startIndex); stmt.setInt(++i, resultCount); } else { - stmt.setInt(2, startIndex); - stmt.setInt(3, resultCount); + stmt.setInt(3, startIndex); + stmt.setInt(4, resultCount); } // executing query rs = stmt.executeQuery(); @@ -171,20 +217,28 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA filteredDeviceWithDetails.setConnectivityStatus(rs.getString("CONNECTIVITY_STATUS")); filteredDevicesWithDetails.add(filteredDeviceWithDetails); } - - // fetching total records count - sql = "SELECT COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants. - DatabaseView.DEVICES_VIEW_1 + " WHERE TENANT_ID = ?"; - + if(APIUtil.isDeviceAdminUser()){ + sql = "SELECT COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants. + DatabaseView.DEVICES_VIEW_1 + " WHERE TENANT_ID = ?"; + }else{ + sql = "SELECT COUNT(POLICY__INFO.DEVICE_ID) AS DEVICE_COUNT FROM "+GadgetDataServiceDAOConstants. + DatabaseView.DEVICES_VIEW_1+" POLICY__INFO INNER JOIN DM_ENROLMENT ENR_DB ON " + + "ENR_DB.DEVICE_ID = POLICY__INFO.DEVICE_ID AND POLICY__INFO.TENANT_ID = ? AND ENR_DB.OWNER = ? "; + } stmt = con.prepareStatement(sql); stmt.setInt(1, tenantId); - + if(!APIUtil.isDeviceAdminUser()){ + stmt.setString(2, userName); + } // executing query rs = stmt.executeQuery(); // fetching query results while (rs.next()) { totalRecordsCount = rs.getInt("DEVICE_COUNT"); } + } catch (DeviceAccessAuthorizationException e) { + String msg = "Error occurred while checking device access authorization"; + log.error(msg, e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, rs); } @@ -196,7 +250,7 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA @Override public PaginationResult getFeatureNonCompliantDevicesWithDetails(String featureCode, - BasicFilterSet basicFilterSet, int startIndex, int resultCount) + BasicFilterSet basicFilterSet, int startIndex, int resultCount, String userName) throws InvalidFeatureCodeValueException, InvalidStartIndexValueException, InvalidResultCountValueException, SQLException { @@ -219,7 +273,7 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA Connection con; PreparedStatement stmt = null; ResultSet rs = null; - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + int tenantId = getAuthenticatedUserTenantDomainId(); List filteredDevicesWithDetails = new ArrayList<>(); int totalRecordsCount = 0; try { @@ -229,19 +283,34 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA // [1] appending filter columns, if exist if (filters != null && filters.size() > 0) { for (String column : filters.keySet()) { - advancedSqlFiltering = advancedSqlFiltering + "AND " + column + " = ? "; + advancedSqlFiltering = advancedSqlFiltering + "AND FEATURE_INFO." + column + " = ? "; } } - sql = "SELECT DEVICE_ID, DEVICE_IDENTIFICATION, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM " + + if(APIUtil.isDeviceAdminUser()){ + sql = "SELECT DEVICE_ID, DEVICE_IDENTIFICATION, PLATFORM, OWNERSHIP, CONNECTIVITY_STATUS FROM " + GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 + - " WHERE TENANT_ID = ? AND FEATURE_CODE = ? " + advancedSqlFiltering + + " FEATURE_INFO WHERE TENANT_ID = ? AND FEATURE_CODE = ? " + advancedSqlFiltering + "ORDER BY DEVICE_ID ASC LIMIT ?, ?"; + }else{ + sql = "SELECT FEATURE_INFO.DEVICE_ID, FEATURE_INFO.DEVICE_IDENTIFICATION, FEATURE_INFO.PLATFORM, " + + "FEATURE_INFO.OWNERSHIP, FEATURE_INFO.CONNECTIVITY_STATUS FROM " + + GadgetDataServiceDAOConstants.DatabaseView.DEVICES_VIEW_2 + " FEATURE_INFO INNER JOIN DM_ENROLMENT " + + "ENR_DB ON ENR_DB.DEVICE_ID = FEATURE_INFO.DEVICE_ID " + + " AND FEATURE_INFO.TENANT_ID = ? AND FEATURE_INFO.FEATURE_CODE = ? AND ENR_DB.OWNER = ? " + + advancedSqlFiltering + " ORDER BY DEVICE_ID ASC LIMIT ?,?"; + } + stmt = con.prepareStatement(sql); // [2] appending filter column values, if exist stmt.setInt(1, tenantId); stmt.setString(2, featureCode); + int index = 3; + if(!APIUtil.isDeviceAdminUser()){ + stmt.setString(3, userName); + index = 4; + } if (filters != null && filters.values().size() > 0) { - int i = 3; + int i = index; for (Object value : filters.values()) { if (value instanceof Integer) { stmt.setInt(i, (Integer) value); @@ -253,8 +322,8 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA stmt.setInt(i, startIndex); stmt.setInt(++i, resultCount); } else { - stmt.setInt(3, startIndex); - stmt.setInt(4, resultCount); + stmt.setInt(index, startIndex); + stmt.setInt(++index, resultCount); } // executing query rs = stmt.executeQuery(); @@ -269,21 +338,30 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA filteredDeviceWithDetails.setConnectivityStatus(rs.getString("CONNECTIVITY_STATUS")); filteredDevicesWithDetails.add(filteredDeviceWithDetails); } - - // fetching total records count - sql = "SELECT COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants. - DatabaseView.DEVICES_VIEW_2 + " WHERE TENANT_ID = ? AND FEATURE_CODE = ?"; - + if(APIUtil.isDeviceAdminUser()){ + sql = "SELECT COUNT(DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants. + DatabaseView.DEVICES_VIEW_2 + " WHERE TENANT_ID = ? AND FEATURE_CODE = ?"; + }else{ + sql = "SELECT COUNT(FEATURE_INFO.DEVICE_ID) AS DEVICE_COUNT FROM " + GadgetDataServiceDAOConstants. + DatabaseView.DEVICES_VIEW_2 + " FEATURE_INFO INNER JOIN DM_ENROLMENT ENR_DB ON " + + "ENR_DB.DEVICE_ID = FEATURE_INFO.DEVICE_ID AND FEATURE_INFO.TENANT_ID = ? AND " + + "FEATURE_INFO.FEATURE_CODE = ? AND ENR_DB.OWNER = ? "; + } stmt = con.prepareStatement(sql); stmt.setInt(1, tenantId); stmt.setString(2, featureCode); - + if(!APIUtil.isDeviceAdminUser()){ + stmt.setString(3, userName); + } // executing query rs = stmt.executeQuery(); // fetching query results while (rs.next()) { totalRecordsCount = rs.getInt("DEVICE_COUNT"); } + } catch (DeviceAccessAuthorizationException e) { + String msg = "Error occurred while checking device access authorization"; + log.error(msg, e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, rs); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/MSSQLGadgetDataServiceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/MSSQLGadgetDataServiceDAOImpl.java index 396a596c9b..23374a3fc2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/MSSQLGadgetDataServiceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/MSSQLGadgetDataServiceDAOImpl.java @@ -40,7 +40,7 @@ import java.util.Map; public class MSSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO { @Override - public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount) + public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount, String userName) throws InvalidStartIndexValueException, InvalidResultCountValueException, SQLException { if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) { @@ -104,7 +104,7 @@ public class MSSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO } @Override - public PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount) + public PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount, String userName) throws InvalidPotentialVulnerabilityValueException, InvalidStartIndexValueException, InvalidResultCountValueException, @@ -198,7 +198,7 @@ public class MSSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO @Override public PaginationResult getFeatureNonCompliantDevicesWithDetails(String featureCode, - BasicFilterSet basicFilterSet, int startIndex, int resultCount) + BasicFilterSet basicFilterSet, int startIndex, int resultCount, String userName) throws InvalidFeatureCodeValueException, InvalidStartIndexValueException, InvalidResultCountValueException, SQLException { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/OracleGadgetDataServiceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/OracleGadgetDataServiceDAOImpl.java index b90a9046b0..4d58e508e7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/OracleGadgetDataServiceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/OracleGadgetDataServiceDAOImpl.java @@ -40,7 +40,7 @@ import java.util.Map; public class OracleGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO { @Override - public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount) + public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount, String userName) throws InvalidStartIndexValueException, InvalidResultCountValueException, SQLException { if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) { @@ -105,7 +105,7 @@ public class OracleGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO } @Override - public PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount) + public PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount, String userName) throws InvalidPotentialVulnerabilityValueException, InvalidStartIndexValueException, InvalidResultCountValueException, SQLException { @@ -197,7 +197,7 @@ public class OracleGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO @Override public PaginationResult getFeatureNonCompliantDevicesWithDetails(String featureCode, BasicFilterSet basicFilterSet, - int startIndex, int resultCount) throws InvalidFeatureCodeValueException, + int startIndex, int resultCount, String userName) throws InvalidFeatureCodeValueException, InvalidStartIndexValueException, InvalidResultCountValueException, SQLException { if (featureCode == null || featureCode.isEmpty()) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/PostgreSQLGadgetDataServiceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/PostgreSQLGadgetDataServiceDAOImpl.java index d44ad929ee..5f859ec8b2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/PostgreSQLGadgetDataServiceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/dao/impl/PostgreSQLGadgetDataServiceDAOImpl.java @@ -40,7 +40,7 @@ import java.util.Map; public class PostgreSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO { @Override - public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount) + public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount, String userName) throws InvalidStartIndexValueException, InvalidResultCountValueException, SQLException { if (startIndex < GadgetDataServiceDAOConstants.Pagination.MIN_START_INDEX) { @@ -105,7 +105,7 @@ public class PostgreSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServic } @Override - public PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount) + public PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount, String userName) throws InvalidPotentialVulnerabilityValueException, InvalidStartIndexValueException, InvalidResultCountValueException, SQLException { @@ -198,7 +198,7 @@ public class PostgreSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServic @Override public PaginationResult getFeatureNonCompliantDevicesWithDetails(String featureCode, BasicFilterSet basicFilterSet, - int startIndex, int resultCount) throws InvalidFeatureCodeValueException, + int startIndex, int resultCount, String userName) throws InvalidFeatureCodeValueException, InvalidStartIndexValueException, InvalidResultCountValueException, SQLException { if (featureCode == null || featureCode.isEmpty()) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/impl/GadgetDataServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/impl/GadgetDataServiceImpl.java index 495172e3e0..9a392ab8df 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/impl/GadgetDataServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/impl/GadgetDataServiceImpl.java @@ -36,13 +36,14 @@ import java.util.List; public class GadgetDataServiceImpl implements GadgetDataService { @Override - public DeviceCountByGroup getDeviceCount(ExtendedFilterSet extendedFilterSet) + public DeviceCountByGroup getDeviceCount(ExtendedFilterSet extendedFilterSet, String userName) throws InvalidPotentialVulnerabilityValueException, DataAccessLayerException { DeviceCountByGroup filteredDeviceCount; try { + GadgetDataServiceDAOFactory.openConnection(); filteredDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO(). - getDeviceCount(extendedFilterSet); + getDeviceCount(extendedFilterSet, userName); } catch (SQLException e) { throw new DataAccessLayerException("Error in either opening a database connection or " + "accessing the database to fetch corresponding results.", e); @@ -53,13 +54,13 @@ public class GadgetDataServiceImpl implements GadgetDataService { } @Override - public DeviceCountByGroup getFeatureNonCompliantDeviceCount(String featureCode, BasicFilterSet basicFilterSet) + public DeviceCountByGroup getFeatureNonCompliantDeviceCount(String featureCode, BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, DataAccessLayerException { DeviceCountByGroup featureNonCompliantDeviceCount; try { GadgetDataServiceDAOFactory.openConnection(); featureNonCompliantDeviceCount = GadgetDataServiceDAOFactory. - getGadgetDataServiceDAO().getFeatureNonCompliantDeviceCount(featureCode, basicFilterSet); + getGadgetDataServiceDAO().getFeatureNonCompliantDeviceCount(featureCode, basicFilterSet, userName); } catch (SQLException e) { throw new DataAccessLayerException("Error in either opening a database connection or " + "accessing the database to fetch corresponding results.", e); @@ -70,11 +71,11 @@ public class GadgetDataServiceImpl implements GadgetDataService { } @Override - public DeviceCountByGroup getTotalDeviceCount() throws DataAccessLayerException { + public DeviceCountByGroup getTotalDeviceCount(String userName) throws DataAccessLayerException { DeviceCountByGroup totalDeviceCount; try { GadgetDataServiceDAOFactory.openConnection(); - totalDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getTotalDeviceCount(); + totalDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getTotalDeviceCount(userName); } catch (SQLException e) { throw new DataAccessLayerException("Error in either opening a database connection or " + "accessing the database to fetch corresponding results.", e); @@ -85,12 +86,12 @@ public class GadgetDataServiceImpl implements GadgetDataService { } @Override - public List getDeviceCountsByConnectivityStatuses() throws DataAccessLayerException { + public List getDeviceCountsByConnectivityStatuses(String userName) throws DataAccessLayerException { List deviceCountsByConnectivityStatuses; try { GadgetDataServiceDAOFactory.openConnection(); deviceCountsByConnectivityStatuses = GadgetDataServiceDAOFactory. - getGadgetDataServiceDAO().getDeviceCountsByConnectivityStatuses(); + getGadgetDataServiceDAO().getDeviceCountsByConnectivityStatuses(userName); } catch (SQLException e) { throw new DataAccessLayerException("Error in either opening a database connection or " + "accessing the database to fetch corresponding results.", e); @@ -101,12 +102,12 @@ public class GadgetDataServiceImpl implements GadgetDataService { } @Override - public List getDeviceCountsByPotentialVulnerabilities() throws DataAccessLayerException { + public List getDeviceCountsByPotentialVulnerabilities(String userName) throws DataAccessLayerException { List deviceCountsByPotentialVulnerabilities; try { GadgetDataServiceDAOFactory.openConnection(); deviceCountsByPotentialVulnerabilities = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO(). - getDeviceCountsByPotentialVulnerabilities(); + getDeviceCountsByPotentialVulnerabilities(userName); } catch (SQLException e) { throw new DataAccessLayerException("Error in either opening a database connection or " + "accessing the database to fetch corresponding results.", e); @@ -117,14 +118,14 @@ public class GadgetDataServiceImpl implements GadgetDataService { } @Override - public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount) + public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount, String userName) throws InvalidStartIndexValueException, InvalidResultCountValueException, DataAccessLayerException { PaginationResult paginationResult; try { GadgetDataServiceDAOFactory.openConnection(); paginationResult = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO(). - getNonCompliantDeviceCountsByFeatures(startIndex, resultCount); + getNonCompliantDeviceCountsByFeatures(startIndex, resultCount, userName); } catch (SQLException e) { throw new DataAccessLayerException("Error in either opening a database connection or " + "accessing the database to fetch corresponding results.", e); @@ -135,13 +136,13 @@ public class GadgetDataServiceImpl implements GadgetDataService { } @Override - public List getDeviceCountsByPlatforms(ExtendedFilterSet extendedFilterSet) + public List getDeviceCountsByPlatforms(ExtendedFilterSet extendedFilterSet, String userName) throws InvalidPotentialVulnerabilityValueException, DataAccessLayerException { List deviceCountsByPlatforms; try { GadgetDataServiceDAOFactory.openConnection(); deviceCountsByPlatforms = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO(). - getDeviceCountsByPlatforms(extendedFilterSet); + getDeviceCountsByPlatforms(extendedFilterSet, userName); } catch (SQLException e) { throw new DataAccessLayerException("Error in either opening a database connection or " + "accessing the database to fetch corresponding results.", e); @@ -153,13 +154,13 @@ public class GadgetDataServiceImpl implements GadgetDataService { @Override public List getFeatureNonCompliantDeviceCountsByPlatforms(String featureCode, - BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException, + BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, DataAccessLayerException { List featureNonCompliantDeviceCountsByPlatforms; try { GadgetDataServiceDAOFactory.openConnection(); featureNonCompliantDeviceCountsByPlatforms = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO(). - getFeatureNonCompliantDeviceCountsByPlatforms(featureCode, basicFilterSet); + getFeatureNonCompliantDeviceCountsByPlatforms(featureCode, basicFilterSet, userName); } catch (SQLException e) { throw new DataAccessLayerException("Error in either opening a database connection or " + "accessing the database to fetch corresponding results.", e); @@ -170,14 +171,14 @@ public class GadgetDataServiceImpl implements GadgetDataService { } @Override - public List getDeviceCountsByOwnershipTypes(ExtendedFilterSet extendedFilterSet) + public List getDeviceCountsByOwnershipTypes(ExtendedFilterSet extendedFilterSet, String userName) throws InvalidPotentialVulnerabilityValueException, DataAccessLayerException { List deviceCountsByOwnershipTypes; try { GadgetDataServiceDAOFactory.openConnection(); deviceCountsByOwnershipTypes = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO(). - getDeviceCountsByOwnershipTypes(extendedFilterSet); + getDeviceCountsByOwnershipTypes(extendedFilterSet, userName); } catch (SQLException e) { throw new DataAccessLayerException("Error in either opening a database connection or " + "accessing the database to fetch corresponding results.", e); @@ -189,13 +190,13 @@ public class GadgetDataServiceImpl implements GadgetDataService { @Override public List - getFeatureNonCompliantDeviceCountsByOwnershipTypes(String featureCode, BasicFilterSet basicFilterSet) + getFeatureNonCompliantDeviceCountsByOwnershipTypes(String featureCode, BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, DataAccessLayerException { List featureNonCompliantDeviceCountsByOwnershipTypes; try { GadgetDataServiceDAOFactory.openConnection(); featureNonCompliantDeviceCountsByOwnershipTypes = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO(). - getFeatureNonCompliantDeviceCountsByOwnershipTypes(featureCode, basicFilterSet); + getFeatureNonCompliantDeviceCountsByOwnershipTypes(featureCode, basicFilterSet, userName); } catch (SQLException e) { throw new DataAccessLayerException("Error in either opening a database connection or " + "accessing the database to fetch corresponding results.", e); @@ -206,14 +207,14 @@ public class GadgetDataServiceImpl implements GadgetDataService { } @Override - public PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount) + public PaginationResult getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, int startIndex, int resultCount, String userName) throws InvalidPotentialVulnerabilityValueException, DataAccessLayerException, InvalidStartIndexValueException, InvalidResultCountValueException { PaginationResult paginationResult; try { GadgetDataServiceDAOFactory.openConnection(); paginationResult = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO(). - getDevicesWithDetails(extendedFilterSet, startIndex, resultCount); + getDevicesWithDetails(extendedFilterSet, startIndex, resultCount, userName); } catch (SQLException e) { throw new DataAccessLayerException("Error in either opening a database connection or " + "accessing the database to fetch corresponding results.", e); @@ -225,14 +226,14 @@ public class GadgetDataServiceImpl implements GadgetDataService { @Override public PaginationResult getFeatureNonCompliantDevicesWithDetails(String featureCode, BasicFilterSet basicFilterSet, - int startIndex, int resultCount) throws InvalidFeatureCodeValueException, + int startIndex, int resultCount, String userName) throws InvalidFeatureCodeValueException, DataAccessLayerException, InvalidStartIndexValueException, InvalidResultCountValueException { PaginationResult paginationResult; try { GadgetDataServiceDAOFactory.openConnection(); paginationResult = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO(). - getFeatureNonCompliantDevicesWithDetails(featureCode, basicFilterSet, startIndex, resultCount); + getFeatureNonCompliantDevicesWithDetails(featureCode, basicFilterSet, startIndex, resultCount, userName); } catch (SQLException e) { throw new DataAccessLayerException("Error in either opening a database connection or " + "accessing the database to fetch corresponding results.", e); @@ -243,13 +244,13 @@ public class GadgetDataServiceImpl implements GadgetDataService { } @Override - public List getDevicesWithDetails(ExtendedFilterSet extendedFilterSet) + public List getDevicesWithDetails(ExtendedFilterSet extendedFilterSet, String userName) throws InvalidPotentialVulnerabilityValueException, DataAccessLayerException { List devicesWithDetails; try { GadgetDataServiceDAOFactory.openConnection(); devicesWithDetails = GadgetDataServiceDAOFactory. - getGadgetDataServiceDAO().getDevicesWithDetails(extendedFilterSet); + getGadgetDataServiceDAO().getDevicesWithDetails(extendedFilterSet, userName); } catch (SQLException e) { throw new DataAccessLayerException("Error in either opening a database connection or " + "accessing the database to fetch corresponding results.", e); @@ -261,13 +262,13 @@ public class GadgetDataServiceImpl implements GadgetDataService { @Override public List getFeatureNonCompliantDevicesWithDetails(String featureCode, - BasicFilterSet basicFilterSet) throws InvalidFeatureCodeValueException, + BasicFilterSet basicFilterSet, String userName) throws InvalidFeatureCodeValueException, DataAccessLayerException { List featureNonCompliantDevicesWithDetails; try { GadgetDataServiceDAOFactory.openConnection(); featureNonCompliantDevicesWithDetails = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO(). - getFeatureNonCompliantDevicesWithDetails(featureCode, basicFilterSet); + getFeatureNonCompliantDevicesWithDetails(featureCode, basicFilterSet, userName); } catch (SQLException e) { throw new DataAccessLayerException("Error in either opening a database connection or " + "accessing the database to fetch corresponding results.", e); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/util/APIUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/util/APIUtil.java new file mode 100644 index 0000000000..e9635e5d58 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/src/main/java/org/wso2/carbon/device/mgt/analytics/dashboard/util/APIUtil.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * you may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.analytics.dashboard.util; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException; +import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; +import org.wso2.carbon.user.api.UserStoreException; + +import java.net.SocketException; + + +/** + * This class provides utility functions used by REST-API. + */ +public class APIUtil { + + private static Log log = LogFactory.getLog(APIUtil.class); + + public static String getAuthenticatedUser() { + PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + String username = threadLocalCarbonContext.getUsername(); + String tenantDomain = threadLocalCarbonContext.getTenantDomain(); + if (username.endsWith(tenantDomain)) { + return username.substring(0, username.lastIndexOf("@")); + } + return username; + } + + public static int getAuthenticatedUserTenantDomainId() { + PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + return threadLocalCarbonContext.getTenantId(); + } + + public static boolean isDeviceAdminUser() throws DeviceAccessAuthorizationException { + return getDeviceAccessAuthorizationService().isDeviceAdminUser(); + } + + private static DeviceAccessAuthorizationService getDeviceAccessAuthorizationService() { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + DeviceAccessAuthorizationService deviceAccessAuthorizationService = + (DeviceAccessAuthorizationService) ctx.getOSGiService(DeviceAccessAuthorizationService.class, null); + if (deviceAccessAuthorizationService == null) { + String msg = "DeviceAccessAuthorization service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + return deviceAccessAuthorizationService; + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml index 512b757a38..3cc2b79748 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml index 62fa85bae9..b572c746c5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java index 2938b7bb96..05a22be16d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java @@ -205,6 +205,13 @@ public interface DeviceManagementService { required = false) @QueryParam("user") String user, + @ApiParam( + name = "role", + value = "A role of device owners. Ex : store-admin", + required = false) + @QueryParam("role") + @Size(max = 45) + String role, @ApiParam( name = "ownership", allowableValues = "BYOD, COPE", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DashboardImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DashboardImpl.java index ba5e00d0d8..c6940599ed 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DashboardImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DashboardImpl.java @@ -38,6 +38,8 @@ import javax.ws.rs.core.Response; import java.util.ArrayList; import java.util.List; +import static org.wso2.carbon.device.mgt.analytics.dashboard.util.APIUtil.getAuthenticatedUser; + /** * This class consists of dashboard related REST APIs * to be consumed by individual client gadgets such as @@ -82,7 +84,8 @@ public class DashboardImpl implements Dashboard { // getting total device count DeviceCountByGroup totalDeviceCount; try { - totalDeviceCount = gadgetDataService.getTotalDeviceCount(); + String userName = getAuthenticatedUser(); + totalDeviceCount = gadgetDataService.getTotalDeviceCount(userName); } catch (DataAccessLayerException e) { log.error("An internal error occurred while trying to execute relevant data service function " + "@ Dashboard API layer to retrieve total device count.", e); @@ -100,7 +103,8 @@ public class DashboardImpl implements Dashboard { // getting device counts by connectivity statuses List deviceCountsByConnectivityStatuses; try { - deviceCountsByConnectivityStatuses = gadgetDataService.getDeviceCountsByConnectivityStatuses(); + String userName = getAuthenticatedUser(); + deviceCountsByConnectivityStatuses = gadgetDataService.getDeviceCountsByConnectivityStatuses(userName); } catch (DataAccessLayerException e) { log.error("An internal error occurred while trying to execute relevant data service function " + "@ Dashboard API layer to retrieve device counts by connectivity statuses.", e); @@ -128,7 +132,8 @@ public class DashboardImpl implements Dashboard { List deviceCountsByPotentialVulnerabilities; try { - deviceCountsByPotentialVulnerabilities = gadgetDataService.getDeviceCountsByPotentialVulnerabilities(); + String userName = getAuthenticatedUser(); + deviceCountsByPotentialVulnerabilities = gadgetDataService.getDeviceCountsByPotentialVulnerabilities(userName); } catch (DataAccessLayerException e) { log.error("An internal error occurred while trying to execute relevant data service function " + "@ Dashboard API layer to retrieve device counts by potential vulnerabilities.", e); @@ -158,8 +163,9 @@ public class DashboardImpl implements Dashboard { PaginationResult paginationResult; try { + String userName = getAuthenticatedUser(); paginationResult = gadgetDataService. - getNonCompliantDeviceCountsByFeatures(startIndex, resultCount); + getNonCompliantDeviceCountsByFeatures(startIndex, resultCount, userName); } catch (InvalidStartIndexValueException e) { log.error("Bad request and error occurred @ Gadget Data Service layer due to " + "invalid (query) parameter value. This was while trying to execute relevant data service " + @@ -210,7 +216,8 @@ public class DashboardImpl implements Dashboard { // creating device-Counts-by-platforms Data Wrapper List deviceCountsByPlatforms; try { - deviceCountsByPlatforms = gadgetDataService.getDeviceCountsByPlatforms(filterSet); + String userName = getAuthenticatedUser(); + deviceCountsByPlatforms = gadgetDataService.getDeviceCountsByPlatforms(filterSet, userName); } catch (InvalidPotentialVulnerabilityValueException e) { log.error("Bad request and error occurred @ Gadget Data Service layer due to " + "invalid (query) parameter value. This was while trying to execute relevant data service " + @@ -232,7 +239,8 @@ public class DashboardImpl implements Dashboard { // creating device-Counts-by-ownership-types Data Wrapper List deviceCountsByOwnerships; try { - deviceCountsByOwnerships = gadgetDataService.getDeviceCountsByOwnershipTypes(filterSet); + String userName = getAuthenticatedUser(); + deviceCountsByOwnerships = gadgetDataService.getDeviceCountsByOwnershipTypes(filterSet, userName); } catch (InvalidPotentialVulnerabilityValueException e) { log.error("Bad request and error occurred @ Gadget Data Service layer due to " + "invalid (query) parameter value. This was while trying to execute relevant data service " + @@ -274,8 +282,9 @@ public class DashboardImpl implements Dashboard { // creating feature-non-compliant-device-Counts-by-platforms Data Wrapper List featureNonCompliantDeviceCountsByPlatforms; try { + String userName = getAuthenticatedUser(); featureNonCompliantDeviceCountsByPlatforms = gadgetDataService. - getFeatureNonCompliantDeviceCountsByPlatforms(nonCompliantFeatureCode, filterSet); + getFeatureNonCompliantDeviceCountsByPlatforms(nonCompliantFeatureCode, filterSet, userName); } catch (InvalidFeatureCodeValueException e) { log.error("Bad request and error occurred @ Gadget Data Service layer due to " + "invalid (query) parameter value. This was while trying to execute relevant data service " + @@ -299,8 +308,9 @@ public class DashboardImpl implements Dashboard { // creating feature-non-compliant-device-Counts-by-ownership-types Data Wrapper List featureNonCompliantDeviceCountsByOwnerships; try { + String userName = getAuthenticatedUser(); featureNonCompliantDeviceCountsByOwnerships = gadgetDataService. - getFeatureNonCompliantDeviceCountsByOwnershipTypes(nonCompliantFeatureCode, filterSet); + getFeatureNonCompliantDeviceCountsByOwnershipTypes(nonCompliantFeatureCode, filterSet, userName); } catch (InvalidFeatureCodeValueException e) { log.error("Bad request and error occurred @ Gadget Data Service layer due to " + "invalid (query) parameter value. This was while trying to execute relevant data service function " + @@ -348,7 +358,8 @@ public class DashboardImpl implements Dashboard { // creating filteredDeviceCount Data Wrapper DeviceCountByGroup filteredDeviceCount; try { - filteredDeviceCount = gadgetDataService.getDeviceCount(filterSet); + String userName = getAuthenticatedUser(); + filteredDeviceCount = gadgetDataService.getDeviceCount(filterSet, userName); } catch (InvalidPotentialVulnerabilityValueException e) { log.error("Bad request and error occurred @ Gadget Data Service layer due to " + "invalid (query) parameter value. This was while trying to execute relevant data service " + @@ -365,7 +376,8 @@ public class DashboardImpl implements Dashboard { // creating TotalDeviceCount Data Wrapper DeviceCountByGroup totalDeviceCount; try { - totalDeviceCount = gadgetDataService.getTotalDeviceCount(); + String userName = getAuthenticatedUser(); + totalDeviceCount = gadgetDataService.getTotalDeviceCount(userName); } catch (DataAccessLayerException e) { log.error("An internal error occurred while trying to execute relevant data service function " + "@ Dashboard API layer to retrieve the total device count over filtered.", e); @@ -405,8 +417,9 @@ public class DashboardImpl implements Dashboard { // creating featureNonCompliantDeviceCount Data Wrapper DeviceCountByGroup featureNonCompliantDeviceCount; try { + String userName = getAuthenticatedUser(); featureNonCompliantDeviceCount = gadgetDataService. - getFeatureNonCompliantDeviceCount(nonCompliantFeatureCode, filterSet); + getFeatureNonCompliantDeviceCount(nonCompliantFeatureCode, filterSet, userName); } catch (InvalidFeatureCodeValueException e) { log.error("Bad request and error occurred @ Gadget Data Service layer due to " + "invalid (query) parameter value. This was while trying to execute relevant data service function " + @@ -423,7 +436,8 @@ public class DashboardImpl implements Dashboard { // creating TotalDeviceCount Data Wrapper DeviceCountByGroup totalDeviceCount; try { - totalDeviceCount = gadgetDataService.getTotalDeviceCount(); + String userName = getAuthenticatedUser(); + totalDeviceCount = gadgetDataService.getTotalDeviceCount(userName); } catch (DataAccessLayerException e) { log.error("An internal error occurred while trying to execute relevant data service function " + "@ Dashboard API layer to retrieve the total device count over filtered feature non-compliant.", e); @@ -477,8 +491,9 @@ public class DashboardImpl implements Dashboard { PaginationResult paginationResult; try { + String userName = getAuthenticatedUser(); paginationResult = gadgetDataService. - getDevicesWithDetails(filterSet, startIndex, resultCount); + getDevicesWithDetails(filterSet, startIndex, resultCount, userName); } catch (InvalidPotentialVulnerabilityValueException e) { log.error("Bad request and error occurred @ Gadget Data Service layer due to " + "invalid (query) parameter value. This was while trying to execute relevant data service " + @@ -530,7 +545,8 @@ public class DashboardImpl implements Dashboard { List devicesWithDetails; try { - devicesWithDetails = gadgetDataService.getDevicesWithDetails(filterSet); + String userName = getAuthenticatedUser(); + devicesWithDetails = gadgetDataService.getDevicesWithDetails(filterSet, userName); } catch (InvalidPotentialVulnerabilityValueException e) { log.error("Bad request and error occurred @ Gadget Data Service layer due to " + "invalid (query) parameter value. This was while trying to execute relevant data service " + @@ -591,9 +607,10 @@ public class DashboardImpl implements Dashboard { PaginationResult paginationResult; try { + String userName = getAuthenticatedUser(); paginationResult = gadgetDataService. getFeatureNonCompliantDevicesWithDetails(nonCompliantFeatureCode, - filterSet, startIndex, resultCount); + filterSet, startIndex, resultCount, userName); } catch (InvalidFeatureCodeValueException e) { log.error("Bad request and error occurred @ Gadget Data Service layer due to " + "invalid (query) parameter value. This was while trying to execute relevant data service " + @@ -648,8 +665,9 @@ public class DashboardImpl implements Dashboard { List featureNonCompliantDevicesWithDetails; try { + String userName = getAuthenticatedUser(); featureNonCompliantDevicesWithDetails = gadgetDataService. - getFeatureNonCompliantDevicesWithDetails(nonCompliantFeatureCode, filterSet); + getFeatureNonCompliantDevicesWithDetails(nonCompliantFeatureCode, filterSet, userName); } catch (InvalidFeatureCodeValueException e) { log.error("Bad request and error occurred @ Gadget Data Service layer due to " + "invalid (query) parameter value. This was while trying to execute relevant data service " + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java index 9a8f3b80f3..bab0d1fd39 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -18,6 +18,7 @@ */ package org.wso2.carbon.device.mgt.jaxrs.service.impl; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.CarbonContext; @@ -84,6 +85,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @QueryParam("name") String name, @QueryParam("type") String type, @QueryParam("user") String user, + @QueryParam("role") String role, @QueryParam("ownership") String ownership, @QueryParam("status") String status, @QueryParam("groupId") int groupId, @@ -92,6 +94,12 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @QueryParam("offset") int offset, @QueryParam("limit") int limit) { try { + if (!StringUtils.isEmpty(name) && !StringUtils.isEmpty(role)) { + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setMessage("Request contains both name and role " + + "parameters. Only one is allowed " + + "at once.").build()).build(); + } // RequestValidationUtil.validateSelectionCriteria(type, user, roleName, ownership, status); RequestValidationUtil.validatePaginationParameters(offset, limit); DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService(); @@ -126,6 +134,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { if (groupId != 0 ) { request.setGroupId(groupId); } + if (role != null && !role.isEmpty()) { + request.setOwnerRole(role); + } // this is the user who initiates the request String authorizedUser = MultitenantUtils.getTenantAwareUsername(CarbonContext.getThreadLocalCarbonContext().getUsername()); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/ApplicationManagementAdminServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/ApplicationManagementAdminServiceImpl.java index 59f32534c9..5141399fa1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/ApplicationManagementAdminServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/ApplicationManagementAdminServiceImpl.java @@ -65,9 +65,10 @@ public class ApplicationManagementAdminServiceImpl implements ApplicationManagem if (applicationWrapper.getDeviceIdentifiers() != null) { for (DeviceIdentifier deviceIdentifier : applicationWrapper.getDeviceIdentifiers()) { - if (Platform.ANDROID.toString().equals(deviceIdentifier.getType())) { + String deviceType = deviceIdentifier.getType().toUpperCase(); + if (Platform.ANDROID.toString().equals(deviceType)) { operation = MDMAndroidOperationUtil.createInstallAppOperation(mobileApp); - } else if (Platform.IOS.toString().equals(deviceIdentifier.getType())) { + } else if (Platform.IOS.toString().equals(deviceType)) { operation = MDMIOSOperationUtil.createInstallAppOperation(mobileApp); } } @@ -114,9 +115,10 @@ public class ApplicationManagementAdminServiceImpl implements ApplicationManagem if (applicationWrapper.getDeviceIdentifiers() != null) { for (DeviceIdentifier deviceIdentifier : applicationWrapper.getDeviceIdentifiers()) { - if (Platform.ANDROID.toString().equals(deviceIdentifier.getType())) { + String deviceType = deviceIdentifier.getType().toUpperCase(); + if (Platform.ANDROID.toString().equals(deviceType)) { operation = MDMAndroidOperationUtil.createAppUninstallOperation(mobileApp); - } else if (deviceIdentifier.getType().equals(Platform.IOS.toString())) { + } else if (deviceType.equals(Platform.IOS.toString())) { operation = MDMIOSOperationUtil.createAppUninstallOperation(mobileApp); } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml index 9f2fb4f03c..380cfd9ae3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/PaginationRequest.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/PaginationRequest.java index 6c3a6c9f60..151e86b6ad 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/PaginationRequest.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/PaginationRequest.java @@ -33,6 +33,7 @@ public class PaginationRequest { private String deviceType; private String deviceName; private String ownership; + private String ownerRole; private Date since; public PaginationRequest(int start, int rowCount) { @@ -112,4 +113,11 @@ public class PaginationRequest { this.since = since; } + public String getOwnerRole() { + return ownerRole; + } + + public void setOwnerRole(String ownerRole) { + this.ownerRole = ownerRole; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index afbf63738a..b98368eed5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 39389ee879..a9d974b4af 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -17,6 +17,7 @@ */ package org.wso2.carbon.device.mgt.core.service; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.CarbonConstants; @@ -607,12 +608,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public PaginationResult getAllDevices(PaginationRequest request) throws DeviceManagementException { + List devicesForRoles = null; PaginationResult paginationResult = new PaginationResult(); List devices = new ArrayList<>(); List allDevices = new ArrayList<>(); int count = 0; int tenantId = this.getTenantId(); request = DeviceManagerUtil.validateDeviceListPageSize(request); + if (!StringUtils.isEmpty(request.getOwnerRole())) { + devicesForRoles = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider() + .getAllDevicesOfRole(request.getOwnerRole()); + } try { DeviceManagementDAOFactory.openConnection(); allDevices = deviceDAO.getDevices(request, tenantId); @@ -625,6 +631,20 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } finally { DeviceManagementDAOFactory.closeConnection(); } + + devices = processDevices(devices, allDevices); + + if (devicesForRoles != null) { + count += devicesForRoles.size(); + devices = processDevices(devices, devicesForRoles); + } + paginationResult.setData(devices); + paginationResult.setRecordsFiltered(count); + paginationResult.setRecordsTotal(count); + return paginationResult; + } + + private List processDevices(List devices, List allDevices) throws DeviceManagementException { for (Device device : allDevices) { DeviceInfo info = null; try { @@ -637,7 +657,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv device.setDeviceInfo(info); } catch (DeviceDetailsMgtDAOException e) { log.error("Error occurred while retrieving advance info of '" + device.getType() + - "' that carries the id '" + device.getDeviceIdentifier() + "'"); + "' that carries the id '" + device.getDeviceIdentifier() + "'"); } catch (SQLException e) { log.error("Error occurred while opening a connection to the data source", e); } finally { @@ -651,7 +671,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv device.setApplications(applications); } catch (DeviceManagementDAOException e) { log.error("Error occurred while retrieving the application list of '" + device.getType() + "', " + - "which carries the id '" + device.getId() + "'", e); + "which carries the id '" + device.getId() + "'", e); } catch (SQLException e) { log.error("Error occurred while opening a connection to the data source", e); } finally { @@ -662,7 +682,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv if (deviceManager == null) { if (log.isDebugEnabled()) { log.debug("Device Manager associated with the device type '" + device.getType() + "' is null. " + - "Therefore, not attempting method 'isEnrolled'"); + "Therefore, not attempting method 'isEnrolled'"); } devices.add(device); continue; @@ -675,12 +695,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } devices.add(device); } - paginationResult.setData(devices); - paginationResult.setRecordsFiltered(count); - paginationResult.setRecordsTotal(count); - return paginationResult; + return devices; } - @Override public List getAllDevices(String deviceType) throws DeviceManagementException { List devices = new ArrayList<>(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml index 4106537df5..3683e9b095 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml index 447fe51c5b..a870326643 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml index 25f9e09ebf..3d980569d4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 3dd861c032..7d86eebc3e 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../../pom.xml diff --git a/components/email-sender/org.wso2.carbon.email.sender.core/pom.xml b/components/email-sender/org.wso2.carbon.email.sender.core/pom.xml index 88db5fd8d4..ecc5f145c3 100644 --- a/components/email-sender/org.wso2.carbon.email.sender.core/pom.xml +++ b/components/email-sender/org.wso2.carbon.email.sender.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt email-sender - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/components/email-sender/pom.xml b/components/email-sender/pom.xml index be1d8fe2db..b433d98724 100644 --- a/components/email-sender/pom.xml +++ b/components/email-sender/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../../pom.xml diff --git a/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/pom.xml b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/pom.xml index 4fa3507780..edbac611eb 100644 --- a/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/pom.xml +++ b/components/identity-extensions/dynamic-client-registration/dynamic-client-web-proxy/pom.xml @@ -21,7 +21,7 @@ dynamic-client-registration org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/dynamic-client-registration/dynamic-client-web/pom.xml b/components/identity-extensions/dynamic-client-registration/dynamic-client-web/pom.xml index c9c58b5700..5e694d7eb0 100644 --- a/components/identity-extensions/dynamic-client-registration/dynamic-client-web/pom.xml +++ b/components/identity-extensions/dynamic-client-registration/dynamic-client-web/pom.xml @@ -21,7 +21,7 @@ dynamic-client-registration org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml index bb6a8c9e61..8527359d77 100644 --- a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml +++ b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/pom.xml @@ -21,13 +21,13 @@ dynamic-client-registration org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.dynamic.client.registration - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT bundle WSO2 Carbon - Dynamic client registration service WSO2 Carbon - Dynamic Client Registration Service diff --git a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/pom.xml b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/pom.xml index 73c1261438..2cf30119e4 100644 --- a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/pom.xml +++ b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/pom.xml @@ -21,13 +21,13 @@ dynamic-client-registration org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.dynamic.client.web.app.registration - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT bundle WSO2 Carbon - Dynamic client web app registration WSO2 Carbon - Dynamic Client Web-app Registration Service diff --git a/components/identity-extensions/dynamic-client-registration/pom.xml b/components/identity-extensions/dynamic-client-registration/pom.xml index 561b1c3752..479fbdd6a3 100644 --- a/components/identity-extensions/dynamic-client-registration/pom.xml +++ b/components/identity-extensions/dynamic-client-registration/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt identity-extensions - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt dynamic-client-registration - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT pom WSO2 Carbon - Dynamic client registration http://wso2.org diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml index 11a6afac84..7991efcfca 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt identity-extensions - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.oauth.extensions - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT bundle WSO2 Carbon - OAuth Extensions http://wso2.org diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml index e970bbc4f5..6b68c6631e 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml @@ -21,7 +21,7 @@ identity-extensions org.wso2.carbon.devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT 4.0.0 diff --git a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml index fd6c2a6244..3f2a1467ae 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt identity-extensions - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index 468813fcdc..c08d3c050c 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../../pom.xml diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml index 41efcc6c3a..57b6dd8ca9 100644 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt policy-mgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.complex.policy.decision.point - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT bundle WSO2 Carbon - Policy Decision Point WSO2 Carbon - Policy Decision Point diff --git a/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml index 8f0c457042..5c2563fcf4 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml @@ -3,14 +3,14 @@ org.wso2.carbon.devicemgt policy-mgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.policy.decision.point - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT bundle WSO2 Carbon - Policy Decision Point WSO2 Carbon - Policy Decision Point diff --git a/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml index 2bd612a543..b729b87600 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml @@ -3,7 +3,7 @@ org.wso2.carbon.devicemgt policy-mgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml @@ -11,7 +11,7 @@ 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.policy.information.point - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT bundle WSO2 Carbon - Policy Information Point WSO2 Carbon - Policy Information Point diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml index 420fc0ddad..5ed57d9e9f 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt policy-mgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.policy.mgt.common - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT bundle WSO2 Carbon - Policy Management Common WSO2 Carbon - Policy Management Common diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml index b53e55fe74..d08f802af6 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt policy-mgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.policy.mgt.core - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT bundle WSO2 Carbon - Policy Management Core WSO2 Carbon - Policy Management Core diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index 72649963e8..fa8bf4bf88 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,13 +23,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../../pom.xml 4.0.0 policy-mgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT pom WSO2 Carbon - Policy Management Component http://wso2.org diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml index 65ac2299b2..8f22c1b7c9 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml @@ -21,14 +21,14 @@ org.wso2.carbon.devicemgt webapp-authenticator-framework - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.devicemgt org.wso2.carbon.webapp.authenticator.framework - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT bundle WSO2 Carbon - Web Application Authenticator Framework Bundle WSO2 Carbon - Web Application Authenticator Framework Bundle diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 287c5cfb70..f66a8402d4 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt webapp-authenticator-framework - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT pom WSO2 Carbon - Webapp Authenticator Framework http://wso2.org diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml index 34c7dcde0f..f28bce04cd 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml @@ -21,14 +21,14 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.application.extension.feature pom - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT WSO2 Carbon - API Management Application Extension Feature http://wso2.org This feature contains an implementation of a api application registration, which takes care of subscription diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml index 4e342280f1..827f3ce889 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.handler.server.feature pom - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT WSO2 Carbon - Device Management - APIM handler Server Feature http://wso2.org This feature contains the handler for the api authentications diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml index 89d2f06b44..16312dfa30 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml @@ -21,14 +21,14 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.webapp.publisher.feature pom - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT WSO2 Carbon - API Management Webapp Publisher Feature http://wso2.org This feature contains an implementation of a Tomcat lifecycle listener, which takes care of publishing diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 67e5ef22d6..f18b297c26 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt apimgt-extensions-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT pom WSO2 Carbon - API Management Extensions Feature http://wso2.org diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml index fa31452abe..95b47dff79 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml index c551a8caf1..96c261e161 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml index a26509edd7..df137c8b45 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.certificate.mgt.server.feature pom - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT WSO2 Carbon - Certificate Management Server Feature http://wso2.org This feature contains the core bundles required for back-end Certificate Management functionality diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index 2a414eff42..788e87630b 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt certificate-mgt-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT pom WSO2 Carbon - Certificate Management Feature http://wso2.org diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml index e449811d35..ae6a64364b 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature pom - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT WSO2 Carbon - Device Type Deployer Feature http://wso2.org WSO2 Carbon - Device Type Deployer Feature diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.feature/pom.xml index 74c27277f5..a02248d5f8 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.feature pom - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT WSO2 Carbon - GCM Based Push Notification Provider Feature http://wso2.org WSO2 Carbon - MQTT Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 7b4dafd7b0..be41639d2e 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature pom - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT WSO2 Carbon - MQTT Based Push Notification Provider Feature http://wso2.org WSO2 Carbon - MQTT Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index 888da00d5f..2cebc2d0c3 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature pom - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT WSO2 Carbon - XMPP Based Push Notification Provider Feature http://wso2.org WSO2 Carbon - XMPP Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index 17f761d74a..a4290fe4c4 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard.feature/pom.xml index f5d5667dd7..b7eb5ddf71 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard.feature/pom.xml @@ -3,13 +3,13 @@ org.wso2.carbon.devicemgt device-mgt-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.analytics.dashboard.feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT pom WSO2 Carbon - Device Management Dashboard Analytics Feature WSO2 Carbon - Device Management Dashboard Analytics Feature diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher.feature/pom.xml index c6d8029d45..d93edaad59 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt device-mgt-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.analytics.data.publisher.feature pom - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT WSO2 Carbon - Device Management Server Feature http://wso2.org This feature contains bundles related to device analytics data publisher diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml index f5ec89ddeb..edb92f0643 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml index 40f41b738f..3453b77947 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml @@ -4,14 +4,14 @@ org.wso2.carbon.devicemgt device-mgt-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.extensions.feature pom - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT WSO2 Carbon - Device Management Extensions Feature http://wso2.org This feature contains common extensions used by key device management functionalities diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml index 0db5a7563a..a79a6af48c 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml index 6723d7773a..e28fc52090 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt device-mgt-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.server.feature pom - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT WSO2 Carbon - Device Management Server Feature http://wso2.org This feature contains the core bundles required for Back-end Device Management functionality diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml index 630472df8c..5c96a49950 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 9e6b593ab2..f40bec0704 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../../pom.xml diff --git a/features/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration.server.feature/pom.xml b/features/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration.server.feature/pom.xml index 46613e4b43..3143350e22 100644 --- a/features/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration.server.feature/pom.xml +++ b/features/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration.server.feature/pom.xml @@ -23,14 +23,14 @@ org.wso2.carbon.devicemgt dynamic-client-registration-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.dynamic.client.registration.server.feature pom - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT WSO2 Carbon - Dynamic Client Registration Server Feature http://wso2.org This feature contains dynamic client registration features diff --git a/features/dynamic-client-registration/pom.xml b/features/dynamic-client-registration/pom.xml index d26fa6b6c0..d5f10f9145 100644 --- a/features/dynamic-client-registration/pom.xml +++ b/features/dynamic-client-registration/pom.xml @@ -23,14 +23,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt dynamic-client-registration-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT pom WSO2 Carbon - Dynamic Client Registration Feature http://wso2.org diff --git a/features/email-sender/org.wso2.carbon.email.sender.feature/pom.xml b/features/email-sender/org.wso2.carbon.email.sender.feature/pom.xml index 24c59b7306..ba9b1c90f0 100644 --- a/features/email-sender/org.wso2.carbon.email.sender.feature/pom.xml +++ b/features/email-sender/org.wso2.carbon.email.sender.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt email-sender-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.email.sender.feature pom - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT WSO2 Carbon - Email Sender Feature http://wso2.org This feature contains the core bundles required for email sender related functionality diff --git a/features/email-sender/pom.xml b/features/email-sender/pom.xml index 71ed8fa383..0af33900ed 100644 --- a/features/email-sender/pom.xml +++ b/features/email-sender/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt email-sender-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT pom WSO2 Carbon - Email Sender Feature http://wso2.org diff --git a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml index 4afc10925f..2ab7b73b2a 100644 --- a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml @@ -23,14 +23,14 @@ org.wso2.carbon.devicemgt jwt-client-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.identity.jwt.client.extension.feature pom - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT WSO2 Carbon - JWT Client Feature http://wso2.org This feature contains jwt client implementation from which we can get a access token using the jwt diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index bfaa5f38c0..935f5ec0c0 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,13 +23,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../../pom.xml 4.0.0 jwt-client-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT pom WSO2 Carbon - Dynamic Client Registration Feature http://wso2.org diff --git a/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml b/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml index 560e2242b2..66ed3c6074 100644 --- a/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml +++ b/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml @@ -23,14 +23,14 @@ org.wso2.carbon.devicemgt oauth-extensions-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.oauth.extensions.feature pom - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT WSO2 Carbon - Device Mgt OAuth Extensions Feature http://wso2.org This feature contains devicemgt related OAuth extensions diff --git a/features/oauth-extensions/pom.xml b/features/oauth-extensions/pom.xml index 5db71fefef..a6583de71c 100644 --- a/features/oauth-extensions/pom.xml +++ b/features/oauth-extensions/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt oauth-extensions-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT pom WSO2 Carbon - Device Management OAuth Extensions Feature http://wso2.org diff --git a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml index 10b18a43b4..fcb6958771 100644 --- a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml @@ -23,14 +23,14 @@ org.wso2.carbon.devicemgt policy-mgt-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.policy.mgt.server.feature pom - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT WSO2 Carbon - Policy Management Server Feature http://wso2.org This feature contains the core bundles required for Back-end Device Management functionality diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index 8db56d41e8..2fac1907c0 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,14 +23,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt policy-mgt-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT pom WSO2 Carbon - Policy Management Feature http://wso2.org diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml index 6cd51096a4..8df4b9b38c 100644 --- a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt webapp-authenticator-framework-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.webapp.authenticator.framework.server.feature pom - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT WSO2 Carbon - Webapp Authenticator Framework Server Feature http://wso2.org This feature contains the core bundles required for Back-end Device Management functionality diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index f81315634d..e18954bb28 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt webapp-authenticator-framework-feature - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT pom WSO2 Carbon - Webapp Authenticator Framework Feature http://wso2.org diff --git a/pom.xml b/pom.xml index b68c12acf4..3600c91adc 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt pom - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -1787,7 +1787,7 @@ 1.2.11.wso2v10 - 2.0.12-SNAPSHOT + 2.0.14-SNAPSHOT 4.4.8