diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java index e3b728eecd..6eaacc1a8e 100644 --- a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java +++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java @@ -73,6 +73,12 @@ public class AndroidDeviceManagementService implements DeviceManagementService { return null; } + @Override + public void notifyOperationToDevices(Operation operation, List deviceIdentifiers) + throws DeviceManagementException { + + } + @Override public Application[] getApplications(String s, int i, int i2) throws ApplicationManagementException { return new Application[0]; @@ -90,9 +96,18 @@ public class AndroidDeviceManagementService implements DeviceManagementService { return null; } - @Override - public void installApplication(Operation operation, - List deviceIdentifiers) throws ApplicationManagementException { + @Override public void installApplicationForDevices(Operation operation, List deviceIdentifiers) + throws ApplicationManagementException { + + } + + @Override public void installApplicationForUsers(Operation operation, List strings) + throws ApplicationManagementException { + + } + + @Override public void installApplicationForUserRoles(Operation operation, List strings) + throws ApplicationManagementException { } diff --git a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidPolicyMonitoringService.java b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidPolicyMonitoringService.java index d5a630c2ba..4d46da7bf8 100644 --- a/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidPolicyMonitoringService.java +++ b/components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidPolicyMonitoringService.java @@ -28,6 +28,8 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; +import org.wso2.carbon.device.mgt.mobile.impl.android.gcm.GCMService; +import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementDataHolder; 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.ComplianceFeature; @@ -43,7 +45,10 @@ public class AndroidPolicyMonitoringService implements PolicyMonitoringService { @Override public void notifyDevices(List list) throws PolicyComplianceException { - + GCMService gcmService = MobileDeviceManagementDataHolder.getInstance().getGCMService(); + if (gcmService.isGCMEnabled() && !list.isEmpty()) { + gcmService.sendNotification("POLICY_BUNDLE", list); + } } @Override diff --git a/components/device-mgt-mdm-windows/org.wso2.carbon.device.mgt.mobile.windows.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsDeviceManagementService.java b/components/device-mgt-mdm-windows/org.wso2.carbon.device.mgt.mobile.windows.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsDeviceManagementService.java index 4ecfa14c47..bbae3b6998 100644 --- a/components/device-mgt-mdm-windows/org.wso2.carbon.device.mgt.mobile.windows.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsDeviceManagementService.java +++ b/components/device-mgt-mdm-windows/org.wso2.carbon.device.mgt.mobile.windows.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsDeviceManagementService.java @@ -73,6 +73,11 @@ public class WindowsDeviceManagementService implements DeviceManagementService { return null; } + @Override public void notifyOperationToDevices(Operation operation, List deviceIdentifiers) + throws DeviceManagementException { + + } + @Override public Application[] getApplications(String s, int i, int i2) throws ApplicationManagementException { return new Application[0]; @@ -90,9 +95,19 @@ public class WindowsDeviceManagementService implements DeviceManagementService { return null; } - @Override - public void installApplication(Operation operation, - List deviceIdentifiers) throws ApplicationManagementException { + @Override public void installApplicationForDevices(Operation operation, List deviceIdentifiers) + throws ApplicationManagementException { + + } + + @Override public void installApplicationForUsers(Operation operation, List strings) + throws ApplicationManagementException { + + } + + @Override public void installApplicationForUserRoles(Operation operation, List strings) + throws ApplicationManagementException { + } } 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 e0d48a9593..d0c0f376e5 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 @@ -61,18 +61,14 @@ javax.xml.bind.*, javax.naming, javax.sql, - javax.xml.bind.annotation.*, - javax.xml.parsers.*;resolution:=optional, + javax.xml.parsers, org.w3c.dom, - org.wso2.carbon.core, org.wso2.carbon.context, org.wso2.carbon.utils.*, org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.ndatasource.core, org.wso2.carbon.policy.mgt.common.*, - org.wso2.carbon.policy.mgt.core.*, org.wso2.carbon.registry.core, - org.wso2.carbon.registry.core.exceptions, org.wso2.carbon.registry.core.service, org.wso2.carbon.registry.core.session, org.wso2.carbon.registry.api, @@ -81,6 +77,7 @@ !org.wso2.carbon.device.mgt.mobile.internal, + !org.wso2.carbon.device.mgt.mobile.impl, org.wso2.carbon.device.mgt.mobile.*, @@ -169,5 +166,9 @@ com.google.code.gson gson + + com.google.android.gcm + gcm-server + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMResult.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMResult.java new file mode 100644 index 0000000000..c15d6d4c4c --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMResult.java @@ -0,0 +1,53 @@ +/* + * 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.gcm; + +/** + * Represents model object for holding GCM response data. + */ +public class GCMResult { + + private String errorMsg; + private String msg; + private int statusCode; + + public String getErrorMsg() { + return errorMsg; + } + + public void setErrorMsg(String errorMsg) { + this.errorMsg = errorMsg; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public int getStatusCode() { + return statusCode; + } + + public void setStatusCode(int statusCode) { + this.statusCode = statusCode; + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMService.java new file mode 100644 index 0000000000..2113dd062f --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMService.java @@ -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.mobile.impl.android.gcm; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.Device; + +import java.util.ArrayList; +import java.util.List; + +/** + * GCM notification service implementation for Android platform. + */ +public class GCMService { + + private static final Log log = LogFactory.getLog(GCMService.class); + private static final String NOTIFIER_TYPE = "notifierType"; + private static final String GCM_NOTIFIER_CODE = "2"; + + public boolean isGCMEnabled() { + String notifierType = GCMUtil.getConfigurationProperty(NOTIFIER_TYPE); + if (GCM_NOTIFIER_CODE.equals(notifierType)) { + return true; + } + return false; + } + + public void sendNotification(String messageData, Device device) { + List devices = new ArrayList<>(); + devices.add(device); + GCMResult result = GCMUtil.sendWakeUpCall(messageData, devices); + if (result.getStatusCode() != 200) { + log.error("Exception occurred while sending the GCM notification : " + result.getErrorMsg()); + } + } + + public void sendNotification(String messageData, List devices) { + GCMResult result = GCMUtil.sendWakeUpCall(messageData, devices); + if (result.getStatusCode() != 200) { + log.error("Exception occurred while sending the GCM notification : " + result.getErrorMsg()); + } + } +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMUtil.java new file mode 100644 index 0000000000..ce08d896d5 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMUtil.java @@ -0,0 +1,191 @@ +/* + * 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.gcm; + +import com.google.gson.*; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; +import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; +import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; +import org.wso2.carbon.device.mgt.mobile.impl.android.util.AndroidPluginConstants; +import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementDataHolder; + +import java.io.*; +import java.net.HttpURLConnection; +import java.net.ProtocolException; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +/** + * Implements utility methods used by GCMService. + */ +public class GCMUtil { + + private static final Log log = LogFactory.getLog(GCMService.class); + + private final static String GCM_ENDPOINT = "https://gcm-http.googleapis.com/gcm/send"; + private static final String GCM_API_KEY = "gcmAPIKey"; + private static final int TIME_TO_LIVE = 60; + private static final int HTTP_STATUS_CODE_OK = 200; + + private static HashMap tenantConfigurationCache = new HashMap<>(); + + public static GCMResult sendWakeUpCall(String message, List devices) { + GCMResult result = new GCMResult(); + + byte[] bytes = getGCMRequest(message, getGCMTokens(devices)).getBytes(); + HttpURLConnection conn; + try { + conn = (HttpURLConnection) (new URL(GCM_ENDPOINT)).openConnection(); + conn.setDoOutput(true); + conn.setUseCaches(false); + conn.setFixedLengthStreamingMode(bytes.length); + conn.setRequestMethod("POST"); + conn.setRequestProperty("Content-Type", "application/json"); + conn.setRequestProperty("Authorization", "key=" + getConfigurationProperty(GCM_API_KEY)); + + OutputStream out = conn.getOutputStream(); + out.write(bytes); + out.close(); + + int status = conn.getResponseCode(); + result.setStatusCode(status); + if (status != HTTP_STATUS_CODE_OK) { + result.setErrorMsg(getString(conn.getErrorStream())); + } else { + result.setMsg(getString(conn.getInputStream())); + } + } catch (ProtocolException e) { + log.error("Exception occurred while setting the HTTP protocol.", e); + } catch (IOException ex) { + log.error("Exception occurred while sending the GCM request.", ex); + } + + return result; + } + + private static String getString(InputStream stream) throws IOException { + if (stream != null) { + BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); + StringBuilder content = new StringBuilder(); + + String newLine; + do { + newLine = reader.readLine(); + if (newLine != null) { + content.append(newLine).append('\n'); + } + } while (newLine != null); + + if (content.length() > 0) { + content.setLength(content.length() - 1); + } + + return content.toString(); + } + return null; + } + + private static String getGCMRequest(String message, List registrationIds) { + JsonObject gcmRequest = new JsonObject(); + gcmRequest.addProperty("delay_while_idle", false); + gcmRequest.addProperty("time_to_live", TIME_TO_LIVE); + + //Add message to GCM request + JsonObject data = new JsonObject(); + if (message != null && !message.isEmpty()) { + data.addProperty("data", message); + gcmRequest.add("data", data); + } + + //Set device reg-ids + JsonArray regIds = new JsonArray(); + for (String regId : registrationIds) { + regIds.add(new JsonPrimitive(regId)); + } + + gcmRequest.add("registration_ids", regIds); + return gcmRequest.toString(); + } + + private static List getGCMTokens(List devices) { + List tokens = new ArrayList<>(); + for (Device device : devices) { + tokens.add(getGCMToken(device.getProperties())); + } + return tokens; + } + + private static String getGCMToken(List properties) { + String gcmToken = null; + for (Device.Property property : properties) { + if (AndroidPluginConstants.GCM_TOKEN.equals(property.getName())) { + gcmToken = property.getValue(); + break; + } + } + return gcmToken; + } + + public static String getConfigurationProperty(String property) { + DeviceManagementService androidDMService = MobileDeviceManagementDataHolder.getInstance(). + getAndroidDeviceManagementService(); + try { + //Get the TenantConfiguration from cache if not we'll get it from DM service + TenantConfiguration tenantConfiguration = getTenantConfigurationFromCache(); + if (tenantConfiguration == null) { + tenantConfiguration = androidDMService.getDeviceManager().getConfiguration(); + if (tenantConfiguration != null) { + addTenantConfigurationToCache(tenantConfiguration); + } + } + + if (tenantConfiguration != null) { + List configs = tenantConfiguration.getConfiguration(); + for (ConfigurationEntry entry : configs) { + if (property.equals(entry.getName())) { + return (String) entry.getValue(); + } + } + } + return ""; + } catch (DeviceManagementException e) { + log.error("Exception occurred while fetching the tenant-config.",e); + } + return null; + } + + private static void addTenantConfigurationToCache(TenantConfiguration tenantConfiguration) { + tenantConfigurationCache.put(getTenantId(), tenantConfiguration); + } + + private static TenantConfiguration getTenantConfigurationFromCache() { + return tenantConfigurationCache.get(getTenantId()); + } + + private static int getTenantId() { + return CarbonContext.getThreadLocalCarbonContext().getTenantId(); + } +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementDataHolder.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementDataHolder.java index 40c6610090..869904e81c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementDataHolder.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementDataHolder.java @@ -18,6 +18,8 @@ package org.wso2.carbon.device.mgt.mobile.internal; +import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; +import org.wso2.carbon.device.mgt.mobile.impl.android.gcm.GCMService; import org.wso2.carbon.registry.core.service.RegistryService; /** @@ -26,6 +28,8 @@ import org.wso2.carbon.registry.core.service.RegistryService; public class MobileDeviceManagementDataHolder { private RegistryService registryService; + private DeviceManagementService androidDeviceManagementService; + private GCMService gcmService; private static MobileDeviceManagementDataHolder thisInstance = new MobileDeviceManagementDataHolder(); @@ -44,4 +48,20 @@ public class MobileDeviceManagementDataHolder { this.registryService = registryService; } + public DeviceManagementService getAndroidDeviceManagementService() { + return androidDeviceManagementService; + } + + public void setAndroidDeviceManagementService( + DeviceManagementService androidDeviceManagementService) { + this.androidDeviceManagementService = androidDeviceManagementService; + } + + public GCMService getGCMService() { + return gcmService; + } + + public void setGCMService(GCMService gcmService) { + this.gcmService = gcmService; + } } 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 0481671ada..92404b67ae 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 @@ -23,13 +23,20 @@ import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException; import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceConfigurationManager; import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceManagementConfig; import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig; import org.wso2.carbon.device.mgt.mobile.dao.AbstractMobileDeviceManagementDAOFactory; 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.android.gcm.GCMService; +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 org.wso2.carbon.registry.core.service.RegistryService; import java.util.Map; @@ -53,7 +60,9 @@ import java.util.Map; */ public class MobileDeviceManagementServiceComponent { + private ServiceRegistration androidServiceRegRef; private ServiceRegistration windowsServiceRegRef; + private ServiceRegistration gcmServiceRegRef; private static final Log log = LogFactory.getLog(MobileDeviceManagementServiceComponent.class); @@ -63,6 +72,7 @@ public class MobileDeviceManagementServiceComponent { log.debug("Activating Mobile Device Management Service Component"); } try { + BundleContext bundleContext = ctx.getBundleContext(); /* Initialize the data source configuration */ MobileDeviceConfigurationManager.getInstance().initConfig(); @@ -90,7 +100,30 @@ public class MobileDeviceManagementServiceComponent { log.error("Exception occurred while initializing mobile device management database schema", e); } } + DeviceManagementService androidDeviceManagementService = new AndroidDeviceManagementService(); + GCMService gcmService = new GCMService(); + androidServiceRegRef = + bundleContext.registerService(DeviceManagementService.class.getName(), + androidDeviceManagementService, null); + windowsServiceRegRef = + bundleContext.registerService(DeviceManagementService.class.getName(), + new WindowsDeviceManagementService(), null); + + gcmServiceRegRef = + bundleContext.registerService(GCMService.class.getName(), gcmService, null); + + + // Policy management service + + bundleContext.registerService(PolicyMonitoringService.class, + new AndroidPolicyMonitoringService(), null); + bundleContext.registerService(PolicyMonitoringService.class, + new WindowsPolicyMonitoringService(), null); + + MobileDeviceManagementDataHolder.getInstance().setAndroidDeviceManagementService( + androidDeviceManagementService); + MobileDeviceManagementDataHolder.getInstance().setGCMService(gcmService); if (log.isDebugEnabled()) { log.debug("Mobile Device Management Service Component has been successfully activated"); } @@ -104,9 +137,15 @@ public class MobileDeviceManagementServiceComponent { log.debug("De-activating Mobile Device Management Service Component"); } try { + if (androidServiceRegRef != null) { + androidServiceRegRef.unregister(); + } if (windowsServiceRegRef != null) { windowsServiceRegRef.unregister(); } + if (gcmServiceRegRef != null) { + gcmServiceRegRef.unregister(); + } if (log.isDebugEnabled()) { log.debug( "Mobile Device Management Service Component has been successfully de-activated"); diff --git a/features/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/h2.sql b/features/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/h2.sql index 09b3cc91c3..3673fd122e 100644 --- a/features/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/h2.sql +++ b/features/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/h2.sql @@ -4,7 +4,7 @@ -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `AD_DEVICE` ( `DEVICE_ID` VARCHAR(45) NOT NULL, - `GCM_TOKEN` VARCHAR(45) NULL DEFAULT NULL, + `GCM_TOKEN` VARCHAR(1000) NULL DEFAULT NULL, `DEVICE_INFO` VARCHAR(8000) NULL DEFAULT NULL, `IMEI` VARCHAR(45) NULL DEFAULT NULL, `IMSI` VARCHAR(45) NULL DEFAULT NULL, diff --git a/features/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mssql.sql b/features/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mssql.sql index f95ec0f913..be8caf6c43 100644 --- a/features/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mssql.sql +++ b/features/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mssql.sql @@ -3,7 +3,7 @@ -- ----------------------------------------------------- CREATE TABLE AD_DEVICE ( DEVICE_ID VARCHAR(45) NOT NULL, - GCM_TOKEN VARCHAR(45) NULL DEFAULT NULL, + GCM_TOKEN VARCHAR(1000) NULL DEFAULT NULL, DEVICE_INFO VARCHAR(8000) NULL DEFAULT NULL, IMEI VARCHAR(45) NULL DEFAULT NULL, IMSI VARCHAR(45) NULL DEFAULT NULL, diff --git a/features/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mysql.sql b/features/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mysql.sql index 0f80bdd344..8e85b92c2b 100644 --- a/features/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mysql.sql +++ b/features/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mysql.sql @@ -3,7 +3,7 @@ -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `AD_DEVICE` ( `DEVICE_ID` VARCHAR(45) NOT NULL, - `GCM_TOKEN` VARCHAR(45) NULL DEFAULT NULL, + `GCM_TOKEN` VARCHAR(1000) NULL DEFAULT NULL, `DEVICE_INFO` VARCHAR(8000) NULL DEFAULT NULL, `IMEI` VARCHAR(45) NULL DEFAULT NULL, `IMSI` VARCHAR(45) NULL DEFAULT NULL, diff --git a/features/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/oracle.sql b/features/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/oracle.sql index 7e3007ee6c..1331581e79 100644 --- a/features/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/oracle.sql +++ b/features/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/oracle.sql @@ -3,8 +3,8 @@ -- ----------------------------------------------------- CREATE TABLE AD_DEVICE ( DEVICE_ID VARCHAR(45) NOT NULL , - DEVICE_INFO VARCHAR(1000) DEFAULT NULL, - GCM_TOKEN VARCHAR(45) DEFAULT NULL, + DEVICE_INFO VARCHAR(4000) DEFAULT NULL, + GCM_TOKEN VARCHAR(1000) DEFAULT NULL, IMEI VARCHAR(45) DEFAULT NULL, IMSI VARCHAR(45) DEFAULT NULL, OS_VERSION VARCHAR(45) DEFAULT NULL, diff --git a/features/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/postgresql.sql b/features/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/postgresql.sql index 18d67c43dd..e4512c53fc 100644 --- a/features/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/postgresql.sql +++ b/features/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/postgresql.sql @@ -4,7 +4,7 @@ CREATE TABLE IF NOT EXISTS AD_DEVICE ( DEVICE_ID VARCHAR(45) NOT NULL , DEVICE_INFO TEXT NULL DEFAULT NULL, - GCM_TOKEN VARCHAR(45) NULL DEFAULT NULL, + GCM_TOKEN VARCHAR(1000) NULL DEFAULT NULL, IMEI VARCHAR(45) NULL DEFAULT NULL, IMSI VARCHAR(45) NULL DEFAULT NULL, OS_VERSION VARCHAR(45) NULL DEFAULT NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/oracle.sql index 315402e181..3ce0a85780 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/oracle.sql @@ -8,7 +8,7 @@ CREATE TABLE IOS_DEVICE ( MDM_TOKEN VARCHAR(100) DEFAULT NULL, UNLOCK_TOKEN VARCHAR(2000) DEFAULT NULL, CHALLENGE_TOKEN VARCHAR(45) DEFAULT NULL, - DEVICE_INFO VARCHAR(8000) DEFAULT NULL, + DEVICE_INFO VARCHAR(4000) DEFAULT NULL, SERIAL VARCHAR(45) DEFAULT NULL, PRODUCT VARCHAR(45) DEFAULT NULL, IMEI VARCHAR(45) DEFAULT NULL, diff --git a/pom.xml b/pom.xml index 56df00e873..a1ead1e750 100644 --- a/pom.xml +++ b/pom.xml @@ -17,6 +17,7 @@ ~ under the License. --> + @@ -144,6 +145,10 @@ org.wso2.carbon org.wso2.carbon.registry.api + + xerces.wso2 + xercesImpl + @@ -366,8 +371,24 @@ h2-database-engine ${orbit.h2.engine.version} + + org.apache.tomcat.wso2 + jdbc-pool + ${orbit.tomcat.jdbc.pooling.version} + + org.wso2.carbon.apimgt org.wso2.carbon.apimgt.core @@ -499,6 +520,14 @@ com.googlecode.json-simple.wso2 json-simple + + org.apache.bsf + bsf-all + + + xerces + xercesImpl + @@ -817,6 +846,11 @@ gson ${google.gson.version} + + com.google.android.gcm + gcm-server + ${gcm.server.version} + @@ -849,9 +883,7 @@ 1.2.140.wso2v3 - - - 7.0.59.wso2v1 + 7.0.52.wso2v5 7.0.34.wso2v2 7.0.59.wso2v1 @@ -865,7 +897,7 @@ 4.4.8 - 4.3.0-SNAPSHOT + 4.3.0 4.6.0 @@ -908,6 +940,11 @@ 2.4 1.1.1 2.3.1 + 2.2.4 + 1.0.2 + + + github-scm @@ -1097,5 +1134,10 @@ false + + gcm-server-repository + GCM Server repository - GitHub + https://github.com/slorber/gcm-server-repository/raw/master/releases/ +