Merge branch 'master' of https://github.com/wso2/carbon-device-mgt into geo-fencing

revert-70aa11f8
Rasika Perera 8 years ago
commit 8da1f62cd9

@ -22,13 +22,13 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId> <artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Annotations</name> <name>WSO2 Carbon - API Management Annotations</name>
<description>WSO2 Carbon - API Management Custom Annotation Module</description> <description>WSO2 Carbon - API Management Custom Annotation Module</description>

@ -21,12 +21,12 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<artifactId>org.wso2.carbon.apimgt.application.extension.api</artifactId> <artifactId>org.wso2.carbon.apimgt.application.extension.api</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<name>WSO2 Carbon - API Application Management API</name> <name>WSO2 Carbon - API Application Management API</name>

@ -22,12 +22,12 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<artifactId>org.wso2.carbon.apimgt.application.extension</artifactId> <artifactId>org.wso2.carbon.apimgt.application.extension</artifactId>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Application Management</name> <name>WSO2 Carbon - API Application Management</name>

@ -21,13 +21,13 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.handlers</artifactId> <artifactId>org.wso2.carbon.apimgt.handlers</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Security Handler Component</name> <name>WSO2 Carbon - API Security Handler Component</name>
<description>WSO2 Carbon - API Management Security Handler Module</description> <description>WSO2 Carbon - API Management Security Handler Module</description>

