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 735ba78d31..e2213aee9a 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.4-SNAPSHOT
+ 2.0.6-SNAPSHOT
../pom.xml
4.0.0
org.wso2.carbon.apimgt.annotations
- 2.0.4-SNAPSHOT
+ 2.0.6-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 cd50d7c532..5faf10c78c 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.4-SNAPSHOT
+ 2.0.6-SNAPSHOT
../pom.xml
4.0.0
- 2.0.4-SNAPSHOT
+ 2.0.6-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 4b55f62c41..d21f4f2094 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.4-SNAPSHOT
+ 2.0.6-SNAPSHOT
../pom.xml
4.0.0
- 2.0.4-SNAPSHOT
+ 2.0.6-SNAPSHOT
org.wso2.carbon.apimgt.application.extension
bundle
WSO2 Carbon - API Application Management
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java
index 913541e533..087a6ee4a2 100644
--- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java
@@ -75,16 +75,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
"Api application creation failed for " + applicationName + " to the user " + username);
}
- APIKey retrievedApiApplicationKey = null;
- for (APIKey apiKey : application.getKeys()) {
- String applicationKeyType = apiKey.getType();
- if (applicationKeyType != null && applicationKeyType.equals(keyType)) {
- retrievedApiApplicationKey = apiKey;
- break;
- }
- }
- if (retrievedApiApplicationKey != null) {
- if (retrievedApiApplicationKey.getConsumerKey().equals(clientId)) {
+ OAuthApplicationInfo oAuthApp = application.getOAuthApp(keyType);
+ if (oAuthApp != null) {
+ if (oAuthApp.getClientId().equals(clientId)) {
if (tags != null && tags.length > 0) {
createApplicationAndSubscribeToAPIs(applicationName, tags, username);
}
@@ -131,7 +124,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
* {@inheritDoc}
*/
@Override
- public ApiApplicationKey generateAndRetrieveApplicationKeys(String apiApplicationName, String tags[],
+ public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String apiApplicationName, String tags[],
String keyType, String username,
boolean isAllowedAllDomains, String validityTime)
throws APIManagerException {
@@ -152,18 +145,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
"Api application creation failed for " + apiApplicationName + " to the user " + username);
}
- APIKey retrievedApiApplicationKey = null;
- for (APIKey apiKey : application.getKeys()) {
- String applicationKeyType = apiKey.getType();
- if (applicationKeyType != null && applicationKeyType.equals(keyType)) {
- retrievedApiApplicationKey = apiKey;
- break;
- }
- }
- if (retrievedApiApplicationKey != null) {
+ OAuthApplicationInfo oAuthApp = application.getOAuthApp(keyType);
+ if (oAuthApp != null) {
ApiApplicationKey apiApplicationKey = new ApiApplicationKey();
- apiApplicationKey.setConsumerKey(retrievedApiApplicationKey.getConsumerKey());
- apiApplicationKey.setConsumerSecret(retrievedApiApplicationKey.getConsumerSecret());
+ apiApplicationKey.setConsumerKey(oAuthApp.getClientId());
+ apiApplicationKey.setConsumerSecret(oAuthApp.getClientSecret());
return apiApplicationKey;
}
String[] allowedDomains = new String[1];
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 4eaafadb32..a76baa3d88 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.4-SNAPSHOT
+ 2.0.6-SNAPSHOT
../pom.xml
4.0.0
org.wso2.carbon.apimgt.webapp.publisher
- 2.0.4-SNAPSHOT
+ 2.0.6-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 845f1608c2..850097bc1b 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.4-SNAPSHOT
+ 2.0.6-SNAPSHOT
../../pom.xml
4.0.0
apimgt-extensions
- 2.0.4-SNAPSHOT
+ 2.0.6-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 dec9d819b8..c5694a53fb 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.4-SNAPSHOT
+ 2.0.6-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 0937df34b0..377b33ea3e 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.4-SNAPSHOT
+ 2.0.6-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 3d6927cb7d..cbc9281c54 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.4-SNAPSHOT
+ 2.0.6-SNAPSHOT
../pom.xml
4.0.0
org.wso2.carbon.certificate.mgt.core
- 2.0.4-SNAPSHOT
+ 2.0.6-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 415d4adc39..8b33754ea4 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.4-SNAPSHOT
+ 2.0.6-SNAPSHOT
../../pom.xml
4.0.0
org.wso2.carbon.devicemgt
certificate-mgt
- 2.0.4-SNAPSHOT
+ 2.0.6-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 507a1b4ffa..df0314173c 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.4-SNAPSHOT
+ 2.0.6-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java
index 8a9bcd7ed5..eba2f18721 100644
--- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java
+++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java
@@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.extensions.device.type.deployer.template;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
@@ -41,6 +42,7 @@ import org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.util.
import org.wso2.carbon.device.mgt.extensions.license.mgt.registry.RegistryBasedLicenseManager;
import org.wso2.carbon.registry.api.RegistryException;
import org.wso2.carbon.registry.api.Resource;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
@@ -118,25 +120,34 @@ public class DeviceTypeManager implements DeviceManager {
throw new DeviceTypeDeployerFileException("Could not find definition for table: " + tableName);
}
propertiesExist = true;
- DeviceDAODefinition deviceDAODefinition = new DeviceDAODefinition(deviceDefinitionTable);
- String datasourceName = deviceTypeConfiguration.getDataSource().getJndiConfig().getName();
- if (datasourceName != null && !datasourceName.isEmpty()) {
- String setupOption = System.getProperty("setup");
- if (setupOption != null) {
- if (log.isDebugEnabled()) {
- log.debug("-Dsetup is enabled. Device management repository schema initialization is about " +
- "to begin");
- }
- try {
- DeviceTypeUtils.setupDeviceManagementSchema(datasourceName, deviceType,
- deviceDAODefinition.getDeviceTableName());
- } catch (DeviceTypeMgtPluginException e) {
- log.error("Exception occurred while initializing device management database schema", e);
+
+ try {
+ PrivilegedCarbonContext.startTenantFlow();
+ PrivilegedCarbonContext.getThreadLocalCarbonContext()
+ .setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true);
+
+ DeviceDAODefinition deviceDAODefinition = new DeviceDAODefinition(deviceDefinitionTable);
+ String datasourceName = deviceTypeConfiguration.getDataSource().getJndiConfig().getName();
+ if (datasourceName != null && !datasourceName.isEmpty()) {
+ String setupOption = System.getProperty("setup");
+ if (setupOption != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("-Dsetup is enabled. Device management repository schema initialization is about " +
+ "to begin");
+ }
+ try {
+ DeviceTypeUtils.setupDeviceManagementSchema(datasourceName, deviceType,
+ deviceDAODefinition.getDeviceTableName());
+ } catch (DeviceTypeMgtPluginException e) {
+ log.error("Exception occurred while initializing device management database schema", e);
+ }
}
+ deviceTypePluginDAOManager = new DeviceTypePluginDAOManager(datasourceName, deviceDAODefinition);
+ } else {
+ throw new DeviceTypeDeployerFileException("Invalid datasource name.");
}
- deviceTypePluginDAOManager = new DeviceTypePluginDAOManager(datasourceName, deviceDAODefinition);
- } else {
- throw new DeviceTypeDeployerFileException("Invalid datasource name.");
+ } finally {
+ PrivilegedCarbonContext.endTenantFlow();
}
}
}
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 4d7110e269..575df963d7 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.4-SNAPSHOT
+ 2.0.6-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 1d0d63e753..3790a86283 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.4-SNAPSHOT
+ 2.0.6-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 57a17c7d86..4d283f80b7 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.4-SNAPSHOT
+ 2.0.6-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml
index 64f3daea1a..c179254254 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.4-SNAPSHOT
+ 2.0.6-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 c9049089b2..7f7ae68e73 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.4-SNAPSHOT
+ 2.0.6-SNAPSHOT
../pom.xml
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 b5c2c80202..0fa4b4af48 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.4-SNAPSHOT
+ 2.0.6-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 b700a238ca..752fe82878 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.4-SNAPSHOT
+ 2.0.6-SNAPSHOT
../pom.xml
@@ -143,7 +143,7 @@
provided
- org.wso2.carbon.identity
+ org.wso2.carbon.identity.framework
org.wso2.carbon.user.mgt
provided
@@ -190,7 +190,7 @@
- org.wso2.carbon.identity
+ org.wso2.carbon.identity.inbound.auth.oauth2
org.wso2.carbon.identity.oauth.stub
provided
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/EnrollmentInvitation.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/EnrollmentInvitation.java
new file mode 100644
index 0000000000..5703339a39
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/EnrollmentInvitation.java
@@ -0,0 +1,50 @@
+/*
+ * 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.jaxrs.beans;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+@ApiModel(value = "EnrollmentInvitation", description = "Holds data to send enrollment invitation to list of recipients.")
+public class EnrollmentInvitation {
+
+ @ApiModelProperty(name = "deviceType", value = "Device type name.", required = true)
+ private String deviceType;
+
+ @ApiModelProperty(name = "recipients", value = "List of recipients.", required = true)
+ private List recipients;
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public List getRecipients() {
+ return recipients;
+ }
+
+ public void setRecipients(List recipients) {
+ this.recipients = recipients;
+ }
+}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/Dashboard.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/Dashboard.java
index 903c92e5cd..b9d5058ce0 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/Dashboard.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/Dashboard.java
@@ -5,24 +5,50 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
+import io.swagger.annotations.Authorization;
+import io.swagger.annotations.AuthorizationScope;
+import io.swagger.annotations.Extension;
+import io.swagger.annotations.ExtensionProperty;
+import io.swagger.annotations.Info;
import io.swagger.annotations.ResponseHeader;
+import io.swagger.annotations.SwaggerDefinition;
+import io.swagger.annotations.Tag;
import org.wso2.carbon.device.mgt.analytics.dashboard.bean.DeviceCountByGroup;
import org.wso2.carbon.device.mgt.jaxrs.beans.DashboardGadgetDataWrapper;
import org.wso2.carbon.device.mgt.jaxrs.beans.DashboardPaginationGadgetDataWrapper;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
-import javax.ws.rs.*;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
/**
* Device Analytics Dashboard related REST-APIs. This can be used to obtain device related analytics.
*/
+@SwaggerDefinition(
+ info = @Info(
+ version = "1.0.0",
+ title = "",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = "name", value = "DeviceAnalyticsDashboard"),
+ @ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/dashboard"),
+ })
+ }
+ ),
+ tags = {
+ @Tag(name = "device_management", description = "Device Analytics Dashboard related APIs.")
+ }
+)
@Path("/dashboard")
@Api(value = "Device Analytics Dashboard",
description = "Device Analytics Dashboard related information APIs are described here.")
@Produces(MediaType.APPLICATION_JSON)
-@SuppressWarnings("NonJaxWsWebServices")
+@Consumes(MediaType.APPLICATION_JSON)
public interface Dashboard {
String CONNECTIVITY_STATUS = "connectivity-status";
@@ -40,10 +66,17 @@ public interface Dashboard {
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
- value = "Get the details of registered devices in WSO2 EMM.",
+ value = "Get the details of registered devices in WSO2 IoT.",
notes = "Get the details of active, inactive, removed and total number of registered devices in"
- + " WSO2 EMM.",
- tags = "Dashboard")
+ + " WSO2 IoT.",
+ tags = "Dashboard",
+ authorizations = {
+ @Authorization(
+ value = "permission",
+ scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view",
+ description = "View Dashboard")}
+ )
+ })
@ApiResponses(value = {
@ApiResponse(
code = 200,
@@ -92,8 +125,15 @@ public interface Dashboard {
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
- value = "Get the number of unmonitored and non-compliant devices in WSO2 EMM.",
- tags = "Dashboard")
+ value = "Get the number of unmonitored and non-compliant devices in WSO2 IoT.",
+ tags = "Dashboard",
+ authorizations = {
+ @Authorization(
+ value = "permission",
+ scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view",
+ description = "View Dashboard")}
+ )
+ })
@ApiResponses(value = {
@ApiResponse(
code = 200,
@@ -144,7 +184,14 @@ public interface Dashboard {
httpMethod = "GET",
value = "Get the number of devices that have not complied to a policy that was enforced on a "
+ "device.",
- tags = "Dashboard")
+ tags = "Dashboard",
+ authorizations = {
+ @Authorization(
+ value = "permission",
+ scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view",
+ description = "View Dashboard")}
+ )
+ })
@ApiResponses(value = {
@ApiResponse(
code = 200,
@@ -208,7 +255,14 @@ public interface Dashboard {
httpMethod = "GET",
value = "Get the number of devices for a given device type, such as connectivity status, "
+ "potential vulnerability, platform, and ownership.\n",
- tags = "Dashboard")
+ tags = "Dashboard",
+ authorizations = {
+ @Authorization(
+ value = "permission",
+ scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view",
+ description = "View Dashboard")}
+ )
+ })
@ApiResponses(value = {
@ApiResponse(
code = 200,
@@ -254,11 +308,11 @@ public interface Dashboard {
@ApiParam(
name = "connectivity-status",
value = "Provide the connectivity status of the device. The following values can be assigned:\n"
- + "active: The devices that are registered with WSO2 EMM and are actively "
+ + "active: The devices that are registered with WSO2 IoT and are actively "
+ "communicating with the server.\n"
- + "inactive: The devices that are registered with WSO2 EMM but unable to "
+ + "inactive: The devices that are registered with WSO2 IoT but unable to "
+ "actively communicate with the server.\n"
- + "removed: The devices that have unregistered from WSO2 EMM",
+ + "removed: The devices that have unregistered from WSO2 IoT",
required = true)
@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus,
@ApiParam(
@@ -266,7 +320,7 @@ public interface Dashboard {
value = "Provide details of the potential vulnerabilities of the device. The following "
+ "values can be assigned:\n"
+ "non-compliant: Devices that have not complied to the policies enforced on the "
- + "device by WSO2 EMM.\n"
+ + "device by WSO2 IoT.\n"
+ "unmonitored: Devices that have no policy assigned to them.",
required = true)
@QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability,
@@ -291,7 +345,14 @@ public interface Dashboard {
httpMethod = "GET",
value = "Get the number of devices that have not complied to a given policy based on a particular"
+ " device type.",
- tags = "Dashboard")
+ tags = "Dashboard",
+ authorizations = {
+ @Authorization(
+ value = "permission",
+ scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view",
+ description = "View Dashboard")}
+ )
+ })
@ApiResponses(value = {
@ApiResponse(
code = 200,
@@ -359,12 +420,19 @@ public interface Dashboard {
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
- value = "Get the number of devices that are registered with WSO2 EMM filtered by one of the "
+ value = "Get the number of devices that are registered with WSO2 IoT filtered by one of the "
+ "following attributes:\n"
+ "Connectivity status of the device, such as active, inactive or removed.\n"
+ "The device ownership type, such as BYOD or COPE.\n" + "The device platform.\n"
+ "The potential vulnerabilities faced by the devices.",
- tags = "Dashboard")
+ tags = "Dashboard",
+ authorizations = {
+ @Authorization(
+ value = "permission",
+ scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view",
+ description = "View Dashboard")}
+ )
+ })
@ApiResponses(value = {
@ApiResponse(
code = 200,
@@ -411,12 +479,12 @@ public interface Dashboard {
name = "connectivity-status",
value = "Provide the connectivity status of the device. You can assign any of the values "
+ "given below:\n"
- + "Total: All the devices that have registered with WSO2 EMM.\n"
- + "active: The devices that are registered with WSO2 EMM and are actively "
+ + "Total: All the devices that have registered with WSO2 IoT.\n"
+ + "active: The devices that are registered with WSO2 IoT and are actively "
+ "communicating with the server.\n"
- + "inactive: The devices that are registered with WSO2 EMM but unable to actively"
+ + "inactive: The devices that are registered with WSO2 IoT but unable to actively"
+ " communicate with the server.\n"
- + "removed: The devices that have unregistered from WSO2 EMM.",
+ + "removed: The devices that have unregistered from WSO2 IoT.",
required = true)
@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus,
@ApiParam(
@@ -424,7 +492,7 @@ public interface Dashboard {
value = "Provide details of the potential vulnerabilities of the device. You can assign"
+ " any of the values given below:\n"
+ "non-compliant: Devices that have not complied to the policies enforced on the "
- + "device by WSO2 EMM.\n"
+ + "device by WSO2 IoT.\n"
+ "unmonitored: Devices that have no policy assigned to them.",
required = true)
@QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability,
@@ -449,8 +517,15 @@ public interface Dashboard {
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Get the number of devices that have not complied to a given policy over the total"
- + " number of devices registered with WSO2 EMM.\n",
- tags = "Dashboard")
+ + " number of devices registered with WSO2 IoT.\n",
+ tags = "Dashboard",
+ authorizations = {
+ @Authorization(
+ value = "permission",
+ scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view",
+ description = "View Dashboard")}
+ )
+ })
@ApiResponses(value = {
@ApiResponse(
code = 200,
@@ -519,7 +594,14 @@ public interface Dashboard {
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Get device details of devices based on a particular device type.",
- tags = "Dashboard")
+ tags = "Dashboard",
+ authorizations = {
+ @Authorization(
+ value = "permission",
+ scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view",
+ description = "View Dashboard")}
+ )
+ })
@ApiResponses(value = {
@ApiResponse(
code = 200,
@@ -565,19 +647,19 @@ public interface Dashboard {
@ApiParam(
name = "connectivity-status",
value = "Provide the connectivity status of the device. This can be one of the following:\n"
- + "Total: All the devices that have registered with WSO2 EMM.\n"
- + "active: The devices that are registered with WSO2 EMM and are actively "
+ + "Total: All the devices that have registered with WSO2 IoT.\n"
+ + "active: The devices that are registered with WSO2 IoT and are actively "
+ "communicating with the server.\n"
- + "inactive: The devices that are registered with WSO2 EMM but unable to actively"
+ + "inactive: The devices that are registered with WSO2 IoT but unable to actively"
+ " communicate with the server.\n"
- + "removed: The devices that have unregistered from WSO2 EMM.",
+ + "removed: The devices that have unregistered from WSO2 IoT.",
required = true)
@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus,
@ApiParam(
name = "potential-vulnerability",
value = "Provide details of the potential vulnerabilities of the device. This can be:\n"
+ "non-compliant: Devices that have not complied to the policies enforced on "
- + "the device by WSO2 EMM.\n"
+ + "the device by WSO2 IoT.\n"
+ "unmonitored: Devices that have no policy assigned to them. ",
required = true)
@QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability,
@@ -615,7 +697,14 @@ public interface Dashboard {
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Get device details of non-compliant devices which do not comply to a given policy.",
- tags = "Dashboard")
+ tags = "Dashboard",
+ authorizations = {
+ @Authorization(
+ value = "permission",
+ scopes = {@AuthorizationScope(scope = "/device-mgt/dashboard/view",
+ description = "View Dashboard")}
+ )
+ })
@ApiResponses(value = {
@ApiResponse(
code = 200,
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java
index 6a77938b0f..7f28227964 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java
@@ -562,5 +562,8 @@ public interface PolicyManagementService {
required = true)
List priorityUpdatedPolicies);
+ @GET
+ @Path("/effective-policy/{deviceType}/{deviceId}")
+ Response getEffectivePolicy(@PathParam("deviceId") String deviceId, @PathParam("deviceType") String deviceType);
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java
index b211a3a101..41353a0f4c 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java
@@ -18,22 +18,39 @@
*/
package org.wso2.carbon.device.mgt.jaxrs.service.api;
-import io.swagger.annotations.SwaggerDefinition;
-import io.swagger.annotations.Info;
-import io.swagger.annotations.ExtensionProperty;
-import io.swagger.annotations.Extension;
-import io.swagger.annotations.Tag;
import io.swagger.annotations.Api;
-import io.swagger.annotations.AuthorizationScope;
-import io.swagger.annotations.Authorization;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
+import io.swagger.annotations.Authorization;
+import io.swagger.annotations.AuthorizationScope;
+import io.swagger.annotations.Extension;
+import io.swagger.annotations.ExtensionProperty;
+import io.swagger.annotations.Info;
import io.swagger.annotations.ResponseHeader;
-import org.wso2.carbon.device.mgt.jaxrs.beans.*;
+import io.swagger.annotations.SwaggerDefinition;
+import io.swagger.annotations.Tag;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.wso2.carbon.device.mgt.jaxrs.beans.BasicUserInfo;
+import org.wso2.carbon.device.mgt.jaxrs.beans.BasicUserInfoList;
+import org.wso2.carbon.device.mgt.jaxrs.beans.EnrollmentInvitation;
+import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
+import org.wso2.carbon.device.mgt.jaxrs.beans.OldPasswordResetWrapper;
+import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList;
+import org.wso2.carbon.device.mgt.jaxrs.beans.UserInfo;
-import javax.ws.rs.*;
+import javax.validation.Valid;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.List;
@@ -65,7 +82,7 @@ public interface UserManagementService {
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Adding a User",
- notes = "WSO2 EMM supports user management. Add a new user to the WSO2 EMM user management system via this REST API",
+ notes = "WSO2 IoTS supports user management. Add a new user to the WSO2 IoTS user management system via this REST API",
tags = "User Management",
authorizations = {
@Authorization(
@@ -126,7 +143,7 @@ public interface UserManagementService {
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting Details of a User",
- notes = "Get the details of a user registered with WSO2 EMM using the REST API.",
+ notes = "Get the details of a user registered with WSO2 IoTS using the REST API.",
response = BasicUserInfo.class,
tags = "User Management",
authorizations = {
@@ -267,7 +284,7 @@ public interface UserManagementService {
@ApiOperation(
httpMethod = "DELETE",
value = "Deleting a User",
- notes = "When an employee leaves the organization, you can remove the user details from WSO2 EMM using this REST API.",
+ notes = "When an employee leaves the organization, you can remove the user details from WSO2 IoTS using this REST API.",
tags = "User Management",
authorizations = {
@Authorization(
@@ -280,7 +297,7 @@ public interface UserManagementService {
@ApiResponses(value = {
@ApiResponse(
code = 200,
- message = "OK. \n Successfully removed the user from WSO2 EMM."),
+ message = "OK. \n Successfully removed the user from WSO2 IoTS."),
@ApiResponse(
code = 404,
message = "Not Found. \n The specified resource does not exist.",
@@ -312,7 +329,7 @@ public interface UserManagementService {
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting the Role Details of a User",
- notes = "A user can be assigned to one or more role in EMM. Using this REST API you can get the role/roles a user is assigned to.",
+ notes = "A user can be assigned to one or more role in IoTS. Using this REST API you can get the role/roles a user is assigned to.",
tags = "User Management",
authorizations = {
@Authorization(
@@ -375,7 +392,7 @@ public interface UserManagementService {
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting Details of Users",
- notes = "You are able to manage users in WSO2 EMM by adding, updating and removing users. If you wish to get the list of users registered with WSO2 EMM, you can do so "
+ notes = "You are able to manage users in WSO2 IoTS by adding, updating and removing users. If you wish to get the list of users registered with WSO2 IoTS, you can do so "
+ "using this REST API",
tags = "User Management",
authorizations = {
@@ -389,7 +406,7 @@ public interface UserManagementService {
@ApiResponses(value = {
@ApiResponse(
code = 200,
- message = "OK. \n Successfully fetched the list of users registered with WSO2 EMM.",
+ message = "OK. \n Successfully fetched the list of users registered with WSO2 IoTS.",
response = BasicUserInfoList.class,
responseHeaders = {
@ResponseHeader(
@@ -414,7 +431,7 @@ public interface UserManagementService {
response = ErrorResponse.class),
@ApiResponse(
code = 500,
- message = "Internal Server Error. \n Server error occurred while fetching the list of WSO2 EMM users.",
+ message = "Internal Server Error. \n Server error occurred while fetching the list of WSO2 IoTS users.",
response = ErrorResponse.class)
})
Response getUsers(
@@ -449,7 +466,7 @@ public interface UserManagementService {
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting the User Count",
- notes = "Get the number of users in WSO2 EMM via this REST API.",
+ notes = "Get the number of users in WSO2 IoTS via this REST API.",
tags = "User Management",
authorizations = {
@Authorization(
@@ -474,7 +491,7 @@ public interface UserManagementService {
response = ErrorResponse.class),
@ApiResponse(
code = 500,
- message = "Internal Server Error. \n Server error occurred while fetching the total number of users in WSO2 EMM.",
+ message = "Internal Server Error. \n Server error occurred while fetching the total number of users in WSO2 IoTS.",
response = ErrorResponse.class)
})
Response getUserCount();
@@ -608,7 +625,7 @@ public interface UserManagementService {
produces = MediaType.APPLICATION_JSON,
httpMethod = "PUT",
value = "Changing the User Password",
- notes = "A user is able to change the password to secure their WSO2 EMM profile via this REST API.",
+ notes = "A user is able to change the password to secure their WSO2 IoTS profile via this REST API.",
tags = "User Management",
authorizations = {
@Authorization(
@@ -653,8 +670,8 @@ public interface UserManagementService {
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Sending Enrollment Invitations to Users",
- notes = "Send the users a mail inviting them to download the EMM mobile application on their devices using the REST API given below.\n" +
- "Before running the REST API command to send the enrollment invitations to users make sure to configure WSO2 EMM as explained in step 4, under the WSO2 EMM general server configurations documentation.",
+ notes = "Send the users a mail inviting them to enroll their devices using the REST API given below.\n" +
+ "Before running the REST API command to send the enrollment invitations to users make sure to configure WSO2 IoTS as explained in step 4, under the WSO2 IoTS general server configurations documentation.",
tags = "User Management",
authorizations = {
@Authorization(
@@ -691,4 +708,47 @@ public interface UserManagementService {
value = "List of users",
required = true) List usernames);
+ @POST
+ @Path("/enrollment-invite")
+ @ApiOperation(
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = HTTPConstants.HEADER_POST,
+ value = "Sending Enrollment Invitations to email address",
+ notes = "Send the a mail inviting recipients to enroll devices.",
+ tags = "User Management",
+ authorizations = {
+ @Authorization(
+ value = "permission",
+ scopes = {@AuthorizationScope(scope = "/device-mgt/users/invite", description = "Invite Users")}
+ )
+ }
+ )
+ @ApiResponses(value = {
+ @ApiResponse(
+ code = 200,
+ message = "OK. \n Successfully sent the invitation mail."),
+ @ApiResponse(
+ code = 400,
+ message = "Bad Request. \n Invalid request or validation error.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 404,
+ message = "Not Found. \n The specified resource does not exist.\n",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 415,
+ message = "Unsupported media type. \n The format of the requested entity was not supported.\n",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n " +
+ "Server error occurred while updating the user credentials.",
+ response = ErrorResponse.class)
+ })
+ Response inviteToEnrollDevice(
+ @ApiParam(
+ name = "enrollmentInvitation",
+ value = "List of email address of recipients",
+ required = true)
+ @Valid EnrollmentInvitation enrollmentInvitation);
}
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 7de6903180..846fbbb69b 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
@@ -45,6 +45,7 @@ import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData;
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
+import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
import javax.validation.constraints.Size;
import javax.ws.rs.*;
@@ -113,15 +114,16 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
}
// this is the user who initiates the request
- String authorizedUser = CarbonContext.getThreadLocalCarbonContext().getUsername();
+ String authorizedUser = MultitenantUtils.getTenantAwareUsername(CarbonContext.getThreadLocalCarbonContext().getUsername());
// check whether the user is device-mgt admin
if (deviceAccessAuthorizationService.isDeviceAdminUser()) {
if (user != null && !user.isEmpty()) {
- request.setOwner(user);
+ request.setOwner(MultitenantUtils.getTenantAwareUsername(user));
}
} else {
if (user != null && !user.isEmpty()) {
+ user = MultitenantUtils.getTenantAwareUsername(user);
if (user.equals(authorizedUser)) {
request.setOwner(user);
} else {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java
index 16e7a8eb06..73ed8523a2 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java
@@ -373,4 +373,29 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
}
}
+ @GET
+ @Path("/effective-policy/{deviceType}/{deviceId}")
+ @Override
+ public Response getEffectivePolicy(@PathParam("deviceId") String deviceId, @PathParam("deviceType") String deviceType) {
+ PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
+ final org.wso2.carbon.policy.mgt.common.Policy policy;
+ try {
+ DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
+ deviceIdentifier.setId(deviceId);
+ deviceIdentifier.setType(deviceType);
+ policy = policyManagementService.getAppliedPolicyToDevice(deviceIdentifier);
+ if (policy == null) {
+ return Response.status(Response.Status.NOT_FOUND).entity(
+ new ErrorResponse.ErrorResponseBuilder().setMessage(
+ "No policy found for device ID '" + deviceId + "'"+ deviceId).build()).build();
+ }
+ } catch (PolicyManagementException e) {
+ String msg = "Error occurred while retrieving policy corresponding to the id '" + deviceType + "'"+ deviceId;
+ log.error(msg, e);
+ return Response.serverError().entity(
+ new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
+ }
+ return Response.status(Response.Status.OK).entity(policy).build();
+ }
+
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java
index 35ccabfab3..ee664e2c63 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java
@@ -143,6 +143,17 @@ public class RoleManagementServiceImpl implements RoleManagementService {
}
}
+ private UIPermissionNode getAllRolePermissions(String roleName, UserRealm userRealm) throws UserAdminException {
+ org.wso2.carbon.user.core.UserRealm userRealmCore = null;
+ if (userRealm instanceof org.wso2.carbon.user.core.UserRealm) {
+ userRealmCore = (org.wso2.carbon.user.core.UserRealm) userRealm;
+ }
+ final UserRealmProxy userRealmProxy = new UserRealmProxy(userRealmCore);
+ final UIPermissionNode rolePermissions =
+ userRealmProxy.getRolePermissions(roleName, MultitenantConstants.SUPER_TENANT_ID);
+ return rolePermissions;
+ }
+
private UIPermissionNode getUIPermissionNode(String roleName, UserRealm userRealm)
throws UserAdminException {
org.wso2.carbon.user.core.UserRealm userRealmCore = null;
@@ -228,6 +239,19 @@ public class RoleManagementServiceImpl implements RoleManagementService {
return list;
}
+
+ private List getAuthorizedPermissions(UIPermissionNode uiPermissionNode, List list) {
+ for (UIPermissionNode permissionNode : uiPermissionNode.getNodeList()) {
+ if (permissionNode.isSelected()) {
+ list.add(permissionNode.getResourcePath());
+ }
+ if (permissionNode.getNodeList() != null && permissionNode.getNodeList().length > 0) {
+ getAuthorizedPermissions(permissionNode, list);
+ }
+ }
+ return list;
+ }
+
@POST
@Override
public Response addRole(RoleInfo roleInfo) {
@@ -377,6 +401,17 @@ public class RoleManagementServiceImpl implements RoleManagementService {
}
if (roleInfo.getPermissions() != null) {
+ // Get all role permissions
+ final UIPermissionNode rolePermissions = this.getAllRolePermissions(roleName, userRealm);
+ List permissions = new ArrayList();
+ this.getAuthorizedPermissions(rolePermissions, permissions);
+ for (String permission : roleInfo.getPermissions()) {
+ permissions.add(permission);
+ }
+ String [] allApplicablePerms = new String[permissions.size()];
+ allApplicablePerms = permissions.toArray(allApplicablePerms);
+ roleInfo.setPermissions(allApplicablePerms);
+
// Delete all authorizations for the current role before authorizing the permission tree
authorizationManager.clearRoleAuthorization(roleName);
if (roleInfo.getPermissions().length > 0) {
@@ -394,6 +429,11 @@ public class RoleManagementServiceImpl implements RoleManagementService {
log.error(msg, e);
return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
+ } catch (UserAdminException e) {
+ String msg = "Error occurred while updating permissions of the role '" + roleName + "'";
+ log.error(msg, e);
+ return Response.serverError().entity(
+ new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
}
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java
index 1b527337c8..0390e5b13d 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java
@@ -23,9 +23,16 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.wst.common.uriresolver.internal.util.URIEncoder;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
+import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.EmailMetaInfo;
-import org.wso2.carbon.device.mgt.jaxrs.beans.*;
+import org.wso2.carbon.device.mgt.jaxrs.beans.BasicUserInfo;
+import org.wso2.carbon.device.mgt.jaxrs.beans.BasicUserInfoList;
+import org.wso2.carbon.device.mgt.jaxrs.beans.EnrollmentInvitation;
+import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
+import org.wso2.carbon.device.mgt.jaxrs.beans.OldPasswordResetWrapper;
+import org.wso2.carbon.device.mgt.jaxrs.beans.RoleList;
+import org.wso2.carbon.device.mgt.jaxrs.beans.UserInfo;
import org.wso2.carbon.device.mgt.jaxrs.service.api.UserManagementService;
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
@@ -33,15 +40,33 @@ import org.wso2.carbon.device.mgt.jaxrs.util.CredentialManagementResponseBuilder
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.user.api.UserStoreManager;
-
-import javax.ws.rs.*;
+import org.wso2.carbon.utils.CarbonUtils;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.SecureRandom;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
@Path("/users")
@Produces(MediaType.APPLICATION_JSON)
@@ -446,7 +471,7 @@ public class UserManagementServiceImpl implements UserManagementService {
* @param usernames Username list of the users to be invited
*/
@POST
- @Path("send-invitation")
+ @Path("/send-invitation")
@Produces({MediaType.APPLICATION_JSON})
public Response inviteExistingUsersToEnrollDevice(List usernames) {
if (log.isDebugEnabled()) {
@@ -462,7 +487,8 @@ public class UserManagementServiceImpl implements UserManagementService {
props.setProperty("username", username);
EmailMetaInfo metaInfo = new EmailMetaInfo(recipient, props);
- dms.sendEnrolmentInvitation(metaInfo);
+ dms.sendEnrolmentInvitation(DeviceManagementConstants.EmailAttributes.USER_ENROLLMENT_TEMPLATE,
+ metaInfo);
}
} catch (DeviceManagementException e) {
String msg = "Error occurred while inviting user to enrol their device";
@@ -476,6 +502,40 @@ public class UserManagementServiceImpl implements UserManagementService {
return Response.status(Response.Status.OK).entity("Invitation mails have been sent.").build();
}
+ @POST
+ @Path("/enrollment-invite")
+ @Override
+ public Response inviteToEnrollDevice(EnrollmentInvitation enrollmentInvitation) {
+ if (log.isDebugEnabled()) {
+ log.debug("Sending enrollment invitation mail to existing user.");
+ }
+ DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService();
+ try {
+ Set recipients = new HashSet<>();
+ for (String recipient : enrollmentInvitation.getRecipients()) {
+ recipients.add(recipient);
+ }
+ Properties props = new Properties();
+ String username = DeviceMgtAPIUtils.getAuthenticatedUser();
+ String firstName = getClaimValue(username, Constants.USER_CLAIM_FIRST_NAME);
+ if (firstName == null) {
+ firstName = username;
+ }
+ props.setProperty("first-name", firstName);
+ props.setProperty("device-type", enrollmentInvitation.getDeviceType());
+ EmailMetaInfo metaInfo = new EmailMetaInfo(recipients, props);
+ dms.sendEnrolmentInvitation(getEnrollmentTemplateName(enrollmentInvitation.getDeviceType()), metaInfo);
+ } catch (DeviceManagementException e) {
+ String msg = "Error occurred while inviting user to enrol their device";
+ log.error(msg, e);
+ } catch (UserStoreException e) {
+ String msg = "Error occurred while getting claim values to invite user";
+ log.error(msg, e);
+ return Response.serverError().entity(
+ new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
+ }
+ return Response.status(Response.Status.OK).entity("Invitation mails have been sent.").build();
+ }
private Map buildDefaultUserClaims(String firstName, String lastName, String emailAddress) {
Map defaultUserClaims = new HashMap<>();
@@ -522,4 +582,19 @@ public class UserManagementServiceImpl implements UserManagementService {
return userStoreManager.getUserClaimValue(username, claimUri, null);
}
+ private String getEnrollmentTemplateName(String deviceType) {
+ String templateName = deviceType + "-enrollment-invitation";
+ File template = new File(CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator
+ + "resources" + File.separator + "email-templates" + File.separator + templateName
+ + ".vm");
+ if (template.exists()) {
+ return templateName;
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("The template that is expected to use is not available. Therefore, using default template.");
+ }
+ }
+ return DeviceManagementConstants.EmailAttributes.DEFAULT_ENROLLMENT_TEMPLATE;
+ }
+
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java
index c15e92eb9f..afc03336d5 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java
@@ -286,4 +286,14 @@ public class DeviceMgtAPIUtils {
}
}
+ public static String getAuthenticatedUser() {
+ PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ String username = threadLocalCarbonContext.getUsername();
+ String tenantDomain = threadLocalCarbonContext.getTenantDomain();
+ if (username != null && username.endsWith(tenantDomain)) {
+ return username.substring(0, username.lastIndexOf("@"));
+ }
+ return username;
+ }
+
}
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 b7d71adceb..a5a0668e46 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.4-SNAPSHOT
+ 2.0.6-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/MonitoringOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/MonitoringOperation.java
index 7ce7000d81..8d5a8cc434 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/MonitoringOperation.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/MonitoringOperation.java
@@ -42,6 +42,5 @@ public class MonitoringOperation {
this.recurrentTimes = recurrentTimes;
}
-
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationMonitoringTaskConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationMonitoringTaskConfig.java
index ec50a02b6f..237516b26a 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationMonitoringTaskConfig.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationMonitoringTaskConfig.java
@@ -52,6 +52,6 @@ public class OperationMonitoringTaskConfig {
public void setMonitoringOperation(List monitoringOperation) {
this.monitoringOperation = monitoringOperation;
- }
+ }
}
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 ee8e28b01f..432dc99b04 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.4-SNAPSHOT
+ 2.0.6-SNAPSHOT
../pom.xml
@@ -206,17 +206,37 @@
org.wso2.carbon.apimgt
org.wso2.carbon.apimgt.api
+
+
+ org.wso2.carbon.identity
+ org.wso2.carbon.user.mgt.stub
+
+
+ org.wso2.carbon.identity
+ org.wso2.carbon.user.mgt
+
+
org.wso2.carbon.apimgt
org.wso2.carbon.apimgt.impl
+
+
+ org.wso2.carbon.identity
+ org.wso2.carbon.user.mgt.stub
+
+
+ org.wso2.carbon.identity
+ org.wso2.carbon.user.mgt
+
+
org.apache.axis2.wso2
axis2
- org.wso2.carbon.identity
+ org.wso2.carbon.identity.inbound.auth.oauth2
org.wso2.carbon.identity.oauth.stub
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java
index 2b5398fb88..a1749b8f31 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java
@@ -75,6 +75,10 @@ public final class DeviceManagementConstants {
public static final String SERVER_BASE_URL_HTTPS = "base-url-https";
public static final String SERVER_BASE_URL_HTTP = "base-url-http";
public static final String DOWNLOAD_URL = "download-url";
+
+ public static final String USER_REGISTRATION_TEMPLATE = "user-registration";
+ public static final String USER_ENROLLMENT_TEMPLATE = "user-enrollment";
+ public static final String DEFAULT_ENROLLMENT_TEMPLATE = "default-enrollment-invitation";
}
public static final class OperationAttributes {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java
index 9e2a81d5c3..ca32fa037b 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java
@@ -195,7 +195,6 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
} else {
deviceTaskManagerService.startTask(deviceManagementService.getType(),
operationMonitoringTaskConfig);
- // TODO: In here a race condition can arise. Need to handle it.
}
}
} catch (DeviceMgtTaskException e) {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/policy/PolicyConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/policy/PolicyConfiguration.java
index 73d3517d83..1f52150f3f 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/policy/PolicyConfiguration.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/policy/PolicyConfiguration.java
@@ -33,6 +33,7 @@ public class PolicyConfiguration {
private int minRetriesToMarkUnreachable;
private int minRetriesToMarkInactive;
private List platforms;
+ private String policyEvaluationPoint;
@XmlElement(name = "MonitoringClass", required = true)
public String getMonitoringClass() {
@@ -98,4 +99,13 @@ public class PolicyConfiguration {
this.platforms = platforms;
}
+ @XmlElement(name = "PolicyEvaluationPoint", required = true)
+ public String getPolicyEvaluationPointName() {
+ return policyEvaluationPoint;
+ }
+
+ public void setPolicyEvaluationPointName(String policyEvaluationPointName) {
+ this.policyEvaluationPoint = policyEvaluationPointName;
+ }
+
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceTaskManagerServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceTaskManagerServiceComponent.java
index 7dab541321..344d567f0f 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceTaskManagerServiceComponent.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceTaskManagerServiceComponent.java
@@ -58,11 +58,11 @@ public class DeviceTaskManagerServiceComponent {
log.debug("Initializing device details retrieving task manager bundle.");
}
// This will start the device details retrieving task.
-// DeviceTaskManagerService deviceTaskManagerService = new DeviceTaskManagerServiceImpl();
-// DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(
-// deviceTaskManagerService);
-// componentContext.getBundleContext().registerService(DeviceTaskManagerService.class,
-// deviceTaskManagerService, null);
+ // DeviceTaskManagerService deviceTaskManagerService = new DeviceTaskManagerServiceImpl();
+ // DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(
+ // deviceTaskManagerService);
+ // componentContext.getBundleContext().registerService(DeviceTaskManagerService.class,
+ // deviceTaskManagerService, null);
getDeviceOperationMonitoringConfig(componentContext);
@@ -76,12 +76,12 @@ public class DeviceTaskManagerServiceComponent {
}
}
- private void getDeviceOperationMonitoringConfig(ComponentContext componentContext) throws DeviceMgtTaskException {
+ private void getDeviceOperationMonitoringConfig(ComponentContext componentContext)
+ throws DeviceMgtTaskException {
DeviceTaskManagerService deviceTaskManagerService = new DeviceTaskManagerServiceImpl();
- DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(
- deviceTaskManagerService);
+ DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(deviceTaskManagerService);
componentContext.getBundleContext().registerService(DeviceTaskManagerService.class,
deviceTaskManagerService, null);
@@ -89,11 +89,10 @@ public class DeviceTaskManagerServiceComponent {
Map deviceConfigMap = DeviceMonitoringOperationDataHolder
.getInstance().getOperationMonitoringConfigFromMap();
- for (String platformType : new ArrayList(deviceConfigMap.keySet())) {
+ for (String platformType : new ArrayList<>(deviceConfigMap.keySet())) {
deviceTaskManagerService.startTask(platformType, deviceConfigMap.get(platformType));
deviceConfigMap.remove(platformType);
}
-
}
@SuppressWarnings("unused")
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java
index 33bd6c0607..ed1e9abec3 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java
@@ -81,7 +81,7 @@ public interface DeviceManagementProviderService {
*/
PaginationResult getAllDevices(PaginationRequest request) throws DeviceManagementException;
- void sendEnrolmentInvitation(EmailMetaInfo metaInfo) throws DeviceManagementException;
+ void sendEnrolmentInvitation(String templateName, EmailMetaInfo metaInfo) throws DeviceManagementException;
void sendRegistrationEmail(EmailMetaInfo metaInfo) throws DeviceManagementException;
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 210b0927cb..521bcefdf6 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
@@ -50,6 +50,7 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
+import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.core.DeviceManagementPluginRepository;
import org.wso2.carbon.device.mgt.core.dao.ApplicationDAO;
import org.wso2.carbon.device.mgt.core.dao.DeviceDAO;
@@ -73,10 +74,12 @@ import org.wso2.carbon.user.api.UserStoreException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
+import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
public class DeviceManagementProviderServiceImpl implements DeviceManagementProviderService,
@@ -752,21 +755,25 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
}
@Override
- public void sendEnrolmentInvitation(EmailMetaInfo metaInfo) throws DeviceManagementException {
+ public void sendEnrolmentInvitation(String templateName, EmailMetaInfo metaInfo) throws DeviceManagementException {
Map, Object>> params = new HashMap<>();
- params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.FIRST_NAME,
- new TypedValue, Object>(String.class, metaInfo.getProperty("first-name")));
+ Properties props = metaInfo.getProperties();
+ Enumeration e = props.propertyNames();
+ while (e.hasMoreElements()) {
+ String key = (String) e.nextElement();
+ params.put(key, new TypedValue, Object>(String.class, props.getProperty(key)));
+ }
params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.SERVER_BASE_URL_HTTPS,
new TypedValue, Object>(String.class, DeviceManagerUtil.getServerBaseHttpsUrl()));
params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.SERVER_BASE_URL_HTTP,
new TypedValue, Object>(String.class, DeviceManagerUtil.getServerBaseHttpUrl()));
try {
EmailContext ctx =
- new EmailContext.EmailContextBuilder(new ContentProviderInfo("user-enrollment", params),
- metaInfo.getRecipients()).build();
+ new EmailContext.EmailContextBuilder(new ContentProviderInfo(templateName, params),
+ metaInfo.getRecipients()).build();
DeviceManagementDataHolder.getInstance().getEmailSenderService().sendEmail(ctx);
- } catch (EmailSendingFailedException e) {
- throw new DeviceManagementException("Error occurred while sending enrollment invitation", e);
+ } catch (EmailSendingFailedException ex) {
+ throw new DeviceManagementException("Error occurred while sending enrollment invitation", ex);
}
}
@@ -787,7 +794,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
new TypedValue, Object>(String.class, DeviceManagerUtil.getServerBaseHttpUrl()));
try {
EmailContext ctx =
- new EmailContext.EmailContextBuilder(new ContentProviderInfo("user-registration", params),
+ new EmailContext.EmailContextBuilder(
+ new ContentProviderInfo(
+ DeviceManagementConstants.EmailAttributes.USER_REGISTRATION_TEMPLATE,
+ params),
metaInfo.getRecipients()).build();
DeviceManagementDataHolder.getInstance().getEmailSenderService().sendEmail(ctx);
} catch (EmailSendingFailedException e) {
@@ -1222,17 +1232,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
@Override
public List getMonitoringOperationList(String deviceType) {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
-// Map deviceManagementServiceMap =
-// pluginRepository.getAllDeviceManagementServices(tenantId);
+
DeviceManagementService dms = pluginRepository.getDeviceManagementService(deviceType, tenantId);
- // ;
- // OperationMonitoringTaskConfig operationMonitoringTaskConfig;
- //Map> deviceTypeSpecificMonitoringOperations = new HashMap<>();
-// for(DeviceTypeIdentifier dti : deviceManagementServiceMap.keySet()){
-// dms = deviceManagementServiceMap.get(dti);
-//
-// }
OperationMonitoringTaskConfig operationMonitoringTaskConfig = dms.getOperationMonitoringConfig();
return operationMonitoringTaskConfig.getMonitoringOperation();
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceDetailsRetrieverTask.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceDetailsRetrieverTask.java
index 37a90f6f82..69e49b7874 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceDetailsRetrieverTask.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceDetailsRetrieverTask.java
@@ -19,8 +19,10 @@
package org.wso2.carbon.device.mgt.core.task.impl;
+import com.google.gson.Gson;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.core.task.DeviceMgtTaskException;
import org.wso2.carbon.device.mgt.core.task.DeviceTaskManager;
import org.wso2.carbon.ntask.core.Task;
@@ -32,10 +34,18 @@ public class DeviceDetailsRetrieverTask implements Task {
private static Log log = LogFactory.getLog(DeviceDetailsRetrieverTask.class);
// private DeviceTaskManager deviceTaskManager = new DeviceTaskManagerImpl();
private String deviceType;
+ private String oppConfig;
+ private OperationMonitoringTaskConfig operationMonitoringTaskConfig;
@Override
public void setProperties(Map map) {
deviceType = map.get("DEVICE_TYPE");
+ oppConfig = map.get("OPPCONFIG");
+
+ Gson gson = new Gson();
+
+ operationMonitoringTaskConfig = gson.fromJson(oppConfig,
+ OperationMonitoringTaskConfig.class);
}
@Override
@@ -49,14 +59,18 @@ public class DeviceDetailsRetrieverTask implements Task {
log.debug("Device details retrieving task started to run.");
}
- DeviceTaskManager deviceTaskManager = new DeviceTaskManagerImpl(deviceType);
-
+ DeviceTaskManager deviceTaskManager = new DeviceTaskManagerImpl(deviceType,
+ operationMonitoringTaskConfig);
+ //pass the configurations also from here, monitoring tasks
try {
deviceTaskManager.addOperations();
} catch (DeviceMgtTaskException e) {
- log.error("Error occurred while trying to add the operations to device to retrieve device details.", e);
+ log.error(
+ "Error occurred while trying to add the operations to device to retrieve device details.",
+ e);
}
}
+
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceTaskManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceTaskManagerImpl.java
index 2606f07fd3..16fff9ce13 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceTaskManagerImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceTaskManagerImpl.java
@@ -25,6 +25,7 @@ import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
import org.wso2.carbon.device.mgt.common.MonitoringOperation;
+import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
@@ -46,30 +47,26 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
private static Log log = LogFactory.getLog(DeviceTaskManagerImpl.class);
private String deviceType;
private static Map> map = new HashMap<>();
+ private OperationMonitoringTaskConfig operationMonitoringTaskConfig;
+
+ public DeviceTaskManagerImpl(String deviceType,
+ OperationMonitoringTaskConfig operationMonitoringTaskConfig) {
+ this.operationMonitoringTaskConfig = operationMonitoringTaskConfig;
+ this.deviceType = deviceType;
+ }
public DeviceTaskManagerImpl(String deviceType) {
this.deviceType = deviceType;
}
//get device type specific operations
- public List getOperationList() throws DeviceMgtTaskException {
-
- DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder
- .getInstance().
- getDeviceManagementProvider();
-
- return deviceManagementProviderService.getMonitoringOperationList(
- deviceType);//Get task list from each device type
+ private List getOperationList() throws DeviceMgtTaskException {
+ return operationMonitoringTaskConfig.getMonitoringOperation();
}
@Override
public int getTaskFrequency() throws DeviceMgtTaskException {
- DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder
- .getInstance().
- getDeviceManagementProvider();
-
- return deviceManagementProviderService.getDeviceMonitoringFrequency(deviceType);
-
+ return operationMonitoringTaskConfig.getFrequency();
}
// @Override
@@ -80,11 +77,7 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
@Override
public boolean isTaskEnabled() throws DeviceMgtTaskException {
- DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder
- .getInstance().
- getDeviceManagementProvider();
-
- return deviceManagementProviderService.isDeviceMonitoringEnabled(deviceType);
+ return operationMonitoringTaskConfig.isEnabled();
}
@@ -149,13 +142,22 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
return opNames;
}
+ private List getOperationListforTask() throws DeviceMgtTaskException {
+
+ DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder
+ .getInstance().
+ getDeviceManagementProvider();
+
+ return deviceManagementProviderService.getMonitoringOperationList(
+ deviceType);//Get task list from each device type
+ }
@Override
public boolean isTaskOperation(String opName) {
try {
- List monitoringOperations = this.getOperationList();
+ List monitoringOperations = this.getOperationListforTask();
for (MonitoringOperation taop : monitoringOperations) {
if (taop.getTaskName().equalsIgnoreCase(opName)) {
return true;
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceTaskManagerServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceTaskManagerServiceImpl.java
index 7a47f8d6bf..d23939f866 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceTaskManagerServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceTaskManagerServiceImpl.java
@@ -19,6 +19,7 @@
package org.wso2.carbon.device.mgt.core.task.impl;
+import com.google.gson.Gson;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
@@ -46,9 +47,8 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
private static Log log = LogFactory.getLog(DeviceTaskManagerServiceImpl.class);
@Override
- public void startTask(String deviceType, OperationMonitoringTaskConfig operationMonitoringTaskConfig) throws DeviceMgtTaskException {
-
-// String TASK_NAME = deviceType;
+ public void startTask(String deviceType, OperationMonitoringTaskConfig operationMonitoringTaskConfig)
+ throws DeviceMgtTaskException {
log.info("Task adding for " + deviceType);
@@ -60,45 +60,52 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
if (log.isDebugEnabled()) {
log.debug("Device details retrieving task is started for the tenant id " + tenantId);
-// log.debug("Device details retrieving task is at frequency of : " + deviceTaskManager
-// .getTaskFrequency());
- log.debug("Device details retrieving task is at frequency of : " + operationMonitoringTaskConfig
- .getFrequency());
+ // log.debug("Device details retrieving task is at frequency of : " + deviceTaskManager
+ // .getTaskFrequency());
+ log.debug(
+ "Device details retrieving task is at frequency of : " + operationMonitoringTaskConfig
+ .getFrequency());
}
TaskManager taskManager = taskService.getTaskManager(TASK_TYPE);
TaskInfo.TriggerInfo triggerInfo = new TaskInfo.TriggerInfo();
-// triggerInfo.setIntervalMillis(deviceTaskManager.getTaskFrequency());
+ // triggerInfo.setIntervalMillis(deviceTaskManager.getTaskFrequency());
triggerInfo.setIntervalMillis(operationMonitoringTaskConfig.getFrequency());
triggerInfo.setRepeatCount(-1);
+ Gson gson = new Gson();
+ String operationConfigs = gson.toJson(operationMonitoringTaskConfig);
+
Map properties = new HashMap<>();
+
properties.put(TENANT_ID, String.valueOf(tenantId));
properties.put("DEVICE_TYPE", deviceType);
+ properties.put("OPPCONFIG", operationConfigs);
+ String taskName = deviceType + String.valueOf(tenantId);
if (!taskManager.isTaskScheduled(deviceType)) {
- TaskInfo taskInfo = new TaskInfo(deviceType, TASK_CLASS, properties, triggerInfo);
+ TaskInfo taskInfo = new TaskInfo(taskName, TASK_CLASS, properties, triggerInfo);
taskManager.registerTask(taskInfo);
taskManager.rescheduleTask(taskInfo.getName());
} else {
- throw new DeviceMgtTaskException("Device details retrieving task is already started for this tenant " +
- tenantId);
+ throw new DeviceMgtTaskException(
+ "Device details retrieving task is already started for this tenant " + tenantId);
}
} catch (TaskException e) {
- throw new DeviceMgtTaskException("Error occurred while creating the task for tenant " + tenantId, e);
+ throw new DeviceMgtTaskException("Error occurred while creating the task for tenant " + tenantId,
+ e);
}
}
@Override
- public void stopTask(String deviceType, OperationMonitoringTaskConfig operationMonitoringTaskConfig) throws DeviceMgtTaskException {
-
-// String TASK_NAME = deviceType;
+ public void stopTask(String deviceType, OperationMonitoringTaskConfig operationMonitoringTaskConfig)
+ throws DeviceMgtTaskException {
try {
TaskService taskService = DeviceManagementDataHolder.getInstance().getTaskService();
@@ -108,18 +115,18 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
}
} catch (TaskException e) {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
- throw new DeviceMgtTaskException("Error occurred while deleting the task for tenant " + tenantId, e);
+ throw new DeviceMgtTaskException("Error occurred while deleting the task for tenant " + tenantId,
+ e);
}
}
@Override
- public void updateTask(String deviceType, OperationMonitoringTaskConfig operationMonitoringTaskConfig) throws DeviceMgtTaskException {
-
-// String TASK_NAME = deviceType;
+ public void updateTask(String deviceType, OperationMonitoringTaskConfig operationMonitoringTaskConfig)
+ throws DeviceMgtTaskException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
-// deviceTaskManager = new DeviceTaskManagerImpl();
+ // deviceTaskManager = new DeviceTaskManagerImpl();
try {
TaskService taskService = DeviceManagementDataHolder.getInstance().getTaskService();
TaskManager taskManager = taskService.getTaskManager(TASK_TYPE);
@@ -134,21 +141,20 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
Map properties = new HashMap<>();
properties.put(TENANT_ID, String.valueOf(tenantId));
- TaskInfo taskInfo = new TaskInfo(deviceType, TASK_CLASS, properties,
- triggerInfo);
+ TaskInfo taskInfo = new TaskInfo(deviceType, TASK_CLASS, properties, triggerInfo);
taskManager.registerTask(taskInfo);
taskManager.rescheduleTask(taskInfo.getName());
} else {
- throw new DeviceMgtTaskException("Device details retrieving task has not been started for this tenant " +
- tenantId + ". Please start the task first.");
+ throw new DeviceMgtTaskException(
+ "Device details retrieving task has not been started for this tenant " +
+ tenantId + ". Please start the task first.");
}
} catch (TaskException e) {
- throw new DeviceMgtTaskException("Error occurred while updating the task for tenant " + tenantId, e);
+ throw new DeviceMgtTaskException("Error occurred while updating the task for tenant " + tenantId,
+ e);
}
-
-
}
}
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 d2199e5a11..e81d2eb6c0 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.4-SNAPSHOT
+ 2.0.6-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 b2c5909a4b..18e51b934e 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.4-SNAPSHOT
+ 2.0.6-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js
index 65c74e886c..9121f1d3a9 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js
@@ -258,8 +258,10 @@ function loadDevices(searchType, searchParam) {
data: 'name',
class: 'remove-padding icon-only content-fill',
render: function (data, type, row, meta) {
- return '';
+ return '';
}
},
{
@@ -333,22 +335,14 @@ function loadDevices(searchType, searchParam) {
var deviceIdentifier = row.deviceIdentifier;
var html = '';
if (status != 'REMOVED') {
- html =
- ''
- +
- 'View';
+ html = '';
if (analyticsEnabled(row.deviceType)) {
- html +=
- ''
- +
- ''
- +
- 'Analytics';
+ html += '' +
+ '' +
+ 'Analytics';
}
if ((!groupName || !groupId) && groupingEnabled(row.deviceType)) {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.effective-policy.view/view.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.effective-policy.view/view.hbs
new file mode 100644
index 0000000000..4fbf555f53
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.effective-policy.view/view.hbs
@@ -0,0 +1,43 @@
+{{!
+ 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.
+}}
+
+{{unit "cdmf.unit.ui.title" pageTitle="Policy Management | View Policy"}}
+
+{{#zone "breadcrumbs"}}
+
+
+
+
+
+
+
+
+ Policies
+
+
+
+
+ View
+
+
+{{/zone}}
+
+{{#zone "content"}}
+ {{unit "cdmf.unit.device.operation-mod"}}
+ {{unit "cdmf.unit.effective-policy.view"}}
+{{/zone}}
\ No newline at end of file
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.effective-policy.view/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.effective-policy.view/view.js
new file mode 100644
index 0000000000..46b4ed70b7
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.effective-policy.view/view.js
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+function onRequest(context) {
+ var utility = require("/app/modules/utility.js")["utility"];
+ var deviceType = context.uriParams.deviceType;
+ var deviceId = context.uriParams.deviceId;
+ return {"deviceTypePolicyView": utility.getTenantedDeviceUnitName(deviceType, deviceId,"policy-view")};
+}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.effective-policy.view/view.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.effective-policy.view/view.json
new file mode 100644
index 0000000000..ec79d2b203
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.effective-policy.view/view.json
@@ -0,0 +1,5 @@
+{
+ "version": "1.0.0",
+ "uri": "/policy/effective-policy/",
+ "layout": "cdmf.layout.default"
+}
\ No newline at end of file
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs
index 5aeca7d38c..da79afe1bd 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs
@@ -118,16 +118,16 @@
- Select user roles to manage group sharing
+ Select user role(s)
-