From fdec4ec5e2ad1c173d054611d6a38d05ac7c77d4 Mon Sep 17 00:00:00 2001 From: geethkokila Date: Mon, 20 Jul 2015 18:48:57 +0530 Subject: [PATCH] Adding the policy monitoring service for android and windows --- .../pom.xml | 15 ++++++- .../AndroidPolicyMonitoringService.java | 41 ++++++++++++++++++ .../WindowsPolicyMonitoringService.java | 42 +++++++++++++++++++ ...obileDeviceManagementServiceComponent.java | 12 +++++- 4 files changed, 107 insertions(+), 3 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml index c66a4f9e1..00af11e11 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml @@ -18,7 +18,8 @@ ~ under the License. --> - + device-mgt org.wso2.carbon.devicemgt-plugins @@ -66,7 +67,9 @@ org.wso2.carbon.core, org.wso2.carbon.utils.*, org.wso2.carbon.device.mgt.common.*, - org.wso2.carbon.ndatasource.core + org.wso2.carbon.ndatasource.core, + org.wso2.carbon.policy.mgt.common.*, + org.wso2.carbon.policy.mgt.core.* !org.wso2.carbon.device.mgt.mobile.internal, @@ -122,6 +125,14 @@ org.wso2.carbon org.wso2.carbon.ndatasource.core + + org.wso2.carbon.devicemgt + org.wso2.carbon.policy.mgt.common + + + org.wso2.carbon.devicemgt + org.wso2.carbon.policy.mgt.core + org.testng testng diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java new file mode 100644 index 000000000..c9cd702a5 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java @@ -0,0 +1,41 @@ +/* + * 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.mobile.impl.android; + +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; +import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; +import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService; + +import java.util.List; + +public class AndroidPolicyMonitoringService implements PolicyMonitoringService { + @Override + public void notifyDevices(List list) throws PolicyComplianceException { + + } + + @Override + public ComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object o) throws PolicyComplianceException { + return null; + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java new file mode 100644 index 000000000..eec892b30 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsPolicyMonitoringService.java @@ -0,0 +1,42 @@ +/* + * 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.mobile.impl.windows; + +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; +import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; +import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService; + +import java.util.List; + +public class WindowsPolicyMonitoringService implements PolicyMonitoringService { + + @Override + public void notifyDevices(List list) throws PolicyComplianceException { + + } + + @Override + public ComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object o) throws PolicyComplianceException { + return null; + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java index a8985cae8..0be1c4662 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java @@ -31,8 +31,11 @@ import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfi import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManagementService; +import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidPolicyMonitoringService; import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagementService; +import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsPolicyMonitoringService; import org.wso2.carbon.ndatasource.core.DataSourceService; +import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService; import java.util.Map; @@ -82,7 +85,7 @@ public class MobileDeviceManagementServiceComponent { "to begin"); } try { - for (String pluginType : dsConfigMap.keySet()){ + for (String pluginType : dsConfigMap.keySet()) { MobileDeviceManagementDAOUtil .setupMobileDeviceManagementSchema(MobileDeviceManagementDAOFactory.getDataSourceMap ().get(pluginType)); @@ -99,6 +102,13 @@ public class MobileDeviceManagementServiceComponent { bundleContext.registerService(DeviceManagementService.class.getName(), new WindowsDeviceManagementService(), null); + // Policy management service + + bundleContext.registerService(PolicyMonitoringService.class, + new AndroidPolicyMonitoringService(), null); + bundleContext.registerService(PolicyMonitoringService.class, + new WindowsPolicyMonitoringService(), null); + if (log.isDebugEnabled()) { log.debug("Mobile Device Management Service Component has been successfully activated"); }