@ -44,6 +44,8 @@ import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
* Contains util methods for synapse gateway authentication handler * Contains util methods for synapse gateway authentication handler
@ -62,21 +64,47 @@ public class Utils {
public static IOTServerConfiguration initConfig() { public static IOTServerConfiguration initConfig() {
try { try {
String IOTServerAPIConfigurationPath = String IOTServerAPIConfigurationPath = CarbonUtils.getCarbonConfigDirPath() + File.separator
CarbonUtils.getCarbonConfigDirPath() + File.separator + IOT_APIS_CONFIG_FILE; + IOT_APIS_CONFIG_FILE;
File file = new File(IOTServerAPIConfigurationPath); File file = new File(IOTServerAPIConfigurationPath);
Document doc = Utils.convertToDocument(file); Document doc = Utils.convertToDocument(file);
JAXBContext fileContext = JAXBContext.newInstance(IOTServerConfiguration.class); JAXBContext fileContext = JAXBContext.newInstance(IOTServerConfiguration.class);
Unmarshaller unmarshaller = fileContext.createUnmarshaller(); Unmarshaller unmarshaller = fileContext.createUnmarshaller();
return (IOTServerConfiguration) unmarshaller.unmarshal(doc);
IOTServerConfiguration iotServerConfiguration = (IOTServerConfiguration) unmarshaller.unmarshal(
doc);
iotServerConfiguration.setHostname(replaceProperties(iotServerConfiguration.getHostname()));
iotServerConfiguration.setVerificationEndpoint(
replaceProperties(iotServerConfiguration.getVerificationEndpoint()));
iotServerConfiguration.setDynamicClientRegistrationEndpoint(
replaceProperties(iotServerConfiguration.getDynamicClientRegistrationEndpoint()));
iotServerConfiguration.setOauthTokenEndpoint(
replaceProperties(iotServerConfiguration.getOauthTokenEndpoint()));
return iotServerConfiguration;
} catch (JAXBException | APIMCertificateMGTException e) { } catch (JAXBException | APIMCertificateMGTException e) {
log.error("Error occurred while initializing Data Source config", e); log.error("Error occurred while initializing Data Source config", e);
return null; return null;
} }
} }
/**
* This method gets the values from system variables and sets to xml.
*/
public static String replaceProperties(String text) {
String regex = "\\$\\{(.*?)\\}";
Pattern pattern = Pattern.compile(regex);
Matcher matchPattern = pattern.matcher(text);
while (matchPattern.find()) {
String sysPropertyName = matchPattern.group(1);
String sysPropertyValue = System.getProperty(sysPropertyName);
if (sysPropertyValue != null && !sysPropertyName.isEmpty()) {
text = text.replaceAll("\\$\\{(" + sysPropertyName + ")\\}", sysPropertyValue);
}
}
return text;
}
/** /**
* This class build the iot-api-config.xml file. * This class build the iot-api-config.xml file.
* @param file * @param file

@ -13,13 +13,13 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId> <artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Integration Client</name> <name>WSO2 Carbon - API Management Integration Client</name>
<description>WSO2 Carbon - API Management Integration Client</description> <description>WSO2 Carbon - API Management Integration Client</description>

@ -13,13 +13,13 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId> <artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Integration Generated Client</name> <name>WSO2 Carbon - API Management Integration Generated Client</name>
<description>WSO2 Carbon - API Management Integration Client</description> <description>WSO2 Carbon - API Management Integration Client</description>

@ -22,13 +22,13 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId> <artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Webapp Publisher</name> <name>WSO2 Carbon - API Management Webapp Publisher</name>
<description>WSO2 Carbon - API Management Webapp Publisher</description> <description>WSO2 Carbon - API Management Webapp Publisher</description>

@ -22,13 +22,13 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - API Management Extensions Component</name> <name>WSO2 Carbon - API Management Extensions Component</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>certificate-mgt</artifactId> <artifactId>certificate-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>certificate-mgt</artifactId> <artifactId>certificate-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -21,13 +21,13 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt</artifactId> <artifactId>certificate-mgt</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId> <artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Certificate Management Core</name> <name>WSO2 Carbon - Certificate Management Core</name>
<description>WSO2 Carbon - Certificate Management Core</description> <description>WSO2 Carbon - Certificate Management Core</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt</artifactId> <artifactId>certificate-mgt</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Certificate Management Component</name> <name>WSO2 Carbon - Certificate Management Component</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -125,4 +125,28 @@
</tableConfig> </tableConfig>
</DataSource> </DataSource>
<InitialOperationConfig>
<Operations>
<Operation>DEVICE_INFO</Operation>
<Operation>APPLICATION_LIST</Operation>
<Operation>DEVICE_LOCATION</Operation>
</Operations>
</InitialOperationConfig>
<!--This configures the Task service for the device-type. Given below are the property definitions.
<RequireStatusMonitoring> - This will enable or disable status monitoring for that particular device-type.
<Frequency> - The time interval (in seconds) in which the task should run for this device-type
<IdleTimeToMarkInactive> - The time duration (in seconds) in which the device can be moved to inactive status
which means the device will be moved to inactive status if that device does not
contact the server within that time period.
<IdleTimeToMarkUnreachable> - The time duration (in seconds) in which the device can be moved to unreachable status
which means the device will be moved to unreachable status if that device does not
contact the server within that time period.
-->
<DeviceStatusTaskConfig>
<RequireStatusMonitoring>false</RequireStatusMonitoring>
<Frequency>300</Frequency>
<IdleTimeToMarkInactive>600</IdleTimeToMarkInactive>
<IdleTimeToMarkUnreachable>300</IdleTimeToMarkUnreachable>
</DeviceStatusTaskConfig>
</DeviceTypeConfiguration> </DeviceTypeConfiguration>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -21,7 +21,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -37,8 +37,9 @@ public interface DeviceManager {
/** /**
* Method to save platform specific Configuration. * Method to save platform specific Configuration.
* * @param configuration - A Platform configuration object which needs to save
* @return Returns the status of the operation * @return Returns the status of the operation
* @throws DeviceManagementException If something goes wrong while saving the configuration.
*/ */
boolean saveConfiguration(PlatformConfiguration configuration) throws DeviceManagementException; boolean saveConfiguration(PlatformConfiguration configuration) throws DeviceManagementException;
@ -46,6 +47,7 @@ public interface DeviceManager {
* Method to get platform specific Configuration. * Method to get platform specific Configuration.
* *
* @return Returns the platform specific tenant configurations * @return Returns the platform specific tenant configurations
* @throws DeviceManagementException If something goes wrong while fetching the configuration.
*/ */
PlatformConfiguration getConfiguration() throws DeviceManagementException; PlatformConfiguration getConfiguration() throws DeviceManagementException;
@ -53,6 +55,7 @@ public interface DeviceManager {
* Method to enrolling a particular device of type mobile, IoT, etc within CDM. * Method to enrolling a particular device of type mobile, IoT, etc within CDM.
* *
* @param device Metadata corresponding to the device being enrolled * @param device Metadata corresponding to the device being enrolled
* @return A boolean indicating the status of the operation.
* @throws DeviceManagementException If some unusual behaviour is observed while enrolling a device * @throws DeviceManagementException If some unusual behaviour is observed while enrolling a device
*/ */
boolean enrollDevice(Device device) throws DeviceManagementException; boolean enrollDevice(Device device) throws DeviceManagementException;
@ -61,6 +64,7 @@ public interface DeviceManager {
* Method to modify the metadata corresponding to device enrollment. * Method to modify the metadata corresponding to device enrollment.
* *
* @param device Modified device enrollment related metadata * @param device Modified device enrollment related metadata
* @return A boolean indicating the status of the operation.
* @throws DeviceManagementException If some unusual behaviour is observed while modify the enrollment of a * @throws DeviceManagementException If some unusual behaviour is observed while modify the enrollment of a
* device * device
*/ */
@ -70,6 +74,7 @@ public interface DeviceManager {
* Method to disenroll a particular device from CDM. * Method to disenroll a particular device from CDM.
* *
* @param deviceId Fully qualified device identifier * @param deviceId Fully qualified device identifier
* @return A boolean indicating the status of the operation.
* @throws DeviceManagementException If some unusual behaviour is observed while disenrolling a device * @throws DeviceManagementException If some unusual behaviour is observed while disenrolling a device
*/ */
boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException; boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException;
@ -100,6 +105,7 @@ public interface DeviceManager {
* *
* @param deviceId Fully qualified device identifier * @param deviceId Fully qualified device identifier
* @param status Indicates whether the device is active * @param status Indicates whether the device is active
* @return A boolean indicating the status of the operation.
* @throws DeviceManagementException If some unusual behaviour is observed while updating the active status * @throws DeviceManagementException If some unusual behaviour is observed while updating the active status
* of the device * of the device
*/ */
@ -127,6 +133,7 @@ public interface DeviceManager {
* *
* @param deviceIdentifier identifier to identify the device * @param deviceIdentifier identifier to identify the device
* @param device Updated device information related data * @param device Updated device information related data
* @return A boolean indicating the status of the operation.
* @throws DeviceManagementException If some unusual behaviour is observed while updating the device info * @throws DeviceManagementException If some unusual behaviour is observed while updating the device info
*/ */
boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException; boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException;
@ -136,6 +143,7 @@ public interface DeviceManager {
* *
* @param deviceId Fully qualified device identifier * @param deviceId Fully qualified device identifier
* @param ownershipType Type of ownership * @param ownershipType Type of ownership
* @return A boolean indicating the status of the operation.
* @throws DeviceManagementException If some unusual behaviour is observed while setting the ownership * @throws DeviceManagementException If some unusual behaviour is observed while setting the ownership
* of the device * of the device
*/ */

@ -39,7 +39,7 @@ public interface ApplicationManager {
* @param pageNumber Page number of the list. * @param pageNumber Page number of the list.
* @param size Number of items in one page. * @param size Number of items in one page.
* @return The list of applications belongs to a domain. * @return The list of applications belongs to a domain.
* @throws ApplicationManagementException * @throws ApplicationManagementException If something goes wrong
*/ */
Application[] getApplications(String domain, int pageNumber, int size) Application[] getApplications(String domain, int pageNumber, int size)
@ -52,6 +52,7 @@ public interface ApplicationManager {
* @param deviceId Device id of the device that the status belongs to. * @param deviceId Device id of the device that the status belongs to.
* @param application Application details of the app being updated. * @param application Application details of the app being updated.
* @param status Installed/Uninstalled * @param status Installed/Uninstalled
* @throws ApplicationManagementException If something goes wrong
*/ */
void updateApplicationStatus(DeviceIdentifier deviceId, Application application, String status) void updateApplicationStatus(DeviceIdentifier deviceId, Application application, String status)
throws ApplicationManagementException; throws ApplicationManagementException;
@ -62,6 +63,7 @@ public interface ApplicationManager {
* @param deviceId Device id of the device that the status belongs to. * @param deviceId Device id of the device that the status belongs to.
* @param application Application details of the app being searched. * @param application Application details of the app being searched.
* @return Status of the application on the device. * @return Status of the application on the device.
* @throws ApplicationManagementException If something goes wrong
*/ */
String getApplicationStatus(DeviceIdentifier deviceId, Application application) String getApplicationStatus(DeviceIdentifier deviceId, Application application)
throws ApplicationManagementException; throws ApplicationManagementException;

@ -55,8 +55,8 @@ public interface DeviceAccessAuthorizationService {
* DeviceIdentifier list. * DeviceIdentifier list.
* *
* @param deviceIdentifiers - List of DeviceIdentifiers to be checked for authorization. * @param deviceIdentifiers - List of DeviceIdentifiers to be checked for authorization.
* @return DeviceAuthorizationResult - Authorization result including the list of authorized devices & unauthorized * @return DeviceAuthorizationResult - Authorization result object including the list of authorized devices and
* devices. * unauthorized devices.
* @throws DeviceAccessAuthorizationException if something goes wrong when checking the authorization. * @throws DeviceAccessAuthorizationException if something goes wrong when checking the authorization.
*/ */
DeviceAuthorizationResult isUserAuthorized(List<DeviceIdentifier> deviceIdentifiers) throws DeviceAuthorizationResult isUserAuthorized(List<DeviceIdentifier> deviceIdentifiers) throws
@ -68,8 +68,8 @@ public interface DeviceAccessAuthorizationService {
* *
* @param deviceIdentifiers - List of DeviceIdentifiers to be checked for authorization. * @param deviceIdentifiers - List of DeviceIdentifiers to be checked for authorization.
* @param groupPermissions - Group Permissions * @param groupPermissions - Group Permissions
* @return DeviceAuthorizationResult - Authorization result including the list of authorized devices & unauthorized * @return DeviceAuthorizationResult - Authorization result object including the list of authorized devices and
* devices. * unauthorized devices.
* @throws DeviceAccessAuthorizationException if something goes wrong when checking the authorization. * @throws DeviceAccessAuthorizationException if something goes wrong when checking the authorization.
*/ */
DeviceAuthorizationResult isUserAuthorized(List<DeviceIdentifier> deviceIdentifiers, String[] groupPermissions) DeviceAuthorizationResult isUserAuthorized(List<DeviceIdentifier> deviceIdentifiers, String[] groupPermissions)
@ -95,8 +95,8 @@ public interface DeviceAccessAuthorizationService {
* @param deviceIdentifiers - List of DeviceIdentifiers to be checked for authorization. * @param deviceIdentifiers - List of DeviceIdentifiers to be checked for authorization.
* @param username - User name * @param username - User name
* @param groupPermissions - Group Permissions * @param groupPermissions - Group Permissions
* @return DeviceAuthorizationResult - Authorization result including the list of authorized devices & unauthorized * @return DeviceAuthorizationResult - Authorization result object including the list of authorized devices and
* devices. * unauthorized devices.
* @throws DeviceAccessAuthorizationException if something goes wrong when checking the authorization. * @throws DeviceAccessAuthorizationException if something goes wrong when checking the authorization.
*/ */
DeviceAuthorizationResult isUserAuthorized(List<DeviceIdentifier> deviceIdentifiers, String username, DeviceAuthorizationResult isUserAuthorized(List<DeviceIdentifier> deviceIdentifiers, String username,
@ -129,8 +129,8 @@ public interface DeviceAccessAuthorizationService {
* *
* @param deviceIdentifiers - List of DeviceIdentifiers to be checked for authorization. * @param deviceIdentifiers - List of DeviceIdentifiers to be checked for authorization.
* @param username - Username of the user to be checked for authorization. * @param username - Username of the user to be checked for authorization.
* @return DeviceAuthorizationResult - Authorization result including the list of authorized devices & unauthorized * @return DeviceAuthorizationResult - Authorization result object including the list of authorized devices and
* devices. * unauthorized devices.
* @throws DeviceAccessAuthorizationException if something goes wrong when checking the authorization. * @throws DeviceAccessAuthorizationException if something goes wrong when checking the authorization.
*/ */
DeviceAuthorizationResult isUserAuthorized(List<DeviceIdentifier> deviceIdentifiers, String username) throws DeviceAuthorizationResult isUserAuthorized(List<DeviceIdentifier> deviceIdentifiers, String username) throws

@ -28,6 +28,7 @@ public interface PlatformConfigurationManagementService {
* *
* @param platformConfiguration Operation to be added. * @param platformConfiguration Operation to be added.
* @param resourcePath Registry resource path. * @param resourcePath Registry resource path.
* @return A boolean indicating the status of the operation.
* @throws org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException If some unusual behaviour is observed while adding the * @throws org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException If some unusual behaviour is observed while adding the
* configuration. * configuration.
*/ */
@ -38,6 +39,7 @@ public interface PlatformConfigurationManagementService {
* Method to retrieve the list of general tenant configurations. * Method to retrieve the list of general tenant configurations.
* *
* @param resourcePath Registry resource path. * @param resourcePath Registry resource path.
* @return Platform Configuration object.
* @throws org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException If some unusual behaviour is observed while fetching the * @throws org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException If some unusual behaviour is observed while fetching the
* operation list. * operation list.
*/ */

@ -32,6 +32,7 @@ public interface NotificationManagementService {
/** /**
* Method to add a notification to the database. * Method to add a notification to the database.
* *
* @param deviceId - DeviceIdentifier of the device
* @param notification - Notification to be added to database. * @param notification - Notification to be added to database.
* @return boolean status of the operation. * @return boolean status of the operation.
* @throws NotificationManagementException * @throws NotificationManagementException
@ -66,7 +67,7 @@ public interface NotificationManagementService {
* Method to fetch all the notifications in the database. * Method to fetch all the notifications in the database.
* *
* @return List of all Notifications in the database. * @return List of all Notifications in the database.
* @throws NotificationManagementException * @throws NotificationManagementException if something goes wrong while fetching the Notifications.
* *
*/ */
List<Notification> getAllNotifications() throws NotificationManagementException; List<Notification> getAllNotifications() throws NotificationManagementException;

@ -17,11 +17,14 @@
*/ */
package org.wso2.carbon.device.mgt.common.operation.mgt; package org.wso2.carbon.device.mgt.common.operation.mgt;
import org.wso2.carbon.device.mgt.common.*; 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.PaginationRequest;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy; import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* This represents the Device Operation management functionality which should be implemented by * This represents the Device Operation management functionality which should be implemented by
@ -34,8 +37,9 @@ public interface OperationManager {
* *
* @param operation Operation to be added * @param operation Operation to be added
* @param devices List of DeviceIdentifiers to execute the operation * @param devices List of DeviceIdentifiers to execute the operation
* @return Activity object corresponds to the added operation.
* @throws OperationManagementException If some unusual behaviour is observed while adding the operation * @throws OperationManagementException If some unusual behaviour is observed while adding the operation
* InvalidDeviceException If addOperation request contains Invalid DeviceIdentifiers. * @throws InvalidDeviceException If addOperation request contains Invalid DeviceIdentifiers.
*/ */
Activity addOperation(Operation operation, List<DeviceIdentifier> devices) throws OperationManagementException, Activity addOperation(Operation operation, List<DeviceIdentifier> devices) throws OperationManagementException,
InvalidDeviceException; InvalidDeviceException;
@ -43,7 +47,8 @@ public interface OperationManager {
/** /**
* Method to retrieve the list of all operations to a device. * Method to retrieve the list of all operations to a device.
* *
* @param deviceId * @param deviceId - Device Identifier of the device
* @return A List of operations applied to the given device-id.
* @throws OperationManagementException If some unusual behaviour is observed while fetching the * @throws OperationManagementException If some unusual behaviour is observed while fetching the
* operation list. * operation list.
*/ */
@ -64,6 +69,7 @@ public interface OperationManager {
* Method to retrieve the list of available operations to a device. * Method to retrieve the list of available operations to a device.
* *
* @param deviceId DeviceIdentifier of the device * @param deviceId DeviceIdentifier of the device
* @return A List of pending operations.
* @throws OperationManagementException If some unusual behaviour is observed while fetching the * @throws OperationManagementException If some unusual behaviour is observed while fetching the
* operation list. * operation list.
*/ */

@ -27,19 +27,20 @@ import java.util.Properties;
public interface PermissionManagerService { public interface PermissionManagerService {
/** /**
* Adds a permission.
* *
* @param permission - Permission to be added * @param permission - Permission to be added
* @throws PermissionManagementException If some unusual behaviour is observed while adding the * @return A boolean indicating the status of the operation.
* permission. * @throws PermissionManagementException If some unusual behaviour is observed while adding the permission.
*/ */
boolean addPermission(Permission permission) throws PermissionManagementException; boolean addPermission(Permission permission) throws PermissionManagementException;
/** /**
* Fetches a given permission.
* *
* @param properties - Properties of the permission to be fetched. * @param properties - Properties of the permission to be fetched.
* @return The matched Permission object. * @return The matched Permission object.
* @throws PermissionManagementException If some unusual behaviour is observed while fetching the * @throws PermissionManagementException If some unusual behaviour is observed while fetching the permission.
* permission.
*/ */
Permission getPermission(Properties properties) throws PermissionManagementException; Permission getPermission(Properties properties) throws PermissionManagementException;

@ -32,8 +32,8 @@ public interface NotificationStrategy {
void undeploy(); void undeploy();
/** /**
* Provides push notification configuration * Provides push notification configuration.
* * @return PushNotificationConfig for this NotificationStrategy
*/ */
PushNotificationConfig getConfig(); PushNotificationConfig getConfig();

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,6 +22,9 @@ import org.wso2.carbon.device.mgt.core.operation.mgt.PolicyOperation;
public final class DeviceManagementConstants { public final class DeviceManagementConstants {
public static final String DM_CACHE_MANAGER = "DM_CACHE_MANAGER";
public static final String DEVICE_CACHE = "DEVICE_CACHE";
public static final class Common { public static final class Common {
private Common() { private Common() {
throw new AssertionError(); throw new AssertionError();

@ -21,14 +21,22 @@ package org.wso2.carbon.device.mgt.core.app.mgt;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.CarbonContext; 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.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
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.app.mgt.Application;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig; import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig;
import org.wso2.carbon.device.mgt.core.dao.*; import org.wso2.carbon.device.mgt.core.dao.ApplicationDAO;
import org.wso2.carbon.device.mgt.core.dao.ApplicationMappingDAO;
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;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import java.sql.SQLException; import java.sql.SQLException;
@ -190,10 +198,9 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
List<Application> applications) throws ApplicationManagementException { List<Application> applications) throws ApplicationManagementException {
List<Application> installedAppList = getApplicationListForDevice(deviceIdentifier); List<Application> installedAppList = getApplicationListForDevice(deviceIdentifier);
try { try {
Device device = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceIdentifier,
false);
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
DeviceManagementDAOFactory.beginTransaction();
Device device = deviceDAO.getDevice(deviceIdentifier, tenantId);
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Device:" + device.getId() + ":identifier:" + deviceIdentifier.getId()); log.debug("Device:" + device.getId() + ":identifier:" + deviceIdentifier.getId());
} }
@ -212,6 +219,7 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
appIdsToRemove.add(installedApp.getId()); appIdsToRemove.add(installedApp.getId());
} }
} }
DeviceManagementDAOFactory.beginTransaction();
applicationMappingDAO.removeApplicationMapping(device.getId(), appIdsToRemove, tenantId); applicationMappingDAO.removeApplicationMapping(device.getId(), appIdsToRemove, tenantId);
Application installedApp; Application installedApp;
List<Integer> applicationIds = new ArrayList<>(); List<Integer> applicationIds = new ArrayList<>();
@ -247,6 +255,8 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
throw new ApplicationManagementException("Error occurred saving application list to the device", e); throw new ApplicationManagementException("Error occurred saving application list to the device", e);
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
throw new ApplicationManagementException("Error occurred while initializing transaction", e); throw new ApplicationManagementException("Error occurred while initializing transaction", e);
} catch (DeviceManagementException e) {
throw new ApplicationManagementException("Error occurred obtaining the device object.", e);
} finally { } finally {
DeviceManagementDAOFactory.closeConnection(); DeviceManagementDAOFactory.closeConnection();
} }
@ -255,11 +265,14 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
@Override @Override
public List<Application> getApplicationListForDevice( public List<Application> getApplicationListForDevice(
DeviceIdentifier deviceId) throws ApplicationManagementException { DeviceIdentifier deviceId) throws ApplicationManagementException {
Device device; Device device = null;
try { try {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); device = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceId,
DeviceManagementDAOFactory.openConnection(); false);
device = deviceDAO.getDevice(deviceId, tenantId); } catch (DeviceManagementException e) {
throw new ApplicationManagementException("Error occurred while fetching the device of '" +
deviceId.getType() + "' carrying the identifier'" + deviceId.getId(), e);
}
if (device == null) { if (device == null) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("No device is found upon the device identifier '" + deviceId.getId() + log.debug("No device is found upon the device identifier '" + deviceId.getId() +
@ -267,6 +280,8 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
} }
return null; return null;
} }
try {
DeviceManagementDAOFactory.openConnection();
return applicationDAO.getInstalledApplications(device.getId()); return applicationDAO.getInstalledApplications(device.getId());
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
throw new ApplicationManagementException("Error occurred while fetching the Application List of '" + throw new ApplicationManagementException("Error occurred while fetching the Application List of '" +
@ -277,5 +292,4 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
DeviceManagementDAOFactory.closeConnection(); DeviceManagementDAOFactory.closeConnection();
} }
} }
} }

@ -0,0 +1,81 @@
/*
* Copyright (c) 2017, 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.core.cache;
import java.util.Objects;
/**
* This represents a Key object used in DeviceCache.
*/
public class DeviceCacheKey {
private String deviceId;
private String deviceType;
private int tenantId;
private volatile int hashCode;
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType;
}
public int getTenantId() {
return tenantId;
}
public void setTenantId(int tenantId) {
this.tenantId = tenantId;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (!DeviceCacheKey.class.isAssignableFrom(obj.getClass())) {
return false;
}
final DeviceCacheKey other = (DeviceCacheKey) obj;
String thisId = this.deviceId + "-" + this.deviceType + "_" + this.tenantId;
String otherId = other.deviceId + "-" + other.deviceType + "_" + other.tenantId;
if (!thisId.equals(otherId)) {
return false;
}
return true;
}
@Override
public int hashCode() {
if (hashCode == 0) {
hashCode = Objects.hash(deviceId, deviceType, tenantId);
}
return hashCode;
}
}

@ -0,0 +1,73 @@
/*
* Copyright (c) 2017, 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.core.cache;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.Device;
import java.util.List;
/**
* This defines the contract to be implemented by DeviceCacheManager which holds the necessary functionalities to
* manage a cache of Device objects.
*/
public interface DeviceCacheManager {
/**
* Adds a given device object to the device-cache.
* @param deviceIdentifier - DeviceIdentifier of the device to be added.
* @param device - Device object to be added.
* @param tenantId - Owning tenant of the device.
*
*/
void addDeviceToCache(DeviceIdentifier deviceIdentifier, Device device, int tenantId);
/**
* Removes a device object from device-cache.
* @param deviceIdentifier - DeviceIdentifier of the device to be removed.
* @param tenantId - Owning tenant of the device.
*
*/
void removeDeviceFromCache(DeviceIdentifier deviceIdentifier, int tenantId);
/**
* Removes a list of devices from device-cache.
* @param deviceList - List of Cache-Keys of the device objects to be removed.
*
*/
void removeDevicesFromCache(List<DeviceCacheKey> deviceList);
/**
* Updates a given device object in the device-cache.
* @param deviceIdentifier - DeviceIdentifier of the device to be updated.
* @param device - Device object to be updated.
* @param tenantId - Owning tenant of the device.
*
*/
void updateDeviceInCache(DeviceIdentifier deviceIdentifier, Device device, int tenantId);
/**
* Fetches a device object from device-cache.
* @param deviceIdentifier - DeviceIdentifier of the device to be fetched.
* @param tenantId - Owning tenant of the device.
* @return Device object
*
*/
Device getDeviceFromCache(DeviceIdentifier deviceIdentifier, int tenantId);
}

@ -0,0 +1,108 @@
/*
* Copyright (c) 2017, 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.core.cache.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.core.cache.DeviceCacheKey;
import org.wso2.carbon.device.mgt.core.cache.DeviceCacheManager;
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
import javax.cache.Cache;
import java.util.List;
/**
* Implementation of DeviceCacheManager.
*/
public class DeviceCacheManagerImpl implements DeviceCacheManager {
private static final Log log = LogFactory.getLog(DeviceCacheManagerImpl.class);
private static DeviceCacheManagerImpl deviceCacheManager;
private DeviceCacheManagerImpl() {
}
public static DeviceCacheManagerImpl getInstance() {
if (deviceCacheManager == null) {
synchronized (DeviceCacheManagerImpl.class) {
if (deviceCacheManager == null) {
deviceCacheManager = new DeviceCacheManagerImpl();
}
}
}
return deviceCacheManager;
}
@Override
public void addDeviceToCache(DeviceIdentifier deviceIdentifier, Device device, int tenantId) {
Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache();
DeviceCacheKey cacheKey = getCacheKey(deviceIdentifier, tenantId);
if (lCache.containsKey(cacheKey)) {
this.updateDeviceInCache(deviceIdentifier, device, tenantId);
} else {
lCache.put(cacheKey, device);
}
}
@Override
public void removeDeviceFromCache(DeviceIdentifier deviceIdentifier, int tenantId) {
Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache();
DeviceCacheKey cacheKey = getCacheKey(deviceIdentifier, tenantId);
if (lCache.containsKey(cacheKey)) {
lCache.remove(cacheKey);
}
}
@Override
public void removeDevicesFromCache(List<DeviceCacheKey> deviceList) {
Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache();
for (DeviceCacheKey cacheKey : deviceList) {
if (lCache.containsKey(cacheKey)) {
lCache.remove(cacheKey);
}
}
}
@Override
public void updateDeviceInCache(DeviceIdentifier deviceIdentifier, Device device, int tenantId) {
Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache();
DeviceCacheKey cacheKey = getCacheKey(deviceIdentifier, tenantId);
if (lCache.containsKey(cacheKey)) {
lCache.replace(cacheKey, device);
}
}
@Override
public Device getDeviceFromCache(DeviceIdentifier deviceIdentifier, int tenantId) {
Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache();
return lCache.get(getCacheKey(deviceIdentifier, tenantId));
}
private DeviceCacheKey getCacheKey(DeviceIdentifier deviceIdentifier, int tenantId) {
DeviceCacheKey deviceCacheKey = new DeviceCacheKey();
deviceCacheKey.setDeviceId(deviceIdentifier.getId());
deviceCacheKey.setDeviceType(deviceIdentifier.getType());
deviceCacheKey.setTenantId(tenantId);
return deviceCacheKey;
}
}

@ -18,6 +18,7 @@
package org.wso2.carbon.device.mgt.core.config; package org.wso2.carbon.device.mgt.core.config;
import org.wso2.carbon.device.mgt.core.config.geo.location.GeoLocationConfiguration; import org.wso2.carbon.device.mgt.core.config.geo.location.GeoLocationConfiguration;
import org.wso2.carbon.device.mgt.core.config.cache.DeviceCacheConfiguration;
import org.wso2.carbon.device.mgt.core.config.identity.IdentityConfigurations; import org.wso2.carbon.device.mgt.core.config.identity.IdentityConfigurations;
import org.wso2.carbon.device.mgt.core.config.pagination.PaginationConfiguration; import org.wso2.carbon.device.mgt.core.config.pagination.PaginationConfiguration;
import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration; import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration;
@ -26,9 +27,7 @@ import org.wso2.carbon.device.mgt.core.config.status.task.DeviceStatusTaskConfig
import org.wso2.carbon.device.mgt.core.config.task.TaskConfiguration; import org.wso2.carbon.device.mgt.core.config.task.TaskConfiguration;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
/** /**
* Represents Device Mgt configuration. * Represents Device Mgt configuration.
@ -44,9 +43,9 @@ public final class DeviceManagementConfig {
private PaginationConfiguration paginationConfiguration; private PaginationConfiguration paginationConfiguration;
private PushNotificationConfiguration pushNotificationConfiguration; private PushNotificationConfiguration pushNotificationConfiguration;
private DeviceStatusTaskConfig deviceStatusTaskConfig; private DeviceStatusTaskConfig deviceStatusTaskConfig;
private DeviceCacheConfiguration deviceCacheConfiguration;
private GeoLocationConfiguration geoLocationConfiguration; private GeoLocationConfiguration geoLocationConfiguration;
@XmlElement(name = "ManagementRepository", required = true) @XmlElement(name = "ManagementRepository", required = true)
public DeviceManagementConfigRepository getDeviceManagementConfigRepository() { public DeviceManagementConfigRepository getDeviceManagementConfigRepository() {
return deviceManagementConfigRepository; return deviceManagementConfigRepository;
@ -111,6 +110,15 @@ public final class DeviceManagementConfig {
this.deviceStatusTaskConfig = deviceStatusTaskConfig; this.deviceStatusTaskConfig = deviceStatusTaskConfig;
} }
@XmlElement(name = "DeviceCacheConfiguration", required = true)
public DeviceCacheConfiguration getDeviceCacheConfiguration() {
return deviceCacheConfiguration;
}
public void setDeviceCacheConfiguration(DeviceCacheConfiguration deviceCacheConfiguration) {
this.deviceCacheConfiguration = deviceCacheConfiguration;
}
@XmlElement(name = "GeoLocationConfiguration", required = true) @XmlElement(name = "GeoLocationConfiguration", required = true)
public GeoLocationConfiguration getGeoLocationConfiguration() { public GeoLocationConfiguration getGeoLocationConfiguration() {
return geoLocationConfiguration; return geoLocationConfiguration;

@ -0,0 +1,47 @@
/*
* Copyright (c) 2017, 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.core.config.cache;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "DeviceCacheConfiguration")
public class DeviceCacheConfiguration {
private boolean isEnabled;
private int expiryTime;
@XmlElement(name = "Enable", required = true)
public boolean isEnabled() {
return isEnabled;
}
public void setEnabled(boolean enabled) {
isEnabled = enabled;
}
@XmlElement(name = "ExpiryTime", required = true)
public int getExpiryTime() {
return expiryTime;
}
public void setExpiryTime(int expiryTime) {
this.expiryTime = expiryTime;
}
}

@ -158,7 +158,7 @@ public interface DeviceDAO {
HashMap<Integer, Device> getDevice(DeviceIdentifier deviceIdentifier) throws DeviceManagementDAOException; HashMap<Integer, Device> getDevice(DeviceIdentifier deviceIdentifier) throws DeviceManagementDAOException;
/** /**
* This method is used to retrieve a device of a given id. * This method is used to retrieve a device of a given tenant id.
* *
* @param deviceId device id. * @param deviceId device id.
* @param tenantId tenant id. * @param tenantId tenant id.

@ -57,6 +57,7 @@ import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderServiceImpl; import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderServiceImpl;
import org.wso2.carbon.device.mgt.core.task.DeviceTaskManagerService; import org.wso2.carbon.device.mgt.core.task.DeviceTaskManagerService;
import org.wso2.carbon.device.mgt.core.util.DeviceManagementSchemaInitializer; import org.wso2.carbon.device.mgt.core.util.DeviceManagementSchemaInitializer;
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
import org.wso2.carbon.email.sender.core.service.EmailSenderService; import org.wso2.carbon.email.sender.core.service.EmailSenderService;
import org.wso2.carbon.ndatasource.core.DataSourceService; import org.wso2.carbon.ndatasource.core.DataSourceService;
import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.registry.core.service.RegistryService;
@ -152,6 +153,8 @@ public class DeviceManagementServiceComponent {
GroupManagementDAOFactory.init(dsConfig); GroupManagementDAOFactory.init(dsConfig);
NotificationManagementDAOFactory.init(dsConfig); NotificationManagementDAOFactory.init(dsConfig);
OperationManagementDAOFactory.init(dsConfig); OperationManagementDAOFactory.init(dsConfig);
/*Initialize the device cache*/
DeviceManagerUtil.initializeDeviceCache();
/* Initialize Operation Manager */ /* Initialize Operation Manager */
this.initOperationsManager(); this.initOperationsManager();

@ -22,6 +22,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.EntityDoesNotExistException; import org.wso2.carbon.device.mgt.common.EntityDoesNotExistException;
import org.wso2.carbon.device.mgt.common.PaginationRequest; import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.common.PaginationResult;
@ -30,8 +31,8 @@ import org.wso2.carbon.device.mgt.common.notification.mgt.Notification;
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException;
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService;
import org.wso2.carbon.device.mgt.core.dao.DeviceDAO; 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; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.notification.mgt.dao.NotificationDAO; import org.wso2.carbon.device.mgt.core.notification.mgt.dao.NotificationDAO;
import org.wso2.carbon.device.mgt.core.notification.mgt.dao.NotificationManagementDAOFactory; import org.wso2.carbon.device.mgt.core.notification.mgt.dao.NotificationManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.notification.mgt.dao.util.NotificationDAOUtil; import org.wso2.carbon.device.mgt.core.notification.mgt.dao.util.NotificationDAOUtil;
@ -65,7 +66,7 @@ public class NotificationManagementServiceImpl implements NotificationManagement
int notificationId; int notificationId;
int tenantId = NotificationDAOUtil.getTenantId(); int tenantId = NotificationDAOUtil.getTenantId();
Device device = this.getDevice(deviceId, tenantId); Device device = this.getDevice(deviceId);
if (device == null) { if (device == null) {
throw new EntityDoesNotExistException("No device is found with type '" + deviceId.getType() + throw new EntityDoesNotExistException("No device is found with type '" + deviceId.getType() +
"' and id '" + deviceId.getId() + "'"); "' and id '" + deviceId.getId() + "'");
@ -87,19 +88,13 @@ public class NotificationManagementServiceImpl implements NotificationManagement
return true; return true;
} }
private Device getDevice(DeviceIdentifier deviceId, int tenantId) throws NotificationManagementException { private Device getDevice(DeviceIdentifier deviceId) throws NotificationManagementException {
Device device; Device device;
try { try {
DeviceManagementDAOFactory.openConnection(); device = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceId, false);
device = deviceDAO.getDevice(deviceId, tenantId); } catch (DeviceManagementException e) {
} catch (SQLException e) { throw new NotificationManagementException("Error occurred while retrieving device data for " +
throw new NotificationManagementException("Error occurred while opening a connection to" +
" the data source", e);
} catch (DeviceManagementDAOException e) {
throw new NotificationManagementException("Error occurred while retriving device data for " +
" adding notification", e); " adding notification", e);
} finally {
DeviceManagementDAOFactory.closeConnection();
} }
return device; return device;
} }

@ -23,6 +23,7 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.InvalidDeviceException; import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
import org.wso2.carbon.device.mgt.common.MonitoringOperation; import org.wso2.carbon.device.mgt.common.MonitoringOperation;
@ -293,19 +294,11 @@ public class OperationManagerImpl implements OperationManager {
} }
private Device getDevice(DeviceIdentifier deviceId) throws OperationManagementException { private Device getDevice(DeviceIdentifier deviceId) throws OperationManagementException {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
DeviceManagementDAOFactory.openConnection(); return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceId, false);
return deviceDAO.getDevice(deviceId, tenantId); } catch (DeviceManagementException e) {
} catch (SQLException e) {
throw new OperationManagementException("Error occurred while opening a connection the data " +
"source", e);
} catch (DeviceManagementDAOException e) {
OperationManagementDAOFactory.rollbackTransaction();
throw new OperationManagementException( throw new OperationManagementException(
"Error occurred while retrieving device info", e); "Error occurred while retrieving device info.", e);
} finally {
DeviceManagementDAOFactory.closeConnection();
} }
} }

@ -284,7 +284,8 @@ public class SQLServerOperationDAOImpl extends GenericOperationDAOImpl {
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, opStatus.toString()); stmt.setString(1, opStatus.toString());
stmt.setString(2, pushNotificationStatus.toString()); stmt.setString(2, pushNotificationStatus.toString());
stmt.setInt(3, limit); stmt.setInt(3, 0);
stmt.setInt(4, limit);
rs = stmt.executeQuery(); rs = stmt.executeQuery();
while (rs.next()) { while (rs.next()) {
int tenantID = rs.getInt("TENANT_ID"); int tenantID = rs.getInt("TENANT_ID");

@ -57,6 +57,7 @@ import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants; import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.core.DeviceManagementPluginRepository; import org.wso2.carbon.device.mgt.core.DeviceManagementPluginRepository;
import org.wso2.carbon.device.mgt.core.cache.impl.DeviceCacheManagerImpl;
import org.wso2.carbon.device.mgt.core.dao.ApplicationDAO; import org.wso2.carbon.device.mgt.core.dao.ApplicationDAO;
import org.wso2.carbon.device.mgt.core.dao.DeviceDAO; 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.DeviceManagementDAOException;
@ -282,8 +283,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
boolean status = deviceManager.modifyEnrollment(device); boolean status = deviceManager.modifyEnrollment(device);
try { try {
int tenantId = this.getTenantId(); int tenantId = this.getTenantId();
Device currentDevice = this.getDevice(deviceIdentifier, false);
DeviceManagementDAOFactory.beginTransaction(); DeviceManagementDAOFactory.beginTransaction();
Device currentDevice = deviceDAO.getDevice(deviceIdentifier, tenantId);
device.setId(currentDevice.getId()); device.setId(currentDevice.getId());
if (device.getEnrolmentInfo().getId() == 0) { if (device.getEnrolmentInfo().getId() == 0) {
device.getEnrolmentInfo().setId(currentDevice.getEnrolmentInfo().getId()); device.getEnrolmentInfo().setId(currentDevice.getEnrolmentInfo().getId());
@ -294,6 +295,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
deviceDAO.updateDevice(device, tenantId); deviceDAO.updateDevice(device, tenantId);
enrollmentDAO.updateEnrollment(device.getEnrolmentInfo()); enrollmentDAO.updateEnrollment(device.getEnrolmentInfo());
DeviceManagementDAOFactory.commitTransaction(); DeviceManagementDAOFactory.commitTransaction();
this.removeDeviceFromCache(deviceIdentifier);
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
DeviceManagementDAOFactory.rollbackTransaction(); DeviceManagementDAOFactory.rollbackTransaction();
throw new DeviceManagementException("Error occurred while modifying the device " + throw new DeviceManagementException("Error occurred while modifying the device " +
@ -333,11 +335,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
} }
return false; return false;
} }
try {
int tenantId = this.getTenantId(); int tenantId = this.getTenantId();
DeviceManagementDAOFactory.beginTransaction();
Device device = deviceDAO.getDevice(deviceId, tenantId); Device device = this.getDevice(deviceId, false);
if (device == null) { if (device == null) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Device not found for id '" + deviceId.getId() + "'"); log.debug("Device not found for id '" + deviceId.getId() + "'");
@ -349,14 +350,18 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Device has already disenrolled : " + deviceId.getId() + "'"); log.debug("Device has already disenrolled : " + deviceId.getId() + "'");
} }
return false; return true;
} }
try {
device.getEnrolmentInfo().setDateOfLastUpdate(new Date().getTime()); device.getEnrolmentInfo().setDateOfLastUpdate(new Date().getTime());
device.getEnrolmentInfo().setStatus(EnrolmentInfo.Status.REMOVED); device.getEnrolmentInfo().setStatus(EnrolmentInfo.Status.REMOVED);
DeviceManagementDAOFactory.beginTransaction();
enrollmentDAO.updateEnrollment(device.getId(), device.getEnrolmentInfo(), tenantId); enrollmentDAO.updateEnrollment(device.getId(), device.getEnrolmentInfo(), tenantId);
deviceDAO.updateDevice(device, tenantId); deviceDAO.updateDevice(device, tenantId);
DeviceManagementDAOFactory.commitTransaction(); DeviceManagementDAOFactory.commitTransaction();
this.removeDeviceFromCache(deviceId);
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
DeviceManagementDAOFactory.rollbackTransaction(); DeviceManagementDAOFactory.rollbackTransaction();
throw new DeviceManagementException("Error occurred while dis-enrolling '" + deviceId.getType() + throw new DeviceManagementException("Error occurred while dis-enrolling '" + deviceId.getType() +
@ -371,20 +376,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
@Override @Override
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
try { Device device = this.getDevice(deviceId, false);
DeviceManagementDAOFactory.openConnection();
Device device = deviceDAO.getDevice(deviceId, this.getTenantId());
if (device != null) { if (device != null) {
return true; return true;
} }
} catch (DeviceManagementDAOException e) {
throw new DeviceManagementException("Error occurred while obtaining the enrollment information device for" +
"id '" + deviceId.getId() + "'", e);
} catch (SQLException e) {
throw new DeviceManagementException("Error occurred while opening a connection to the data source", e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}
return false; return false;
} }
@ -582,10 +577,12 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
@Override @Override
public Device getDevice(DeviceIdentifier deviceId, boolean requireDeviceInfo) throws DeviceManagementException { public Device getDevice(DeviceIdentifier deviceId, boolean requireDeviceInfo) throws DeviceManagementException {
Device device; int tenantId = this.getTenantId();
Device device = this.getDeviceFromCache(deviceId);
if (device == null) {
try { try {
DeviceManagementDAOFactory.openConnection(); DeviceManagementDAOFactory.openConnection();
device = deviceDAO.getDevice(deviceId, this.getTenantId()); device = deviceDAO.getDevice(deviceId, tenantId);
if (device == null) { if (device == null) {
String msg = "No device is found upon the type '" + deviceId.getType() + "' and id '" + String msg = "No device is found upon the type '" + deviceId.getType() + "' and id '" +
deviceId.getId() + "'"; deviceId.getId() + "'";
@ -594,6 +591,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
} }
return null; return null;
} }
this.addDeviceToCache(deviceId, device);
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
throw new DeviceManagementException("Error occurred while obtaining the device for id " + throw new DeviceManagementException("Error occurred while obtaining the device for id " +
"'" + deviceId.getId() + "'", e); "'" + deviceId.getId() + "'", e);
@ -602,6 +600,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
} finally { } finally {
DeviceManagementDAOFactory.closeConnection(); DeviceManagementDAOFactory.closeConnection();
} }
}
if (requireDeviceInfo) { if (requireDeviceInfo) {
device = this.getAllDeviceInfo(device); device = this.getAllDeviceInfo(device);
} }
@ -690,25 +689,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
@Override @Override
public Device getDeviceWithTypeProperties(DeviceIdentifier deviceId) throws DeviceManagementException { public Device getDeviceWithTypeProperties(DeviceIdentifier deviceId) throws DeviceManagementException {
Device device; Device device = this.getDevice(deviceId, false);
try {
DeviceManagementDAOFactory.openConnection();
device = deviceDAO.getDevice(deviceId, this.getTenantId());
if (device == null) {
if (log.isDebugEnabled()) {
log.debug("No device is found upon the type '" + deviceId.getType() + "' and id '" +
deviceId.getId() + "'");
}
return null;
}
} catch (DeviceManagementDAOException e) {
throw new DeviceManagementException("Error occurred while obtaining the device for id " +
"'" + deviceId.getId() + "'", e);
} catch (SQLException e) {
throw new DeviceManagementException("Error occurred while opening a connection to the data source", e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}
DeviceManager deviceManager = this.getDeviceManager(device.getType()); DeviceManager deviceManager = this.getDeviceManager(device.getType());
if (deviceManager == null) { if (deviceManager == null) {
@ -883,14 +864,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
EnrolmentInfo.Status status) throws DeviceManagementException { EnrolmentInfo.Status status) throws DeviceManagementException {
try { try {
boolean success = false; boolean success = false;
DeviceManagementDAOFactory.beginTransaction();
int tenantId = this.getTenantId(); int tenantId = this.getTenantId();
Device device = deviceDAO.getDevice(deviceId, tenantId); Device device = this.getDevice(deviceId, false);
EnrolmentInfo enrolmentInfo = device.getEnrolmentInfo(); EnrolmentInfo enrolmentInfo = device.getEnrolmentInfo();
DeviceManagementDAOFactory.beginTransaction();
if (enrolmentInfo != null) { if (enrolmentInfo != null) {
success = enrollmentDAO.setStatus(enrolmentInfo.getId(), currentOwner, status, tenantId); success = enrollmentDAO.setStatus(enrolmentInfo.getId(), currentOwner, status, tenantId);
} }
DeviceManagementDAOFactory.commitTransaction(); DeviceManagementDAOFactory.commitTransaction();
this.removeDeviceFromCache(deviceId);
return success; return success;
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
DeviceManagementDAOFactory.rollbackTransaction(); DeviceManagementDAOFactory.rollbackTransaction();
@ -899,7 +881,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
throw new DeviceManagementException("Error occurred while initiating transaction", e); throw new DeviceManagementException("Error occurred while initiating transaction", e);
} finally { } finally {
DeviceManagementDAOFactory.closeConnection(); DeviceManagementDAOFactory.closeConnection();
} }
} }
@ -1210,7 +1191,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
return this.getAllDevicesOfRole(role, true); return this.getAllDevicesOfRole(role, true);
} }
//TODO FIX THIS
@Override @Override
public List<Device> getAllDevicesOfRole(String role, boolean requireDeviceInfo) throws DeviceManagementException { public List<Device> getAllDevicesOfRole(String role, boolean requireDeviceInfo) throws DeviceManagementException {
List<Device> devices = new ArrayList<>(); List<Device> devices = new ArrayList<>();
@ -1433,20 +1413,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
@Override @Override
public boolean isEnrolled(DeviceIdentifier deviceId, String user) throws DeviceManagementException { public boolean isEnrolled(DeviceIdentifier deviceId, String user) throws DeviceManagementException {
try { Device device = this.getDevice(deviceId, false);
DeviceManagementDAOFactory.openConnection(); if (device != null && device.getEnrolmentInfo() != null && device.getEnrolmentInfo().getOwner().equals(user)) {
Device device = deviceDAO.getDevice(deviceId, this.getTenantId());
if (device != null && device.getEnrolmentInfo().getOwner().equals(user)) {
return true; return true;
} }
} catch (DeviceManagementDAOException e) {
throw new DeviceManagementException("Error occurred while obtaining the enrollment information device for" +
"id '" + deviceId.getId() + "' and user : " + user, e);
} catch (SQLException e) {
throw new DeviceManagementException("Error occurred while opening a connection to the data source", e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}
return false; return false;
} }
@ -1726,4 +1696,16 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
} }
return device; return device;
} }
private Device getDeviceFromCache(DeviceIdentifier deviceIdentifier) {
return DeviceCacheManagerImpl.getInstance().getDeviceFromCache(deviceIdentifier, this.getTenantId());
}
private void addDeviceToCache(DeviceIdentifier deviceIdentifier, Device device) {
DeviceCacheManagerImpl.getInstance().addDeviceToCache(deviceIdentifier, device, this.getTenantId());
}
private void removeDeviceFromCache(DeviceIdentifier deviceIdentifier) {
DeviceCacheManagerImpl.getInstance().removeDeviceFromCache(deviceIdentifier, this.getTenantId());
}
} }

@ -21,6 +21,7 @@ package org.wso2.carbon.device.mgt.core.status.task.impl;
import com.google.gson.Gson; import com.google.gson.Gson;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceStatusTaskPluginConfig; import org.wso2.carbon.device.mgt.common.DeviceStatusTaskPluginConfig;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.TransactionManagementException; import org.wso2.carbon.device.mgt.common.TransactionManagementException;
@ -66,8 +67,10 @@ public class DeviceStatusMonitoringTask implements Task {
public void execute() { public void execute() {
List<OperationEnrolmentMapping> operationEnrolmentMappings = null; List<OperationEnrolmentMapping> operationEnrolmentMappings = null;
List<EnrolmentInfo> enrolmentInfoTobeUpdated = new ArrayList<>(); List<EnrolmentInfo> enrolmentInfoTobeUpdated = new ArrayList<>();
List<DeviceIdentifier> identifiers = new ArrayList<>();
Map<Integer, Long> lastActivities = null; Map<Integer, Long> lastActivities = null;
EnrolmentInfo enrolmentInfo; EnrolmentInfo enrolmentInfo;
DeviceIdentifier deviceIdentifier;
try { try {
operationEnrolmentMappings = this.getOperationEnrolmentMappings(); operationEnrolmentMappings = this.getOperationEnrolmentMappings();
if (operationEnrolmentMappings != null && operationEnrolmentMappings.size() > 0) { if (operationEnrolmentMappings != null && operationEnrolmentMappings.size() > 0) {
@ -87,12 +90,19 @@ public class DeviceStatusMonitoringTask implements Task {
enrolmentInfo.setId(mapping.getEnrolmentId()); enrolmentInfo.setId(mapping.getEnrolmentId());
enrolmentInfo.setStatus(newStatus); enrolmentInfo.setStatus(newStatus);
enrolmentInfoTobeUpdated.add(enrolmentInfo); enrolmentInfoTobeUpdated.add(enrolmentInfo);
deviceIdentifier = new DeviceIdentifier();
deviceIdentifier.setId(mapping.getDeviceId());
deviceIdentifier.setId(mapping.getDeviceType());
identifiers.add(deviceIdentifier);
} }
} }
if (enrolmentInfoTobeUpdated.size() > 0) { if (enrolmentInfoTobeUpdated.size() > 0) {
try { try {
this.updateDeviceStatus(enrolmentInfoTobeUpdated); this.updateDeviceStatus(enrolmentInfoTobeUpdated);
//Remove updated entries from cache
//DeviceCacheManagerImpl.getInstance().removeDevicesFromCache(identifiers);
} catch (DeviceStatusTaskException e) { } catch (DeviceStatusTaskException e) {
log.error("Error occurred while updating non-responsive device-status of devices of type '" + deviceType + "'",e); log.error("Error occurred while updating non-responsive device-status of devices of type '" + deviceType + "'",e);
} }

@ -92,6 +92,7 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
operations = this.getValidOperationNames(); //list operations for each device type operations = this.getValidOperationNames(); //list operations for each device type
devices = deviceManagementProviderService.getAllDevices(deviceType, false);//list devices for each type devices = deviceManagementProviderService.getAllDevices(deviceType, false);//list devices for each type
if (!devices.isEmpty()) { if (!devices.isEmpty()) {
if (operations != null) {
for (String str : operations) { for (String str : operations) {
CommandOperation operation = new CommandOperation(); CommandOperation operation = new CommandOperation();
operation.setEnabled(true); operation.setEnabled(true);
@ -100,6 +101,11 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
deviceManagementProviderService.addOperation(deviceType, operation, deviceManagementProviderService.addOperation(deviceType, operation,
DeviceManagerUtil.getValidDeviceIdentifiers(devices)); DeviceManagerUtil.getValidDeviceIdentifiers(devices));
} }
} else {
if (log.isDebugEnabled()) {
log.debug("No operations are available.");
}
}
} else { } else {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("No devices are available to perform the operations."); log.debug("No devices are available to perform the operations.");

@ -53,7 +53,6 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
log.info("Task adding for " + deviceType); log.info("Task adding for " + deviceType);
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
TaskService taskService = DeviceManagementDataHolder.getInstance().getTaskService(); TaskService taskService = DeviceManagementDataHolder.getInstance().getTaskService();
taskService.registerTaskType(TASK_TYPE); taskService.registerTaskType(TASK_TYPE);

@ -33,6 +33,8 @@ import org.wso2.carbon.device.mgt.common.TransactionManagementException;
import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException; import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException;
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.core.cache.DeviceCacheKey;
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig; import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig;
import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig;
@ -51,6 +53,10 @@ import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.utils.ConfigurationContextService; import org.wso2.carbon.utils.ConfigurationContextService;
import org.wso2.carbon.utils.NetworkUtils; import org.wso2.carbon.utils.NetworkUtils;
import javax.cache.Cache;
import javax.cache.CacheConfiguration;
import javax.cache.CacheManager;
import javax.cache.Caching;
import javax.sql.DataSource; import javax.sql.DataSource;
import javax.xml.XMLConstants; import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
@ -62,12 +68,15 @@ import java.util.HashMap;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit;
public final class DeviceManagerUtil { public final class DeviceManagerUtil {
private static final Log log = LogFactory.getLog(DeviceManagerUtil.class); private static final Log log = LogFactory.getLog(DeviceManagerUtil.class);
private static boolean isDeviceCacheInistialized = false;
public static Document convertToDocument(File file) throws DeviceManagementException { public static Document convertToDocument(File file) throws DeviceManagementException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true); factory.setNamespaceAware(true);
@ -455,6 +464,10 @@ public final class DeviceManagerUtil {
return true; return true;
} }
private static CacheManager getCacheManager() {
return Caching.getCacheManagerFactory().getCacheManager(DeviceManagementConstants.DM_CACHE_MANAGER);
}
public static EventsPublisherService getEventPublisherService() { public static EventsPublisherService getEventPublisherService() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
EventsPublisherService eventsPublisherService = EventsPublisherService eventsPublisherService =
@ -466,4 +479,53 @@ public final class DeviceManagerUtil {
} }
return eventsPublisherService; return eventsPublisherService;
} }
public static void initializeDeviceCache() {
DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
int deviceCacheExpiry = config.getDeviceCacheConfiguration().getExpiryTime();
CacheManager manager = getCacheManager();
if (config.getDeviceCacheConfiguration().isEnabled()) {
if(!isDeviceCacheInistialized) {
isDeviceCacheInistialized = true;
if (manager != null) {
if (deviceCacheExpiry > 0) {
manager.<DeviceCacheKey, Device>createCacheBuilder(DeviceManagementConstants.DEVICE_CACHE).
setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration.Duration(TimeUnit.SECONDS,
deviceCacheExpiry)).setExpiry(CacheConfiguration.ExpiryType.ACCESSED, new CacheConfiguration.
Duration(TimeUnit.SECONDS, deviceCacheExpiry)).setStoreByValue(true).build();
} else {
manager.<DeviceCacheKey, Device>getCache(DeviceManagementConstants.DEVICE_CACHE);
}
} else {
if (deviceCacheExpiry > 0) {
Caching.getCacheManager().
<DeviceCacheKey, Device>createCacheBuilder(DeviceManagementConstants.DEVICE_CACHE).
setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration.Duration(TimeUnit.SECONDS,
deviceCacheExpiry)).setExpiry(CacheConfiguration.ExpiryType.ACCESSED, new CacheConfiguration.
Duration(TimeUnit.SECONDS, deviceCacheExpiry)).setStoreByValue(true).build();
} else {
Caching.getCacheManager().<DeviceCacheKey, Device>getCache(DeviceManagementConstants.DEVICE_CACHE);
}
}
}
}
}
public static Cache<DeviceCacheKey, Device> getDeviceCache() {
DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
CacheManager manager = getCacheManager();
Cache<DeviceCacheKey, Device> deviceCache = null;
if (config.getDeviceCacheConfiguration().isEnabled()) {
if(!isDeviceCacheInistialized) {
initializeDeviceCache();
}
if (manager != null) {
deviceCache = manager.<DeviceCacheKey, Device>getCache(DeviceManagementConstants.DEVICE_CACHE);
} else {
deviceCache = Caching.getCacheManager(DeviceManagementConstants.DM_CACHE_MANAGER).
<DeviceCacheKey, Device>getCache(DeviceManagementConstants.DEVICE_CACHE);
}
}
return deviceCache;
}
} }

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -428,7 +428,7 @@ $(document).ready(function () {
$("#right-sidebar").on("click", ".new-notification", function () { $("#right-sidebar").on("click", ".new-notification", function () {
var notificationId = $(this).data("id"); var notificationId = $(this).data("id");
var redirectUrl = $(this).data("url"); var redirectUrl = $(this).data("url");
var markAsReadNotificationsAPI = "/mdm-admin/notifications/" + notificationId + "/CHECKED"; var markAsReadNotificationsAPI = "/api/device-mgt/v1.0/notifications/" + notificationId + "/mark-checked";
var messageSideBar = ".sidebar-messages"; var messageSideBar = ".sidebar-messages";
invokerUtil.put( invokerUtil.put(

@ -23,7 +23,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>email-sender</artifactId> <artifactId>email-sender</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -28,7 +28,8 @@ import org.wso2.carbon.utils.Axis2ConfigurationContextObserver;
import org.wso2.carbon.utils.ConfigurationContextService; import org.wso2.carbon.utils.ConfigurationContextService;
/** /**
* @scr.component name="org.wso2.carbon.email.sender.EmailSenderServiceComponent" immediate="true" * @scr.component name="org.wso2.carbon.email.sender.emailsendereervicecomponent"
* immediate="true"
* @scr.reference name="registry.service" * @scr.reference name="registry.service"
* interface="org.wso2.carbon.registry.core.service.RegistryService" * interface="org.wso2.carbon.registry.core.service.RegistryService"
* cardinality="1..1" * cardinality="1..1"

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -21,7 +21,7 @@
<parent> <parent>
<artifactId>dynamic-client-registration</artifactId> <artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -21,7 +21,7 @@
<parent> <parent>
<artifactId>dynamic-client-registration</artifactId> <artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -21,13 +21,13 @@
<parent> <parent>
<artifactId>dynamic-client-registration</artifactId> <artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.dynamic.client.registration</artifactId> <artifactId>org.wso2.carbon.dynamic.client.registration</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Dynamic client registration service</name> <name>WSO2 Carbon - Dynamic client registration service</name>
<description>WSO2 Carbon - Dynamic Client Registration Service</description> <description>WSO2 Carbon - Dynamic Client Registration Service</description>

@ -21,13 +21,13 @@
<parent> <parent>
<artifactId>dynamic-client-registration</artifactId> <artifactId>dynamic-client-registration</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.dynamic.client.web.app.registration</artifactId> <artifactId>org.wso2.carbon.dynamic.client.web.app.registration</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Dynamic client web app registration</name> <name>WSO2 Carbon - Dynamic client web app registration</name>
<description>WSO2 Carbon - Dynamic Client Web-app Registration Service</description> <description>WSO2 Carbon - Dynamic Client Web-app Registration Service</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId> <artifactId>identity-extensions</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>dynamic-client-registration</artifactId> <artifactId>dynamic-client-registration</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Dynamic client registration</name> <name>WSO2 Carbon - Dynamic client registration</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -22,22 +22,18 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId> <artifactId>identity-extensions</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.oauth.extensions</artifactId> <artifactId>org.wso2.carbon.device.mgt.oauth.extensions</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - OAuth Extensions</name> <name>WSO2 Carbon - OAuth Extensions</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<dependencies> <dependencies>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.identity.authenticator.backend.oauth</artifactId>
</dependency>
<dependency> <dependency>
<groupId>commons-codec.wso2</groupId> <groupId>commons-codec.wso2</groupId>
<artifactId>commons-codec</artifactId> <artifactId>commons-codec</artifactId>
@ -91,7 +87,6 @@
org.wso2.carbon.device.mgt.oauth.extensions.* org.wso2.carbon.device.mgt.oauth.extensions.*
</Export-Package> </Export-Package>
<Import-Package> <Import-Package>
org.wso2.carbon.identity.authenticator.backend.oauth.*,
org.wso2.carbon.identity.oauth2.grant.jwt;version="${carbon.identity.jwt.grant.version.range}", org.wso2.carbon.identity.oauth2.grant.jwt;version="${carbon.identity.jwt.grant.version.range}",
org.apache.commons.lang, org.apache.commons.lang,
org.apache.commons.logging, org.apache.commons.logging,

@ -22,12 +22,11 @@ import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.apimgt.keymgt.ScopesIssuer; import org.wso2.carbon.apimgt.keymgt.ScopesIssuer;
import org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.oauth.validator.LocalOAuthValidator;
import org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.oauth.validator.OAuthValidationResponse;
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser;
import org.wso2.carbon.identity.application.common.IdentityApplicationManagementException; import org.wso2.carbon.identity.application.common.IdentityApplicationManagementException;
import org.wso2.carbon.identity.application.common.model.ServiceProvider; import org.wso2.carbon.identity.application.common.model.ServiceProvider;
import org.wso2.carbon.identity.authenticator.backend.oauth.validator.OAuth2TokenValidator;
import org.wso2.carbon.identity.authenticator.backend.oauth.validator.OAuthValidationResponse;
import org.wso2.carbon.identity.authenticator.backend.oauth.validator.OAuthValidatorFactory;
import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception;
import org.wso2.carbon.identity.oauth2.dto.OAuth2AccessTokenReqDTO; import org.wso2.carbon.identity.oauth2.dto.OAuth2AccessTokenReqDTO;
import org.wso2.carbon.identity.oauth2.internal.OAuth2ServiceComponentHolder; import org.wso2.carbon.identity.oauth2.internal.OAuth2ServiceComponentHolder;
@ -47,12 +46,12 @@ public class AccessTokenGrantHandler extends AbstractAuthorizationGrantHandler {
private static Log log = LogFactory.getLog(AccessTokenGrantHandler.class); private static Log log = LogFactory.getLog(AccessTokenGrantHandler.class);
private static final String TENANT_DOMAIN_KEY = "tenantDomain"; private static final String TENANT_DOMAIN_KEY = "tenantDomain";
private OAuth2TokenValidator tokenValidator; private LocalOAuthValidator tokenValidator;
public static final String TOKEN_GRANT_PARAM = "admin_access_token"; public static final String TOKEN_GRANT_PARAM = "admin_access_token";
public AccessTokenGrantHandler() { public AccessTokenGrantHandler() {
try { try {
tokenValidator = OAuthValidatorFactory.getValidator(); tokenValidator = new LocalOAuthValidator();
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
log.error("Failed to initialise Authenticator", e); log.error("Failed to initialise Authenticator", e);
} }

@ -0,0 +1,60 @@
/*
* 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.oauth.extensions.handlers.grant.oauth.validator;
import org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.oauth.validator.internal.OAuthAuthenticatorDataHolder;
import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationRequestDTO;
import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationResponseDTO;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
import java.rmi.RemoteException;
/**
* Handles the authentication using the inbuilt IS features.
*/
public class LocalOAuthValidator {
private static final String BEARER_TOKEN_TYPE = "bearer";
/**
* This method gets a string accessToken and validates it and generate the OAuth2ClientApplicationDTO
* containing the validity and user details if valid.
*
* @param token which need to be validated.
* @return OAuthValidationResponse with the validated results.
*/
public OAuthValidationResponse validateToken(String token) throws RemoteException{
OAuth2TokenValidationRequestDTO validationRequest = new OAuth2TokenValidationRequestDTO();
OAuth2TokenValidationRequestDTO.OAuth2AccessToken accessToken =
validationRequest.new OAuth2AccessToken();
accessToken.setTokenType(BEARER_TOKEN_TYPE);
accessToken.setIdentifier(token);
validationRequest.setAccessToken(accessToken);
OAuth2TokenValidationResponseDTO tokenValidationResponse = OAuthAuthenticatorDataHolder.getInstance().
getOAuth2TokenValidationService().findOAuthConsumerIfTokenIsValid(validationRequest).getAccessTokenValidationResponse();
boolean isValid = tokenValidationResponse.isValid();
String userName = null;
String tenantDomain = null;
if (isValid) {
userName = MultitenantUtils.getTenantAwareUsername(
tokenValidationResponse.getAuthorizedUser());
tenantDomain =
MultitenantUtils.getTenantDomain(tokenValidationResponse.getAuthorizedUser());
}
return new OAuthValidationResponse(userName, tenantDomain, isValid);
}
}

@ -0,0 +1,59 @@
/*
* 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.oauth.extensions.handlers.grant.oauth.validator;
/**
* This class holds the authenticated user information after the OAuth2 token is validated.
*/
@SuppressWarnings("unused")
public class OAuthValidationResponse {
private String userName;
private String tenantDomain;
private boolean isValid;
public OAuthValidationResponse(String userName, String tenantDomain, boolean isValid) {
this.userName = userName;
this.tenantDomain = tenantDomain;
this.isValid = isValid;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getTenantDomain() {
return tenantDomain;
}
public void setTenantDomain(String tenantDomain) {
this.tenantDomain = tenantDomain;
}
public boolean isValid() {
return isValid;
}
public void setIsValid(boolean isValid) {
this.isValid = isValid;
}
}

@ -0,0 +1,49 @@
/*
* 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.oauth.extensions.handlers.grant.oauth.validator.internal;
import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService;
/**
* DataHolder of Backend OAuth Authenticator component.
*/
public class OAuthAuthenticatorDataHolder {
private OAuth2TokenValidationService oAuth2TokenValidationService;
private static OAuthAuthenticatorDataHolder thisInstance = new OAuthAuthenticatorDataHolder();
private OAuthAuthenticatorDataHolder() {}
public static OAuthAuthenticatorDataHolder getInstance() {
return thisInstance;
}
public OAuth2TokenValidationService getOAuth2TokenValidationService() {
if (oAuth2TokenValidationService == null) {
throw new IllegalStateException("OAuth2TokenValidation service is not initialized properly");
}
return oAuth2TokenValidationService;
}
public void setOAuth2TokenValidationService(
OAuth2TokenValidationService oAuth2TokenValidationService) {
this.oAuth2TokenValidationService = oAuth2TokenValidationService;
}
}

@ -0,0 +1,76 @@
/*
* 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.oauth.extensions.handlers.grant.oauth.validator.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService;
/**
* @scr.component name="org.wso2.carbon.device.mgt.oauth.extensions.authenticator" immediate="true"
* @scr.reference name="identity.oauth2.validation.service"
* interface="org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService"
* cardinality="1..1"
* policy="dynamic"
* bind="setOAuth2ValidationService"
* unbind="unsetOAuth2ValidationService"
*/
public class OAuthAuthenticatorServiceComponent {
private static final Log log = LogFactory.getLog(OAuthAuthenticatorServiceComponent.class);
@SuppressWarnings("unused")
protected void activate(ComponentContext componentContext) {
if (log.isDebugEnabled()) {
log.debug("Starting Backend OAuthAuthenticator Framework Bundle");
}
}
@SuppressWarnings("unused")
protected void deactivate(ComponentContext componentContext) {
//do nothing
}
/**
* Sets OAuth2TokenValidation Service.
*
* @param tokenValidationService An instance of OAuth2TokenValidationService.
*/
@SuppressWarnings("unused")
protected void setOAuth2ValidationService(OAuth2TokenValidationService tokenValidationService) {
if (log.isDebugEnabled()) {
log.debug("Setting OAuth2TokenValidationService Service");
}
OAuthAuthenticatorDataHolder.getInstance().setOAuth2TokenValidationService(tokenValidationService);
}
/**
* Unsets OAuth2TokenValidation Service.
*
* @param tokenValidationService An instance of OAuth2TokenValidationService
*/
@SuppressWarnings("unused")
protected void unsetOAuth2ValidationService(OAuth2TokenValidationService tokenValidationService) {
if (log.isDebugEnabled()) {
log.debug("Unsetting OAuth2TokenValidationService Service");
}
OAuthAuthenticatorDataHolder.getInstance().setOAuth2TokenValidationService(null);
}
}

@ -21,7 +21,7 @@
<parent> <parent>
<artifactId>identity-extensions</artifactId> <artifactId>identity-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId> <artifactId>identity-extensions</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.complex.policy.decision.point</artifactId> <artifactId>org.wso2.carbon.complex.policy.decision.point</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Decision Point</name> <name>WSO2 Carbon - Policy Decision Point</name>
<description>WSO2 Carbon - Policy Decision Point</description> <description>WSO2 Carbon - Policy Decision Point</description>

@ -3,14 +3,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.decision.point</artifactId> <artifactId>org.wso2.carbon.policy.decision.point</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Decision Point</name> <name>WSO2 Carbon - Policy Decision Point</name>
<description>WSO2 Carbon - Policy Decision Point</description> <description>WSO2 Carbon - Policy Decision Point</description>

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
@ -11,7 +11,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.information.point</artifactId> <artifactId>org.wso2.carbon.policy.information.point</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Information Point</name> <name>WSO2 Carbon - Policy Information Point</name>
<description>WSO2 Carbon - Policy Information Point</description> <description>WSO2 Carbon - Policy Information Point</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.mgt.common</artifactId> <artifactId>org.wso2.carbon.policy.mgt.common</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Management Common</name> <name>WSO2 Carbon - Policy Management Common</name>
<description>WSO2 Carbon - Policy Management Common</description> <description>WSO2 Carbon - Policy Management Common</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.mgt.core</artifactId> <artifactId>org.wso2.carbon.policy.mgt.core</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Management Core</name> <name>WSO2 Carbon - Policy Management Core</name>
<description>WSO2 Carbon - Policy Management Core</description> <description>WSO2 Carbon - Policy Management Core</description>

@ -72,7 +72,7 @@ public class PolicyInformationPointImpl implements PolicyInformationPoint {
GroupManagementProviderService groupManagementProviderService = new GroupManagementProviderServiceImpl(); GroupManagementProviderService groupManagementProviderService = new GroupManagementProviderServiceImpl();
try { try {
device = deviceManagementService.getDevice(deviceIdentifier); device = deviceManagementService.getDevice(deviceIdentifier, false);
if (device != null) { if (device != null) {
pipDevice.setDevice(device); pipDevice.setDevice(device);

@ -190,7 +190,7 @@ public class PolicyManagerImpl implements PolicyManager {
policy.setProfileId(profileId); policy.setProfileId(profileId);
Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime()); Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
policy.getProfile().setUpdatedDate(currentTimestamp); policy.getProfile().setUpdatedDate(currentTimestamp);
policy.setPriorityId(previousPolicy.getPriorityId());
policyDAO.updatePolicy(policy); policyDAO.updatePolicy(policy);
profileDAO.updateProfile(policy.getProfile()); profileDAO.updateProfile(policy.getProfile());

@ -24,6 +24,7 @@
<Name>jdbc/DM_DS</Name> <Name>jdbc/DM_DS</Name>
</JndiLookupDefinition> </JndiLookupDefinition>
</DataSourceConfiguration> </DataSourceConfiguration>
</ManagementRepository>
<EmailClientConfiguration> <EmailClientConfiguration>
<minimumThread>8</minimumThread> <minimumThread>8</minimumThread>
<maximumThread>100</maximumThread> <maximumThread>100</maximumThread>
@ -45,6 +46,13 @@
<!--<PolicyEvaluationPoint>Simple</PolicyEvaluationPoint>--> <!--<PolicyEvaluationPoint>Simple</PolicyEvaluationPoint>-->
<PolicyEvaluationPoint>Simple</PolicyEvaluationPoint> <PolicyEvaluationPoint>Simple</PolicyEvaluationPoint>
</PolicyConfiguration> </PolicyConfiguration>
</ManagementRepository> <!--This specifies whether to enable the DeviceStatus Task in this node.-->
<DeviceStatusTaskConfig>
<Enable>true</Enable>
</DeviceStatusTaskConfig>
<DeviceCacheConfiguration>
<Enable>true</Enable>
<ExpiryTime>300</ExpiryTime>
</DeviceCacheConfiguration>
</DeviceMgtConfiguration> </DeviceMgtConfiguration>

@ -23,13 +23,13 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Policy Management Component</name> <name>WSO2 Carbon - Policy Management Component</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -21,14 +21,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>webapp-authenticator-framework</artifactId> <artifactId>webapp-authenticator-framework</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.webapp.authenticator.framework</artifactId> <artifactId>org.wso2.carbon.webapp.authenticator.framework</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Web Application Authenticator Framework Bundle</name> <name>WSO2 Carbon - Web Application Authenticator Framework Bundle</name>
<description>WSO2 Carbon - Web Application Authenticator Framework Bundle</description> <description>WSO2 Carbon - Web Application Authenticator Framework Bundle</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>webapp-authenticator-framework</artifactId> <artifactId>webapp-authenticator-framework</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Webapp Authenticator Framework</name> <name>WSO2 Carbon - Webapp Authenticator Framework</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -21,14 +21,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId> <artifactId>apimgt-extensions-feature</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.application.extension.feature</artifactId> <artifactId>org.wso2.carbon.apimgt.application.extension.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<name>WSO2 Carbon - API Management Application Extension Feature</name> <name>WSO2 Carbon - API Management Application Extension Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>This feature contains an implementation of a api application registration, which takes care of subscription <description>This feature contains an implementation of a api application registration, which takes care of subscription

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId> <artifactId>apimgt-extensions-feature</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.handler.server.feature</artifactId> <artifactId>org.wso2.carbon.apimgt.handler.server.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<name>WSO2 Carbon - Device Management - APIM handler Server Feature</name> <name>WSO2 Carbon - Device Management - APIM handler Server Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>This feature contains the handler for the api authentications <description>This feature contains the handler for the api authentications

@ -21,13 +21,13 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId> <artifactId>apimgt-extensions-feature</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.integration.client.feature</artifactId> <artifactId>org.wso2.carbon.apimgt.integration.client.feature</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - APIM Integration Client Feature</name> <name>WSO2 Carbon - APIM Integration Client Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -21,14 +21,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId> <artifactId>apimgt-extensions-feature</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.webapp.publisher.feature</artifactId> <artifactId>org.wso2.carbon.apimgt.webapp.publisher.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<name>WSO2 Carbon - API Management Webapp Publisher Feature</name> <name>WSO2 Carbon - API Management Webapp Publisher Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>This feature contains an implementation of a Tomcat lifecycle listener, which takes care of publishing <description>This feature contains an implementation of a Tomcat lifecycle listener, which takes care of publishing

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId> <artifactId>apimgt-extensions-feature</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - API Management Extensions Feature</name> <name>WSO2 Carbon - API Management Extensions Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId> <artifactId>certificate-mgt-feature</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId> <artifactId>certificate-mgt-feature</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId> <artifactId>certificate-mgt-feature</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.certificate.mgt.server.feature</artifactId> <artifactId>org.wso2.carbon.certificate.mgt.server.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<name>WSO2 Carbon - Certificate Management Server Feature</name> <name>WSO2 Carbon - Certificate Management Server Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>This feature contains the core bundles required for back-end Certificate Management functionality <description>This feature contains the core bundles required for back-end Certificate Management functionality

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId> <artifactId>certificate-mgt-feature</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Certificate Management Feature</name> <name>WSO2 Carbon - Certificate Management Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-extensions-feature</artifactId> <artifactId>device-mgt-extensions-feature</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature</artifactId> <artifactId>org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<name>WSO2 Carbon - Device Type Deployer Feature</name> <name>WSO2 Carbon - Device Type Deployer Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>WSO2 Carbon - Device Type Deployer Feature</description> <description>WSO2 Carbon - Device Type Deployer Feature</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-extensions-feature</artifactId> <artifactId>device-mgt-extensions-feature</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature</artifactId> <artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<name>WSO2 Carbon - FCM Based Push Notification Provider Feature</name> <name>WSO2 Carbon - FCM Based Push Notification Provider Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>WSO2 Carbon - MQTT Based Push Notification Provider Feature</description> <description>WSO2 Carbon - MQTT Based Push Notification Provider Feature</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-extensions-feature</artifactId> <artifactId>device-mgt-extensions-feature</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature</artifactId> <artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<name>WSO2 Carbon - MQTT Based Push Notification Provider Feature</name> <name>WSO2 Carbon - MQTT Based Push Notification Provider Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>WSO2 Carbon - MQTT Based Push Notification Provider Feature</description> <description>WSO2 Carbon - MQTT Based Push Notification Provider Feature</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-extensions-feature</artifactId> <artifactId>device-mgt-extensions-feature</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature</artifactId> <artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<name>WSO2 Carbon - XMPP Based Push Notification Provider Feature</name> <name>WSO2 Carbon - XMPP Based Push Notification Provider Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>WSO2 Carbon - XMPP Based Push Notification Provider Feature</description> <description>WSO2 Carbon - XMPP Based Push Notification Provider Feature</description>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -3,13 +3,13 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-feature</artifactId> <artifactId>device-mgt-feature</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.analytics.dashboard.feature</artifactId> <artifactId>org.wso2.carbon.device.mgt.analytics.dashboard.feature</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Device Management Dashboard Analytics Feature</name> <name>WSO2 Carbon - Device Management Dashboard Analytics Feature</name>
<description>WSO2 Carbon - Device Management Dashboard Analytics Feature</description> <description>WSO2 Carbon - Device Management Dashboard Analytics Feature</description>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-feature</artifactId> <artifactId>device-mgt-feature</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher.feature</artifactId> <artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<name>WSO2 Carbon - Device Management Server Feature</name> <name>WSO2 Carbon - Device Management Server Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>This feature contains bundles related to device analytics data publisher</description> <description>This feature contains bundles related to device analytics data publisher</description>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-feature</artifactId> <artifactId>device-mgt-feature</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -4,14 +4,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-feature</artifactId> <artifactId>device-mgt-feature</artifactId>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.extensions.feature</artifactId> <artifactId>org.wso2.carbon.device.mgt.extensions.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.0.76-SNAPSHOT</version> <version>3.0.3-SNAPSHOT</version>
<name>WSO2 Carbon - Device Management Extensions Feature</name> <name>WSO2 Carbon - Device Management Extensions Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>This feature contains common extensions used by key device management functionalities <description>This feature contains common extensions used by key device management functionalities

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save