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 ea216af1dd..339110eac7 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.2-SNAPSHOT + 2.0.3-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.annotations - 2.0.2-SNAPSHOT + 2.0.3-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 c99a029ff3..3ad5078676 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.2-SNAPSHOT + 2.0.3-SNAPSHOT ../pom.xml 4.0.0 - 2.0.2-SNAPSHOT + 2.0.3-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.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java index ca3c77f093..a69ae339f2 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java @@ -37,7 +37,6 @@ import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; -import java.util.ArrayList; import java.util.Arrays; @@ -66,7 +65,8 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi APIManagementProviderService apiManagementProviderService = APIUtil.getAPIManagementProviderService(); ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( applicationName, APIUtil.getAllowedApisTags().toArray(new String[APIUtil.getAllowedApisTags().size()]), - ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, false); + ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, false, + ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } catch (APIManagerException e) { String msg = "Error occurred while registering an application '" + applicationName + "'"; @@ -98,6 +98,12 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi } String username = APIUtil.getAuthenticatedUser() + "@" + APIUtil.getTenantDomainOftheUser(); APIManagementProviderService apiManagementProviderService = APIUtil.getAPIManagementProviderService(); + String validityPeriod; + if (registrationProfile.getValidityPeriod() == null) { + validityPeriod = ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD; + } else { + validityPeriod = registrationProfile.getValidityPeriod(); + } if (registrationProfile.isMappingAnExistingOAuthApp()) { JSONObject jsonStringObject = new JSONObject(); jsonStringObject.put(ApiApplicationConstants.JSONSTRING_USERNAME_TAG, username); @@ -106,8 +112,7 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi jsonStringObject.put(ApiApplicationConstants.OAUTH_CLIENT_ID, registrationProfile.getConsumerKey()); jsonStringObject.put(ApiApplicationConstants.OAUTH_CLIENT_SECRET, registrationProfile.getConsumerSecret()); - jsonStringObject.put(ApiApplicationConstants.JSONSTRING_VALIDITY_PERIOD_TAG, - ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD); + jsonStringObject.put(ApiApplicationConstants.JSONSTRING_VALIDITY_PERIOD_TAG, validityPeriod); apiManagementProviderService.registerExistingOAuthApplicationToAPIApplication( jsonStringObject.toJSONString(), registrationProfile.getApplicationName(), registrationProfile.getConsumerKey(), username, registrationProfile.isAllowedToAllDomains(), @@ -116,7 +121,8 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi } else { ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( registrationProfile.getApplicationName(), registrationProfile.getTags(), - ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, false); + ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, + registrationProfile.isAllowedToAllDomains(), validityPeriod); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } } catch (APIManagerException e) { diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/util/RegistrationProfile.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/util/RegistrationProfile.java index c0d231039c..b1634923f3 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/util/RegistrationProfile.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/util/RegistrationProfile.java @@ -41,6 +41,8 @@ public class RegistrationProfile { private boolean isMappingAnExistingOAuthApp; private String consumerKey; private String consumerSecret; + @XmlElement(required = false) + private String validityPeriod; public String getApplicationName() { return applicationName; @@ -89,4 +91,12 @@ public class RegistrationProfile { public void setConsumerSecret(String consumerSecret) { this.consumerSecret = consumerSecret; } + + public String getValidityPeriod() { + return validityPeriod; + } + + public void setValidityPeriod(String validityPeriod) { + this.validityPeriod = validityPeriod; + } } 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 ed99e95ab6..cec4c34f7d 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.2-SNAPSHOT + 2.0.3-SNAPSHOT ../pom.xml 4.0.0 - 2.0.2-SNAPSHOT + 2.0.3-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/APIManagementProviderService.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java index e931c28358..7e04924dc4 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderService.java @@ -34,11 +34,14 @@ public interface APIManagementProviderService { * @param tags tags of the apis that application needs to be subscribed. * @param keyType of the application. * @param username to whom the application is created + * @param isAllowedAllDomains application is allowed to all the tenants + * @param validityTime validity period of the application * @return consumerkey and secrete of the created application. * @throws APIManagerException */ ApiApplicationKey generateAndRetrieveApplicationKeys(String apiApplicationName, String tags[], - String keyType, String username, boolean isAllowedAllDomains) + String keyType, String username, boolean isAllowedAllDomains, + String validityTime) throws APIManagerException; /** 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 ce92eba32a..913541e533 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 @@ -133,7 +133,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe @Override public ApiApplicationKey generateAndRetrieveApplicationKeys(String apiApplicationName, String tags[], String keyType, String username, - boolean isAllowedAllDomains) + boolean isAllowedAllDomains, String validityTime) throws APIManagerException { try { APIManagerUtil.loadTenantRegistry(); @@ -172,7 +172,6 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } else { allowedDomains[0] = APIManagerUtil.getTenantDomain(); } - String validityTime = "3600"; String ownerJsonString = "{\"username\":\"" + username + "\"}"; Map keyDetails = apiConsumer.requestApprovalForApplicationRegistration(username, apiApplicationName, 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 dd139b8ff9..74566bd237 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.2-SNAPSHOT + 2.0.3-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.webapp.publisher - 2.0.2-SNAPSHOT + 2.0.3-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 7e6e61c2e4..4086cf5a18 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.2-SNAPSHOT + 2.0.3-SNAPSHOT ../../pom.xml 4.0.0 apimgt-extensions - 2.0.2-SNAPSHOT + 2.0.3-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 ab955c1382..e54da97c1a 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.2-SNAPSHOT + 2.0.3-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 33f1bb6ecc..ee995e22bf 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.2-SNAPSHOT + 2.0.3-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 09edacd71c..bae82a92b0 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.2-SNAPSHOT + 2.0.3-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.certificate.mgt.core - 2.0.2-SNAPSHOT + 2.0.3-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 258059c8d6..d61aa97851 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.2-SNAPSHOT + 2.0.3-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt certificate-mgt - 2.0.2-SNAPSHOT + 2.0.3-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 bf340f57c3..9b958b392e 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.2-SNAPSHOT + 2.0.3-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/config/DataSource.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/config/DataSource.java index d55db0e6cb..f416facc4a 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/config/DataSource.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/config/DataSource.java @@ -34,8 +34,8 @@ import javax.xml.bind.annotation.XmlType; * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> - * <element name="jndiConfig" type="{}jndiConfig"/> - * <element name="tableConfig" type="{}tableConfig"/> + * <element name="JndiConfig" type="{}JndiConfig"/> + * <element name="TableConfig" type="{}TableConfig"/> * </sequence> * </restriction> * </complexContent> @@ -51,9 +51,10 @@ import javax.xml.bind.annotation.XmlType; }) public class DataSource { - @XmlElement(required = true) + @XmlElement(name = "JndiConfig", required = true) protected JndiConfig jndiConfig; - @XmlElement(required = true) + + @XmlElement(name = "TableConfig", required = true) protected TableConfig tableConfig; /** 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/config/DeviceAuthorizationConfig.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/config/DeviceAuthorizationConfig.java new file mode 100644 index 0000000000..833719ba2a --- /dev/null +++ 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/config/DeviceAuthorizationConfig.java @@ -0,0 +1,68 @@ +/* + * 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.extensions.device.type.deployer.config; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +/** + *

Java class for Device type authorization requirement. + *

+ *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <complexType name="DeviceAuthorizationConfig">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="authorizationRequired" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "DeviceAuthorizationConfig", propOrder = { + "authorizationRequired" +}) +public class DeviceAuthorizationConfig { + + @XmlElement(name = "authorizationRequired") + protected boolean authorizationRequired; + + /** + * Gets the value of the sharedWithAllTenants property. + */ + public boolean isAuthorizationRequired() { + return authorizationRequired; + } + + /** + * Sets the value of the sharedWithAllTenants property. + */ + public void setAuthorizationRequired(boolean authorizationRequired) { + this.authorizationRequired = authorizationRequired; + } + +} + 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/config/DeviceTypeConfiguration.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/config/DeviceTypeConfiguration.java index 4e8cfc4a88..867e0a377d 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/config/DeviceTypeConfiguration.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/config/DeviceTypeConfiguration.java @@ -27,9 +27,9 @@ import javax.xml.bind.annotation.XmlRootElement; /** *

Java class for DeviceTypeConfiguration complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType name="DeviceTypeConfiguration">
  *   <complexContent>
@@ -41,14 +41,13 @@ import javax.xml.bind.annotation.XmlRootElement;
  *         <element name="PushNotificationProvider" type="{}PushNotificationProvider"/>
  *         <element name="License" type="{}License"/>
  *         <element name="DataSource" type="{}DataSource"/>
+ *         <element name="DeviceAuthorizationConfig" type="{}DeviceAuthorizationConfig"/>
  *       </sequence>
  *       <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
  *     </restriction>
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlRootElement(name = "DeviceTypeConfiguration") @@ -66,16 +65,42 @@ public class DeviceTypeConfiguration { protected License license; @XmlElement(name = "DataSource", required = true) protected DataSource dataSource; + @XmlElement(name = "TaskConfiguration", required = true) + private TaskConfiguration taskConfiguration; + @XmlElement(name = "DeviceAuthorizationConfig", required = true) + protected DeviceAuthorizationConfig deviceAuthorizationConfig; @XmlAttribute(name = "name") protected String name; /** - * Gets the value of the deviceDetails property. - * + * Gets the value of the taskConfiguration property. + * * @return * possible object is - * {@link DeviceDetails } - * + * {@link TaskConfiguration } + * + */ + public TaskConfiguration getTaskConfiguration() { + return taskConfiguration; + } + + /** + * Sets the value of the taskConfiguration property. + * + * @param taskConfiguration + * allowed object is + * {@link TaskConfiguration } + * + */ + public void setTaskConfiguration(TaskConfiguration taskConfiguration) { + this.taskConfiguration = taskConfiguration; + } + + /** + * Gets the value of the deviceDetails property. + * + * @return possible object is + * {@link DeviceDetails } */ public DeviceDetails getDeviceDetails() { return deviceDetails; @@ -83,11 +108,9 @@ public class DeviceTypeConfiguration { /** * Sets the value of the deviceDetails property. - * - * @param value - * allowed object is - * {@link DeviceDetails } - * + * + * @param value allowed object is + * {@link DeviceDetails } */ public void setDeviceDetails(DeviceDetails value) { this.deviceDetails = value; @@ -95,11 +118,9 @@ public class DeviceTypeConfiguration { /** * Gets the value of the features property. - * - * @return - * possible object is - * {@link Features } - * + * + * @return possible object is + * {@link Features } */ public Features getFeatures() { return features; @@ -107,11 +128,9 @@ public class DeviceTypeConfiguration { /** * Sets the value of the features property. - * - * @param value - * allowed object is - * {@link Features } - * + * + * @param value allowed object is + * {@link Features } */ public void setFeatures(Features value) { this.features = value; @@ -119,11 +138,9 @@ public class DeviceTypeConfiguration { /** * Gets the value of the provisioningConfig property. - * - * @return - * possible object is - * {@link ProvisioningConfig } - * + * + * @return possible object is + * {@link ProvisioningConfig } */ public ProvisioningConfig getProvisioningConfig() { return provisioningConfig; @@ -131,11 +148,9 @@ public class DeviceTypeConfiguration { /** * Sets the value of the provisioningConfig property. - * - * @param value - * allowed object is - * {@link ProvisioningConfig } - * + * + * @param value allowed object is + * {@link ProvisioningConfig } */ public void setProvisioningConfig(ProvisioningConfig value) { this.provisioningConfig = value; @@ -143,11 +158,9 @@ public class DeviceTypeConfiguration { /** * Gets the value of the pushNotificationProvider property. - * - * @return - * possible object is - * {@link PushNotificationProvider } - * + * + * @return possible object is + * {@link PushNotificationProvider } */ public PushNotificationProvider getPushNotificationProvider() { return pushNotificationProvider; @@ -155,11 +168,9 @@ public class DeviceTypeConfiguration { /** * Sets the value of the pushNotificationProvider property. - * - * @param value - * allowed object is - * {@link PushNotificationProvider } - * + * + * @param value allowed object is + * {@link PushNotificationProvider } */ public void setPushNotificationProvider(PushNotificationProvider value) { this.pushNotificationProvider = value; @@ -167,11 +178,9 @@ public class DeviceTypeConfiguration { /** * Gets the value of the license property. - * - * @return - * possible object is - * {@link License } - * + * + * @return possible object is + * {@link License } */ public License getLicense() { return license; @@ -179,11 +188,9 @@ public class DeviceTypeConfiguration { /** * Sets the value of the license property. - * - * @param value - * allowed object is - * {@link License } - * + * + * @param value allowed object is + * {@link License } */ public void setLicense(License value) { this.license = value; @@ -191,11 +198,9 @@ public class DeviceTypeConfiguration { /** * Gets the value of the dataSource property. - * - * @return - * possible object is - * {@link DataSource } - * + * + * @return possible object is + * {@link DataSource } */ public DataSource getDataSource() { return dataSource; @@ -203,11 +208,9 @@ public class DeviceTypeConfiguration { /** * Sets the value of the dataSource property. - * - * @param value - * allowed object is - * {@link DataSource } - * + * + * @param value allowed object is + * {@link DataSource } */ public void setDataSource(DataSource value) { this.dataSource = value; @@ -215,11 +218,9 @@ public class DeviceTypeConfiguration { /** * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * + * + * @return possible object is + * {@link String } */ public String getName() { return name; @@ -227,14 +228,32 @@ public class DeviceTypeConfiguration { /** * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * + * + * @param value allowed object is + * {@link String } */ public void setName(String value) { this.name = value; } + /** + * Gets the value of the authorizationRequired property. + * + * @return possible object is + * {@link DeviceAuthorizationConfig } + */ + public DeviceAuthorizationConfig getDeviceAuthorizationConfig() { + return deviceAuthorizationConfig; + } + + /** + * Sets the value of the provisioningConfig property. + * + * @param value allowed object is + * {@link DeviceAuthorizationConfig } + */ + public void setDeviceAuthorizationConfig(DeviceAuthorizationConfig value) { + this.deviceAuthorizationConfig = value; + } + } 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/config/JndiConfig.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/config/JndiConfig.java index a43dc26b9c..d28201d8a0 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/config/JndiConfig.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/config/JndiConfig.java @@ -30,7 +30,7 @@ import javax.xml.bind.annotation.XmlType; *

The following schema fragment specifies the expected content contained within this class. * *

- * <complexType name="jndiConfig">
+ * <complexType name="JndiConfig">
  *   <complexContent>
  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
  *       <sequence>
@@ -44,12 +44,12 @@ import javax.xml.bind.annotation.XmlType;
  * 
  */
 @XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "jndiConfig", propOrder = {
+@XmlType(name = "JndiConfig", propOrder = {
     "name"
 })
 public class JndiConfig {
 
-    @XmlElement(required = true)
+    @XmlElement(name = "Name", required = true)
     protected String name;
 
     /**
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/config/Operation.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/config/Operation.java
index 81ab8fdaf2..0a954c242d 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/config/Operation.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/config/Operation.java
@@ -40,6 +40,7 @@ import javax.xml.bind.annotation.XmlType;
  *       </sequence>
  *       <attribute name="context" type="{http://www.w3.org/2001/XMLSchema}string" />
  *       <attribute name="method" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
  *     </restriction>
  *   </complexContent>
  * </complexType>
@@ -62,6 +63,32 @@ public class Operation {
     protected String context;
     @XmlAttribute(name = "method")
     protected String method;
+    @XmlAttribute(name = "type")
+    protected String type;
+
+    /**
+     * Gets the value of the Content Type property.
+     *
+     * @return
+     *     possible object is
+     *     {@link String }
+     *
+     */
+    public String getType() {
+        return type;
+    }
+
+    /**
+     * Sets the value of the Content Type property.
+     *
+     * @param type
+     *     allowed object is
+     *     {@link String }
+     *
+     */
+    public void setType(String type) {
+        this.type = type;
+    }
 
     /**
      * Gets the value of the queryParameters property.
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/config/TableConfig.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/config/TableConfig.java
index c587844033..4d912e2dd1 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/config/TableConfig.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/config/TableConfig.java
@@ -46,7 +46,7 @@ import javax.xml.bind.annotation.XmlType;
  * 
  */
 @XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "tableConfig", propOrder = {
+@XmlType(name = "TableConfig", propOrder = {
     "table"
 })
 public class TableConfig {
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/config/TaskConfiguration.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/config/TaskConfiguration.java
new file mode 100644
index 0000000000..c2539d2e6e
--- /dev/null
+++ 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/config/TaskConfiguration.java
@@ -0,0 +1,102 @@
+/*
+ *   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.extensions.device.type.deployer.config;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.List;
+
+/**
+ *
+ */
+@XmlRootElement(name = "TaskConfiguration")
+public class TaskConfiguration {
+
+
+    private boolean enabled;
+    private int frequency;
+    private String taskClazz;
+    private List operations;
+
+    @XmlElement(name = "Enable", required = true)
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    public void setEnabled(boolean enabled) {
+        this.enabled = enabled;
+    }
+
+    @XmlElement(name = "Frequency", required = true)
+    public int getFrequency() {
+        return frequency;
+    }
+
+    public void setFrequency(int frequency) {
+        this.frequency = frequency;
+    }
+
+    @XmlElement(name = "TaskClass", required = true)
+    public String getTaskClazz() {
+        return taskClazz;
+    }
+
+    public void setTaskClazz(String taskClazz) {
+        this.taskClazz = taskClazz;
+    }
+
+    @XmlElementWrapper(name="Operations")
+    @XmlElement(name = "Operation", required = true)
+    public List getOperations() {
+        return operations;
+    }
+
+    public void setOperations(List operations) {
+        this.operations = operations;
+    }
+
+    @XmlRootElement(name = "Operation")
+    public static class Operation {
+
+        private String operationName;
+        private int recurrency;
+
+        @XmlElement(name = "Name", required = true)
+        public String getOperationName() {
+            return operationName;
+        }
+
+        public void setOperationName(String operationName) {
+            this.operationName = operationName;
+        }
+
+        @XmlElement(name = "RecurrentTimes", required = true)
+        public int getRecurrency() {
+            return recurrency;
+        }
+
+        public void setRecurrency(int recurrency) {
+            this.recurrency = recurrency;
+        }
+
+    }
+}
+
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 e0f2d45f10..8a9bcd7ed5 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
@@ -30,11 +30,8 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration
 import org.wso2.carbon.device.mgt.common.license.mgt.License;
 import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
 import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager;
-import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.DeviceDetails;
-import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.DeviceTypeConfiguration;
-import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.Table;
+import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.*;
 import org.wso2.carbon.device.mgt.extensions.device.type.deployer.util.DeviceTypePluginConstants;
-import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.Feature;
 import org.wso2.carbon.device.mgt.extensions.device.type.deployer.exception.DeviceTypeDeployerFileException;
 import org.wso2.carbon.device.mgt.extensions.device.type.deployer.exception.DeviceTypeMgtPluginException;
 import org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.dao.DeviceDAODefinition;
@@ -65,18 +62,26 @@ public class DeviceTypeManager implements DeviceManager {
     private DeviceTypePluginDAOManager deviceTypePluginDAOManager;
     private LicenseManager licenseManager;
     private boolean propertiesExist;
+    private boolean requiredDeviceTypeAuthorization;
 
     private FeatureManager featureManager;
+
     public DeviceTypeManager(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier,
-                                    DeviceTypeConfiguration deviceTypeConfiguration) {
+                             DeviceTypeConfiguration deviceTypeConfiguration) {
         deviceType = deviceTypeConfigIdentifier.getDeviceType();
-        if (deviceTypeConfiguration.getFeatures() != null && deviceTypeConfiguration.getFeatures().getFeature() != null ) {
+        if (deviceTypeConfiguration.getFeatures() != null && deviceTypeConfiguration.getFeatures().
+                getFeature() != null) {
             List features = deviceTypeConfiguration.getFeatures().getFeature();
             if (features != null) {
                 featureManager = new ConfigurationBasedFeatureManager(features);
             }
         }
-
+        if (deviceTypeConfiguration.getDeviceAuthorizationConfig() != null) {
+            requiredDeviceTypeAuthorization = deviceTypeConfiguration.getDeviceAuthorizationConfig().
+                    isAuthorizationRequired();
+        } else {
+            requiredDeviceTypeAuthorization = true;
+        }
         //add license to registry.
         this.licenseManager = new RegistryBasedLicenseManager();
         try {
@@ -120,11 +125,11 @@ public class DeviceTypeManager implements DeviceManager {
                     if (setupOption != null) {
                         if (log.isDebugEnabled()) {
                             log.debug("-Dsetup is enabled. Device management repository schema initialization is about " +
-                                              "to begin");
+                                    "to begin");
                         }
                         try {
                             DeviceTypeUtils.setupDeviceManagementSchema(datasourceName, deviceType,
-                                                                        deviceDAODefinition.getDeviceTableName());
+                                    deviceDAODefinition.getDeviceTableName());
                         } catch (DeviceTypeMgtPluginException e) {
                             log.error("Exception occurred while initializing device management database schema", e);
                         }
@@ -346,7 +351,7 @@ public class DeviceTypeManager implements DeviceManager {
 
     @Override
     public boolean requireDeviceAuthorization() {
-        return true;
+        return requiredDeviceTypeAuthorization;
     }
 
     @Override
@@ -370,7 +375,7 @@ public class DeviceTypeManager implements DeviceManager {
                     deviceTypePluginDAOManager.getDeviceTypeDAOHandler().rollbackTransaction();
                 } catch (DeviceTypeMgtPluginException e1) {
                     log.warn("Error occurred while roll back the update device info transaction : '" +
-                                     device.toString() + "'", e1);
+                            device.toString() + "'", e1);
                 }
                 throw new DeviceManagementException(
                         "Error occurred while updating the " + deviceType + " device: '" +
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/DeviceTypeManagerService.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/DeviceTypeManagerService.java
index 6602141b0e..c83318ca9b 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/DeviceTypeManagerService.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/DeviceTypeManagerService.java
@@ -23,6 +23,7 @@ import org.apache.commons.logging.LogFactory;
 import org.wso2.carbon.device.mgt.common.DeviceManagementException;
 import org.wso2.carbon.device.mgt.common.DeviceManager;
 import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
+import org.wso2.carbon.device.mgt.common.TaskOperation;
 import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
 import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
 import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
@@ -31,7 +32,9 @@ import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
 import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.DeviceTypeConfiguration;
 import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.Property;
 import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.PushNotificationProvider;
+import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.TaskConfiguration;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -48,6 +51,7 @@ public class DeviceTypeManagerService implements DeviceManagementService {
     private PushNotificationConfig pushNotificationConfig;
     private ProvisioningConfig provisioningConfig;
     private String type;
+    private List taskOperations;
 
     public DeviceTypeManagerService(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier,
                                     DeviceTypeConfiguration deviceTypeConfiguration) {
@@ -55,6 +59,7 @@ public class DeviceTypeManagerService implements DeviceManagementService {
         this.deviceManager = new DeviceTypeManager(deviceTypeConfigIdentifier, deviceTypeConfiguration);
         this.setType(deviceTypeConfiguration.getName());
         this.populatePushNotificationConfig(deviceTypeConfiguration.getPushNotificationProvider());
+        this.setTask(deviceTypeConfiguration);
     }
 
     @Override
@@ -62,6 +67,28 @@ public class DeviceTypeManagerService implements DeviceManagementService {
         return type;
     }
 
+    @Override
+    public List getTasksForPlatform(){
+        return taskOperations;
+    }
+
+    private void setTask(DeviceTypeConfiguration deviceTypeConfiguration) {
+        //Read the config file and take the list of operations there in the config
+        TaskConfiguration taskConfiguration = deviceTypeConfiguration.getTaskConfiguration();
+        if (taskConfiguration != null) {
+            List ops = taskConfiguration.getOperations();
+            if (ops != null && !ops.isEmpty()) {
+                taskOperations = new ArrayList<>();
+                for (TaskConfiguration.Operation op : ops) {
+                    TaskOperation taskOperation = new TaskOperation();
+                    taskOperation.setTaskName(op.getOperationName());
+                    taskOperation.setRecurrentTimes(op.getRecurrency());
+                    taskOperations.add(taskOperation);
+                }
+            }
+        }
+    }
+
     @Override
     public void init() throws DeviceManagementException {
     }
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/dao/DeviceTypePluginDAO.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/dao/DeviceTypePluginDAO.java
index 79d60be5da..ee4f6071b7 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/dao/DeviceTypePluginDAO.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/dao/DeviceTypePluginDAO.java
@@ -69,7 +69,7 @@ public class DeviceTypePluginDAO {
                 device = new Device();
                 if (log.isDebugEnabled()) {
                     log.debug(deviceId + " data has been fetched from " + deviceDAODefinition.getDeviceTableName() +
-                                      " database.");
+                            " database.");
                 }
                 List properties = new ArrayList<>();
                 for (String columnName : deviceDAODefinition.getColumnNames()) {
@@ -112,7 +112,7 @@ public class DeviceTypePluginDAO {
                 status = true;
                 if (log.isDebugEnabled()) {
                     log.debug("device " + device.getDeviceIdentifier() + " data has been" +
-                                      " added to the " + deviceDAODefinition.getDeviceTableName() + " database.");
+                            " added to the " + deviceDAODefinition.getDeviceTableName() + " database.");
                 }
             }
         } catch (SQLException e) {
@@ -170,7 +170,7 @@ public class DeviceTypePluginDAO {
                 status = true;
                 if (log.isDebugEnabled()) {
                     log.debug("device " + deviceId + " data has deleted from the " +
-                                      deviceDAODefinition.getDeviceTableName() + " table.");
+                            deviceDAODefinition.getDeviceTableName() + " table.");
                 }
             }
         } catch (SQLException e) {
@@ -241,7 +241,7 @@ public class DeviceTypePluginDAO {
 
     private String getPropertString(List properties, String propertyName) {
         for (Device.Property property : properties) {
-            if (property.getName().equals(propertyName)) {
+            if (property.getName() != null && property.getName().equals(propertyName)) {
                 return property.getValue();
             }
         }
@@ -257,7 +257,7 @@ public class DeviceTypePluginDAO {
                 + getPreparedInputString(deviceDAODefinition.getColumnNames().size() + 1) + ")";
 
         updateDBQueryForUpdateDevice = "UPDATE " + deviceDAODefinition.getDeviceTableName() + " SET "
-                + getDeviceTableColumnNamesForUpdateQuery()+ " WHERE " + deviceDAODefinition.getPrimaryKey()
+                + getDeviceTableColumnNamesForUpdateQuery() + " WHERE " + deviceDAODefinition.getPrimaryKey()
                 + " = ?";
 
         deleteDBQueryToRemoveDevicd = "DELETE FROM " + deviceDAODefinition.getDeviceTableName()
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/feature/ConfigurationBasedFeatureManager.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/feature/ConfigurationBasedFeatureManager.java
index 7e53718442..5d689fec5c 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/feature/ConfigurationBasedFeatureManager.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/feature/ConfigurationBasedFeatureManager.java
@@ -38,6 +38,7 @@ public class ConfigurationBasedFeatureManager implements FeatureManager {
     private List features = new ArrayList<>();
     private static final String METHOD = "method";
     private static final String URI = "uri";
+    private static final String CONTENT_TYPE = "contentType";
     private static final String PATH_PARAMS = "pathParams";
     private static final String QUERY_PARAMS = "queryParams";
     private static final String FORM_PARAMS = "formParams";
@@ -55,6 +56,7 @@ public class ConfigurationBasedFeatureManager implements FeatureManager {
                 Map apiParams = new HashMap<>();
                 apiParams.put(METHOD, operation.getMethod().toUpperCase());
                 apiParams.put(URI, operation.getContext());
+                apiParams.put(CONTENT_TYPE, operation.getType());
                 List pathParams = new ArrayList<>();
                 List queryParams = new ArrayList<>();
                 List formParams = new ArrayList<>();
diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml
index 1f0584227c..a3d19a34ac 100644
--- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml
+++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml
@@ -25,7 +25,7 @@
         
             abc
             this is a feature
-            
+            
                 
                     deviceId
                 
@@ -63,6 +63,10 @@
         false
     
 
+    
+        true
+    
+
     
         true
         
@@ -97,5 +101,20 @@
             
         
     
-
+    
+        
+            
+                DEVICE_INFO
+                1
+            
+            
+                APPLICATION_LIST
+                5
+            
+            
+                DEVICE_LOCATION
+                1
+            
+        
+    
 
\ No newline at end of file
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 0dfaa553c2..4f9ce19d66 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.2-SNAPSHOT
+        2.0.3-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 6ddeff397d..8061872787 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.2-SNAPSHOT
+        2.0.3-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 b43c12277e..dc8a94bffa 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.2-SNAPSHOT
+        2.0.3-SNAPSHOT
         ../pom.xml
     
 
diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml
index 83fa0ab8d1..d974c8d0a2 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.2-SNAPSHOT
+        2.0.3-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 3898a2163f..986cdf9855 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.2-SNAPSHOT
+        2.0.3-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 29be44a708..3b494b77e6 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.2-SNAPSHOT
+        2.0.3-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 47dd5c89f3..a1f3bc8657 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.2-SNAPSHOT
+        2.0.3-SNAPSHOT
         ../pom.xml
     
 
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyWrapper.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyWrapper.java
index c0c768eeb2..e7ef0c0e6e 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyWrapper.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyWrapper.java
@@ -21,6 +21,7 @@ package org.wso2.carbon.device.mgt.jaxrs.beans;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
+import org.wso2.carbon.policy.mgt.common.DeviceGroupWrapper;
 
 import javax.validation.constraints.Size;
 import java.util.List;
@@ -75,6 +76,10 @@ public class PolicyWrapper {
             required = true)
     private List users;
 
+    @ApiModelProperty(name = "deviceGroups", value = "Lists out the groups on whose devices the policy is enforced",
+            required = true)
+    private List deviceGroups;
+
     public Profile getProfile() {
         return profile;
     }
@@ -147,4 +152,12 @@ public class PolicyWrapper {
         this.users = users;
     }
 
+    public List getDeviceGroups() {
+        return deviceGroups;
+    }
+
+    public void setDeviceGroups(List deviceGroups) {
+        this.deviceGroups = deviceGroups;
+    }
+
 }
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 3934ceedf1..16e7a8eb06 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
@@ -122,6 +122,7 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
         policy.setRoles(policyWrapper.getRoles());
         policy.setUsers(policyWrapper.getUsers());
         policy.setCompliance(policyWrapper.getCompliance());
+        policy.setDeviceGroups(policyWrapper.getDeviceGroups());
         //TODO iterates the device identifiers to create the object. need to implement a proper DAO layer here.
         List devices = new ArrayList();
         List deviceIdentifiers = policyWrapper.getDeviceIdentifiers();
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 b907e8224f..4228d88255 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.2-SNAPSHOT
+        2.0.3-SNAPSHOT
         ../pom.xml
     
 
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/TaskOperation.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/TaskOperation.java
new file mode 100644
index 0000000000..a7143b7173
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/TaskOperation.java
@@ -0,0 +1,46 @@
+/*
+ *   Copyright (c) 2015, 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.common;
+
+/**
+ *
+ */
+public class TaskOperation {
+
+    private String taskName;
+    private int recurrentTimes;
+
+    public String getTaskName() {
+        return taskName;
+    }
+
+    public void setTaskName(String taskName) {
+        this.taskName = taskName;
+    }
+
+    public int getRecurrentTimes() {
+        return recurrentTimes;
+    }
+
+    public void setRecurrentTimes(int recurrentTimes) {
+        this.recurrentTimes = recurrentTimes;
+    }
+
+}
+
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java
index 25f11458c1..24836a02ae 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java
@@ -21,9 +21,12 @@ package org.wso2.carbon.device.mgt.common.spi;
 import org.wso2.carbon.device.mgt.common.DeviceManagementException;
 import org.wso2.carbon.device.mgt.common.DeviceManager;
 import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
+import org.wso2.carbon.device.mgt.common.TaskOperation;
 import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
 import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
 
+import java.util.List;
+
 /**
  * Composite interface that acts as the SPI exposing all device management as well as application management
  * functionalities.
@@ -34,6 +37,8 @@ public interface DeviceManagementService {
 
     String getType();
 
+    List getTasksForPlatform();//getTasksConfiguraitons
+
     DeviceManager getDeviceManager();
 
     ApplicationManager getApplicationManager();
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 18544988a8..190b432425 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.2-SNAPSHOT
+        2.0.3-SNAPSHOT
         ../pom.xml
     
 
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/GroupDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/GroupDAOImpl.java
index 52dba3579a..7d9947a421 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/GroupDAOImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/GroupDAOImpl.java
@@ -105,6 +105,11 @@ public class GroupDAOImpl implements GroupDAO {
             stmt.setInt(1, groupId);
             stmt.setInt(2, tenantId);
             stmt.executeUpdate();
+            sql = "DELETE FROM DM_DEVICE_GROUP_POLICY WHERE DEVICE_GROUP_ID = ? AND TENANT_ID = ?";
+            stmt = conn.prepareStatement(sql);
+            stmt.setInt(1, groupId);
+            stmt.setInt(2, tenantId);
+            stmt.executeUpdate();
         } catch (SQLException e) {
             throw new GroupManagementDAOException("Error occurred while removing mappings for group.'", e);
         } finally {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java
index b5a7bad285..7f4e2f7a99 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java
@@ -21,16 +21,25 @@ package org.wso2.carbon.device.mgt.core.operation.mgt;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.wso2.carbon.context.CarbonContext;
-import org.wso2.carbon.device.mgt.common.*;
+import org.wso2.carbon.device.mgt.common.Device;
+import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
+import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
+import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
+import org.wso2.carbon.device.mgt.common.PaginationRequest;
+import org.wso2.carbon.device.mgt.common.PaginationResult;
+import org.wso2.carbon.device.mgt.common.TaskOperation;
+import org.wso2.carbon.device.mgt.common.TransactionManagementException;
 import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
 import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroupConstants;
-import org.wso2.carbon.device.mgt.common.operation.mgt.*;
+import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
+import org.wso2.carbon.device.mgt.common.operation.mgt.ActivityStatus;
+import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
+import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
+import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
 import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
 import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
 import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationExecutionFailedException;
 import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
-import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
-import org.wso2.carbon.device.mgt.core.config.task.TaskConfiguration;
 import org.wso2.carbon.device.mgt.core.dao.DeviceDAO;
 import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
 import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
@@ -43,6 +52,7 @@ import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationMappingDAO;
 import org.wso2.carbon.device.mgt.core.operation.mgt.dao.util.OperationDAOUtil;
 import org.wso2.carbon.device.mgt.core.operation.mgt.util.DeviceIDHolder;
 import org.wso2.carbon.device.mgt.core.operation.mgt.util.OperationCreateTimeComparator;
+import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
 import org.wso2.carbon.device.mgt.core.task.DeviceTaskManager;
 import org.wso2.carbon.device.mgt.core.task.impl.DeviceTaskManagerImpl;
 import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
@@ -51,7 +61,9 @@ import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * This class implements all the functionality exposed as part of the OperationManager. Any transaction initiated
@@ -127,7 +139,7 @@ public class OperationManagerImpl implements OperationManager {
                 org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operationDto =
                         OperationDAOUtil.convertOperation(operation);
                 int operationId = this.lookupOperationDAO(operation).addOperation(operationDto);
-                boolean isScheduledOperation = this.isTaskScheduledOperation(operation);
+                boolean isScheduledOperation = this.isTaskScheduledOperation(operation, deviceIds);
                 boolean isNotRepeated = false;
                 boolean hasExistingTaskOperation;
                 int enrolmentId;
@@ -231,7 +243,7 @@ public class OperationManagerImpl implements OperationManager {
         List unAuthorizedDeviceList = new ArrayList<>();
         DeviceIDHolder deviceIDHolder = new DeviceIDHolder();
         try {
-            if (operation != null && isAuthenticationSkippedOperation(operation)) {
+            if (operation != null && isAuthenticationSkippedOperation(operation, deviceIds)) {
                 authorizedDeviceList = deviceIds;
             } else {
                 boolean isAuthorized;
@@ -873,11 +885,11 @@ public class OperationManagerImpl implements OperationManager {
         return CarbonContext.getThreadLocalCarbonContext().getUsername();
     }
 
-    private boolean isAuthenticationSkippedOperation(Operation operation) {
+    private boolean isAuthenticationSkippedOperation(Operation operation, List deviceIds) {
 
         //This is to check weather operations are coming from the task related to retrieving device information.
         DeviceTaskManager taskManager = new DeviceTaskManagerImpl();
-        if (taskManager.isTaskOperation(operation.getCode())) {
+        if (taskManager.isTaskOperation(operation.getCode(), deviceIds)) {
             return true;
         }
 
@@ -1021,14 +1033,37 @@ public class OperationManagerImpl implements OperationManager {
         return resetStatus;
     }
 
-    private boolean isTaskScheduledOperation(Operation operation) {
-        TaskConfiguration taskConfiguration = DeviceConfigurationManager.getInstance().getDeviceManagementConfig().
-                getTaskConfiguration();
-        for (TaskConfiguration.Operation op : taskConfiguration.getOperations()) {
-            if (operation.getCode().equals(op.getOperationName())) {
-                return true;
+    private boolean isTaskScheduledOperation(Operation operation, List deviceIds) {
+        List taskOperations = new ArrayList<>();
+        Map> deviceTypeSpecificTasks = new HashMap<>();
+        DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance().
+                getDeviceManagementProvider();
+
+        deviceTypeSpecificTasks = deviceManagementProviderService.getTaskList();//Get task list from each device type
+
+        for(DeviceIdentifier deviceIdentifier : deviceIds){
+            String deviceType = deviceIdentifier.getType();
+            for(String dti : deviceTypeSpecificTasks.keySet()){
+                if (dti.equals(deviceType)) {
+                    taskOperations = deviceTypeSpecificTasks.get(dti);
+                    for(TaskOperation op : taskOperations){
+                    if (operation.getCode().equals(op.getTaskName())) {
+                        return true;
+                    }
+                    }
+                }
             }
+
+
         }
+
+//        TaskConfiguration taskConfiguration = DeviceConfigurationManager.getInstance().getDeviceManagementConfig().
+//                getTaskConfiguration();
+//        for (TaskConfiguration.Operation op : taskConfiguration.getOperations()) {
+//            if (operation.getCode().equals(op.getOperationName())) {
+//                return true;
+//            }
+//        }
         return false;
     }
 
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 17732fea86..317f875b1c 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
@@ -27,6 +27,7 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementExcept
 import java.util.HashMap;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Proxy class for all Device Management related operations that take the corresponding plugin type in
@@ -275,4 +276,6 @@ public interface DeviceManagementProviderService {
 
     int getActivityCountUpdatedAfter(long timestamp) throws OperationManagementException;
 
+    Map> getTaskList();
+
 }
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 4053c641e3..aa6a9ba080 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
@@ -21,6 +21,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.wso2.carbon.CarbonConstants;
 import org.wso2.carbon.context.CarbonContext;
+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;
@@ -32,6 +33,7 @@ import org.wso2.carbon.device.mgt.common.FeatureManager;
 import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
 import org.wso2.carbon.device.mgt.common.PaginationRequest;
 import org.wso2.carbon.device.mgt.common.PaginationResult;
+import org.wso2.carbon.device.mgt.common.TaskOperation;
 import org.wso2.carbon.device.mgt.common.TransactionManagementException;
 import org.wso2.carbon.device.mgt.common.app.mgt.Application;
 import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
@@ -1213,6 +1215,27 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
         return DeviceManagementDataHolder.getInstance().getOperationManager().getActivityCountUpdatedAfter(timestamp);
     }
 
+    @Override
+    public Map> getTaskList() {
+        int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
+        Map deviceManagementServiceMap =
+                pluginRepository.getAllDeviceManagementServices(tenantId);
+        DeviceManagementService dms;
+        String deviceType;
+        List taskOperations;
+        Map> deviceTypeSpecificTasks = new HashMap<>();
+
+        for(DeviceTypeIdentifier dti : deviceManagementServiceMap.keySet()){
+            dms = deviceManagementServiceMap.get(dti);
+            taskOperations = dms.getTasksForPlatform();
+            if (taskOperations != null) {
+                deviceType = dms.getType();
+                deviceTypeSpecificTasks.put(deviceType, taskOperations);
+            }
+        }
+        return deviceTypeSpecificTasks;
+    }
+
     @Override
     public List getDevicesOfUser(String username) throws DeviceManagementException {
         List devices = new ArrayList<>();
@@ -1903,6 +1926,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
             defaultGroup = new DeviceGroup(groupName);
             // Setting system level user (wso2.system.user) as the owner
             defaultGroup.setOwner(CarbonConstants.REGISTRY_SYSTEM_USERNAME);
+            defaultGroup.setDescription("Default system group for devices with " + groupName + " ownership.");
             try {
                 service.createGroup(defaultGroup, DeviceGroupConstants.Roles.DEFAULT_ADMIN_ROLE,
                         DeviceGroupConstants.Permissions.DEFAULT_ADMIN_PERMISSIONS);
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/DeviceTaskManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/DeviceTaskManager.java
index 9e3306cbc1..b7d59c9072 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/DeviceTaskManager.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/DeviceTaskManager.java
@@ -19,6 +19,8 @@
 
 package org.wso2.carbon.device.mgt.core.task;
 
+import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
+
 import java.util.List;
 
 public interface DeviceTaskManager {
@@ -29,8 +31,8 @@ public interface DeviceTaskManager {
      * @return - list of Task Operations.
      * @throws DeviceMgtTaskException
      */
-    List getOperationList() throws DeviceMgtTaskException;
-
+    List getOperationList(String deviceType)
+            throws DeviceMgtTaskException;
 
     /**
      * This method will take the monitoring frequency.
@@ -66,7 +68,7 @@ public interface DeviceTaskManager {
      * @return
      * @throws DeviceMgtTaskException
      */
-    List getValidOperationNames() throws DeviceMgtTaskException;
+    List getValidOperationNames(String deviceType) throws DeviceMgtTaskException;
 
     /**
      * This method will check wheather give operation is added by the task.
@@ -74,6 +76,6 @@ public interface DeviceTaskManager {
      * @return - true or false
      * @throws DeviceMgtTaskException
      */
-    boolean isTaskOperation(String opName);
+    boolean isTaskOperation(String opName, List deviceIds);
 
 }
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 dafd763e61..106159ef06 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
@@ -22,22 +22,27 @@ package org.wso2.carbon.device.mgt.core.task.impl;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.wso2.carbon.device.mgt.common.Device;
+import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
 import org.wso2.carbon.device.mgt.common.DeviceManagementException;
 import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
+import org.wso2.carbon.device.mgt.common.TaskOperation;
 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.config.DeviceConfigurationManager;
-import org.wso2.carbon.device.mgt.core.config.task.TaskConfiguration;
 import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
 import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
 import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
 import org.wso2.carbon.device.mgt.core.task.DeviceMgtTaskException;
 import org.wso2.carbon.device.mgt.core.task.DeviceTaskManager;
-import org.wso2.carbon.device.mgt.core.task.TaskOperation;
 import org.wso2.carbon.device.mgt.core.task.Utils;
 import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 public class DeviceTaskManagerImpl implements DeviceTaskManager {
 
@@ -47,34 +52,35 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
 
 
     @Override
-    public List getOperationList() throws DeviceMgtTaskException {
-        TaskConfiguration taskConfiguration =
-                DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getTaskConfiguration();
+    //get device type specific operations
+    public List getOperationList(String deviceType) throws DeviceMgtTaskException {
 
-        List ops = taskConfiguration.getOperations();
         List taskOperations = new ArrayList<>();
-        for (TaskConfiguration.Operation op : ops) {
-            TaskOperation taskOperation = new TaskOperation();
-            taskOperation.setTaskName(op.getOperationName());
-            taskOperation.setRecurrentTimes(op.getRecurrency());
-            taskOperation.setTaskPlatforms(op.getPlatforms());
-            taskOperations.add(taskOperation);
+        Map> deviceTypeSpecificTasks;
+        //This Map contains task list against device type
+        DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance().
+                getDeviceManagementProvider();
+
+        deviceTypeSpecificTasks = deviceManagementProviderService.getTaskList();//Get task list from each device type
+        for(String dti : deviceTypeSpecificTasks.keySet()){
+            if (dti.equals(deviceType)) {
+                taskOperations = deviceTypeSpecificTasks.get(dti);
+            }
         }
         return taskOperations;
     }
 
-    public List getPlatformsForOperations(String opName) {
+    private List getDeviceTypes() {
         List operationPlatforms =  new ArrayList<>();
-        TaskConfiguration taskConfiguration =
-                DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getTaskConfiguration();
-        List ops = taskConfiguration.getOperations();
-        for (TaskConfiguration.Operation op : ops) {
-            if (op.getOperationName().equals(opName)) {
-                List platform = op.getPlatforms();
-                for (String operationPlatform : platform) {
-                     operationPlatforms.add(operationPlatform);
-                }
-            }
+        Map> deviceTypeSpecificTasks;
+
+        DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance().
+                getDeviceManagementProvider();
+        deviceTypeSpecificTasks = deviceManagementProviderService.getTaskList();
+
+        Set platformTypes = deviceTypeSpecificTasks.keySet();
+        for(String platformType : platformTypes ){
+          operationPlatforms.add(platformType);
         }
         return operationPlatforms;
     }
@@ -100,32 +106,31 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
 
     @Override
     public void addOperations() throws DeviceMgtTaskException {
-        List deviceTypes;
         DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance().
                 getDeviceManagementProvider();
         try {
             List devices;
-            List operations = this.getValidOperationNames();
-            for (String taskOperation : operations) {
-                deviceTypes = getPlatformsForOperations(taskOperation);
-                 for (String deviceType : deviceTypes) {
-                     devices = deviceManagementProviderService.getAllDevices(deviceType);
-                     if (!devices.isEmpty()) {
-                         for (String str : operations) {
-                             CommandOperation operation = new CommandOperation();
-                             operation.setEnabled(true);
-                             operation.setType(Operation.Type.COMMAND);
-                             operation.setCode(str);
-                             deviceManagementProviderService.addOperation(deviceType, operation,
-                                     DeviceManagerUtil.getValidDeviceIdentifiers(devices));
-                         }
-                     } else {
-                         if (log.isDebugEnabled()) {
-                             log.debug("No devices are available to perform the operations.");
-                         }
-                     }
-
-                 }
+            List operations;
+            List deviceTypes = this.getDeviceTypes();//list available device types
+
+            for(String deviceType : deviceTypes){
+                operations = this.getValidOperationNames(deviceType); //list operations for each device type
+                devices = deviceManagementProviderService.getAllDevices(deviceType);//list devices for each type
+                if (!devices.isEmpty()) {
+                    for (String str : operations) {
+                        CommandOperation operation = new CommandOperation();
+                        operation.setEnabled(true);
+                        operation.setType(Operation.Type.COMMAND);
+                        operation.setCode(str);
+                        deviceManagementProviderService.addOperation(deviceType, operation,
+                                DeviceManagerUtil.getValidDeviceIdentifiers(devices));
+                    }
+                } else {
+                    if (log.isDebugEnabled()) {
+                        log.debug("No devices are available to perform the operations.");
+                    }
+                }
+
             }
         } catch (InvalidDeviceException e) {
             throw new DeviceMgtTaskException("Invalid DeviceIdentifiers found.", e);
@@ -137,8 +142,9 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
     }
 
     @Override
-    public List getValidOperationNames() throws DeviceMgtTaskException {
-        List taskOperations = this.getOperationList();
+    public List getValidOperationNames(String deviceType) throws DeviceMgtTaskException {
+
+        List taskOperations = this.getOperationList(deviceType);
         List opNames = new ArrayList<>();
         Long milliseconds = System.currentTimeMillis();
         int frequency = this.getTaskFrequency();
@@ -167,17 +173,22 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
 
 
     @Override
-    public boolean isTaskOperation(String opName) {
-        try {
-            List taskOperations = this.getOperationList();
-            for (TaskOperation taop : taskOperations) {
-                if (taop.getTaskName().equalsIgnoreCase(opName)) {
-                    return true;
+    public boolean isTaskOperation(String opName, List deviceIds) {
+
+        for(DeviceIdentifier deviceIdentifier : deviceIds){
+            String deviceType = deviceIdentifier.getType();
+            try {
+                List taskOperations = this.getOperationList(deviceType);
+                for (TaskOperation taop : taskOperations) {
+                    if (taop.getTaskName().equalsIgnoreCase(opName)) {
+                        return true;
+                    }
                 }
+            } catch (DeviceMgtTaskException e) {
+                // ignoring the error, no need to throw, If error occurs, return value will be false.
             }
-        } catch (DeviceMgtTaskException e) {
-            // ignoring the error, no need to throw, If error occurs, return value will be false.
         }
+
         return false;
 
     }
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 9a0b1b630f..87c45d079e 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
@@ -39,6 +39,8 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
     public static final String TASK_TYPE = "DEVICE_DETAILS";
     public static final String TASK_NAME = "DEVICE_DETAILS_TASK";
     public static final String TENANT_ID = "TENANT_ID";
+    private static String TASK_CLASS = "org.wso2.carbon.device.mgt.core.task.impl.DeviceDetailsRetrieverTask";
+
 
     private DeviceTaskManager deviceTaskManager;
 
@@ -75,7 +77,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
 
             if (!taskManager.isTaskScheduled(TASK_NAME)) {
 
-                TaskInfo taskInfo = new TaskInfo(TASK_NAME, deviceTaskManager.getTaskImplementedClazz(),
+                TaskInfo taskInfo = new TaskInfo(TASK_NAME, TASK_CLASS,
                         properties, triggerInfo);
 
                 taskManager.registerTask(taskInfo);
@@ -130,7 +132,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
                 Map properties = new HashMap<>();
                 properties.put(TENANT_ID, String.valueOf(tenantId));
 
-                TaskInfo taskInfo = new TaskInfo(TASK_NAME, deviceTaskManager.getTaskImplementedClazz(), properties,
+                TaskInfo taskInfo = new TaskInfo(TASK_NAME, TASK_CLASS, properties,
                         triggerInfo);
 
                 taskManager.registerTask(taskInfo);
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java
index 67e7d2a4f8..fcba894206 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java
@@ -17,12 +17,11 @@
  */
 package org.wso2.carbon.device.mgt.core;
 
-import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
 import org.wso2.carbon.device.mgt.common.DeviceManagementException;
 import org.wso2.carbon.device.mgt.common.DeviceManager;
 import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
+import org.wso2.carbon.device.mgt.common.TaskOperation;
 import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
-import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
 import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
 import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
 
@@ -42,6 +41,11 @@ public class TestDeviceManagementService implements DeviceManagementService {
         return providerType;
     }
 
+    @Override
+    public List getTasksForPlatform(){
+        return null;
+    }
+
     @Override
     public void init() throws DeviceManagementException {
 
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 76313396dd..7f5c837578 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.2-SNAPSHOT
+        2.0.3-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 b7548107cd..35cc220a83 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.2-SNAPSHOT
+        2.0.3-SNAPSHOT
         ../pom.xml
     
 
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/app-conf.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/app-conf.json
index d12169830e..2e2ad8b83a 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/app-conf.json
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/app-conf.json
@@ -27,7 +27,7 @@
             }
         },
         "sso": {
-            "enabled": false,
+            "enabled": true,
             "issuer" : "devicemgt",
             "appName" : "devicemgt",
             "identityProviderUrl" : "https://localhost:9443/samlsso",
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json
index 5236f8a877..6c11194110 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json
@@ -11,6 +11,7 @@
     "dashboardServerURL" : "%https.ip%",
     "androidEnrollmentDir": "/android-web-agent/enrollment",
     "windowsEnrollmentDir": "/windows-web-agent/enrollment",
+    "iOSEnrollmentDir": "/ios-web-agent/enrollment",
     "iOSConfigRoot" : "%https.ip%/ios-enrollment/",
     "iOSAPIRoot" : "%https.ip%/ios/",
     "adminService": "%https.ip%",
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js
index 5862f6bc8e..fefd73bd0b 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js
@@ -79,4 +79,30 @@ var groupModule = {};
         );
     };
 
+    groupModule.getGroups = function () {
+        var permissions = userModule.getUIPermissions();
+        if (permissions.LIST_ALL_GROUPS) {
+            endPoint = deviceServiceEndpoint + "/admin/groups";
+        } else if (permissions.LIST_GROUPS) {
+            endPoint = deviceServiceEndpoint + "/groups";
+        } else {
+            log.error("Access denied for user: " + carbonUser.username);
+            return -1;
+        }
+        return serviceInvokers.XMLHttp.get(
+            endPoint, function (responsePayload) {
+                var data = JSON.parse(responsePayload.responseText);
+                if(data) {
+                    return data.deviceGroups;
+                } else {
+                    return [];
+                }
+            },
+            function (responsePayload) {
+                log.error(responsePayload);
+                return -1;
+            }
+        );
+    };
+
 }(groupModule));
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js
index f072a27d5b..127a0df064 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js
@@ -48,6 +48,7 @@ var operationModule = function () {
                    feature["operation"] = features[i].code;
                    feature["name"] = features[i].name;
                    feature["description"] = features[i].description;
+                   feature["contentType"] = features[i].contentType;
                    feature["deviceType"] = deviceType;
                    feature["params"] = [];
                    var metaData = features[i].metadataEntries;
@@ -81,6 +82,10 @@ var operationModule = function () {
                     var iconPath = utility.getOperationIcon(deviceType, iconIdentifier);
                     operations[op]["icon"] = iconPath;
                 }
+                var formParams = features[iconIdentifier].formParams;
+                if (formParams) {
+                    operations[op]["uiParams"] = formParams;
+                }
             }
         }
         return operations;
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js
index 0283fd214d..693d00b236 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js
@@ -500,10 +500,11 @@ var userModule = function () {
 
     publicMethods.getUIPermissions = function () {
         var permissions = {};
-        if (publicMethods.isAuthorized("/permission/admin/device-mgt/devices/list")) {
+        if (publicMethods.isAuthorized("/permission/admin/device-mgt/devices/any-device")) {
             permissions["LIST_DEVICES"] = true;
+            permissions["LIST_OWN_DEVICES"] = true;
         }
-        if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/devices/list")) {
+        if (publicMethods.isAuthorized("/permission/admin/device-mgt/devices/owning-device")) {
             permissions["LIST_OWN_DEVICES"] = true;
         }
         if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/groups/view")) {
@@ -524,10 +525,10 @@ var userModule = function () {
         if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/policies/list")) {
             permissions["LIST_POLICIES"] = true;
         }
-        if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/devices/add")) {
+        if (publicMethods.isAuthorized("/permission/admin/device-mgt/devices/enroll")) {
             permissions["ADD_DEVICE"] = true;
         }
-        if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/groups/add")) {
+        if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/add")) {
             permissions["ADD_GROUP"] = true;
         }
         if (publicMethods.isAuthorized("/permission/admin/device-mgt/users/add")) {
@@ -542,9 +543,6 @@ var userModule = function () {
         if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/devices/view")) {
             permissions["VIEW_GROUP_DEVICES"] = true;
         }
-        if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/roles/create")) {
-            permissions["CREATE_GROUP_ROLES"] = true;
-        }
         if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/roles/view")) {
             permissions["VIEW_GROUP_ROLES"] = true;
         }
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js
index ed2dc01a8e..a71495851f 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js
@@ -60,6 +60,8 @@ var WEB_SERVICE_ADDRESSING_VERSION = 1.0;
 var TOKEN_PAIR = "tokenPair";
 var ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS = "encodedTenantBasedClientAppCredentials";
 var CONTENT_TYPE_IDENTIFIER = "Content-Type";
+var ENCODED_TENANT_BASED_WEB_SOCKET_CLIENT_CREDENTIALS = "encodedTenantBasedWebSocketClientCredentials";
+
 var CONTENT_DISPOSITION_IDENTIFIER = "Content-Disposition";
 var APPLICATION_JSON = "application/json";
 var APPLICATION_ZIP = "application/zip";
@@ -76,4 +78,6 @@ var HTTP_CONFLICT = 409;
 var HTTP_CREATED = 201;
 
 var CACHED_CREDENTIALS = "tenantBasedCredentials";
+var CACHED_CREDENTIALS_FOR_WEBSOCKET_APP = "tenantBasedWebSocketClientCredentials";
+
 var ALLOWED_SCOPES = "scopes";
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js
index bf5f26cac8..bc0fa5abb0 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js
@@ -29,7 +29,9 @@ var carbonServer = new carbonModule.server.Server({
 application.put("carbonServer", carbonServer);
 
 var permissions = {
-    "/permission/admin/device-mgt/devices": ["ui.execute"],
+    "/permission/admin/device-mgt/devices/enroll": ["ui.execute"],
+    "/permission/admin/device-mgt/devices/disenroll": ["ui.execute"],
+    "/permission/admin/device-mgt/devices/owning-device": ["ui.execute"],
     "/permission/admin/device-mgt/groups": ["ui.execute"],
     "/permission/admin/device-mgt/notifications": ["ui.execute"],
     "/permission/admin/device-mgt/policies": ["ui.execute"],
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js
index e6cecaeba6..81cdc1729b 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js
@@ -138,6 +138,63 @@ var utils = function () {
         }
     };
 
+    publicMethods["getTenantBasedWebSocketClientAppCredentials"] = function (username) {
+        if (!username) {
+            log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving tenant " +
+                "based client app credentials. No username " +
+                "as input - getTenantBasedWebSocketClientAppCredentials(x)");
+            return null;
+        } else {
+            //noinspection JSUnresolvedFunction, JSUnresolvedVariable
+            var tenantDomain = carbon.server.tenantDomain({username: username});
+            if (!tenantDomain) {
+                log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving tenant " +
+                    "based client application credentials. Unable to obtain a valid tenant domain for provided " +
+                    "username - getTenantBasedWebSocketClientAppCredentials(x, y)");
+                return null;
+            } else {
+                var cachedBasedWebsocketClientAppCredentials = privateMethods.
+                getCachedBasedWebSocketClientAppCredentials(tenantDomain);
+                if (cachedBasedWebsocketClientAppCredentials) {
+                    return cachedBasedWebsocketClientAppCredentials;
+                } else {
+                    var adminUsername = deviceMgtProps["adminUser"];
+                    var adminUserTenantId = deviceMgtProps["adminUserTenantId"];
+                    //claims required for jwtAuthenticator.
+                    var claims = {"http://wso2.org/claims/enduserTenantId": adminUserTenantId,
+                        "http://wso2.org/claims/enduser": adminUsername};
+                    var jwtToken = publicMethods.getJwtToken(adminUsername, claims);
+
+                    // register a tenant based  app at API Manager
+                    var applicationName = "websocket_webapp_" + tenantDomain;
+                    var requestURL = (deviceMgtProps["oauthProvider"]["appRegistration"]
+                        ["apiManagerClientAppRegistrationServiceURL"]).replace("/tenants","");
+                    var xhr = new XMLHttpRequest();
+                    xhr.open("POST", requestURL, false);
+                    xhr.setRequestHeader("Content-Type", "application/json");
+                    xhr.setRequestHeader("X-JWT-Assertion", "" + jwtToken);
+                    xhr.send(stringify({applicationName:applicationName, tags:["device_management"],
+                        isAllowedToAllDomains:false, isMappingAnExistingOAuthApp:false, validityPeriod: 3600}));
+                    if (xhr["status"] == 201 && xhr["responseText"]) {
+                        var responsePayload = parse(xhr["responseText"]);
+                        var tenantTenantBasedWebsocketClientAppCredentials = {};
+                        tenantTenantBasedWebsocketClientAppCredentials["clientId"] = responsePayload["client_id"];
+                        tenantTenantBasedWebsocketClientAppCredentials["clientSecret"] =
+                            responsePayload["client_secret"];
+                        privateMethods.setCachedBasedWebSocketClientAppCredentials(tenantDomain,
+                            tenantTenantBasedWebsocketClientAppCredentials);
+                        return tenantTenantBasedWebsocketClientAppCredentials;
+                    } else {
+                        log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving tenant " +
+                            "based client application credentials from API " +
+                            "Manager - getTenantBasedWebSocketClientAppCredentials(x, y)");
+                        return null;
+                    }
+                }
+            }
+        }
+    };
+
     privateMethods["setCachedTenantBasedClientAppCredentials"] = function (tenantDomain, clientAppCredentials) {
         var cachedTenantBasedClientAppCredentialsMap = application.get(constants["CACHED_CREDENTIALS"]);
         if (!cachedTenantBasedClientAppCredentialsMap) {
@@ -159,7 +216,32 @@ var utils = function () {
         }
     };
 
-    publicMethods["getTokenPairAndScopesByPasswordGrantType"] = function (username, password, encodedClientAppCredentials, scopes) {
+    privateMethods["getCachedBasedWebSocketClientAppCredentials"] = function (tenantDomain) {
+        var cachedBasedWebSocketClientAppCredentialsMap
+            = application.get(constants["CACHED_CREDENTIALS_FOR_WEBSOCKET_APP"]);
+        if (!cachedBasedWebSocketClientAppCredentialsMap ||
+            !cachedBasedWebSocketClientAppCredentialsMap[tenantDomain]) {
+            return null;
+        } else {
+            return cachedBasedWebSocketClientAppCredentialsMap[tenantDomain];
+        }
+    };
+
+    privateMethods["setCachedBasedWebSocketClientAppCredentials"] = function (tenantDomain, clientAppCredentials) {
+        var cachedBasedWebSocketClientAppCredentialsMap
+            = application.get(constants["CACHED_CREDENTIALS_FOR_WEBSOCKET_APP"]);
+        if (!cachedBasedWebSocketClientAppCredentialsMap) {
+            cachedBasedWebSocketClientAppCredentialsMap = {};
+            cachedBasedWebSocketClientAppCredentialsMap[tenantDomain] = clientAppCredentials;
+            application.put(constants["CACHED_CREDENTIALS_FOR_WEBSOCKET_APP"]
+                , cachedBasedWebSocketClientAppCredentialsMap);
+        } else if (!cachedBasedWebSocketClientAppCredentialsMap[tenantDomain]) {
+            cachedBasedWebSocketClientAppCredentialsMap[tenantDomain] = clientAppCredentials;
+        }
+    };
+
+    publicMethods["getTokenPairAndScopesByPasswordGrantType"] = function (username, password
+        , encodedClientAppCredentials, scopes) {
         if (!username || !password || !encodedClientAppCredentials || !scopes) {
             log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access token by password " +
                 "grant type. No username, password, encoded client app credentials or scopes are " +
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handlers.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handlers.js
index d515471198..9c969f4ab1 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handlers.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handlers.js
@@ -39,6 +39,7 @@ var handlers = function () {
                     "as input - setupTokenPairByPasswordGrantType(x, y)");
         } else {
             privateMethods.setUpEncodedTenantBasedClientAppCredentials(username);
+            privateMethods.setUpEncodedTenantBasedWebSocketClientAppCredentials(username);
             var encodedClientAppCredentials = session.get(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"]);
             if (!encodedClientAppCredentials) {
                 throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up access token pair by " +
@@ -81,6 +82,7 @@ var handlers = function () {
                     "as input - setupTokenPairByPasswordGrantType(x, y)");
         } else {
             privateMethods.setUpEncodedTenantBasedClientAppCredentials(username);
+            privateMethods.setUpEncodedTenantBasedWebSocketClientAppCredentials(username);
             var encodedClientAppCredentials = session.get(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"]);
             if (!encodedClientAppCredentials) {
                 throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up access token pair " +
@@ -168,5 +170,44 @@ var handlers = function () {
         }
     };
 
+    privateMethods["setUpEncodedTenantBasedWebSocketClientAppCredentials"] = function (username) {
+        if (!username) {
+            throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant based " +
+                "client credentials to session context. No username of logged in user is found as " +
+                "input - setUpEncodedTenantBasedWebSocketClientAppCredentials(x)");
+        } else {
+            if (devicemgtProps["apimgt-gateway"]) {
+                var tenantBasedWebSocketClientAppCredentials
+                    = tokenUtil.getTenantBasedWebSocketClientAppCredentials(username);
+                if (!tenantBasedWebSocketClientAppCredentials) {
+                    throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant " +
+                        "based client credentials to session context as the server is unable " +
+                        "to obtain such credentials - setUpEncodedTenantBasedWebSocketClientAppCredentials(x)");
+                } else {
+                    var encodedTenantBasedWebSocketClientAppCredentials =
+                        tokenUtil.encode(tenantBasedWebSocketClientAppCredentials["clientId"] + ":" +
+                            tenantBasedWebSocketClientAppCredentials["clientSecret"]);
+                    // setting up encoded tenant based client credentials to session context.
+                    session.put(constants["ENCODED_TENANT_BASED_WEB_SOCKET_CLIENT_CREDENTIALS"],
+                        encodedTenantBasedWebSocketClientAppCredentials);
+                }
+            } else {
+                var dynamicClientAppCredentials = tokenUtil.getDynamicClientAppCredentials();
+                if (!dynamicClientAppCredentials) {
+                    throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant based " +
+                        "client credentials to session context as the server is unable to obtain " +
+                        "dynamic client credentials - setUpEncodedTenantBasedWebSocketClientAppCredentials(x)");
+                }
+                var encodedTenantBasedWebSocketClientAppCredentials =
+                    tokenUtil.encode(dynamicClientAppCredentials["clientId"] + ":" +
+                        dynamicClientAppCredentials["clientSecret"]);
+                // setting up encoded tenant based client credentials to session context.
+                session.put(constants["ENCODED_TENANT_BASED_WEB_SOCKET_CLIENT_CREDENTIALS"],
+                    encodedTenantBasedWebSocketClientAppCredentials);
+            }
+
+        }
+    };
+
     return publicMethods;
 }();
\ 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.certificates/public/templates/certificate-listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/templates/certificate-listing.hbs
index c492e4f800..e2aa6cc2ec 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/templates/certificate-listing.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/templates/certificate-listing.hbs
@@ -6,9 +6,9 @@
                 
             
         
-         {{serialNumber}}
-         {{subject}}
         
             {{#unequal adminUser serialNumber }}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.search/public/templates/device-listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.search/public/templates/device-listing.hbs
index 7bb2b3e306..eafe9cd4b1 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.search/public/templates/device-listing.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.search/public/templates/device-listing.hbs
@@ -12,21 +12,21 @@
                         
                     
                 
-                
+                
                     

Device {{name}}

{{#if properties.DEVICE_MODEL}}
({{properties.VENDOR}} - {{properties.DEVICE_MODEL}})
{{/if}} - {{enrolmentInfo.owner}} - + {{enrolmentInfo.owner}} + {{#equal enrolmentInfo.status "ACTIVE"}} Active{{/equal}} {{#equal enrolmentInfo.status "INACTIVE"}} Inactive{{/equal}} {{#equal enrolmentInfo.status "BLOCKED"}} Blocked{{/equal}} {{#equal enrolmentInfo.status "REMOVED"}} Removed{{/equal}} - {{type}} - {{enrolmentInfo.ownership}} + {{type}} + {{enrolmentInfo.ownership}} + + + + + Assign from My Devices {{else}} - - - - - - Enroll New Device - + {{#if permissions.enroll}} + + + + + + + Enroll New Device + + {{/if}} {{/if}} -

+ {{/if}} 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 6f2ed5caa2..a340b0e6f2 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 @@ -265,7 +265,7 @@ function loadDevices(searchType, searchParam) { { targets: 1, data: 'name', - class: 'fade-edge', + class: '', render: function (name, type, row, meta) { var model = getPropertyValue(row.properties, 'DEVICE_MODEL'); var vendor = getPropertyValue(row.properties, 'VENDOR'); @@ -279,12 +279,12 @@ function loadDevices(searchType, searchParam) { { targets: 2, data: 'user', - class: 'fade-edge remove-padding-top', + class: 'remove-padding-top', }, { targets: 3, data: 'status', - class: 'fade-edge remove-padding-top', + class: 'remove-padding-top', render: function (status, type, row, meta) { var html; switch (status) { @@ -307,7 +307,7 @@ function loadDevices(searchType, searchParam) { { targets: 4, data: 'deviceType', - class: 'fade-edge remove-padding-top', + class: 'remove-padding-top', render: function (status, type, row, meta) { return getDeviceTypeLabel(row.deviceType); } @@ -315,7 +315,7 @@ function loadDevices(searchType, searchParam) { { targets: 5, data: 'ownership', - class: 'fade-edge remove-padding-top', + class: 'remove-padding-top', render: function (status, type, row, meta) { if (getDeviceTypeCategory(row.deviceType) == 'mobile') { return row.ownership; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs index 8ae4393a8f..9d9edd0c53 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs @@ -36,9 +36,11 @@