diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java index cb575909d..24acb80f7 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java @@ -26,6 +26,7 @@ import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroupConstants; import org.wso2.carbon.device.mgt.iot.androidsense.service.impl.constants.AndroidSenseConstants; import org.wso2.carbon.device.mgt.iot.androidsense.service.impl.util.APIUtil; diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/APIUtil.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/APIUtil.java index 82d6737df..2f8d15644 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/APIUtil.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/APIUtil.java @@ -10,7 +10,6 @@ import org.wso2.carbon.analytics.dataservice.commons.SortByField; import org.wso2.carbon.analytics.datasource.commons.Record; import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; -import org.wso2.carbon.base.ServerConfiguration; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.core.util.Utils; diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoServiceImpl.java b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoServiceImpl.java index 462de254d..d1132f6e0 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoServiceImpl.java +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoServiceImpl.java @@ -18,7 +18,6 @@ package org.wso2.carbon.device.mgt.iot.arduino.service.impl; -import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.analytics.dataservice.commons.SortByField; @@ -30,6 +29,8 @@ import org.wso2.carbon.apimgt.application.extension.exception.APIManagerExceptio import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroupConstants; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; @@ -46,7 +47,6 @@ import org.wso2.carbon.user.api.UserStoreException; import javax.ws.rs.*; import javax.ws.rs.core.Response; -import java.io.IOException; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.*; diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ArduinoServiceUtils.java b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ArduinoServiceUtils.java index 4d1087345..1b86e08e7 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ArduinoServiceUtils.java +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ArduinoServiceUtils.java @@ -25,7 +25,7 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.concurrent.FutureCallback; import org.apache.http.impl.nio.client.CloseableHttpAsyncClient; import org.apache.http.impl.nio.client.HttpAsyncClients; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.iot.arduino.service.impl.constants.ArduinoConstants; import javax.ws.rs.HttpMethod; diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipUtil.java b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipUtil.java index 66b99da1e..9a7f980ff 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipUtil.java +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipUtil.java @@ -18,29 +18,23 @@ package org.wso2.carbon.device.mgt.iot.arduino.service.impl.util; -import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.base.ServerConfiguration; import org.wso2.carbon.core.util.Utils; -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.ConfigurationManagementException; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.utils.CarbonUtils; -import org.wso2.carbon.utils.NetworkUtils; -import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; import java.net.SocketException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiServiceImpl.java b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiServiceImpl.java index 9d0c48689..f9ecc0632 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiServiceImpl.java +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiServiceImpl.java @@ -18,7 +18,6 @@ package org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl; -import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.analytics.dataservice.commons.SortByField; @@ -30,6 +29,8 @@ import org.wso2.carbon.apimgt.application.extension.exception.APIManagerExceptio import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroupConstants; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; @@ -46,7 +47,6 @@ import org.wso2.carbon.user.api.UserStoreException; import javax.ws.rs.*; import javax.ws.rs.core.Response; -import java.io.IOException; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.*; diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipUtil.java b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipUtil.java index 220de83a2..1f1faafc0 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipUtil.java +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipUtil.java @@ -25,10 +25,10 @@ import org.apache.commons.logging.LogFactory; import org.json.JSONObject; import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants; import org.wso2.carbon.core.util.Utils; -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.ConfigurationManagementException; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.utils.CarbonUtils; import java.io.BufferedOutputStream; diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java index 367cd248b..a0d200dd9 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java @@ -18,7 +18,6 @@ package org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl; -import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.analytics.dataservice.commons.SortByField; @@ -30,10 +29,10 @@ import org.wso2.carbon.apimgt.application.extension.exception.APIManagerExceptio import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroupConstants; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; -import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; import org.wso2.carbon.device.mgt.core.operation.mgt.ConfigOperation; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.constants.VirtualFireAlarmConstants; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.dto.SensorRecord; @@ -53,7 +52,6 @@ import javax.ws.rs.Consumes; import javax.ws.rs.FormParam; import javax.ws.rs.GET; import javax.ws.rs.POST; -import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipUtil.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipUtil.java index 496d5eb5a..b52d74da6 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipUtil.java +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipUtil.java @@ -25,10 +25,10 @@ import org.apache.commons.logging.LogFactory; import org.json.JSONObject; import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants; import org.wso2.carbon.core.util.Utils; -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.ConfigurationManagementException; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.xmpp.XmppConfig; import org.wso2.carbon.utils.CarbonUtils; diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/pom.xml b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/pom.xml deleted file mode 100644 index d2fb52f72..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/pom.xml +++ /dev/null @@ -1,175 +0,0 @@ - - - - - org.wso2.carbon.devicemgt-plugins - appm-connector - 5.0.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.appmgt.mdm.osgiconnector - bundle - WSO2 Carbon - App Manager WSO2 MDM OSGI Connector Component - http://maven.apache.org - - - - - org.apache.felix - maven-scr-plugin - - - generate-scr-scrdescriptor - - scr - - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - ${project.artifactId} - org.wso2.carbon.appmgt.mdm.osgiconnector.internal - - org.wso2.carbon.device.mgt.core.*, - org.wso2.carbon.appmgt.mobile.utils.*, - org.wso2.carbon.appmgt.mobile.mdm.*, - org.wso2.carbon.appmgt.mobile.interfaces.*, - *;resolution:=optional - - - !org.wso2.carbon.appmgt.mdm.osgiconnector.internal, - org.wso2.carbon.appmgt.mdm.osgiconnector.* - - - - - - org.jacoco - jacoco-maven-plugin - - ${basedir}/target/coverage-reports/jacoco-unit.exec - - - - jacoco-initialize - - prepare-agent - - - - jacoco-site - test - - report - - - ${basedir}/target/coverage-reports/jacoco-unit.exec - ${basedir}/target/coverage-reports/site - - - - - - - - - org.wso2.carbon.appmgt - org.wso2.carbon.appmgt.mobile - - - org.apache.ws.commons.axiom - axiom-api - - - org.apache.ws.commons.axiom - axiom-impl - - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.core - - - org.apache.ws.commons.axiom - axiom-api - - - org.apache.ws.commons.axiom - axiom-impl - - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.policy.mgt.core - - - org.apache.ws.commons.axiom - axiom-api - - - org.apache.ws.commons.axiom - axiom-impl - - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.common - - - org.apache.ws.commons.axiom - axiom-api - - - org.apache.ws.commons.axiom - axiom-impl - - - - - commons-io.wso2 - commons-io - - - com.googlecode.json-simple.wso2 - json-simple - - - com.googlecode.plist - dd-plist - - - org.apache.felix - org.apache.felix.scr - - - com.google.code.gson - gson - - - - diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java deleted file mode 100644 index 5977deeb3..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java +++ /dev/null @@ -1,463 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.appmgt.mdm.osgiconnector; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; -import org.wso2.carbon.appmgt.impl.service.ServiceReferenceHolder; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.beans.MobileApp; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.beans.MobileAppTypes; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.common.DeviceApplicationException; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.util.AndroidApplicationOperationUtil; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.util.IOSApplicationOperationUtil; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.util.MDMAppConstants; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.util.MDMServiceAPIUtils; -import org.wso2.carbon.appmgt.mobile.beans.ApplicationOperationAction; -import org.wso2.carbon.appmgt.mobile.beans.ApplicationOperationDevice; -import org.wso2.carbon.appmgt.mobile.interfaces.ApplicationOperations; -import org.wso2.carbon.appmgt.mobile.mdm.App; -import org.wso2.carbon.appmgt.mobile.mdm.Device; -import org.wso2.carbon.appmgt.mobile.store.Generic; -import org.wso2.carbon.appmgt.mobile.utils.MobileApplicationException; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.Platform; -import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; -import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException; -import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService; -import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.appmgt.mobile.utils.User; - -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; -import org.wso2.carbon.registry.api.Resource; -import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.wso2.carbon.registry.core.session.UserRegistry; -import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.user.api.UserStoreManager; -import org.wso2.carbon.user.core.service.RealmService; - -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -public class ApplicationOperationsImpl implements ApplicationOperations { - private static final Log log = LogFactory.getLog(ApplicationOperationsImpl.class); - private static final String MEDIA_TYPE_XML = "application/xml"; - private static final String INSTALL = "install"; - private static final String UNINSTALL = "uninstall"; - - /** - * @param applicationOperationAction holds the information needs to perform an action on mdm. - * @throws MobileApplicationException If error occurred while performing the action. - */ - public String performAction(ApplicationOperationAction applicationOperationAction) - throws MobileApplicationException { - if (log.isDebugEnabled()) { - log.debug(applicationOperationAction.getAction() + " action is triggered for " + - applicationOperationAction.getType() + "."); - } - Operation operation = null; - List deviceIdentifiers = new ArrayList<>(); - List deviceList; - if (MDMAppConstants.USER.equals(applicationOperationAction.getType())) { - String userName = null; - try { - for (String param : applicationOperationAction.getParams()) { - userName = param; - deviceList = MDMServiceAPIUtils - .getDeviceManagementService(applicationOperationAction.getTenantId()). - getDevicesOfUser(userName); - for (org.wso2.carbon.device.mgt.common.Device device : deviceList) { - if (MDMAppConstants.WEBAPP.equals(applicationOperationAction.getApp().getPlatform()) || - applicationOperationAction.getApp().getPlatform().equalsIgnoreCase(device.getType())) { - if (MDMAppConstants.ACTIVE.equalsIgnoreCase(device.getEnrolmentInfo(). - getStatus().toString())) { - deviceIdentifiers.add(getDeviceIdentifierByDevice(device)); - } - } - } - } - } catch (DeviceManagementException devEx) { - String errorMsg = "Error occurred fetch device for user " + userName + " at app installation"; - logError(errorMsg, devEx); - throw new MobileApplicationException(errorMsg, devEx); - } - } else if (MDMAppConstants.ROLE.equals(applicationOperationAction.getType())) { - String userRole = null; - try { - for (String param : applicationOperationAction.getParams()) { - userRole = param; - deviceList = MDMServiceAPIUtils - .getDeviceManagementService(applicationOperationAction.getTenantId()). - getAllDevicesOfRole(userRole); - for (org.wso2.carbon.device.mgt.common.Device device : deviceList) { - if (MDMAppConstants.WEBAPP.equals(applicationOperationAction.getApp().getPlatform()) - || applicationOperationAction.getApp().getPlatform() - .equalsIgnoreCase(device.getType())) { - if (MDMAppConstants.ACTIVE - .equalsIgnoreCase(device.getEnrolmentInfo().getStatus().toString())) { - deviceIdentifiers.add(getDeviceIdentifierByDevice(device)); - } - } - } - } - } catch (DeviceManagementException devMgtEx) { - String errorMsg = "Error occurred fetch device for user role " + userRole + " at app installation"; - logError(errorMsg, devMgtEx); - throw new MobileApplicationException(errorMsg, devMgtEx); - } - } else if (MDMAppConstants.DEVICE.equals(applicationOperationAction.getType())) { - DeviceIdentifier deviceIdentifier; - for (String param : applicationOperationAction.getParams()) { - deviceIdentifier = new DeviceIdentifier(); - if (isValidJSON(param)) { - JSONParser parser = new JSONParser(); - try { - JSONObject parsedObj = (JSONObject) parser.parse(param); - deviceIdentifier.setId((String) parsedObj.get(MDMAppConstants.ID)); - deviceIdentifier.setType((String) parsedObj.get(MDMAppConstants.TYPE)); - deviceIdentifiers.add(deviceIdentifier); - } catch (ParseException e) { - logError("Device Identifier is not valid json object.", e); - throw new MobileApplicationException(e); - } - } - } - } else { - throw new IllegalStateException("invalid type is received from app store."); - } - App app = applicationOperationAction.getApp(); - MobileApp mobileApp = new MobileApp(); - mobileApp.setId(app.getId()); - mobileApp.setType(MobileAppTypes.valueOf(app.getType().toUpperCase())); - mobileApp.setAppIdentifier(app.getAppIdentifier()); - mobileApp.setIconImage(app.getIconImage()); - mobileApp.setIdentifier(app.getIdentifier()); - mobileApp.setLocation(app.getLocation()); - mobileApp.setName(app.getName()); - mobileApp.setPackageName(app.getPackageName()); - mobileApp.setPlatform(app.getPlatform()); - mobileApp.setVersion(app.getVersion()); - Properties properties = new Properties(); - - if (MDMAppConstants.IOS.equals(app.getPlatform())) { - if (MDMAppConstants.ENTERPRISE.equals(app.getType())) { - properties.put(MDMAppConstants.IOSConstants.IS_REMOVE_APP, true); - properties.put(MDMAppConstants.IOSConstants.IS_PREVENT_BACKUP, true); - } else if (MDMAppConstants.IOSConstants.PUBLIC.equals(app.getType())) { - properties.put(MDMAppConstants.IOSConstants.I_TUNES_ID, app.getIdentifier()); - properties.put(MDMAppConstants.IOSConstants.IS_REMOVE_APP, true); - properties.put(MDMAppConstants.IOSConstants.IS_PREVENT_BACKUP, true); - } else if (MDMAppConstants.WEBAPP.equals(app.getType())) { - properties.put(MDMAppConstants.IOSConstants.LABEL, app.getName()); - properties.put(MDMAppConstants.IOSConstants.IS_REMOVE_APP, true); - } - } else if (MDMAppConstants.WEBAPP.equals(app.getPlatform())) { - properties.put(MDMAppConstants.IOSConstants.LABEL, app.getName()); - properties.put(MDMAppConstants.IOSConstants.IS_REMOVE_APP, true); - } - mobileApp.setProperties(properties); - Activity activity = null; - try { - if (deviceIdentifiers.size() > 0) { - if (deviceIdentifiers.get(0).getType().equalsIgnoreCase(Platform.ANDROID.toString())) { - if (MDMAppConstants.INSTALL.equals(applicationOperationAction.getAction())) { - operation = AndroidApplicationOperationUtil - .createInstallAppOperation(mobileApp, applicationOperationAction.getSchedule()); - } else if (MDMAppConstants.UPDATE.equals(applicationOperationAction.getAction())) { - operation = AndroidApplicationOperationUtil - .createUpdateAppOperation(mobileApp, applicationOperationAction.getSchedule()); - } else { - operation = AndroidApplicationOperationUtil - .createAppUninstallOperation(mobileApp, applicationOperationAction.getSchedule()); - } - } else if (deviceIdentifiers.get(0).getType().equalsIgnoreCase(Platform.IOS.toString())) { - if (MDMAppConstants.INSTALL.equals(applicationOperationAction.getAction())) { - operation = - IOSApplicationOperationUtil.createInstallAppOperation(mobileApp); - } else { - if (MDMAppConstants.WEBAPP.equals(app.getPlatform())) { - operation = IOSApplicationOperationUtil.createWebClipUninstallOperation(mobileApp); - } else { - operation = IOSApplicationOperationUtil.createAppUninstallOperation(mobileApp); - } - } - } - activity = MDMServiceAPIUtils.getAppManagementService(applicationOperationAction.getTenantId()) - .installApplicationForDevices(operation, deviceIdentifiers); - } - if (activity != null) { - return activity.getActivityId(); - } - return null; - } catch (DeviceApplicationException mdmExce) { - logError("Error in creating operation object using app.", mdmExce); - throw new MobileApplicationException(mdmExce.getMessage()); - } catch (ApplicationManagementException appMgtExce) { - logError("Error in app installation.", appMgtExce); - throw new MobileApplicationException(appMgtExce.getErrorMessage()); - } - } - - /** - * Create a new device identifier from Device object. - * - * @param device device which is to be retrieved type and id - * @return created device identifier - */ - private static DeviceIdentifier getDeviceIdentifierByDevice(org.wso2.carbon.device.mgt.common.Device device) { - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setId(device.getDeviceIdentifier()); - deviceIdentifier.setType(device.getType()); - return deviceIdentifier; - } - - /** - * @param applicationOperationDevice holds the information needs to retrieve device list. - * @return List of devices - * @throws MobileApplicationException If an error occurred in getting devices or if app platform is not supported. - */ - public List getDevices(ApplicationOperationDevice applicationOperationDevice) - throws MobileApplicationException { - List devices; - List deviceList; - try { - final int tenantId = applicationOperationDevice.getTenantId(); - final String username = applicationOperationDevice.getCurrentUser().getUsername(); - final String platform = applicationOperationDevice.getPlatform(); - DeviceAccessAuthorizationService deviceAccessAuthorizationService = MDMServiceAPIUtils - .getDeviceAccessAuthorizationService(applicationOperationDevice.getTenantId()); - DeviceManagementProviderService deviceManagementService = MDMServiceAPIUtils - .getDeviceManagementService(tenantId); - boolean isAdmin = deviceAccessAuthorizationService.isDeviceAdminUser(); - - switch (platform) { - case MDMAppConstants.WEBAPP: - deviceList = isAdmin ? deviceManagementService.getAllDevices() : - deviceManagementService.getDevicesOfUser(username); - break; - case MDMAppConstants.ANDROID: - deviceList = isAdmin ? deviceManagementService.getAllDevices(MDMAppConstants.ANDROID) : - deviceManagementService.getDevicesOfUser(username, MDMAppConstants.ANDROID); - break; - case MDMAppConstants.IOS: - deviceList = isAdmin ? deviceManagementService.getAllDevices(MDMAppConstants.IOS) : - deviceManagementService.getDevicesOfUser(username, MDMAppConstants.IOS); - break; - default: - throw new MobileApplicationException("App platform: [" + platform + "] is not supported."); - } - - devices = new ArrayList<>(deviceList.size()); - if (log.isDebugEnabled()) { - log.debug("device list got from mdm " + deviceList.toString()); - } - for (org.wso2.carbon.device.mgt.common.Device commonDevice : deviceList) { - if (MDMAppConstants.ACTIVE - .equals(commonDevice.getEnrolmentInfo().getStatus().toString(). - toLowerCase())) { - Device device = new Device(); - org.wso2.carbon.appmgt.mobile.beans.DeviceIdentifier deviceIdentifier = - new org.wso2.carbon.appmgt.mobile.beans.DeviceIdentifier(); - deviceIdentifier.setId(commonDevice.getDeviceIdentifier()); - deviceIdentifier.setType(commonDevice.getType()); - device.setDeviceIdentifier(deviceIdentifier); - device.setName(commonDevice.getName()); - device.setModel(commonDevice.getName()); - device.setType(MDMAppConstants.MOBILE_DEVICE); - String imgUrl; - if (MDMAppConstants.ANDROID.equalsIgnoreCase(commonDevice.getType())) { - imgUrl = String.format(applicationOperationDevice.getConfigParams() - .get(MDMAppConstants.IMAGE_URL), - MDMAppConstants.NEXUS); - } else if (MDMAppConstants.IOS.equalsIgnoreCase(commonDevice.getType())) { - imgUrl = String.format(applicationOperationDevice.getConfigParams() - .get(MDMAppConstants.IMAGE_URL), - MDMAppConstants.IPHONE); - } else { - imgUrl = String.format(applicationOperationDevice.getConfigParams() - .get(MDMAppConstants.IMAGE_URL), - MDMAppConstants.NONE); - } - device.setImage(imgUrl); - device.setPlatform(commonDevice.getType()); - devices.add(device); - } - } - } catch (DeviceManagementException e) { - logError("Error While retrieving Device List.", e); - throw new MobileApplicationException(e.getMessage()); - } catch (DeviceAccessAuthorizationException e) { - throw new MobileApplicationException("Error while checking user permissions", e); - } - return devices; - } - - private boolean isValidJSON(String json) { - JSONParser parser = new JSONParser(); - try { - parser.parse(json); - } catch (ParseException e) { - return false; - } - return true; - } - - private void logError(String errorMessage, Throwable e) { - if (log.isDebugEnabled()) { - log.error(errorMessage, e); - } else { - log.error(errorMessage); - } - } - - private static UserStoreManager getUserStoreManager() throws UserStoreException { - RealmService realmService; - UserStoreManager userStoreManager; - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); - if (realmService == null) { - String msg = "Realm service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - int tenantId = ctx.getTenantId(); - userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager(); - return userStoreManager; - } - - class ApplicationSubscription extends Thread { - - User currentUser; - String action; - App app; - int tenantId; - String type; - String[] params; - UserStoreManager userStoreManager; - UserRegistry userRegistry; - - public ApplicationSubscription(User currentUser, String action, App app, int tenantId, final String type, - final String[] params) { - this.currentUser = currentUser; - this.action = action; - this.app = app; - this.tenantId = tenantId; - this.type = type; - this.params = params; - } - - @Override - public void run() { - try { - PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext privilegedCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - privilegedCarbonContext.setTenantId(tenantId); - RealmService realmService = (RealmService) privilegedCarbonContext.getOSGiService(RealmService.class, null); - if (realmService == null) { - String msg = "RealmService is not initialized"; - log.error(msg); - throw new IllegalStateException(msg); - } - - String tenantDomain; - try { - tenantDomain = realmService.getTenantManager().getDomain(tenantId); - privilegedCarbonContext.setTenantDomain(tenantDomain); - privilegedCarbonContext.setUsername(currentUser.getUsername()); - userStoreManager = getUserStoreManager(); - userRegistry = ServiceReferenceHolder.getInstance().getRegistryService() - .getGovernanceUserRegistry(currentUser.getUsername(), tenantId); - } catch (UserStoreException e) { - log.error("Error occured while fetching user store", e); - } catch (RegistryException e) { - log.error("Error occured while fetching registry instance", e); - } - - String basePath = "/users/"; - String subscriptionPath = "/subscriptions/mobileapp/"; - String path; - if (type != null && type.equals("role")) { - for (String param : params) { - String[] users; - if (log.isDebugEnabled()) { - log.debug("role being added:" + param); - } - try { - users = userStoreManager.getUserListOfRole(param); - for (String user : users) { - path = basePath + user + subscriptionPath + app.getId(); - updateSubscription(action, path, user, userRegistry); - } - } catch (UserStoreException e) { - log.error("Error occured while getting user list of role " + param, e); - } - - } - } else if (type != null && type.equals("user")) { - for (String user : params) { - if (log.isDebugEnabled()) { - log.debug("user:" + user); - } - path = basePath + user + subscriptionPath + app.getId(); - updateSubscription(action, path, user, userRegistry); - } - } else if (type != null && type.equals("device")) { - log.debug("device user:" + currentUser.getUsername()); - path = basePath + currentUser.getUsername() + subscriptionPath + app.getId(); - updateSubscription(action, path, currentUser.getUsername(), userRegistry); - } - log.info("registry subscription complete."); - } finally { - PrivilegedCarbonContext.endTenantFlow(); - } - } - } - - private void updateSubscription(String action, String path, String username, UserRegistry userRegistry) { - if (log.isDebugEnabled()) { - log.debug("update subscribe user:" + username + " , action:" + action + " ,path:" + path); - } - if (action != null && action.equals(INSTALL)) { - try { - if (!userRegistry.resourceExists(path)) { - Resource resource = userRegistry.newResource(); - resource.setMediaType(MEDIA_TYPE_XML); - userRegistry.put(path, resource); - Generic generic = new Generic(); - generic.showAppVisibilityToUser(path, username, "ALLOW"); - } - } catch (RegistryException e) { - log.error("Error occured while accessing registry.", e); - } - } else if (action != null && action.equals(UNINSTALL)) { - try { - if (userRegistry.resourceExists(path)) { - userRegistry.delete(path); - Generic generic = new Generic(); - generic.showAppVisibilityToUser(path, username, "DENY"); - } - } catch (RegistryException e) { - log.error("Error occured while accessing registry.", e); - } - } - } -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/internal/DeviceApplicationServiceComponent.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/internal/DeviceApplicationServiceComponent.java deleted file mode 100644 index 085f3a650..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/internal/DeviceApplicationServiceComponent.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.appmgt.mdm.osgiconnector.internal; - -import org.apache.commons.logging.Log; -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.appmgt.mdm.osgiconnector.ApplicationOperationsImpl; -import org.wso2.carbon.appmgt.mobile.interfaces.ApplicationOperations; - -/** - * @scr.component name="org.wso2.carbon.appmgt.mdm.osgiconnector" immediate="true" - */ - -public class DeviceApplicationServiceComponent { - - private static final Log log = LogFactory.getLog(DeviceApplicationServiceComponent.class); - - private ServiceRegistration mdmServiceRegistration; - - protected void activate(ComponentContext context) { - BundleContext bundleContext = context.getBundleContext(); - mdmServiceRegistration = bundleContext - .registerService(ApplicationOperations.class.getName(), new ApplicationOperationsImpl(), null); - if (log.isDebugEnabled()) { - log.debug("Device Application Service Component activated."); - } - - } - - protected void deactivate(ComponentContext context) { - if (mdmServiceRegistration != null) { - mdmServiceRegistration.unregister(); - mdmServiceRegistration = null; - } - if (log.isDebugEnabled()) { - log.debug("Device Application Service Component deactivated."); - } - - } - -} - - diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/MobileApp.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/MobileApp.java deleted file mode 100644 index 2933669a4..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/MobileApp.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.appmgt.mdm.osgiconnector.mdmmgt.beans; - -import java.util.Properties; - -/** - * This class represents the generic mobile Application information - * which is used by AppM. - */ -public class MobileApp { - - private String id; - private String name; - private MobileAppTypes type; - private String platform; - private String version; - private String identifier; - private String iconImage; - private String packageName; - private String appIdentifier; - private String location; - private Properties properties; - - public MobileAppTypes getType() { - return type; - } - - public void setType(MobileAppTypes type) { - this.type = type; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getPlatform() { - return platform; - } - - public void setPlatform(String platform) { - this.platform = platform; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getIdentifier() { - return identifier; - } - - public void setIdentifier(String identifier) { - this.identifier = identifier; - } - - public String getIconImage() { - return iconImage; - } - - public void setIconImage(String iconImage) { - this.iconImage = iconImage; - } - - public String getPackageName() { - return packageName; - } - - public void setPackageName(String packageName) { - this.packageName = packageName; - } - - public String getAppIdentifier() { - return appIdentifier; - } - - public void setAppIdentifier(String appIdentifier) { - this.appIdentifier = appIdentifier; - } - - public String getLocation() { - return location; - } - - public void setLocation(String location) { - this.location = location; - } - - public Properties getProperties() { - return properties; - } - - public void setProperties(Properties properties) { - this.properties = properties; - } - -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/MobileAppTypes.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/MobileAppTypes.java deleted file mode 100644 index 9b1b306c0..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/MobileAppTypes.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.appmgt.mdm.osgiconnector.mdmmgt.beans; - -public enum MobileAppTypes { - ENTERPRISE, WEBAPP, PUBLIC - -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/AndroidApplication.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/AndroidApplication.java deleted file mode 100644 index d638d7b11..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/AndroidApplication.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.appmgt.mdm.osgiconnector.mdmmgt.beans.android; - -import com.google.gson.Gson; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.common.DeviceApplicationException; - -public class AndroidApplication { - private String type; - private String appIdentifier; - - public String getAppIdentifier() { - return appIdentifier; - } - - public void setAppIdentifier(String appIdentifier) { - this.appIdentifier = appIdentifier; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String toJSON() throws DeviceApplicationException { - Gson gson = new Gson(); - return gson.toJson(this); - } - -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/AppStoreApplication.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/AppStoreApplication.java deleted file mode 100644 index 6f78eb244..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/AppStoreApplication.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.appmgt.mdm.osgiconnector.mdmmgt.beans.android; - -import com.google.gson.Gson; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.common.DeviceApplicationException; - -import java.io.Serializable; - -/** - * This class represents the Appstore Application information. - */ -public class AppStoreApplication extends AndroidApplication implements Serializable { - -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/EnterpriseApplication.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/EnterpriseApplication.java deleted file mode 100644 index f8990e585..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/EnterpriseApplication.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.appmgt.mdm.osgiconnector.mdmmgt.beans.android; - -import com.google.gson.Gson; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.common.DeviceApplicationException; - -import java.io.Serializable; - -/** - * This class represents the Enterprise Application information. - */ -public class EnterpriseApplication extends AndroidApplication implements Serializable { - - private String url; - private String schedule; - private String packageName; - - public String getSchedule() { - return schedule; - } - - public void setSchedule(String schedule) { - this.schedule = schedule; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getPackageName() { - return packageName; - } - - public void setPackageName(String packageName) { - this.packageName = packageName; - } -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/WebApplication.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/WebApplication.java deleted file mode 100644 index 08a35e08e..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/WebApplication.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.appmgt.mdm.osgiconnector.mdmmgt.beans.android; - -import com.google.gson.Gson; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.common.DeviceApplicationException; - -import java.io.Serializable; - -/** - * This class represents the Web Application information. - */ -public class WebApplication implements Serializable { - - private String name; - private String url; - private String type; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String toJSON() throws DeviceApplicationException { - Gson gson = new Gson(); - return gson.toJson(this); - } - -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/AppStoreApplication.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/AppStoreApplication.java deleted file mode 100644 index b8e6a4e09..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/AppStoreApplication.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.beans.ios; - -import java.io.Serializable; - -public class AppStoreApplication extends IOSApplication implements Serializable { - - private int iTunesStoreID; - - public int getiTunesStoreID() { - return iTunesStoreID; - } - - public void setiTunesStoreID(int iTunesStoreID) { - this.iTunesStoreID = iTunesStoreID; - } - -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/EnterpriseApplication.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/EnterpriseApplication.java deleted file mode 100644 index 3a09b7325..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/EnterpriseApplication.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.beans.ios; - -import java.io.Serializable; - -public class EnterpriseApplication extends IOSApplication implements Serializable { - - private String manifestURL; - - public String getManifestURL() { - return manifestURL; - } - - public void setManifestURL(String manifestURL) { - this.manifestURL = manifestURL; - } - -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/IOSApplication.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/IOSApplication.java deleted file mode 100644 index 12a8db23a..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/IOSApplication.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.appmgt.mdm.osgiconnector.mdmmgt.beans.ios; - -import com.google.gson.Gson; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.common.DeviceApplicationException; - -public class IOSApplication { - - private String identifier; - private boolean removeAppUponMDMProfileRemoval; - private boolean preventBackupOfAppData; - private String bundleId; - private String UUID; - - public String getUUID() { - return UUID; - } - - public void setUUID(String UUID) { - this.UUID = UUID; - } - - public String getIdentifier() { - return identifier; - } - - public void setIdentifier(String identifier) { - this.identifier = identifier; - } - - public boolean isRemoveAppUponMDMProfileRemoval() { - return removeAppUponMDMProfileRemoval; - } - - public void setRemoveAppUponMDMProfileRemoval(boolean removeAppUponMDMProfileRemoval) { - this.removeAppUponMDMProfileRemoval = removeAppUponMDMProfileRemoval; - } - - public boolean isPreventBackupOfAppData() { - return preventBackupOfAppData; - } - - public void setPreventBackupOfAppData(boolean preventBackupOfAppData) { - this.preventBackupOfAppData = preventBackupOfAppData; - } - - public String getBundleId() { - return bundleId; - } - - public void setBundleId(String bundleId) { - this.bundleId = bundleId; - } - - public String toJSON() throws DeviceApplicationException { - Gson gson = new Gson(); - return gson.toJson(this); - } - -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/RemoveApplication.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/RemoveApplication.java deleted file mode 100644 index d5ae92170..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/RemoveApplication.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.appmgt.mdm.osgiconnector.mdmmgt.beans.ios; - -import com.google.gson.Gson; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.common.DeviceApplicationException; - -import java.io.Serializable; - -public class RemoveApplication implements Serializable { - - private String bundleId; - private String url; - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getBundleId() { - return bundleId; - } - - public void setBundleId(String bundleId) { - this.bundleId = bundleId; - } - - public String toJSON() throws DeviceApplicationException { - Gson gson = new Gson(); - return gson.toJson(this); - } - -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/WebClip.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/WebClip.java deleted file mode 100644 index 000374c43..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/WebClip.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.appmgt.mdm.osgiconnector.mdmmgt.beans.ios; - -import com.google.gson.Gson; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.common.DeviceApplicationException; - -public class WebClip { - - private String URL; - private String label; - private String icon; - private String isRemovable; - private String UUID; - - public String getUUID() { - return UUID; - } - - public void setUUID(String UUID) { - this.UUID = UUID; - } - - public String getURL() { - return URL; - } - - public void setURL(String URL) { - this.URL = URL; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public String getIcon() { - return icon; - } - - public void setIcon(String icon) { - this.icon = icon; - } - - public String getIsRemovable() { - return isRemovable; - } - - public void setIsRemovable(String isRemovable) { - this.isRemovable = isRemovable; - } - - public String toJSON() throws DeviceApplicationException { - Gson gson = new Gson(); - return gson.toJson(this); - } - -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/common/DeviceApplicationException.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/common/DeviceApplicationException.java deleted file mode 100644 index 84818e4a0..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/common/DeviceApplicationException.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.appmgt.mdm.osgiconnector.mdmmgt.common; - -public class DeviceApplicationException extends Exception { - - private static final long serialVersionUID = 5136875495185597926L; - private String errorMessage; - - public DeviceApplicationException(String msg, Exception e) { - super(msg, e); - setErrorMessage(msg); - } - - public DeviceApplicationException(String msg, Throwable cause) { - super(msg, cause); - setErrorMessage(msg); - } - - public DeviceApplicationException(String msg) { - super(msg); - setErrorMessage(msg); - } - - public DeviceApplicationException() { - super(); - } - - public DeviceApplicationException(Throwable cause) { - super(cause); - } - - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/AndroidApplicationOperationUtil.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/AndroidApplicationOperationUtil.java deleted file mode 100644 index 7c1288b1a..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/AndroidApplicationOperationUtil.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.appmgt.mdm.osgiconnector.mdmmgt.util; - -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.beans.MobileApp; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.beans.android.AppStoreApplication; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.beans.android.EnterpriseApplication; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.beans.android.WebApplication; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.common.DeviceApplicationException; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; - -/** - * This class contains the all the operations related to Android. - */ -public class AndroidApplicationOperationUtil { - - /** - * Create Install Application operation. - * - * @param application MobileApp application - * @return operation - * @throws DeviceApplicationException - */ - public static Operation createInstallAppOperation(MobileApp application, String schedule) throws - DeviceApplicationException { - - ProfileOperation operation = new ProfileOperation(); - operation.setCode(MDMAppConstants.AndroidConstants.OPCODE_INSTALL_APPLICATION); - operation.setType(Operation.Type.PROFILE); - switch (application.getType()) { - case ENTERPRISE: - EnterpriseApplication enterpriseApplication = new EnterpriseApplication(); - enterpriseApplication.setType(application.getType().toString()); - enterpriseApplication.setUrl(application.getLocation()); - enterpriseApplication.setSchedule(schedule); - enterpriseApplication.setPackageName(application.getPackageName()); - operation.setPayLoad(enterpriseApplication.toJSON()); - break; - case PUBLIC: - setOperationForPublicApp(operation, application); - break; - case WEBAPP: - setOperationForWebApp(operation, application); - break; - default: - String errorMessage = "Invalid application type."; - throw new DeviceApplicationException(errorMessage); - } - return operation; - } - - /** - * Create Update Application operation. - * - * @param application MobileApp application - * @return operation - * @throws DeviceApplicationException - */ - public static Operation createUpdateAppOperation(MobileApp application, String schedule) throws - DeviceApplicationException { - - ProfileOperation operation = new ProfileOperation(); - operation.setCode(MDMAppConstants.AndroidConstants.OPCODE_UPDATE_APPLICATION); - operation.setType(Operation.Type.PROFILE); - switch (application.getType()) { - case ENTERPRISE: - EnterpriseApplication enterpriseApplication = new EnterpriseApplication(); - enterpriseApplication.setType(application.getType().toString()); - enterpriseApplication.setUrl(application.getLocation()); - enterpriseApplication.setSchedule(schedule); - operation.setPayLoad(enterpriseApplication.toJSON()); - break; - case PUBLIC: - setOperationForPublicApp(operation, application); - break; - case WEBAPP: - setOperationForWebApp(operation, application); - break; - default: - String errorMessage = "Invalid application type."; - throw new DeviceApplicationException(errorMessage); - } - return operation; - } - - /** - * Create Uninstall Application operation. - * - * @param application MobileApp application - * @return operation - * @throws DeviceApplicationException - */ - public static Operation createAppUninstallOperation(MobileApp application, String schedule) throws - DeviceApplicationException { - - ProfileOperation operation = new ProfileOperation(); - operation.setCode(MDMAppConstants.AndroidConstants.OPCODE_UNINSTALL_APPLICATION); - operation.setType(Operation.Type.PROFILE); - - switch (application.getType()) { - case ENTERPRISE: - EnterpriseApplication enterpriseApplication = new EnterpriseApplication(); - enterpriseApplication.setType(application.getType().toString()); - enterpriseApplication.setAppIdentifier(application.getIdentifier()); - enterpriseApplication.setSchedule(schedule); - operation.setPayLoad(enterpriseApplication.toJSON()); - break; - case PUBLIC: - setOperationForPublicApp(operation, application); - break; - case WEBAPP: - setOperationForWebApp(operation, application); - break; - default: - String errorMessage = "Invalid application type."; - throw new DeviceApplicationException(errorMessage); - } - return operation; - } - - private static void setOperationForPublicApp(Operation operation, MobileApp application) - throws DeviceApplicationException { - AppStoreApplication appStoreApplication = new AppStoreApplication(); - appStoreApplication.setType(application.getType().toString()); - appStoreApplication.setAppIdentifier(application.getIdentifier()); - operation.setPayLoad(appStoreApplication.toJSON()); - } - - private static void setOperationForWebApp(Operation operation, MobileApp application) - throws DeviceApplicationException { - WebApplication webApplication = new WebApplication(); - webApplication.setUrl(application.getLocation()); - webApplication.setName(application.getName()); - webApplication.setType(application.getType().toString()); - operation.setPayLoad(webApplication.toJSON()); - } - -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/IOSApplicationOperationUtil.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/IOSApplicationOperationUtil.java deleted file mode 100644 index 6adb9fe09..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/IOSApplicationOperationUtil.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.appmgt.mdm.osgiconnector.mdmmgt.util; - -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.beans.MobileApp; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.beans.ios.AppStoreApplication; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.beans.ios.WebClip; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.common.DeviceApplicationException; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.beans.ios.EnterpriseApplication; -import org.wso2.carbon.appmgt.mdm.osgiconnector.mdmmgt.beans.ios.RemoveApplication; - -import java.util.Properties; - -/** - * This class contains the all the operations related to IOS. - */ -public class IOSApplicationOperationUtil { - - /** - * Create Install Application operation. - * - * @param application MobileApp application - * @return operation - * @throws DeviceApplicationException - */ - public static Operation createInstallAppOperation(MobileApp application) throws - DeviceApplicationException { - - ProfileOperation operation = new ProfileOperation(); - switch (application.getType()) { - case ENTERPRISE: - EnterpriseApplication enterpriseApplication = new EnterpriseApplication(); - enterpriseApplication.setBundleId(application.getId()); - enterpriseApplication.setIdentifier(application.getIdentifier()); - enterpriseApplication.setManifestURL(application.getLocation()); - - Properties properties = application.getProperties(); - enterpriseApplication.setPreventBackupOfAppData( - (Boolean) properties.get(MDMAppConstants.IOSConstants.IS_PREVENT_BACKUP)); - enterpriseApplication.setRemoveAppUponMDMProfileRemoval( - (Boolean) properties.get(MDMAppConstants.IOSConstants.IS_REMOVE_APP)); - operation.setCode( - MDMAppConstants.IOSConstants.OPCODE_INSTALL_ENTERPRISE_APPLICATION); - operation.setPayLoad(enterpriseApplication.toJSON()); - operation.setType(Operation.Type.COMMAND); - break; - case PUBLIC: - AppStoreApplication appStoreApplication = new AppStoreApplication(); - appStoreApplication.setRemoveAppUponMDMProfileRemoval( - (Boolean) application.getProperties() - .get(MDMAppConstants.IOSConstants.IS_REMOVE_APP)); - appStoreApplication.setIdentifier(application.getIdentifier()); - appStoreApplication.setPreventBackupOfAppData((Boolean) application.getProperties(). - get(MDMAppConstants.IOSConstants.IS_PREVENT_BACKUP)); - appStoreApplication.setBundleId(application.getId()); - appStoreApplication.setiTunesStoreID(Integer.parseInt((String)application.getProperties(). - get(MDMAppConstants.IOSConstants.I_TUNES_ID))); - operation.setCode(MDMAppConstants.IOSConstants.OPCODE_INSTALL_STORE_APPLICATION); - operation.setType(Operation.Type.COMMAND); - operation.setPayLoad(appStoreApplication.toJSON()); - break; - case WEBAPP: - WebClip webClip = new WebClip(); - webClip.setIcon(application.getIconImage()); - webClip.setIsRemovable(application.getProperties(). - getProperty(MDMAppConstants.IOSConstants.IS_REMOVE_APP)); - webClip.setLabel(application.getProperties(). - getProperty(MDMAppConstants.IOSConstants.LABEL)); - webClip.setURL(application.getLocation()); - operation.setCode(MDMAppConstants.IOSConstants.OPCODE_INSTALL_WEB_APPLICATION); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(webClip.toJSON()); - break; - default: - String errorMessage = "Invalid application type."; - throw new DeviceApplicationException(errorMessage); - } - return operation; - } - - /** - * Create uninstall operations. - * - * @param application - * @return Uninstall operation - * @throws DeviceApplicationException - */ - public static Operation createAppUninstallOperation(MobileApp application) throws - DeviceApplicationException { - ProfileOperation operation = new ProfileOperation(); - operation.setCode(MDMAppConstants.IOSConstants.OPCODE_REMOVE_APPLICATION); - operation.setType(Operation.Type.PROFILE); - RemoveApplication removeApplication = new RemoveApplication(); - removeApplication.setBundleId(application.getPackageName()); - operation.setPayLoad(removeApplication.toJSON()); - return operation; - } - - /** - * Create uninstall operations for webclip. - * - * @param application - * @return Uninstall operation - * @throws DeviceApplicationException - */ - public static Operation createWebClipUninstallOperation(MobileApp application) throws - DeviceApplicationException { - ProfileOperation operation = new ProfileOperation(); - operation.setCode(MDMAppConstants.IOSConstants.OPCODE_REMOVE_APPLICATION); - operation.setType(Operation.Type.PROFILE); - RemoveApplication removeApplication = new RemoveApplication(); - removeApplication.setUrl(application.getIdentifier()); - operation.setPayLoad(removeApplication.toJSON()); - return operation; - } -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/MDMAppConstants.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/MDMAppConstants.java deleted file mode 100644 index 5903b6484..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/MDMAppConstants.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.appmgt.mdm.osgiconnector.mdmmgt.util; - -/** - * This class holds all the constants used for IOS and Android. - */ -public class MDMAppConstants { - - public static final String USER = "user"; - public static final String ROLE = "role"; - public static final String IOS = "ios"; - public static final String ANDROID = "android"; - public static final String WEBAPP = "webapp"; - public static final String INSTALL = "install"; - public static final String UPDATE = "update"; - public static final String ACTIVE = "active"; - public static final String ENTERPRISE = "enterprise"; - public static final String DEVICE = "device"; - public static final String MOBILE_DEVICE = "mobileDevice"; - public static final String NEXUS = "nexus"; - public static final String IPHONE = "iphone"; - public static final String NONE = "none"; - public static final String IMAGE_URL = "ImageURL"; - public static final String TYPE = "type"; - public static final String ID = "id"; - - public class IOSConstants { - - private IOSConstants() { - throw new AssertionError(); - } - - public static final String IS_REMOVE_APP = "isRemoveApp"; - public static final String IS_PREVENT_BACKUP = "isPreventBackup"; - public static final String I_TUNES_ID = "iTunesId"; - public static final String LABEL = "label"; - public static final String PUBLIC = "public"; - public static final String OPCODE_INSTALL_ENTERPRISE_APPLICATION = - "INSTALL_ENTERPRISE_APPLICATION"; - public static final String OPCODE_INSTALL_STORE_APPLICATION = "INSTALL_STORE_APPLICATION"; - public static final String OPCODE_INSTALL_WEB_APPLICATION = "WEB_CLIP"; - public static final String OPCODE_REMOVE_APPLICATION = "REMOVE_APPLICATION"; - } - - public class AndroidConstants { - private AndroidConstants() { - throw new AssertionError(); - } - - public static final String OPCODE_INSTALL_APPLICATION = "INSTALL_APPLICATION"; - public static final String OPCODE_UPDATE_APPLICATION = "UPDATE_APPLICATION"; - public static final String OPCODE_UNINSTALL_APPLICATION = "UNINSTALL_APPLICATION"; - } - - public class RegistryConstants { - private RegistryConstants() { - throw new AssertionError(); - } - - public static final String GENERAL_CONFIG_RESOURCE_PATH = "general"; - } - - public class APPManagerConstants { - private static final String APP_MANAGER_MDM_SERVICE_NAME = - "org.wso2.carbon.appmgt.mobile.interfaces.MDMOperations"; - } - -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/MDMServiceAPIUtils.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/MDMServiceAPIUtils.java deleted file mode 100644 index 9bf9822eb..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/MDMServiceAPIUtils.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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.appmgt.mdm.osgiconnector.mdmmgt.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService; -import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService; -import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; - -/** - * MDMServiceAPIUtils class provides utility function. - */ -public class MDMServiceAPIUtils { - - private static Log log = LogFactory.getLog(MDMServiceAPIUtils.class); - - /** - * Returns the DeviceManagementProviderService osgi service. - * - * @param tenantId tenant id - * @return DeviceManagementProviderService - */ - public static DeviceManagementProviderService getDeviceManagementService(int tenantId) { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - ctx.setTenantId(tenantId, true); - DeviceManagementProviderService deviceManagementProviderService = - (DeviceManagementProviderService) ctx - .getOSGiService(DeviceManagementProviderService.class, null); - if (deviceManagementProviderService == null) { - String msg = "Device Management provider service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - return deviceManagementProviderService; - } - - /** - * Returns the DeviceAccessAuthorizationService osgi service. - * - * @param tenantId tenant id - * @return {@link DeviceAccessAuthorizationService} - */ - public static DeviceAccessAuthorizationService getDeviceAccessAuthorizationService(int tenantId) { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - ctx.setTenantId(tenantId, true); - DeviceAccessAuthorizationService deviceAccessAuthorizationService = - (DeviceAccessAuthorizationService) ctx - .getOSGiService(DeviceAccessAuthorizationService.class, null); - if (deviceAccessAuthorizationService == null) { - String msg = "Device Access Authorization service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - return deviceAccessAuthorizationService; - } - - /** - * Returns the ApplicationManagementProviderService osgi service. - * - * @param tenantId tenant id - * @return ApplicationManagementProviderService - */ - public static ApplicationManagementProviderService getAppManagementService(int tenantId) { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - ctx.setTenantId(tenantId, true); - ApplicationManagementProviderService applicationManagementProviderService = - (ApplicationManagementProviderService) ctx. - getOSGiService( - ApplicationManagementProviderService.class, - null); - if (applicationManagementProviderService == null) { - String msg = "Application management service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - return applicationManagementProviderService; - } - -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/pom.xml b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/pom.xml deleted file mode 100644 index 44adc5bd4..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/pom.xml +++ /dev/null @@ -1,158 +0,0 @@ - - - - - org.wso2.carbon.devicemgt-plugins - appm-connector - 5.0.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.appmgt.mdm.restconnector - bundle - WSO2 Carbon - App Manager WSO2 MDM REST Connector Component - http://maven.apache.org - - - - - org.apache.felix - maven-scr-plugin - - - generate-scr-scrdescriptor - - scr - - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - ${project.artifactId} - org.wso2.carbon.appmgt.mdm.restconnector.internal - - org.osgi.framework, - org.osgi.service.component, - org.wso2.carbon.appmgt.mobile.utils.*, - org.wso2.carbon.appmgt.mobile.mdm.*, - org.wso2.carbon.appmgt.mobile.interfaces.*, - org.apache.commons.*, - org.wso2.carbon.user.core.service, - org.wso2.carbon.user.core.tenant, - org.wso2.carbon.user.api, - feign, - feign.auth, - feign.codec, - feign.gson, - org.json.simple.*, - org.wso2.carbon.appmgt.mobile.beans, - org.wso2.carbon.base, - org.wso2.carbon.context, - javax.net.ssl, - feign.slf4j - - - !org.wso2.carbon.appmgt.mdm.restconnector.internal, - org.wso2.carbon.appmgt.mdm.restconnector.* - - - jsr311-api, - feign-jaxrs - - - - - - org.jacoco - jacoco-maven-plugin - - ${basedir}/target/coverage-reports/jacoco-unit.exec - - - - jacoco-initialize - - prepare-agent - - - - jacoco-site - test - - report - - - ${basedir}/target/coverage-reports/jacoco-unit.exec - ${basedir}/target/coverage-reports/site - - - - - - - - - - com.googlecode.json-simple.wso2 - json-simple - - - org.wso2.carbon - org.wso2.carbon.logging - - - org.wso2.carbon.devicemgt - org.wso2.carbon.identity.jwt.client.extension - - - io.github.openfeign - feign-core - - - io.github.openfeign - feign-jaxrs - - - io.github.openfeign - feign-gson - - - javax.ws.rs - jsr311-api - - - io.swagger - swagger-jaxrs - - - org.wso2.carbon.appmgt - org.wso2.carbon.appmgt.mobile - - - io.github.openfeign - feign-slf4j - - - - diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/ApplicationOperationsImpl.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/ApplicationOperationsImpl.java deleted file mode 100644 index 1f5399bca..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/ApplicationOperationsImpl.java +++ /dev/null @@ -1,383 +0,0 @@ -/* - * 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.appmgt.mdm.restconnector; - -import feign.Client; -import feign.Feign; -import feign.Logger; -import feign.Request; -import feign.Response; -import feign.gson.GsonDecoder; -import feign.gson.GsonEncoder; -import feign.jaxrs.JAXRSContract; -import feign.slf4j.Slf4jLogger; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; -import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.OAuthRequestInterceptor; -import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.Activity; -import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.ApplicationManagementAdminService; -import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.ApplicationWrapper; -import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.DeviceManagementAdminService; -import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.MobileApp; -import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.MobileAppTypes; -import org.wso2.carbon.appmgt.mdm.restconnector.config.AuthorizationConfigurationManager; -import org.wso2.carbon.appmgt.mobile.beans.ApplicationOperationAction; -import org.wso2.carbon.appmgt.mobile.beans.ApplicationOperationDevice; -import org.wso2.carbon.appmgt.mobile.beans.DeviceIdentifier; -import org.wso2.carbon.appmgt.mobile.interfaces.ApplicationOperations; -import org.wso2.carbon.appmgt.mobile.mdm.App; -import org.wso2.carbon.appmgt.mobile.mdm.Device; -import org.wso2.carbon.appmgt.mobile.utils.MobileApplicationException; -import org.wso2.carbon.appmgt.mobile.utils.MobileConfigurations; -import org.wso2.carbon.base.ServerConfiguration; -import org.wso2.carbon.context.PrivilegedCarbonContext; - -import javax.net.ssl.*; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.security.*; -import java.security.cert.CertificateException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -public class ApplicationOperationsImpl implements ApplicationOperations { - private static final String CDMF_SERVER_BASE_CONTEXT = "/api/device-mgt/v1.0"; - private static DeviceManagementAdminService deviceManagementAdminService; - private static final Log log = LogFactory.getLog(ApplicationOperationsImpl.class); - private static ApplicationManagementAdminService applicationManagementAdminService; - - /** - * Constructor. - */ - public ApplicationOperationsImpl() { - String authorizationConfigManagerServerURL = AuthorizationConfigurationManager.getInstance().getServerURL(); - OAuthRequestInterceptor oAuthRequestInterceptor = new OAuthRequestInterceptor(); - deviceManagementAdminService = Feign.builder().client(getSSLClient()).logger(new Slf4jLogger()).logLevel( - Logger.Level.FULL).requestInterceptor(oAuthRequestInterceptor) - .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) - .target(DeviceManagementAdminService.class, - authorizationConfigManagerServerURL + CDMF_SERVER_BASE_CONTEXT); - applicationManagementAdminService = Feign.builder().client(getSSLClient()).logger(new Slf4jLogger()).logLevel( - Logger.Level.FULL).requestInterceptor(oAuthRequestInterceptor) - .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) - .target(ApplicationManagementAdminService.class, - authorizationConfigManagerServerURL + CDMF_SERVER_BASE_CONTEXT); - } - - /** - * Install, uninstall, reinstall application in devices. - * - * @param applicationOperationAction {@link ApplicationOperationAction} object - * @return Activity id - * @throws MobileApplicationException on errors while trying to perform action in devices - */ - @Override - public String performAction(ApplicationOperationAction applicationOperationAction) - throws MobileApplicationException { - ApplicationWrapper applicationWrapper = new ApplicationWrapper(); - MobileApp mobileApp = new MobileApp(); - - String type = applicationOperationAction.getType(); - String[] params = applicationOperationAction.getParams(); - int tenantId = applicationOperationAction.getTenantId(); - - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId); - - List deviceIdentifiers = new ArrayList<>(); - List deviceList; - if (Constants.USER.equals(type)) { - String platform = applicationOperationAction.getApp().getPlatform(); - String userName; - for (String param : params) { - userName = param; - deviceList = deviceManagementAdminService.getDevices(userName, null).getList(); - - for (org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.Device device : deviceList) { - if (Constants.WEBAPP.equals(platform) || platform.equalsIgnoreCase(device.getType())) { - if (Constants.ACTIVE.equalsIgnoreCase(device.getEnrolmentInfo().getStatus().toString())) { - deviceIdentifiers.add(getDeviceIdentifierByDevice(device)); - } - } - } - } - } else if (Constants.ROLE.equals(type)) { - String userRole; - for (String param : applicationOperationAction.getParams()) { - userRole = param; - deviceList = deviceManagementAdminService.getDevices(null, userRole).getList(); - for (org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.Device device : deviceList) { - if (Constants.ACTIVE.equalsIgnoreCase(device.getEnrolmentInfo().getStatus().toString())) { - deviceIdentifiers.add(getDeviceIdentifierByDevice(device)); - } - } - } - } else if (Constants.DEVICE.equals(type)) { - DeviceIdentifier deviceIdentifier; - for (String param : params) { - deviceIdentifier = new DeviceIdentifier(); - if (isValidJSON(param)) { - JSONParser parser = new JSONParser(); - try { - JSONObject parsedObj = (JSONObject) parser.parse(param); - deviceIdentifier.setId((String) parsedObj.get(Constants.ID)); - String deviceType = (String) parsedObj.get(Constants.TYPE); - deviceIdentifier.setType(deviceType); - deviceIdentifiers.add(deviceIdentifier); - } catch (ParseException e) { - throw new MobileApplicationException("Device Identifier is not valid json object.", e); - } - } - } - } else { - throw new IllegalStateException("Invalid type is received from app store."); - } - - App app = applicationOperationAction.getApp(); - mobileApp.setId(app.getId()); - mobileApp.setType(MobileAppTypes.valueOf(app.getType().toUpperCase())); - mobileApp.setAppIdentifier(app.getAppIdentifier()); - mobileApp.setIconImage(app.getIconImage()); - mobileApp.setIdentifier(app.getIdentifier()); - mobileApp.setLocation(app.getLocation()); - mobileApp.setName(app.getName()); - mobileApp.setPackageName(app.getPackageName()); - mobileApp.setPlatform(app.getPlatform()); - mobileApp.setVersion(app.getVersion()); - Properties mobileAppProperties = new Properties(); - - if (Constants.IOS.equals(app.getPlatform())) { - if (Constants.ENTERPRISE.equals(app.getType())) { - mobileAppProperties.put(Constants.IOSConstants.IS_REMOVE_APP, true); - mobileAppProperties.put(Constants.IOSConstants.IS_PREVENT_BACKUP, true); - } else if (Constants.IOSConstants.PUBLIC.equals(app.getType())) { - mobileAppProperties.put(Constants.IOSConstants.I_TUNES_ID, app.getIdentifier()); - mobileAppProperties.put(Constants.IOSConstants.IS_REMOVE_APP, true); - mobileAppProperties.put(Constants.IOSConstants.IS_PREVENT_BACKUP, true); - } else if (Constants.WEBAPP.equals(app.getType())) { - mobileAppProperties.put(Constants.IOSConstants.LABEL, app.getName()); - mobileAppProperties.put(Constants.IOSConstants.IS_REMOVE_APP, true); - } - } else if (Constants.WEBAPP.equals(app.getPlatform())) { - mobileAppProperties.put(Constants.IOSConstants.LABEL, app.getName()); - mobileAppProperties.put(Constants.IOSConstants.IS_REMOVE_APP, true); - } - mobileApp.setProperties(mobileAppProperties); - applicationWrapper.setApplication(mobileApp); - Activity activity = null; - - if (deviceIdentifiers.size() > 0) { - applicationWrapper.setDeviceIdentifiers(deviceIdentifiers); - if (Constants.INSTALL.equals(applicationOperationAction.getAction())) { - activity = applicationManagementAdminService.installApplication(applicationWrapper); - } else if (Constants.UPDATE.equals(applicationOperationAction.getAction())) { - activity = applicationManagementAdminService.installApplication(applicationWrapper); - } else { - activity = applicationManagementAdminService.uninstallApplication(applicationWrapper); - } - } - - if (activity != null) { - return activity.getActivityId(); - } - return null; - } - - /** - * Get devices. - * - * @param applicationOperationDevice {@link ApplicationOperationAction} object - * @return list of {@link Device} objects - * @throws MobileApplicationException on errors while trying to get devices list - */ - @Override - public List getDevices(ApplicationOperationDevice applicationOperationDevice) - throws MobileApplicationException { - Map queryParamsMap = new HashMap<>(); - String platform = applicationOperationDevice.getPlatform(); - String platformVersion = applicationOperationDevice.getPlatformVersion(); - String userName = applicationOperationDevice.getCurrentUser().getUsername(); - queryParamsMap.put(Constants.PLATFORM, platform); - queryParamsMap.put(Constants.PLATFORM_VERSION, platformVersion); - queryParamsMap.put(Constants.USER, userName); - String type = applicationOperationDevice.getType(); - queryParamsMap.put(Constants.TYPE, type); - List deviceList = - deviceManagementAdminService.getDevices(userName, null).getList(); - - List processedDevices = new ArrayList<>(); - for (org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.Device device : deviceList) { - Device processedDevice = new Device(); - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setId(device.getDeviceIdentifier().toString()); - deviceIdentifier.setType(device.getType().toString()); - processedDevice.setDeviceIdentifier(deviceIdentifier); - processedDevice.setName(device.getName()); - processedDevice.setModel(device.getName()); - processedDevice.setType(device.getType()); - String imgUrl; - if (Constants.ANDROID.equalsIgnoreCase((device.getType().toString()))) { - imgUrl = String.format(getActiveMDMProperties().get(Constants.PROPERTY_IMAGE_URL), Constants.NEXUS); - } else if (Constants.IOS.equalsIgnoreCase((device.getType().toString()))) { - imgUrl = String.format(getActiveMDMProperties().get(Constants.PROPERTY_IMAGE_URL), Constants.IPHONE); - } else { - imgUrl = String.format(getActiveMDMProperties().get(Constants.PROPERTY_IMAGE_URL), Constants.NONE); - } - processedDevice.setImage(imgUrl); - processedDevice.setPlatform(device.getType().toString()); - processedDevices.add(processedDevice); - } - return processedDevices; - - } - - private HashMap getActiveMDMProperties() { - MobileConfigurations configurations = MobileConfigurations.getInstance(); - return configurations.getActiveMDMProperties(); - } - - private static DeviceIdentifier getDeviceIdentifierByDevice( - org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.Device device) { - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setId(device.getDeviceIdentifier()); - deviceIdentifier.setType(device.getType()); - - return deviceIdentifier; - } - - private boolean isValidJSON(String json) { - JSONParser parser = new JSONParser(); - try { - parser.parse(json); - } catch (ParseException e) { - return false; - } - return true; - } - - private void logError(String errorMessage, Throwable e) { - if (log.isDebugEnabled()) { - log.error(errorMessage, e); - } else { - log.error(errorMessage); - } - } - - public static Client getSSLClient() { - boolean isIgnoreHostnameVerification = Boolean.parseBoolean(System.getProperty("org.wso2.ignoreHostnameVerification")); - if(isIgnoreHostnameVerification) { - return new Client.Default(getSimpleTrustedSSLSocketFactory(), new HostnameVerifier() { - @Override - public boolean verify(String s, SSLSession sslSession) { - return true; - } - }); - }else { - return new Client.Default(getTrustedSSLSocketFactory(), null); - } - } - - private static SSLSocketFactory getSimpleTrustedSSLSocketFactory() { - try { - TrustManager[] trustAllCerts = new TrustManager[]{ - new X509TrustManager() { - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return null; - } - public void checkClientTrusted( - java.security.cert.X509Certificate[] certs, String authType) { - } - public void checkServerTrusted( - java.security.cert.X509Certificate[] certs, String authType) { - } - } - }; - SSLContext sc = SSLContext.getInstance("SSL"); - sc.init(null, trustAllCerts, new java.security.SecureRandom()); - return sc.getSocketFactory(); - } catch (KeyManagementException | NoSuchAlgorithmException e) { - return null; - } - } - - //FIXME - I know hard-cording values is a bad practice , this code is repeating in - // several class, so this hard-coding strings will be removed once this code block is moved into a central location - // this should be done after the 3.1.0 release. - private static SSLSocketFactory getTrustedSSLSocketFactory() { - try { - String keyStorePassword = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Password"); - String keyStoreLocation = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Location"); - String trustStorePassword = ServerConfiguration.getInstance().getFirstProperty( - "Security.TrustStore.Password"); - String trustStoreLocation = ServerConfiguration.getInstance().getFirstProperty( - "Security.TrustStore.Location"); - - KeyStore keyStore = loadKeyStore(keyStoreLocation,keyStorePassword,"JKS"); - KeyStore trustStore = loadTrustStore(trustStoreLocation,trustStorePassword); - return initSSLConnection(keyStore,keyStorePassword,trustStore); - } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException - |CertificateException | IOException | UnrecoverableKeyException e) { - log.error("Error while creating the SSL socket factory due to "+e.getMessage(),e); - return null; - } - } - - private static SSLSocketFactory initSSLConnection(KeyStore keyStore,String keyStorePassword,KeyStore trustStore) throws NoSuchAlgorithmException, UnrecoverableKeyException, - KeyStoreException, KeyManagementException { - KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("SunX509"); - keyManagerFactory.init(keyStore, keyStorePassword.toCharArray()); - TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance("SunX509"); - trustManagerFactory.init(trustStore); - - // Create and initialize SSLContext for HTTPS communication - SSLContext sslContext = SSLContext.getInstance("SSLv3"); - sslContext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null); - SSLContext.setDefault(sslContext); - return sslContext.getSocketFactory(); - } - - private static KeyStore loadKeyStore(String keyStorePath, String ksPassword, String type) - throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException { - InputStream fileInputStream = null; - try { - char[] keypassChar = ksPassword.toCharArray(); - KeyStore keyStore = KeyStore.getInstance(type); - fileInputStream = new FileInputStream(keyStorePath); - keyStore.load(fileInputStream, keypassChar); - return keyStore; - } finally { - if (fileInputStream != null) { - fileInputStream.close(); - } - } - } - - private static KeyStore loadTrustStore(String trustStorePath, String tsPassword) - throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException { - - return loadKeyStore(trustStorePath,tsPassword,"JKS"); - } - - -} \ No newline at end of file diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/Constants.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/Constants.java deleted file mode 100644 index 1721fc1a7..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/Constants.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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.appmgt.mdm.restconnector; - -public class Constants { - public static final String PROPERTY_SERVER_URL = "ServerURL"; - public static final String PROPERTY_TOKEN_API_URL = "TokenApiURL"; - public static final String PROPERTY_IMAGE_URL = "ImageURL"; - public static final String PROPERTY_TOKEN_REFRESH_TIME_OFFSET = "TokenRefreshTimeOffset"; - public static final String PROPERTY_USERNAME = "Username"; - public static final String PROPERTY_PASSWORD = "Password"; - - public static final String USER = "user"; - public static final String ROLE = "role"; - public static final String USERS = USER + "s"; - public static final String ROLES = ROLE + "s"; - public static final String ANDROID = "android"; - public static final String IOS = "ios"; - public static final String WEBAPP = "webapp"; - public static final String PLATFORM = "platform"; - public static final String PLATFORM_VERSION = "platformVersion"; - public static final String PROPERTIES = "properties"; - public static final String TYPE = "type"; - public static final String TYPES = TYPE + "s"; - public static final String ID = "id"; - public static final String NAME = "name"; - public static final String USER_LIST = "userList"; - public static final String DEVICE_IDENTIFIER = "deviceIdentifier"; - public static final String DEVICE_IDENTIFIERS = DEVICE_IDENTIFIER + "s"; - public static final String DEVICES = "devices"; - public static final String APPLICATION = "application"; - public static final String NEXUS = "nexus"; - public static final String IPHONE = "iphone"; - public static final String NONE = "none"; - public static final String INSTALL = "install"; - public static final String UPDATE = "update"; - public static final String MOBILE_DEVICE = "mobileDevice"; - public static final String ENTERPRISE = "enterprise"; - public static final String ACTIVE = "active"; - public static final String DEVICE = "device"; - - - public class IOSConstants { - - private IOSConstants() { - throw new AssertionError(); - } - - public static final String IS_REMOVE_APP = "isRemoveApp"; - public static final String IS_PREVENT_BACKUP = "isPreventBackup"; - public static final String I_TUNES_ID = "iTunesId"; - public static final String LABEL = "label"; - public static final String PUBLIC = "public"; - public static final String OPCODE_INSTALL_ENTERPRISE_APPLICATION = - "INSTALL_ENTERPRISE_APPLICATION"; - public static final String OPCODE_INSTALL_STORE_APPLICATION = "INSTALL_STORE_APPLICATION"; - public static final String OPCODE_INSTALL_WEB_APPLICATION = "WEB_CLIP"; - public static final String OPCODE_REMOVE_APPLICATION = "REMOVE_APPLICATION"; - } - - public class AndroidConstants { - private AndroidConstants() { - throw new AssertionError(); - } - - public static final String OPCODE_INSTALL_APPLICATION = "INSTALL_APPLICATION"; - public static final String OPCODE_UPDATE_APPLICATION = "UPDATE_APPLICATION"; - public static final String OPCODE_UNINSTALL_APPLICATION = "UNINSTALL_APPLICATION"; - } - - public class WebAppConstants { - public static final String WEBAPP = "webapp"; - public static final String LABEL = "label"; - public static final String IS_REMOVE_APP = "isRemoveApp"; - public static final String NAME = "name"; - } - - public class RestConstants { - public static final String USERNAME = "username"; - public static final String PASSWORD = "password"; - public static final String AUTHORIZATION = "Authorization"; - public static final String BEARER = "Bearer "; - public static final String BASIC = "Basic "; - public static final String COLON = ":"; - public static final String GRANT_TYPE = "grant_type"; - public static final String CONTENT_TYPE = "Content-Type"; - public static final String ACCESS_TOKEN = "accessToken"; - public static final String ACCEPT = "Accept"; - public static final String APPLICATION_JSON = "application/json"; - public static final String APPLICATION_FORM_URL_ENCODED = "application/x-www-form-urlencoded"; - } - -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/OAuthRequestInterceptor.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/OAuthRequestInterceptor.java deleted file mode 100755 index 1ff87e7e6..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/OAuthRequestInterceptor.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * 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.appmgt.mdm.restconnector.authorization.client; - -import feign.Client; -import feign.Feign; -import feign.FeignException; -import feign.Logger; -import feign.Request; -import feign.RequestInterceptor; -import feign.RequestTemplate; -import feign.Response; -import feign.auth.BasicAuthRequestInterceptor; -import feign.gson.GsonDecoder; -import feign.gson.GsonEncoder; -import feign.jaxrs.JAXRSContract; -import feign.slf4j.Slf4jLogger; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.appmgt.mdm.restconnector.Constants; -import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.AccessTokenInfo; -import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.ApiApplicationKey; -import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.ApiApplicationRegistrationService; -import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.ApiRegistrationProfile; -import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.TokenIssuerService; -import org.wso2.carbon.appmgt.mdm.restconnector.config.AuthorizationConfigurationManager; -import org.wso2.carbon.appmgt.mdm.restconnector.internal.AuthorizationDataHolder; -import org.wso2.carbon.base.ServerConfiguration; - -import javax.net.ssl.*; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.security.*; -import java.security.cert.CertificateException; - -/** - * This is a request interceptor to add oauth token header. - */ -public class OAuthRequestInterceptor implements RequestInterceptor { - private AccessTokenInfo tokenInfo; - private String refreshTimeOffset; - private static final String API_APPLICATION_REGISTRATION_CONTEXT = "/api-application-registration"; - private static final String DEVICE_MANAGEMENT_SERVICE_TAG[] = {"device_management"}; - private static final String APPLICATION_NAME = "appm_restconnector_application"; - private static final String PASSWORD_GRANT_TYPE = "password"; - private static final String REFRESH_GRANT_TYPE = "refresh_token"; - private ApiApplicationRegistrationService apiApplicationRegistrationService; - private TokenIssuerService tokenIssuerService; - private static Log log = LogFactory.getLog(OAuthRequestInterceptor.class); - private ApiApplicationKey apiApplicationKey; - - /** - * Creates an interceptor that authenticates all requests. - */ - public OAuthRequestInterceptor() { - refreshTimeOffset = AuthorizationConfigurationManager.getInstance().getTokenRefreshTimeOffset(); - String username = AuthorizationConfigurationManager.getInstance().getUserName(); - String password = AuthorizationConfigurationManager.getInstance().getPassword(); - apiApplicationRegistrationService = Feign.builder().client(getSSLClient()).logger(new Slf4jLogger()).logLevel( - Logger.Level.FULL).requestInterceptor(new BasicAuthRequestInterceptor(username, password)) - .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) - .target(ApiApplicationRegistrationService.class, - AuthorizationConfigurationManager.getInstance().getServerURL() + - API_APPLICATION_REGISTRATION_CONTEXT); - AuthorizationDataHolder.getInstance().setApiApplicationRegistrationService(apiApplicationRegistrationService); - - } - - /** - * Api create. - * - * @param template {@link RequestTemplate} object - */ - @Override - public void apply(RequestTemplate template) { - if (tokenInfo == null) { - if (apiApplicationKey == null) { - ApiRegistrationProfile apiRegistrationProfile = new ApiRegistrationProfile(); - apiRegistrationProfile.setApplicationName(APPLICATION_NAME); - apiRegistrationProfile.setIsAllowedToAllDomains(false); - apiRegistrationProfile.setIsMappingAnExistingOAuthApp(false); - apiRegistrationProfile.setTags(DEVICE_MANAGEMENT_SERVICE_TAG); - apiApplicationKey = apiApplicationRegistrationService.register(apiRegistrationProfile); - } - String consumerKey = apiApplicationKey.getConsumerKey(); - String consumerSecret = apiApplicationKey.getConsumerSecret(); - String username = AuthorizationConfigurationManager.getInstance().getUserName(); - String password = AuthorizationConfigurationManager.getInstance().getPassword(); - if (tokenIssuerService == null) { - tokenIssuerService = Feign.builder().client(getSSLClient()).logger(new Slf4jLogger()).logLevel( - Logger.Level.FULL) - .requestInterceptor(new BasicAuthRequestInterceptor(consumerKey, consumerSecret)) - .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) - .target(TokenIssuerService.class, - AuthorizationConfigurationManager.getInstance().getTokenApiURL()); - } - tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password); - tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in()); - } else { - synchronized (this) { - if (System.currentTimeMillis() + Long.parseLong(refreshTimeOffset) > tokenInfo.getExpires_in()) { - try { - tokenInfo = tokenIssuerService.getToken(REFRESH_GRANT_TYPE, tokenInfo.getRefresh_token()); - tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in()); - } catch (FeignException e) { - tokenInfo = null; - apply(template); - } - } - } - } - String headerValue = Constants.RestConstants.BEARER + tokenInfo.getAccess_token(); - template.header(Constants.RestConstants.AUTHORIZATION, headerValue); - } - - public static Client getSSLClient() { - boolean isIgnoreHostnameVerification = Boolean.parseBoolean(System.getProperty("org.wso2.ignoreHostnameVerification")); - if(isIgnoreHostnameVerification) { - return new Client.Default(getSimpleTrustedSSLSocketFactory(), new HostnameVerifier() { - @Override - public boolean verify(String s, SSLSession sslSession) { - return true; - } - }); - }else { - return new Client.Default(getTrustedSSLSocketFactory(), null); - } - } - - private static SSLSocketFactory getSimpleTrustedSSLSocketFactory() { - try { - TrustManager[] trustAllCerts = new TrustManager[]{ - new X509TrustManager() { - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return null; - } - public void checkClientTrusted( - java.security.cert.X509Certificate[] certs, String authType) { - } - public void checkServerTrusted( - java.security.cert.X509Certificate[] certs, String authType) { - } - } - }; - SSLContext sc = SSLContext.getInstance("SSL"); - sc.init(null, trustAllCerts, new java.security.SecureRandom()); - return sc.getSocketFactory(); - } catch (KeyManagementException | NoSuchAlgorithmException e) { - return null; - } - } - - //FIXME - I know hard-cording values is a bad practice , this code is repeating in - // several class, so this hard-coding strings will be removed once this code block is moved into a central location - // this should be done after the 3.1.0 release. - private static SSLSocketFactory getTrustedSSLSocketFactory() { - try { - String keyStorePassword = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Password"); - String keyStoreLocation = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Location"); - String trustStorePassword = ServerConfiguration.getInstance().getFirstProperty( - "Security.TrustStore.Password"); - String trustStoreLocation = ServerConfiguration.getInstance().getFirstProperty( - "Security.TrustStore.Location"); - - KeyStore keyStore = loadKeyStore(keyStoreLocation,keyStorePassword,"JKS"); - KeyStore trustStore = loadTrustStore(trustStoreLocation,trustStorePassword); - return initSSLConnection(keyStore,keyStorePassword,trustStore); - } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException - |CertificateException | IOException | UnrecoverableKeyException e) { - log.error("Error while creating the SSL socket factory due to "+e.getMessage(),e); - return null; - } - } - - private static SSLSocketFactory initSSLConnection(KeyStore keyStore,String keyStorePassword,KeyStore trustStore) throws NoSuchAlgorithmException, UnrecoverableKeyException, - KeyStoreException, KeyManagementException { - KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("SunX509"); - keyManagerFactory.init(keyStore, keyStorePassword.toCharArray()); - TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance("SunX509"); - trustManagerFactory.init(trustStore); - - // Create and initialize SSLContext for HTTPS communication - SSLContext sslContext = SSLContext.getInstance("SSLv3"); - sslContext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null); - SSLContext.setDefault(sslContext); - return sslContext.getSocketFactory(); - } - - private static KeyStore loadKeyStore(String keyStorePath, String ksPassword, String type) - throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException { - InputStream fileInputStream = null; - try { - char[] keypassChar = ksPassword.toCharArray(); - KeyStore keyStore = KeyStore.getInstance(type); - fileInputStream = new FileInputStream(keyStorePath); - keyStore.load(fileInputStream, keypassChar); - return keyStore; - } finally { - if (fileInputStream != null) { - fileInputStream.close(); - } - } - } - - private static KeyStore loadTrustStore(String trustStorePath, String tsPassword) - throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException { - - return loadKeyStore(trustStorePath,tsPassword,"JKS"); - } - -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/AccessTokenInfo.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/AccessTokenInfo.java deleted file mode 100755 index f315ae116..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/AccessTokenInfo.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.appmgt.mdm.restconnector.authorization.client.dto; - -/** - * This hold access token info that returned from the api call. - */ -public class AccessTokenInfo { - public String token_type; - public long expires_in; - public String refresh_token; - public String access_token; - - public String getToken_type() { - return token_type; - } - - public void setToken_type(String token_type) { - this.token_type = token_type; - } - - public long getExpires_in() { - return expires_in; - } - - public void setExpires_in(long expires_in) { - this.expires_in = expires_in; - } - - public String getRefresh_token() { - return refresh_token; - } - - public void setRefresh_token(String refresh_token) { - this.refresh_token = refresh_token; - } - - public String getAccess_token() { - return access_token; - } - - public void setAccess_token(String access_token) { - this.access_token = access_token; - } -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/Activity.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/Activity.java deleted file mode 100644 index b373a1c63..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/Activity.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto; - - -public class Activity { - - public enum Type { - CONFIG, MESSAGE, INFO, COMMAND, PROFILE, POLICY - } - private String activityId; - private String code; - private Type type; - private String createdTimeStamp; - - public String getActivityId() { - return activityId; - } - - public void setActivityId(String activityId) { - this.activityId = activityId; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public Type getType() { - return type; - } - - public void setType(Type type) { - this.type = type; - } - - public String getCreatedTimeStamp() { - return createdTimeStamp; - } - - public void setCreatedTimeStamp(String createdTimeStamp) { - this.createdTimeStamp = createdTimeStamp; - } -} - diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApiApplicationKey.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApiApplicationKey.java deleted file mode 100644 index 0c34147e2..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApiApplicationKey.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.appmgt.mdm.restconnector.authorization.client.dto; - -/** - * This holds api application consumer key and secret. - */ -public class ApiApplicationKey { - private String client_id; - private String client_secret; - - public String getConsumerKey() { - return this.client_id; - } - - public void setClient_id(String consumerKey) { - this.client_id = consumerKey; - } - - public String getConsumerSecret() { - return this.client_secret; - } - - public void setClient_secret(String consumerSecret) { - this.client_secret = consumerSecret; - } -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApiApplicationRegistrationService.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApiApplicationRegistrationService.java deleted file mode 100755 index 65f5db187..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApiApplicationRegistrationService.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.appmgt.mdm.restconnector.authorization.client.dto; - -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -/** - * This is the application registration service that exposed for apimApplicationRegistration. - */ - -@Path("/register") -public interface ApiApplicationRegistrationService { - - /** - * This method is used to register api application. - * - * @param registrationProfile contains the necessary attributes that are needed in order to register an app - */ - @POST - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - ApiApplicationKey register(ApiRegistrationProfile registrationProfile); -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApiRegistrationProfile.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApiRegistrationProfile.java deleted file mode 100755 index 15179e1a9..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApiRegistrationProfile.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.appmgt.mdm.restconnector.authorization.client.dto; - - -/** - * This class represents the data that are required to register the oauth application. - */ -public class ApiRegistrationProfile { - public String applicationName; - public String tags[]; - public boolean isAllowedToAllDomains; - public String consumerKey; - public String consumerSecret; - public boolean isMappingAnExistingOAuthApp; - - public String getApplicationName() { - return applicationName; - } - - public void setApplicationName(String applicationName) { - this.applicationName = applicationName; - } - - public String[] getTags() { - return tags; - } - - public void setTags(String[] tags) { - this.tags = tags; - } - - public boolean isAllowedToAllDomains() { - return isAllowedToAllDomains; - } - - public void setIsAllowedToAllDomains(boolean isAllowedToAllDomains) { - this.isAllowedToAllDomains = isAllowedToAllDomains; - } - - public boolean isMappingAnExistingOAuthApp() { - return isMappingAnExistingOAuthApp; - } - - public void setIsMappingAnExistingOAuthApp(boolean isMappingAnExistingOAuthApp) { - this.isMappingAnExistingOAuthApp = isMappingAnExistingOAuthApp; - } - - public String getConsumerKey() { - return consumerKey; - } - - public void setConsumerKey(String consumerKey) { - this.consumerKey = consumerKey; - } - - public String getConsumerSecret() { - return consumerSecret; - } - - public void setConsumerSecret(String consumerSecret) { - this.consumerSecret = consumerSecret; - } -} \ No newline at end of file diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApplicationManagementAdminService.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApplicationManagementAdminService.java deleted file mode 100644 index e48e8e5c1..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApplicationManagementAdminService.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.appmgt.mdm.restconnector.authorization.client.dto; - - -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -@Path("/admin/applications") - -/** - * This interface provided the definition of the application management service. - */ -public interface ApplicationManagementAdminService { - - /** - * Install application. - * - * @param applicationWrapper {@link ApplicationWrapper} object - * @return {@link Activity} object - */ - @POST - @Path("/install-application") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - Activity installApplication(ApplicationWrapper applicationWrapper); - - /** - * Uninstall application. - * - * @param applicationWrapper {@link ApplicationWrapper} object - * @return {@link Activity} object - */ - @POST - @Path("/uninstall-application") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - Activity uninstallApplication(ApplicationWrapper applicationWrapper); -} \ No newline at end of file diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApplicationWrapper.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApplicationWrapper.java deleted file mode 100644 index 4e0d497d1..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/ApplicationWrapper.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.appmgt.mdm.restconnector.authorization.client.dto; - -import org.wso2.carbon.appmgt.mobile.beans.DeviceIdentifier; - -import java.util.List; - -/** - * This DTO class is used to send application details and devices details to installation/uninstallation service. - */ -public class ApplicationWrapper { - private List userNameList; - private List roleNameList; - private List deviceIdentifiers; - private MobileApp application; - - public List getUserNameList() { - return userNameList; - } - - public void setUserNameList(List userNameList) { - this.userNameList = userNameList; - } - - public List getDeviceIdentifiers() { - return deviceIdentifiers; - } - - public void setDeviceIdentifiers( - List deviceIdentifiers) { - this.deviceIdentifiers = deviceIdentifiers; - } - - public List getRoleNameList() { - return roleNameList; - } - - public void setRoleNameList(List roleNameList) { - this.roleNameList = roleNameList; - } - - public MobileApp getApplication() { - return application; - } - - public void setApplication(MobileApp application) { - this.application = application; - } -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/Device.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/Device.java deleted file mode 100644 index 96af8865a..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/Device.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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.appmgt.mdm.restconnector.authorization.client.dto; - -import java.io.Serializable; - -/** - * The DTO class of device. - */ -public class Device implements Serializable { - private static final long serialVersionUID = 1998101711L; - private int id; - private String name; - private String type; - private String description; - private String deviceIdentifier; - private EnrolmentInfo enrolmentInfo; - - public Device() { - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getDeviceIdentifier() { - return deviceIdentifier; - } - - public void setDeviceIdentifier(String deviceIdentifier) { - this.deviceIdentifier = deviceIdentifier; - } - - public EnrolmentInfo getEnrolmentInfo() { - return enrolmentInfo; - } - - public void setEnrolmentInfo(EnrolmentInfo enrolmentInfo) { - this.enrolmentInfo = enrolmentInfo; - } - - public static class Property { - - private String name; - private String value; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - } - - @Override - public String toString() { - return "device [" + - "name=" + name + ";" + - "type=" + type + ";" + - "description=" + description + ";" + - "identifier=" + deviceIdentifier + ";" + - "EnrolmentInfo[" + - "owner=" + enrolmentInfo.getOwner() + ";" + - "ownership=" + enrolmentInfo.getOwnership() + ";" + - "status=" + enrolmentInfo.getStatus() + ";" + - "]" + - "]"; - } -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/DeviceList.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/DeviceList.java deleted file mode 100644 index 6470910c2..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/DeviceList.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.appmgt.mdm.restconnector.authorization.client.dto; - -import java.util.ArrayList; -import java.util.List; - -public class DeviceList { - private List devices = new ArrayList<>(); - private int count; - - public int getCount() { - return count; - } - - public void setCount(int count) { - this.count = count; - } - - public List getList() { - return devices; - } - - public void setList(List devices) { - this.devices = devices; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("{\n"); - - sb.append(" count: ").append(getCount()).append(",\n"); - sb.append(" devices: [").append(devices).append("\n"); - sb.append("]}\n"); - return sb.toString(); - } -} \ No newline at end of file diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/DeviceManagementAdminService.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/DeviceManagementAdminService.java deleted file mode 100644 index 0bed67b3a..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/DeviceManagementAdminService.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.appmgt.mdm.restconnector.authorization.client.dto; - - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - - -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -@Path("/devices") - -/** - * This interface provided the definition of the device management service. - */ -public interface DeviceManagementAdminService { - /** - * Get devices. - * - * @param user Username - * @param role Role of the user - * @return {@link DeviceList} object - */ - @GET - @Produces(MediaType.APPLICATION_JSON) - DeviceList getDevices(@QueryParam("user") String user, @QueryParam("role") String role); -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/EnrolmentInfo.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/EnrolmentInfo.java deleted file mode 100644 index 66cd08304..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/EnrolmentInfo.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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.appmgt.mdm.restconnector.authorization.client.dto; - -import java.io.Serializable; - -/** - * The DTO class for enrollment information. - */ -public class EnrolmentInfo implements Serializable { - private static final long serialVersionUID = 1998101712L; - - public enum Status { - CREATED, ACTIVE, INACTIVE, UNREACHABLE, UNCLAIMED, SUSPENDED, BLOCKED, REMOVED, DISENROLLMENT_REQUESTED - } - - public enum OwnerShip { - BYOD, COPE - } - - private int id; - private OwnerShip ownership; - private Status status; - private String owner; - private Long dateOfEnrolment; - private Long dateOfLastUpdate; - - public EnrolmentInfo() { - } - - public EnrolmentInfo(String owner, OwnerShip ownership, Status status) { - this.owner = owner; - this.ownership = ownership; - this.status = status; - } - - public Long getDateOfEnrolment() { - return dateOfEnrolment; - } - - public void setDateOfEnrolment(Long dateOfEnrolment) { - this.dateOfEnrolment = dateOfEnrolment; - } - - public Long getDateOfLastUpdate() { - return dateOfLastUpdate; - } - - public void setDateOfLastUpdate(Long dateOfLastUpdate) { - this.dateOfLastUpdate = dateOfLastUpdate; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - - public OwnerShip getOwnership() { - return ownership; - } - - public void setOwnership(OwnerShip ownership) { - this.ownership = ownership; - } - - public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } - - public String getOwner() { - return owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof EnrolmentInfo) { - EnrolmentInfo tempInfo = (EnrolmentInfo) obj; - if (this.owner != null && this.ownership != null) { - if (this.owner.equals(tempInfo.getOwner()) && this.ownership.equals(tempInfo.getOwnership())) { - return true; - } - } - } - return false; - } - - @Override - public int hashCode() { - return owner.hashCode() ^ ownership.hashCode(); - } -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/MobileApp.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/MobileApp.java deleted file mode 100644 index 18a7b853f..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/MobileApp.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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.appmgt.mdm.restconnector.authorization.client.dto; - -import java.util.Properties; - -/** - * This class represents the generic mobile Application information which is used by AppM. - */ -public class MobileApp { - - private String id; - private String name; - private MobileAppTypes type; - private String platform; - private String version; - private String identifier; - private String iconImage; - private String packageName; - private String appIdentifier; - private String location; - private Properties properties; - - public MobileAppTypes getType() { - return type; - } - - public void setType(MobileAppTypes type) { - this.type = type; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getPlatform() { - return platform; - } - - public void setPlatform(String platform) { - this.platform = platform; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getIdentifier() { - return identifier; - } - - public void setIdentifier(String identifier) { - this.identifier = identifier; - } - - public String getIconImage() { - return iconImage; - } - - public void setIconImage(String iconImage) { - this.iconImage = iconImage; - } - - public String getPackageName() { - return packageName; - } - - public void setPackageName(String packageName) { - this.packageName = packageName; - } - - public String getAppIdentifier() { - return appIdentifier; - } - - public void setAppIdentifier(String appIdentifier) { - this.appIdentifier = appIdentifier; - } - - public String getLocation() { - return location; - } - - public void setLocation(String location) { - this.location = location; - } - - public Properties getProperties() { - return properties; - } - - public void setProperties(Properties properties) { - this.properties = properties; - } -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/MobileAppTypes.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/MobileAppTypes.java deleted file mode 100644 index f3127ab25..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/MobileAppTypes.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.appmgt.mdm.restconnector.authorization.client.dto; - -/** - * This enum contains the mobile app types. - */ -public enum MobileAppTypes { - ENTERPRISE, WEBAPP, PUBLIC -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/TokenIssuerService.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/TokenIssuerService.java deleted file mode 100755 index 81e44bb2c..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/authorization/client/dto/TokenIssuerService.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.appmgt.mdm.restconnector.authorization.client.dto; - -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -/** - * This hold the api definition that is used as a contract with netflix feign. - */ -@Path("/token") -public interface TokenIssuerService { - - /** - * Get a token for password grant type. - * @param grant Token grant type - * @param username Username - * @param password Password - * @return {@link AccessTokenInfo} object - */ - @POST - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_FORM_URLENCODED) - AccessTokenInfo getToken(@QueryParam("grant_type") String grant, @QueryParam("username") String username, - @QueryParam("password") String password); - - /** - * Get a token for refresh grant type. - * @param grant Token grant type - * @param refreshToken Refresh token - * @return {@link AccessTokenInfo} object - */ - @POST - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_FORM_URLENCODED) - AccessTokenInfo getToken(@QueryParam("grant_type") String grant, @QueryParam("refreshToken") String refreshToken); -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/config/AuthorizationConfigurationManager.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/config/AuthorizationConfigurationManager.java deleted file mode 100644 index 707ef50fa..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/config/AuthorizationConfigurationManager.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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.appmgt.mdm.restconnector.config; - -import org.wso2.carbon.appmgt.mdm.restconnector.Constants; -import org.wso2.carbon.appmgt.mobile.utils.MobileConfigurations; - -import java.util.HashMap; - -/** - * The DTO class to AuthorizationConfigurationManager. - */ -public class AuthorizationConfigurationManager { - private String tokenApiURL; - private String imageURL; - private String serverURL; - private String userName; - private String password; - private String tokenRefreshTimeOffset; - - private static AuthorizationConfigurationManager authorizationConfigurationManager = new - AuthorizationConfigurationManager(); - - private AuthorizationConfigurationManager() { - MobileConfigurations configurations = MobileConfigurations.getInstance(); - HashMap configProperties = configurations.getActiveMDMProperties(); - setTokenApiURL(configProperties.get(Constants.PROPERTY_TOKEN_API_URL)); - setImageURL(configProperties.get(Constants.PROPERTY_IMAGE_URL)); - setServerURL(configProperties.get(Constants.PROPERTY_SERVER_URL)); - setUserName(configProperties.get(Constants.PROPERTY_USERNAME)); - setPassword(configProperties.get(Constants.PROPERTY_PASSWORD)); - setTokenRefreshTimeOffset(configProperties.get(Constants.PROPERTY_TOKEN_REFRESH_TIME_OFFSET)); - } - - public static AuthorizationConfigurationManager getInstance() { - return authorizationConfigurationManager; - } - - public String getTokenApiURL() { - return tokenApiURL; - } - - public void setTokenApiURL(String tokenApiURL) { - this.tokenApiURL = tokenApiURL; - } - - public String getImageURL() { - return imageURL; - } - - public void setImageURL(String imageURL) { - this.imageURL = imageURL; - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getServerURL() { - return serverURL; - } - - public void setServerURL(String serverURL) { - this.serverURL = serverURL; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public static AuthorizationConfigurationManager getAuthorizationConfigurationManager() { - return authorizationConfigurationManager; - } - - public static void setAuthorizationConfigurationManager( - AuthorizationConfigurationManager authorizationConfigurationManager) { - AuthorizationConfigurationManager.authorizationConfigurationManager = authorizationConfigurationManager; - } - - public String getTokenRefreshTimeOffset() { - return tokenRefreshTimeOffset; - } - - public void setTokenRefreshTimeOffset(String tokenRefreshTimeOffset) { - this.tokenRefreshTimeOffset = tokenRefreshTimeOffset; - } -} \ No newline at end of file diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/internal/AuthorizationDataHolder.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/internal/AuthorizationDataHolder.java deleted file mode 100644 index 15a53b7ff..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/internal/AuthorizationDataHolder.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.appmgt.mdm.restconnector.internal; - -import org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto.ApiApplicationRegistrationService; - -public class AuthorizationDataHolder { - private static AuthorizationDataHolder thisInstance = new AuthorizationDataHolder(); - - private ApiApplicationRegistrationService apiApplicationRegistrationService; - - private AuthorizationDataHolder() { - } - - public static AuthorizationDataHolder getInstance() { - return thisInstance; - } - - public ApiApplicationRegistrationService getApiApplicationRegistrationService() { - return apiApplicationRegistrationService; - } - - public void setApiApplicationRegistrationService( - ApiApplicationRegistrationService apiApplicationRegistrationService) { - this.apiApplicationRegistrationService = apiApplicationRegistrationService; - } -} diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/internal/MDMComponent.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/internal/MDMComponent.java deleted file mode 100644 index 2c1e6b2f1..000000000 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/src/main/java/org/wso2/carbon/appmgt/mdm/restconnector/internal/MDMComponent.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * 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.appmgt.mdm.restconnector.internal; - -import org.apache.commons.logging.Log; -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.appmgt.mdm.restconnector.ApplicationOperationsImpl; -import org.wso2.carbon.appmgt.mobile.interfaces.ApplicationOperations; - -/** - * @scr.component name="org.wso2.carbon.appmgt.mdm.restconnector" immediate="true" - */ -public class MDMComponent { - private static final Log log = LogFactory.getLog(MDMComponent.class); - private ServiceRegistration mdmServiceRegistration; - - protected void activate(ComponentContext context) { - BundleContext bundleContext = context.getBundleContext(); - mdmServiceRegistration = bundleContext.registerService(ApplicationOperations.class.getName(), new - ApplicationOperationsImpl(), null); - if (log.isDebugEnabled()) { - log.debug("WSO2MDM MDM Component activated."); - } - } - - protected void deactivate(ComponentContext context) { - if (mdmServiceRegistration != null) { - mdmServiceRegistration.unregister(); - mdmServiceRegistration = null; - } - if (log.isDebugEnabled()) { - log.debug("WSO2MDM MDM Component deactivated"); - } - } -} diff --git a/components/extensions/appm-connector/pom.xml b/components/extensions/appm-connector/pom.xml deleted file mode 100644 index 2df21e3be..000000000 --- a/components/extensions/appm-connector/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - org.wso2.carbon.devicemgt-plugins - extensions - 5.0.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - appm-connector - pom - WSO2 Carbon - IoT Base Plugin - http://wso2.org - - - org.wso2.carbon.appmgt.mdm.osgiconnector - org.wso2.carbon.appmgt.mdm.restconnector - - - - - - - org.apache.felix - maven-scr-plugin - 1.7.2 - - - generate-scr-scrdescriptor - - scr - - - - - - - - - diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/pom.xml b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/pom.xml index 66b9e579e..769c40f4c 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/pom.xml +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/pom.xml @@ -80,6 +80,10 @@ org.wso2.carbon.devicemgt org.wso2.carbon.identity.jwt.client.extension + + org.wso2.carbon + org.wso2.carbon.user.api + diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/pom.xml b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/pom.xml index 288ecd5da..47db0fcda 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/pom.xml +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/pom.xml @@ -54,6 +54,14 @@ org.wso2.carbon.devicemgt org.wso2.carbon.identity.jwt.client.extension + + org.wso2.carbon + org.wso2.carbon.user.api + + + com.googlecode.json-simple.wso2 + json-simple + diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/pom.xml b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/pom.xml index b79703d11..358c6f9b3 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/pom.xml +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/pom.xml @@ -69,6 +69,10 @@ org.wso2.carbon.devicemgt org.wso2.carbon.identity.jwt.client.extension + + org.wso2.carbon + org.wso2.carbon.user.api + diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/pom.xml b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/pom.xml index 60db01140..e453d1308 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/pom.xml +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/pom.xml @@ -28,7 +28,7 @@ org.wso2.carbon.device.mgt.output.adapter.xmpp bundle - WSO2 Carbon - Device Mgt Output MQTT Adaptor Module + WSO2 Carbon - Device Mgt Output XMPP Adaptor Module org.wso2.carbon.device.mgt.output.adapter.xmpp provides the back-end functionality of xmpp adaptor http://wso2.org diff --git a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/pom.xml b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/pom.xml index aed965538..f67e1894c 100644 --- a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/pom.xml +++ b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/pom.xml @@ -327,6 +327,18 @@ + + org.wso2.carbon + org.wso2.carbon.user.api + + + org.wso2.carbon + org.wso2.carbon.user.core + + + org.apache.axis2.wso2 + axis2 + diff --git a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/jaxrs/util/MQTTMgtAPIUtils.java b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/jaxrs/util/MQTTMgtAPIUtils.java index 725c79450..53f999a7b 100644 --- a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/jaxrs/util/MQTTMgtAPIUtils.java +++ b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/jaxrs/util/MQTTMgtAPIUtils.java @@ -22,8 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; -//import org.wso2.carbon.device.mgt.analytics.dashboard.GadgetDataService; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.user.api.AuthorizationManager; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; diff --git a/components/extensions/pom.xml b/components/extensions/pom.xml index 60ed286fc..8cbeb99e9 100644 --- a/components/extensions/pom.xml +++ b/components/extensions/pom.xml @@ -33,7 +33,6 @@ http://wso2.org - appm-connector cdmf-transport-adapters mb-extensions siddhi-extensions diff --git a/components/extensions/pull-notification-listeners/org.wso2.carbon.device.mgt.mqtt.notification.listener/pom.xml b/components/extensions/pull-notification-listeners/org.wso2.carbon.device.mgt.mqtt.notification.listener/pom.xml index c57509397..4cab89226 100644 --- a/components/extensions/pull-notification-listeners/org.wso2.carbon.device.mgt.mqtt.notification.listener/pom.xml +++ b/components/extensions/pull-notification-listeners/org.wso2.carbon.device.mgt.mqtt.notification.listener/pom.xml @@ -63,6 +63,10 @@ org.wso2.carbon.devicemgt-plugins org.wso2.carbon.device.mgt.input.adapter.extension + + org.wso2.carbon + org.wso2.carbon.user.api + diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/pom.xml b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/pom.xml index bfc0929b1..8c95ffe2b 100644 --- a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/pom.xml +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/pom.xml @@ -54,6 +54,22 @@ org.json.wso2 json + + org.wso2.carbon + org.wso2.carbon.utils + + + org.wso2.carbon + org.wso2.carbon.core + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.common + + + javax.websocket + javax.websocket-api + +
+ +

+

+ Android For Work Configurations +
+

+

+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+ +
+
+ +

+

+ Unenroll from EMM +

+
+ + +
+ +
+
+
+
+

Do you really want to unenroll? This cannot be undone.

+ + +
+
+
+
+
+ diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.platform.configuration/public/js/platform-configuration.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.platform.configuration/public/js/platform-configuration.js index 0faae04ee..48069ebec 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.platform.configuration/public/js/platform-configuration.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.platform.configuration/public/js/platform-configuration.js @@ -92,6 +92,16 @@ var kioskConfigs = { "serverIP" : "android.app.extra.serverIp" }; +function getParameterByName(name, url) { + if (!url) url = window.location.href; + name = name.replace(/[\[\]]/g, '\\$&'); + var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), + results = regex.exec(url); + if (!results) return null; + if (!results[2]) return ''; + return decodeURIComponent(results[2].replace(/\+/g, ' ')); +} + $(document).ready(function () { $("#fcm-inputs").hide(); tinymce.init({ @@ -109,6 +119,12 @@ $(document).ready(function () { var androidConfigAPI = "/api/device-mgt/android/v1.0/configuration"; + var enterpriseSuccess = getParameterByName('enterprise-success'); + if (enterpriseSuccess) { + $("#config-save-form").addClass("hidden"); + $("#record-created-msg").removeClass("hidden"); + } + /** * Following requests would execute * on page load event of platform configuration page in WSO2 EMM Console. @@ -152,11 +168,16 @@ $(document).ready(function () { $("input#android-kiosk-config-download-url").val(config.value); } else if (config.name === kioskConfigs["skipEncryption"]) { $("#android-kiosk-config-encryption").val(config.value); + } else if (config.name === "esa") { + $("#afw-esa").val(config.value); + } else if (config.name === "enterpriseId") { + $("#afw-enterprise-id").val(config.value); } else if (config.name === kioskConfigs["defaultOwnership"]) { $("#android-kiosk-config-defaultOwner").val(config.value); } else if (config.name === kioskConfigs["serverIP"]) { $("#android-kiosk-config-server-ip").val(config.value); } + } } }, function (data) { @@ -191,6 +212,8 @@ $(document).ready(function () { var androidLicense = tinyMCE.activeEditor.getContent(); var errorMsgWrapper = "#android-config-error-msg"; var errorMsg = "#android-config-error-msg span"; + var esa = $("input#afw-esa").val(); + var enterpriseId = $("input#afw-enterprise-id").val(); // KIOSK configs var adminComponentName = $("input#android-kiosk-config-admin-component").val(); @@ -289,6 +312,18 @@ $(document).ready(function () { "contentType": "text" }; + var esa = { + "name": "esa", + "value": esa, + "contentType": "text" + }; + + var enterpriseId = { + "name": "enterpriseId", + "value": enterpriseId, + "contentType": "text" + }; + var kioskDefaultOwner = { "name": kioskConfigs["defaultOwnership"], "value": defaultOwner, @@ -312,6 +347,8 @@ $(document).ready(function () { configList.push(kioskWifiSSID); configList.push(kioskWifiPassword); configList.push(kioskWifiSecurity); + configList.push(esa); + configList.push(enterpriseId); configList.push(kioskDefaultOwner); configList.push(kioskServerIp); @@ -341,8 +378,136 @@ $(document).ready(function () { $(errorMsg).text("An unexpected error occurred."); } $(errorMsgWrapper).removeClass("hidden"); + $(window).scrollTop(0); } ); } }); -}); \ No newline at end of file + + function getSignupUrl(serverUrl, emmToken) { + + var appContext = window.location.href;// mgt:9443 call to jaggery API + var tokenURL = appContext.replace("platform-configuration", "api/enterprise/token"); + var callbackURL = appContext.replace("platform-configuration", "api/enterprise/enroll-complete"); + + var requestData = {}; + requestData.externalToken = emmToken; + requestData.endpoint = serverUrl + "/api/android-for-work/v1.0/google/enterprise/signup-url"; + requestData.callbackURL = callbackURL; + + $.ajax({ + type: "POST", + url: tokenURL, + data: JSON.stringify(requestData), + contentType: "application/json", + success: function(response) { + window.location.replace(response.signupURL); + }, + error: function(data) { + var errorMsgWrapper = "#android-config-error-msg"; + var errorMsg = "#android-config-error-msg span"; + if (data.status == 500) { + $(errorMsg).text("Exception occurred at backend."); + } else if (data.status == 403) { + $(errorMsg).text("Action was not permitted."); + } else { + $(errorMsg).text("An unexpected error occurred."); + } + $(errorMsgWrapper).removeClass("hidden"); + $(window).scrollTop(0); + }, + dataType: 'json' + }); + } + + $("button#afw-configure").click(function() { + var serverDetails = $("input#afw-server-details").val(); + var emmToken = $("input#afw-backend-token").val(); + getSignupUrl(serverDetails, emmToken) + }); + + + var modalPopup = ".modal"; + var modalPopupContainer = modalPopup + " .modal-content"; + var modalPopupContent = modalPopup + " .modal-content"; + var body = "body"; + + function unenroll(serverUrl, emmToken) { + + var appContext = window.location.href; + var unenrollURL = appContext.replace("platform-configuration", "api/enterprise/unenroll"); + + var requestData = {}; + requestData.externalToken = emmToken; + requestData.endpoint = serverUrl; + + $.ajax({ + type: "PUT", + url: unenrollURL, + data: JSON.stringify(requestData), + contentType: "application/json", + success: function(response) { + $("input#afw-server-details").val("") ; + $("input#afw-backend-token").val(""); + $("input#afw-esa").val(""); + $("input#afw-enterprise-id").val(""); + }, + error: function(data) { + var errorMsgWrapper = "#android-config-error-msg"; + var errorMsg = "#android-config-error-msg span"; + if (data.status == 200) { + $(errorMsg).text("hari."); + } + else if (data.status == 500) { + $(errorMsg).text("Exception occurred at backend."); + } else if (data.status == 403) { + $(errorMsg).text("Action was not permitted."); + } else { + $(errorMsg).text("An unexpected error occurred."); + } + $(errorMsgWrapper).removeClass("hidden"); + $(window).scrollTop(0); + }, + dataType: 'text' + }); + } + + + $("button#afw-unenroll").click(function() { + + $(modalPopupContent).html($('#remove-unenroll-modal-content').html()); + showPopup(); + + $("a#remove-unenroll-yes-link").click(function () { + var serverDetails = $("input#afw-server-details").val() + "/api/device-mgt/android/v1.0/enterprise/324/unenroll"; + var emmToken = $("input#afw-backend-token").val(); + unenroll(serverDetails, emmToken); + hidePopup(); + }); + + $("a#remove-unenroll-cancel-link").click(function () { + hidePopup(); + }); + + }); + + /* + * show popup function. + */ + function showPopup() { + $(modalPopup).modal('show'); + } + + /* + * hide popup function. + */ + function hidePopup() { + $(modalPopupContent).html(""); + $(modalPopupContent).removeClass("operation-data"); + $(modalPopup).modal('hide'); + $('body').removeClass('modal-open').css('padding-right', '0px'); + $('.modal-backdrop').remove(); + } + + +}); diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js index c34646467..abbbd343d 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js @@ -151,6 +151,122 @@ var inputIsValidAgainstRange = function (numberInput, min, max) { return (numberInput == min || (numberInput > min && numberInput < max) || numberInput == max); }; +var enrollmentAppInstallClick = function (input) { + if (input.checked) { + $("div#install-app-enrollment").find("input").filterByData("child-key", "installGooglePolicy").filterByData + ("app-id", + input.getAttribute("data-app-id")).parent().parents("tr").last().find("input").each(function () { + if(!$(this).hasClass("child-input")) { + $(this).addClass("child-input"); + } + }); + } else { + var isInstallPolicyChecked = $("div#install-app-enrollment").find("input") + .filterByData("app-id", input.getAttribute("data-app-id")) + .filterByData("child-key", "installGooglePolicy").prop('checked'); + + if (!isInstallPolicyChecked) { + $("div#install-app-enrollment").find("input").filterByData("child-key", "installGooglePolicy").filterByData("app-id", + input.getAttribute("data-app-id")).parent().parents("tr").last().find + ("input").each(function () { + $(this).removeClass("child-input"); + }); + } + } +}; + +var appAvailabilityClick = function (input) { + var appAvailabilityConfigFormTitle = document.getElementById("app-availability-config-form-title"); + var isEnrollmentAppTicked = $("div#install-app-enrollment").find("input").filterByData("child-key", + "enrollmentAppInstall").filterByData("app-id", input.getAttribute("data-app-id")).prop('checked'); + if (input.checked) { + + var configureAppAvailabilityFormData = {}; + configureAppAvailabilityFormData.autoInstallMode = "autoInstallOnce"; + configureAppAvailabilityFormData.autoInstallPriority = "50"; + configureAppAvailabilityFormData.chargingStateConstraint = "chargingNotRequired"; + configureAppAvailabilityFormData.deviceIdleStateConstraint = "deviceIdleNotRequired"; + configureAppAvailabilityFormData.networkTypeConstraint = "anyNetwork"; + configureAppAvailabilityForm(configureAppAvailabilityFormData); + + var title = "Add Configurations for " + input.getAttribute("data-app-name"); + appAvailabilityConfigFormTitle.innerHTML = title; + $("input#app-install-config-save").attr("data-app-id", input.getAttribute("data-app-id")); + $("input#app-install-config-save").attr("data-package-name", input.getAttribute("data-package-name")); + $("div#app-availability-config-form").attr("hidden", false); + + } else { + $("input#app-install-config-save").attr("data-app-id", ""); + $("input#app-install-config-save").attr("data-package-name", ""); + $("div#app-availability-config-form").attr("hidden", true); + if (!isEnrollmentAppTicked) { + // Enrollment app install tick is also not present. Meaning this row is not needed. + $("div#install-app-enrollment").find("input").filterByData("child-key", + "enrollmentAppInstall").filterByData("app-id", input + .getAttribute("data-app-id")).parent().parents("tr") + .last().find("input").each(function () { + $(this).removeClass("child-input"); + }); + + } + } +}; + +var configureAppAvailabilityForm = function (input) { + $("select#app-availability-auto-install-mode").val(input.autoInstallMode).change(); + $("select#app-availability-install-priority").val(input.autoInstallPriority).change(); + $("select#app-availability-install-charging").val(input.chargingStateConstraint).change(); + $("select#app-availability-install-idle").val(input.deviceIdleStateConstraint).change(); + $("select#app-availability-install-network").val(input.networkTypeConstraint).change(); +}; + + +loadedGooglePolicyCount = 0; +var changeSavedGlobalAppConfig = function (input) { + // Adding this console log as, it is not possible to access the JS files otherwise. + console.log("This is printing from android-policy-*,js that is in accessible via source."); + $("div#install-app-enrollment").find("input").filterByData("child-key", "productSetBehavior") + .each(function () { + $(this).val($("select#product-set-behaviour").val()); + }); + $("div#install-app-enrollment").find("input").filterByData("child-key", "autoUpdatePolicy") + .each(function () { + $(this).val($("select#auto-update-policy").val()); + }); + + var behaviour = $('select#product-set-behaviour').data('product-set-behavior'); + var autoUpdatePolicy = $('select#auto-update-policy').data('auto-update-policy'); + loadedGooglePolicyCount++; + if (autoUpdatePolicy && loadedGooglePolicyCount == 2) { + $("select#auto-update-policy").val(autoUpdatePolicy).change(); + $("select#product-set-behaviour").val(behaviour).change() + } +}; + +var changeSavedAppInstallData = function (input) { + var appId = input.getAttribute("data-app-id"); + var packageName = input.getAttribute("data-package-name") + + var json = {}; + json.appId = appId; + json.packageName = packageName; + json.autoInstallMode = $("select#app-availability-auto-install-mode").val(); + json.autoInstallPriority = $("select#app-availability-install-priority").val(); + json.chargingStateConstraint = $("select#app-availability-install-charging").val(); + json.deviceIdleStateConstraint = $("select#app-availability-install-idle").val(); + json.networkTypeConstraint = $("select#app-availability-install-network").val(); + + var payload = JSON.stringify(json); + + + $("div#install-app-enrollment").find("input").filterByData("package-name", packageName).parent().find("input")[1].value = payload; + $("div#install-app-enrollment").find("input").filterByData("package-name", packageName).parent().parents("tr") + .last().find("input").each(function () { + $(this).addClass("child-input"); + }); + $("div#app-availability-config-form").attr("hidden", true); +}; + var ovpnConfigUploaded = function () { var ovpnFileInput = document.getElementById("ovpn-file"); if ('files' in ovpnFileInput) { @@ -1188,7 +1304,7 @@ var showHideHelpText = function (addFormContainer) { var applyDataTable = function() { $("#enrollment-app-install-table").datatables_extended({ ordering: false, - lengthMenu: [5, 10, 25, 50, 100] + lengthMenu: [100, 200, 500] }); }; var myFrom; @@ -1387,22 +1503,4 @@ $(document).ready(function () { setId(addFormContainer); showHideHelpText(addFormContainer); }); - - // add app entry for enrollment-app-install - $(advanceOperations).on("click", "[data-click-event=add-enrollment-app]", function () { - $(this).attr("hidden", true); - $(this).siblings("a").removeAttr("hidden"); - $(this).parent().parent().find("input").each(function () { - $(this).addClass("child-input"); - }); - }); - - // remove app entry for enrollment-app-install - $(advanceOperations).on("click", "[data-click-event=remove-enrollment-app]", function () { - $(this).attr("hidden", true); - $(this).siblings("a").removeAttr("hidden"); - $(this).parent().parent().find("input").each(function () { - $(this).removeClass("child-input"); - }); - }); }); diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/templates/android-policy-edit.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/templates/android-policy-edit.hbs index 319f06510..835ffbdee 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/templates/android-policy-edit.hbs +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/templates/android-policy-edit.hbs @@ -315,6 +315,146 @@ + + +

Passcode policy for work profile

+
+ +
+ @@ -2973,14 +3113,15 @@
+ data-key="enrollmentAppInstall" data-column-count="11"> - + + @@ -2999,18 +3140,31 @@ + {{else}} @@ -3019,10 +3173,146 @@ + {{/each}}
Application Name Type VersionAuto InstallWork Profile Availability
- + - - - - - - + + + + + + +
+ + +
+ +
+

+

Work profile global user configurations

+
+ + +
+ +
+ + +
@@ -3030,4 +3320,4 @@ - + \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-view/public/templates/android-policy-view.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-view/public/templates/android-policy-view.hbs index e2a9ab316..4fef569d6 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-view/public/templates/android-policy-view.hbs +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-view/public/templates/android-policy-view.hbs @@ -297,6 +297,144 @@ + + +

Passcode policy for work profile

+
+ +
+ @@ -3083,6 +3221,8 @@ Application Name Type Version + Auto Install + Work Profile Availability diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js index 381fa6f5d..330bdee1a 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js @@ -93,6 +93,122 @@ var inputIsValidAgainstRange = function (numberInput, min, max) { return (numberInput == min || (numberInput > min && numberInput < max) || numberInput == max); }; +var enrollmentAppInstallClick = function (input) { + if (input.checked) { + $("div#install-app-enrollment").find("input").filterByData("child-key", "installGooglePolicy").filterByData + ("app-id", + input.getAttribute("data-app-id")).parent().parents("tr").last().find("input").each(function () { + if(!$(this).hasClass("child-input")) { + $(this).addClass("child-input"); + } + }); + } else { + var isInstallPolicyChecked = $("div#install-app-enrollment").find("input") + .filterByData("app-id", input.getAttribute("data-app-id")) + .filterByData("child-key", "installGooglePolicy").prop('checked'); + + if (!isInstallPolicyChecked) { + $("div#install-app-enrollment").find("input").filterByData("child-key", "installGooglePolicy").filterByData("app-id", + input.getAttribute("data-app-id")).parent().parents("tr").last().find + ("input").each(function () { + $(this).removeClass("child-input"); + }); + } + } +}; + +var appAvailabilityClick = function (input) { + var appAvailabilityConfigFormTitle = document.getElementById("app-availability-config-form-title"); + var isEnrollmentAppTicked = $("div#install-app-enrollment").find("input").filterByData("child-key", + "enrollmentAppInstall").filterByData("app-id", input.getAttribute("data-app-id")).prop('checked'); + if (input.checked) { + + var configureAppAvailabilityFormData = {}; + configureAppAvailabilityFormData.autoInstallMode = "autoInstallOnce"; + configureAppAvailabilityFormData.autoInstallPriority = "50"; + configureAppAvailabilityFormData.chargingStateConstraint = "chargingNotRequired"; + configureAppAvailabilityFormData.deviceIdleStateConstraint = "deviceIdleNotRequired"; + configureAppAvailabilityFormData.networkTypeConstraint = "anyNetwork"; + configureAppAvailabilityForm(configureAppAvailabilityFormData); + + var title = "Add Configurations for " + input.getAttribute("data-app-name"); + appAvailabilityConfigFormTitle.innerHTML = title; + $("input#app-install-config-save").attr("data-app-id", input.getAttribute("data-app-id")); + $("input#app-install-config-save").attr("data-package-name", input.getAttribute("data-package-name")); + $("div#app-availability-config-form").attr("hidden", false); + + $("div#install-app-enrollment").find("input").filterByData("child-key", "productSetBehavior").each(function () { + if (!$(this).val()) { + $(this).val("whitelist"); + } + }); + $("div#install-app-enrollment").find("input").filterByData("child-key", "autoUpdatePolicy").each(function () { + if (!$(this).val()) { + $(this).val("wifiOnly"); + } + }); + + } else { + $("input#app-install-config-save").attr("data-app-id", ""); + $("input#app-install-config-save").attr("data-package-name", ""); + $("div#app-availability-config-form").attr("hidden", true); + if (!isEnrollmentAppTicked) { + // Enrollment app install tick is also not present. Meaning this row is not needed. + $("div#install-app-enrollment").find("input").filterByData("child-key", + "enrollmentAppInstall").filterByData("app-id", input + .getAttribute("data-app-id")).parent().parents("tr") + .last().find("input").each(function () { + $(this).removeClass("child-input"); + }); + + } + } +}; + +var configureAppAvailabilityForm = function (input) { + $("select#app-availability-auto-install-mode").val(input.autoInstallMode).change(); + $("select#app-availability-install-priority").val(input.autoInstallPriority).change(); + $("select#app-availability-install-charging").val(input.chargingStateConstraint).change(); + $("select#app-availability-install-idle").val(input.deviceIdleStateConstraint).change(); + $("select#app-availability-install-network").val(input.networkTypeConstraint).change(); +}; + +var changeSavedGlobalAppConfig = function (input) { + $("div#install-app-enrollment").find("input").filterByData("child-key", "productSetBehavior") + .each(function () { + $(this).val($("select#product-set-behaviour").val()); + }); + $("div#install-app-enrollment").find("input").filterByData("child-key", "autoUpdatePolicy") + .each(function () { + $(this).val($("select#auto-update-policy").val()); + }); +}; + +var changeSavedAppInstallData = function (input) { + var appId = input.getAttribute("data-app-id"); + var packageName = input.getAttribute("data-package-name") + + var json = {}; + json.appId = appId; + json.packageName = packageName; + json.autoInstallMode = $("select#app-availability-auto-install-mode").val(); + json.autoInstallPriority = $("select#app-availability-install-priority").val(); + json.chargingStateConstraint = $("select#app-availability-install-charging").val(); + json.deviceIdleStateConstraint = $("select#app-availability-install-idle").val(); + json.networkTypeConstraint = $("select#app-availability-install-network").val(); + + var payload = JSON.stringify(json); + + + $("div#install-app-enrollment").find("input").filterByData("package-name", packageName).parent().find("input")[1].value = payload; + $("div#install-app-enrollment").find("input").filterByData("package-name", packageName).parent().parents("tr") + .last().find("input").each(function () { + $(this).addClass("child-input"); + }); + $("div#app-availability-config-form").attr("hidden", true); +}; + + var ovpnConfigUploaded = function () { var ovpnFileInput = document.getElementById("ovpn-file"); if ('files' in ovpnFileInput) { @@ -1163,7 +1279,7 @@ var showHideHelpText = function (addFormContainer) { var applyDataTable = function() { $("#enrollment-app-install-table").datatables_extended({ ordering: false, - lengthMenu: [5, 10, 25, 50, 100] + lengthMenu: [100, 200, 500] }); }; @@ -1344,22 +1460,4 @@ $(document).ready(function () { setId(addFormContainer); showHideHelpText(addFormContainer); }); - - // add app entry for enrollment-app-install - $(advanceOperations).on("click", "[data-click-event=add-enrollment-app]", function () { - $(this).attr("hidden", true); - $(this).siblings("a").removeAttr("hidden"); - $(this).parent().parent().find("input").each(function () { - $(this).addClass("child-input"); - }); - }); - - // remove app entry for enrollment-app-install - $(advanceOperations).on("click", "[data-click-event=remove-enrollment-app]", function () { - $(this).attr("hidden", true); - $(this).siblings("a").removeAttr("hidden"); - $(this).parent().parent().find("input").each(function () { - $(this).removeClass("child-input"); - }); - }); }); diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/templates/android-policy-operations.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/templates/android-policy-operations.hbs index 9ffd23e9a..3eb127619 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/templates/android-policy-operations.hbs +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/templates/android-policy-operations.hbs @@ -323,9 +323,150 @@ + + +

Passcode policy for work profile

+
+ +
+ +
@@ -2959,6 +3100,7 @@
+
+ data-key="enrollmentAppInstall" data-column-count="11"> - - - - - - + + + + + + + {{#each storeapps}} @@ -3015,23 +3158,32 @@ {{this.type}} - + {{else}} @@ -3040,10 +3192,144 @@ + {{/each}}
Application NameTypeVersion
Application NameTypeVersionAuto InstallWork Profile Availability
+ {{this.version}} - + - - - - - - + + + + + + +
+ + +
+
+

+

Work profile global user configurations

+
+ + +
+ +
+ + +
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/private/config.json b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/private/config.json index 82394b258..17511f509 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/private/config.json +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view/private/config.json @@ -36,6 +36,7 @@ "perm:android:unlock-devices", "perm:android:control-camera", "perm:android:reboot", + "perm:android:change-LockTask", "perm:android:logcat", "perm:android:send-app-restrictions" ], @@ -74,6 +75,11 @@ "filter" : {"property" : "ownership", "value" : "COPE", "text": "This feature is only available in COPE/COSU"}, "permission": "/device-mgt/devices/owning-device/operations/android/reboot" }, + "CHANGE_LOCK_TASK_MODE": { + "icon": "fw-mobile", + "filter" : {"property" : "ownership", "value" : "COPE", "text": "This feature is only available in COSU(KIOSK)"}, + "permission": "/device-mgt/devices/owning-device/operations/android/change-LockTask" + }, "UPGRADE_FIRMWARE": { "icon": "fw-hardware", "filter" : {"property" : "ownership", "value" : "COPE", "text": "This feature is only available in COPE/COSU"}, diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/pom.xml deleted file mode 100644 index 1fd922653..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/pom.xml +++ /dev/null @@ -1,360 +0,0 @@ - - - - - - android-plugin - org.wso2.carbon.devicemgt-plugins - 5.0.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.device.mgt.mobile.android.v09.api - WSO2 Carbon - Android JAX-RS v09 API - Android JAX-RS v09 API - war - - - - - maven-compiler-plugin - - 1.8 - 1.8 - - 2.3.2 - - - maven-war-plugin - 2.2 - - WEB-INF/lib/*cxf*.jar - api#device-mgt#android#v0.9 - - - - org.jacoco - jacoco-maven-plugin - - ${basedir}/target/coverage-reports/jacoco-unit.exec - - - - jacoco-initialize - - prepare-agent - - - - jacoco-site - test - - report - - - ${basedir}/target/coverage-reports/jacoco-unit.exec - ${basedir}/target/coverage-reports/site - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - file:src/test/resources/log4j.properties - - - src/test/resources/testng.xml - - - - - - - - - deploy - - compile - - - org.apache.maven.plugins - maven-antrun-plugin - 1.7 - - - compile - - run - - - - - - - - - - - - - - - org.jacoco - jacoco-maven-plugin - - ${basedir}/target/coverage-reports/jacoco-unit.exec - - - - jacoco-initialize - - prepare-agent - - - - jacoco-site - test - - report - - - ${basedir}/target/coverage-reports/jacoco-unit.exec - ${basedir}/target/coverage-reports/site - - - - - - - - - - client - - test - - - org.codehaus.mojo - exec-maven-plugin - 1.2.1 - - - test - - java - - - - - - - - - - - - - org.apache.cxf - cxf-rt-frontend-jaxws - - - org.apache.cxf - cxf-rt-frontend-jaxrs - - - org.apache.cxf - cxf-rt-transports-http - - - javax.ws.rs - jsr311-api - provided - - - org.wso2.carbon - org.wso2.carbon.utils - provided - - - org.wso2.carbon - org.wso2.carbon.logging - provided - - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.common - provided - - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.annotations - provided - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.core - provided - - - org.slf4j - slf4j-api - - - - - org.wso2.carbon.devicemgt - org.wso2.carbon.policy.mgt.common - provided - - - org.wso2.carbon.devicemgt - org.wso2.carbon.policy.mgt.core - provided - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.mobile.android - provided - - - commons-httpclient.wso2 - commons-httpclient - provided - - - com.google.code.gson - gson - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.analytics.data.publisher - provided - - - org.slf4j - slf4j-api - - - - - org.wso2.carbon.analytics - org.wso2.carbon.analytics.api - provided - - - io.swagger - swagger-annotations - - - io.swagger - swagger-core - - - org.slf4j - slf4j-api - - - - - io.swagger - swagger-jaxrs - - - org.slf4j - slf4j-api - - - - - javax.servlet - servlet-api - provided - - - org.hibernate - hibernate-validator - - - javax.ws.rs - javax.ws.rs-api - - - org.testng - testng - test - - - org.powermock - powermock-module-testng - test - - - org.powermock - powermock-api-mockito - test - - - com.h2database.wso2 - h2-database-engine - test - - - org.wso2.carbon - org.wso2.carbon.queuing - test - - - org.wso2.carbon - org.wso2.carbon.ndatasource.core - test - - - commons-dbcp.wso2 - commons-dbcp - test - - - commons-pool.wso2 - commons-pool - test - - - org.wso2.carbon - javax.cache.wso2 - test - - - javassist - javassist - test - - - org.codehaus.jackson - jackson-core-asl - - - diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidOperation.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidOperation.java deleted file mode 100644 index 2074b62a4..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidOperation.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import com.google.gson.Gson; -/* -* This abstract class is used for extending generic functions with regard to operation. -*/ -public abstract class AndroidOperation { - - /* - * This method is used to convert operation object to a json format. - * - * @return json formatted String. - */ - public String toJSON() { - Gson gson = new Gson(); - return gson.toJson(this); - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidPlatformConfiguration.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidPlatformConfiguration.java deleted file mode 100644 index d0dd95e2e..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidPlatformConfiguration.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; -import javax.validation.constraints.Pattern; -import javax.validation.constraints.Size; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import java.io.Serializable; -import java.util.List; - -@XmlRootElement( - name = "PlatformConfiguration" -) -@XmlAccessorType(XmlAccessType.NONE) -@ApiModel( - value = "PlatformConfiguration", - description = "This class carries all the information related to Android platform configurations." -) -public class AndroidPlatformConfiguration implements Serializable { - public static final int INVALID_NOTIFIER_FREQUENCY = -1; - @XmlElement( - name = "type" - ) - @ApiModelProperty( - name = "type", - value = "type of device", - required = true - ) - @Size(min = 2, max = 10) - private String type; - @ApiModelProperty( - name = "configuration", - value = "List of Configuration Entries", - required = true - ) - @XmlElement( - name = "configuration" - ) - private List configuration; - - public AndroidPlatformConfiguration() { - } - - public String getType() { - return this.type; - } - - public void setType(String type) { - this.type = type; - } - - public List getConfiguration() { - return this.configuration; - } - - public void setConfiguration(List configuration) { - this.configuration = configuration; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AppRestriction.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AppRestriction.java deleted file mode 100644 index 8e8a88e28..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AppRestriction.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import java.io.Serializable; -import java.util.List; - -/** - * This class represents information of configuring App Restriction ex: White list and Black list - */ -@ApiModel(value = "AppRestriction", - description = "This class carries all information related to application restriction.") -public class AppRestriction extends AndroidOperation implements Serializable { - - @ApiModelProperty(name = "restrictionType", value = "Restriction type of the application.", required = true) - private String restrictionType; - @ApiModelProperty(name = "restrictedList", value = "Device id list of the operation to be executed.", required = true) - private List restrictedList; - - public String getRestrictionType() { - return restrictionType; - } - - public void setRestrictionType(String restrictionType) { - this.restrictionType = restrictionType; - } - - public List getRestrictedList() { - return restrictedList; - } - - public void setRestrictedList(List restrictedList) { - this.restrictedList = restrictedList; - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationInstallation.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationInstallation.java deleted file mode 100644 index 67048b60d..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationInstallation.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import javax.validation.constraints.Pattern; -import javax.validation.constraints.Size; -import java.io.Serializable; - -/** - * This class represents the information of install application operation. - */ -@ApiModel(value = "ApplicationInstallation", - description = "This class carries all information related to install application") -public class ApplicationInstallation extends AndroidOperation implements Serializable { - - @ApiModelProperty(name = "appIdentifier", value = "Application Identifier", required = true) - @Size(min = 2, max = 45) - @Pattern(regexp = "^[A-Za-z0-9]*$") - private String appIdentifier; - - @ApiModelProperty(name = "type", value = "Application type(Enterprise/Web/public)", required = true) - @Size(min = 2, max = 12) - @Pattern(regexp = "^[A-Za-z]*$") - private String type; - - @ApiModelProperty(name = "url", value = "Application URL", required = true) - private String url; - - @ApiModelProperty(name = "schedule", value = "Schedule of the App installation.") - private String schedule; - - public String getAppIdentifier() { - return appIdentifier; - } - - public void setAppIdentifier(String appIdentifier) { - this.appIdentifier = appIdentifier; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - @SuppressWarnings("unused") - public String getSchedule() { - return schedule; - } - - @SuppressWarnings("unused") - public void setSchedule(String schedule) { - this.schedule = schedule; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUninstallation.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUninstallation.java deleted file mode 100644 index 7207c659f..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUninstallation.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import javax.validation.constraints.Pattern; -import javax.validation.constraints.Size; -import java.io.Serializable; - -/** - * This class represents the information of uninstall application operation. - */ -@ApiModel(value = "ApplicationUninstallation", - description = "This class carries all information related to application uninstallation.") -public class ApplicationUninstallation extends AndroidOperation implements Serializable { - - @ApiModelProperty(name = "appIdentifier", value = "The package name of the application to be uninstalled.", required = true) - @Size(min = 2, max = 45) - @Pattern(regexp = "^[A-Za-z0-9]*$") - private String appIdentifier; - - @ApiModelProperty(name = "type", value = "The type of the application. The following types of applications " + - "are supported: enterprise, public and webapp.", required = true) - @Size(min = 2, max = 12) - @Pattern(regexp = "^[A-Za-z]*$") - private String type; - - public String getAppIdentifier() { - return appIdentifier; - } - - public void setAppIdentifier(String appIdentifier) { - this.appIdentifier = appIdentifier; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUpdate.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUpdate.java deleted file mode 100644 index d48689b62..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ApplicationUpdate.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import javax.validation.constraints.Pattern; -import javax.validation.constraints.Size; -import java.io.Serializable; - -/** - * This class represents the information of Update application operation. - */ -@ApiModel(value = "ApplicationUpdate", - description = "This class carries all information related to application update.") -public class ApplicationUpdate extends AndroidOperation implements Serializable { - - @ApiModelProperty(name = "appIdentifier", value = "The package name of the application " + - "to be update.", required = true) - @Size(min = 2, max = 45) - @Pattern(regexp = "^[A-Za-z0-9]*$") - private String appIdentifier; - @ApiModelProperty(name = "type", value = "The type of the application. The following types of applications " + - "are supported: enterprise, public and webapp.", required = true) - @Size(min = 2, max = 12) - @Pattern(regexp = "^[A-Za-z]*$") - private String type; - @ApiModelProperty(name = "url", value = "The URL of the application.", required = true) - private String url; - @ApiModelProperty(name = "schedule", value = "Application update schedule.", required = false) - private String schedule; - - public String getAppIdentifier() { - return appIdentifier; - } - - public void setAppIdentifier(String appIdentifier) { - this.appIdentifier = appIdentifier; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getSchedule() { - return schedule; - } - - public void setSchedule(String schedule) { - this.schedule = schedule; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/BlacklistApplications.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/BlacklistApplications.java deleted file mode 100644 index 553a6a7a6..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/BlacklistApplications.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import javax.validation.constraints.Size; -import java.io.Serializable; -import java.util.List; - -/** - * This class represents the blacklist applications information. - */ -@ApiModel(value = "BlacklistApplications", - description = "This class represents the blacklist applications information.") -public class BlacklistApplications extends AndroidOperation implements Serializable { - - @ApiModelProperty(name = "appIdentifiers", value = "A list of application package names to be blacklisted.", - required = true) - @Size(min = 1, max = 45) - private List appIdentifiers; - - public List getAppIdentifier() { - return appIdentifiers; - } - - public void setAppIdentifier(List appIdentifiers) { - this.appIdentifiers = appIdentifiers; - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Camera.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Camera.java deleted file mode 100644 index eb66b28c4..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Camera.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import java.io.Serializable; - -/** - * This class represents the information of camera operation. - */ -@ApiModel(value = "Camera", - description = "This class represents the information of camera operation.") -public class Camera extends AndroidOperation implements Serializable { - - @ApiModelProperty(name = "enabled", value = "Disable the camera on the device by assigning false as the value or " + - "enable the camera on the device to function by defining true as the value.", required = true) - private boolean enabled; - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceEncryption.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceEncryption.java deleted file mode 100644 index 43eade11b..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceEncryption.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import java.io.Serializable; - -/** - * This class represents the information of encrypt operation. - */ - -@ApiModel(value = "DeviceEncryption", - description = "Details related device encryption.") -public class DeviceEncryption extends AndroidOperation implements Serializable { - - @ApiModelProperty(name = "encrypted", value = "Whether to enable encryption or not.", required = true) - private boolean encrypted; - - public boolean isEncrypted() { - return encrypted; - } - - public void setEncrypted(boolean encrypted) { - this.encrypted = encrypted; - } -} \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceLock.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceLock.java deleted file mode 100644 index f4d67af9d..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceLock.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import java.io.Serializable; -@ApiModel(value = "DeviceLock", - description = "This class carries all information related to device lock operation.") -public class DeviceLock extends AndroidOperation implements Serializable { - - @ApiModelProperty(name = "message", value = "Pop up message of the lock operation.", required = false) - private String message; - @ApiModelProperty(name = "isHardLockEnabled", value = "Hard lock enable status of the Device", required = true) - private boolean isHardLockEnabled; - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public boolean isHardLockEnabled() { - return isHardLockEnabled; - } - - public void setHardLockEnabled(boolean hardLockEnabled) { - isHardLockEnabled = hardLockEnabled; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceState.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceState.java deleted file mode 100644 index 8a5d36a61..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DeviceState.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.codehaus.jackson.annotate.JsonIgnoreProperties; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -@XmlRootElement -/** - * Store Device state event/data for androidDevice. - */ -@ApiModel(value = "DeviceState", - description = "This class carries all information related to device state.") -@JsonIgnoreProperties(ignoreUnknown = true) -public class DeviceState { - - @XmlElementWrapper(required = true, name = "values") - @ApiModelProperty(name = "values", value = "Device and its statuses.", required = true) - private Map values; - - /** The id. */ - @XmlElement(required = false, name = "id") - @ApiModelProperty(name = "id", value = "Identification code.", required = true) - private String id; - - /** - * Gets the values. - * @return the values - */ - public Map getValues() { - return values; - } - - /** - * Sets the values. - * @param values the values - */ - public void setValues(Map values) { - this.values = values; - } - - /** - * Sets the id. - * @param id the new id - */ - public void setId(String id) { - this.id = id; - } - - /** - * Gets the id. - * @return the id - */ - public String getId() { - return id; - } - - @Override - public String toString(){ - List valueList = new ArrayList(); - for (Map.Entry entry : values.entrySet()) { - valueList.add(entry.getKey() + ":" + entry.getValue()); - } - return valueList.toString(); - - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Disenrollment.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Disenrollment.java deleted file mode 100644 index ca497ed3c..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Disenrollment.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import java.io.Serializable; - -@ApiModel(value = "Disenrollment", - description = "Details related to disenrolling a device.") -public class Disenrollment extends AndroidOperation implements Serializable { - - @ApiModelProperty(name = "enabled", value = "Whether to enable disenrollment or not.", required = true) - private boolean enabled; - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ErrorListItem.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ErrorListItem.java deleted file mode 100644 index c5e884e31..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ErrorListItem.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import javax.validation.constraints.NotNull; - -@ApiModel(description = "") -public class ErrorListItem { - - @NotNull - private String code = null; - @NotNull - private String message = null; - - @ApiModelProperty(required = true, value = "") - @JsonProperty("code") - public String getCode() { - return code; - } - public void setCode(String code) { - this.code = code; - } - - public ErrorListItem() {} - - public ErrorListItem(String code, String msg) { - this.code = code; - this.message = msg; - } - - - /** - * Description about individual errors occurred - **/ - @ApiModelProperty(required = true, value = "Description about individual errors occurred") - @JsonProperty("message") - public String getMessage() { - return message; - } - public void setMessage(String message) { - this.message = message; - } - - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("errorItem {\n"); - - sb.append(" code: ").append(code).append("\n"); - sb.append(" message: ").append(message).append("\n"); - sb.append("}\n"); - return sb.toString(); - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ErrorResponse.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ErrorResponse.java deleted file mode 100644 index 08b847445..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ErrorResponse.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import java.util.ArrayList; -import java.util.List; - -@ApiModel(description = "") -public class ErrorResponse { - - private Long code = null; - private String message = null; - private String description = null; - private String moreInfo = null; - private List errorItems = new ArrayList<>(); - - @JsonProperty(value = "code") - @ApiModelProperty(required = true, value = "") - public Long getCode() { - return code; - } - - public void setCode(Long code) { - this.code = code; - } - - @JsonProperty(value = "message") - @ApiModelProperty(required = true, value = "ErrorResponse message.") - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - @JsonProperty(value = "description") - @ApiModelProperty(value = "A detail description about the error message.") - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - @JsonProperty(value = "moreInfo") - @ApiModelProperty(value = "Preferably an url with more details about the error.") - public String getMoreInfo() { - return moreInfo; - } - - public void setMoreInfo(String moreInfo) { - this.moreInfo = moreInfo; - } - - public void addErrorListItem(ErrorListItem item) { - this.errorItems.add(item); - } - - /** - * If there are more than one error list them out. \nFor example, list out validation errors by each field. - */ - @JsonProperty(value = "errorItems") - @ApiModelProperty(value = "If there are more than one error list them out. \n" + - "For example, list out validation errors by each field.") - public List getErrorItems() { - return errorItems; - } - - public void setErrorItems(List error) { - this.errorItems = error; - } - - @Override - public String toString() { -// StringBuilder sb = new StringBuilder(); -// sb.append("{"); -// boolean cont = false; -// if (code != null) { -// cont = true; -// sb.append(" \"code\": ").append(code); -// } -// if (message != null) { -// if (cont) { -// sb.append(","); -// } -// cont = true; -// sb.append(" \"message\": \"").append(message).append("\""); -// } -// if (description != null) { -// if (cont) { -// sb.append(","); -// } -// cont = true; -// sb.append(" \"description\": ").append(description).append("\""); -// } -// if (moreInfo != null) { -// if (cont) { -// sb.append(","); -// } -// cont = true; -// sb.append(" \"moreInfo\": \"").append(moreInfo).append("\""); -// } -// if (error != null && error.size() > 0) { -// if (cont) { -// sb.append(","); -// } -// sb.append(" \"errorItems\": ").append(error); -// } -// sb.append("}"); -// return sb.toString(); - return null; - } - - public static class ErrorResponseBuilder { - - private Long code = null; - private String message = null; - private String description = null; - private String moreInfo = null; - private List error; - - - public ErrorResponseBuilder() { - this.error = new ArrayList<>(); - } - - public ErrorResponseBuilder setCode(long code) { - this.code = code; - return this; - } - - public ErrorResponseBuilder setMessage(String message) { - this.message = message; - return this; - } - - public ErrorResponseBuilder setDescription(String description) { - this.description = description; - return this; - } - - public ErrorResponseBuilder setMoreInfo(String moreInfo) { - this.moreInfo = moreInfo; - return this; - } - - public ErrorResponseBuilder addErrorItem(String code, String msg) { - ErrorListItem item = new ErrorListItem(); - item.setCode(code); - item.setMessage(msg); - this.error.add(item); - return this; - } - - public ErrorResponse build() { - ErrorResponse errorResponse = new ErrorResponse(); - errorResponse.setCode(code); - errorResponse.setMessage(message); - errorResponse.setErrorItems(error); - errorResponse.setDescription(description); - errorResponse.setMoreInfo(moreInfo); - return errorResponse; - } - } - -} - - diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/FileTransfer.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/FileTransfer.java deleted file mode 100644 index 89127f91a..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/FileTransfer.java +++ /dev/null @@ -1,77 +0,0 @@ -/* -* 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.mdm.services.android.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.AndroidOperation; - -import java.io.Serializable; - -/** - * This class represents the information of file transfer operation payload. - */ -@ApiModel(value = "FileTransfer", - description = "This class carries all information related to file transfer operation.") -public class FileTransfer extends AndroidOperation implements Serializable { - - @ApiModelProperty(name = "fileURL", value = "File URL", required = true) - private String fileURL; - - @ApiModelProperty(name = "userName", value = "User Name", required = true) - private String userName; - - @ApiModelProperty(name = "ftpPassword", value = "FTP password", required = true) - private String ftpPassword; - - @ApiModelProperty(name = "fileLocation", value = "fileLocation", required = true) - private String fileLocation; - - public String getFileURL() { - return fileURL; - } - - public void setFileURL(String fileURL) { - this.fileURL = fileURL; - } - - public String getFtpPassword() { - return ftpPassword; - } - - public void setFtpPassword(String ftpPassword) { - this.ftpPassword = ftpPassword; - } - - public String getFileLocation() { - return fileLocation; - } - - public void setFileLocation(String fileLocation) { - this.fileLocation = fileLocation; - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/LockCode.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/LockCode.java deleted file mode 100644 index 40f7d92ff..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/LockCode.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import java.io.Serializable; - -/** - * This class represents the information of changing lock code operation. - */ -@ApiModel(value = "LockCode", - description = "Details related to lock code sent on device.") -public class LockCode extends AndroidOperation implements Serializable { - - @ApiModelProperty(name = "lockCode", value = "The lock code to be sent to the device.", required = true) - private String lockCode; - - public String getLockCode() { - return lockCode; - } - - public void setLockCode(String lockCode) { - this.lockCode = lockCode; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Notification.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Notification.java deleted file mode 100644 index fe41b00c3..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Notification.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import java.io.Serializable; - -/** - * This class represents the information of sending notification operation. - */ -@ApiModel(value = "Notification", - description = "Details related to notifications passed to device.") -public class Notification extends AndroidOperation implements Serializable { - - @ApiModelProperty(name = "messageText", value = "The message text to be sent to the device.", required = true) - private String messageText; - - @ApiModelProperty(name = "messageTitle", value = "The message title to be sent to the device.", required = true) - private String messageTitle; - - public String getMessageText() { - return messageText; - } - - public void setMessageText(String messageText) { - this.messageText = messageText; - } - - public String getMessageTitle() { - return messageTitle; - } - - public void setMessageTitle(String messageTitle) { - this.messageTitle = messageTitle; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/NotifierFrequency.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/NotifierFrequency.java deleted file mode 100644 index f97f410f7..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/NotifierFrequency.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2018, 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.mdm.services.android.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import java.io.Serializable; - -@ApiModel(value = "NotifierFrequency", - description = "This class represents notification frequency configuration.") -public class NotifierFrequency extends AndroidOperation implements Serializable { - - @ApiModelProperty(name = "value", value = "Notification polling frequency", required = true) - private int value; - - public int getValue() { - return value; - } - - public void setValue(int value) { - this.value = value; - } - -} \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/PasscodePolicy.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/PasscodePolicy.java deleted file mode 100644 index 1e690fc7f..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/PasscodePolicy.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import javax.validation.constraints.Max; -import java.io.Serializable; - -/** - * This class represents the information of setting up password policy. - */ -@ApiModel(value = "PasscodePolicy", description = "This class represents the information of setting up " - + "password policy") -public class PasscodePolicy extends AndroidOperation implements Serializable { - - @ApiModelProperty(name = "maxFailedAttempts", value = "The maximum number of times the end-user can enter" - + " his/her device passcode incorrectly. EMM will take different courses of action based on the" - + " OS when the failed attempts exceed the maximum failed attempts. Android devices will be " - + "automatically reset to the original factory settings", required = true) - - @Max(10) - private int maxFailedAttempts; - @ApiModelProperty(name = "minLength", value = "The minimum number of alphanumerical values that the " - + "end-user can enter as his/her passcode", required = true) - @Max(15) - private int minLength; - @ApiModelProperty(name = "pinHistory", value = "The end-user will not be allowed to reuse a passcode that" - + " he/she previously entered until he/she exceeds the set pin history length", required = true) - @Max(50) - private int pinHistory; - @ApiModelProperty(name = "minComplexChars", value = "The minimum number of special characters that the " - + "end-user will have to enter in his/her passcode", required = true) - @Max(5) - private int minComplexChars; - @ApiModelProperty(name = "maxPINAgeInDays", value = "The number of days after which the device owner has" - + " to change his/her passcode", required = true) - @Max(730) - private int maxPINAgeInDays; - @ApiModelProperty(name = "requireAlphanumeric", value = "Whether or not it is mandatory for the end-user" - + " to have a mix of digits and characters in his/her passcode", required = true) - private boolean requireAlphanumeric; - @ApiModelProperty(name = "allowSimple", value = "If this field is set to 'true', the device owner will be" - + " able to have a simple passcode and the following criteria in the passcode policy will not be" - + " applicable:\n" - + "Minimum length\n" + "Minimum complex characters", required = true) - private boolean allowSimple; - - public int getMaxFailedAttempts() { - return maxFailedAttempts; - } - - public void setMaxFailedAttempts(int maxFailedAttempts) { - this.maxFailedAttempts = maxFailedAttempts; - } - - public int getMinLength() { - return minLength; - } - - public void setMinLength(int minLength) { - this.minLength = minLength; - } - - public int getPinHistory() { - return pinHistory; - } - - public void setPinHistory(int pinHistory) { - this.pinHistory = pinHistory; - } - - public int getMinComplexChars() { - return minComplexChars; - } - - public void setMinComplexChars(int minComplexChars) { - this.minComplexChars = minComplexChars; - } - - public int getMaxPINAgeInDays() { - return maxPINAgeInDays; - } - - public void setMaxPINAgeInDays(int maxPINAgeInDays) { - this.maxPINAgeInDays = maxPINAgeInDays; - } - - public boolean isRequireAlphanumeric() { - return requireAlphanumeric; - } - - public void setRequireAlphanumeric(boolean requireAlphanumeric) { - this.requireAlphanumeric = requireAlphanumeric; - } - - public boolean isAllowSimple() { - return allowSimple; - } - - public void setAllowSimple(boolean allowSimple) { - this.allowSimple = allowSimple; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/UpgradeFirmware.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/UpgradeFirmware.java deleted file mode 100644 index 63b3ae2f6..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/UpgradeFirmware.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import java.io.Serializable; - -/** - * This class represents the information of sending Upgrade Firmware operation. - */ -@ApiModel(value = "UpgradeFirmware", - description = "This class carries all information related to UpgradeFirmware.") -public class UpgradeFirmware extends AndroidOperation implements Serializable { - - @ApiModelProperty(name = "schedule", value = "Schedule of the UpgradeFirmware.") - private String schedule; - - @ApiModelProperty(name = "server", value = "Firmware package server.") - private String server; - - @SuppressWarnings("unused") - public String getSchedule() { - return schedule; - } - - @SuppressWarnings("unused") - public void setSchedule(String schedule) { - this.schedule = schedule; - } - - @SuppressWarnings("unused") - public String getServer() { - return server; - } - - @SuppressWarnings("unused") - public void setServer(String server) { - this.server = server; - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Vpn.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Vpn.java deleted file mode 100644 index 786254d50..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Vpn.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import java.io.Serializable; - -/** - * This class represents the information of configuring VPN operation. - */ -@ApiModel(value = "Vpn", - description = "This class carries all information related to VPN.") -public class Vpn extends AndroidOperation implements Serializable { - @ApiModelProperty(name = "serverAddress", value = "Server Address.", required = true) - private String serverAddress; - @ApiModelProperty(name = "serverPort", value = "Server Port.", required = true) - private String serverPort; - @ApiModelProperty(name = "sharedSecret", value = "Shared secret.", required = true) - private String sharedSecret; - @ApiModelProperty(name = "dnsServer", value = "DNS server.", required = true) - private String dnsServer; - - public String getServerAddress() { - return serverAddress; - } - - public void setServerAddress(String serverAddress) { - this.serverAddress = serverAddress; - } - - public String getServerPort() { - return serverPort; - } - - public void setServerPort(String serverPort) { - this.serverPort = serverPort; - } - - public String getSharedSecret() { - return sharedSecret; - } - - public void setSharedSecret(String sharedSecret) { - this.sharedSecret = sharedSecret; - } - - public String getDnsServer() { - return dnsServer; - } - - public void setDnsServer(String dnsServer) { - this.dnsServer = dnsServer; - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WebClip.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WebClip.java deleted file mode 100644 index 55727359f..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WebClip.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import java.io.Serializable; - -/** - * This class represents the information of setting up webclip. - */ -@ApiModel(value = "WebClip", description = "This class represents the information of setting up webclip") -public class WebClip extends AndroidOperation implements Serializable { - - @ApiModelProperty(name = "identity", value = "The URL of the application", required = true) - private String identity; - @ApiModelProperty(name = "title", value = "The name of the web application", required = true) - private String title; - @ApiModelProperty(name = "type", value = "The type of the operation. Following are the possible operation" - + " types: install and uninstall. If the operation type is install, the web clip is added, and " - + "if the operation type is uninstall, the existing web clip is removed", required = true) - private String type; - - public String getIdentity() { - return identity; - } - - public void setIdentity(String identity) { - this.identity = identity; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Wifi.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Wifi.java deleted file mode 100644 index f83a83002..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/Wifi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import java.io.Serializable; - -/** - * This class represents the information of configuring wifi operation. - */ -@ApiModel(value = "Wifi", description = "This class represents the information of configuring wifi operation") -public class Wifi extends AndroidOperation implements Serializable { - - @ApiModelProperty(name = "ssid", value = "The name of the Wifi network that you wish to configure", - required = true) - private String ssid; - @ApiModelProperty(name = "password", value = "The password to connect to the specified Wifi network", - required = true) - private String password; - - public String getSsid() { - return ssid; - } - - public void setSsid(String ssid) { - this.ssid = ssid; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WipeData.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WipeData.java deleted file mode 100644 index c6e65c42a..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/WipeData.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.mdm.services.android.bean; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import java.io.Serializable; - -/** - * This class represents the information of wipedata operation. - */ -@ApiModel(value = "WipeData", description = "This class represents the information of wipedata operation") -public class WipeData extends AndroidOperation implements Serializable { - - @ApiModelProperty(name = "pin", value = "PIN number to proceed with the data wipe", required = true) - private String pin; - - public String getPin() { - return pin; - } - - public void setPin(String pin) { - this.pin = pin; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidApplication.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidApplication.java deleted file mode 100644 index ad1c48702..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidApplication.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import java.io.Serializable; -import java.util.Properties; - -@ApiModel( - value = "Application", - description = "This class carries all information related application" -) -public class AndroidApplication implements Serializable{ - private static final long serialVersionUID = 1998101711L; - @ApiModelProperty( - name = "id", - value = "The ID given to the application when it is stored in the EMM database", - required = true - ) - private int id; - @ApiModelProperty( - name = "platform", - value = "The mobile device platform. It can be android, ios or windows", - required = true - ) - private String platform; - @ApiModelProperty( - name = "category", - value = "The application category", - required = true - ) - private String category; - @ApiModelProperty( - name = "name", - value = "The application\'s name", - required = true - ) - private String name; - private String locationUrl; - @ApiModelProperty( - name = "imageUrl", - value = "The icon url of the application", - required = true - ) - private String imageUrl; - @ApiModelProperty( - name = "version", - value = "The application\'s version", - required = true - ) - private String version; - @ApiModelProperty( - name = "type", - value = "The application type", - required = true - ) - private String type; - @ApiModelProperty( - name = "appProperties", - value = "The properties of the application", - required = true - ) - private Properties appProperties; - @ApiModelProperty( - name = "applicationIdentifier", - value = "The application identifier", - required = true - ) - private String applicationIdentifier; - @ApiModelProperty( - name = "memoryUsage", - value = "Amount of memory used by the application", - required = true - ) - private int memoryUsage; - @ApiModelProperty( - name = "isActive", - value = "Is the application actively running", - required = true - ) - private boolean isActive; - - public AndroidApplication() { - } - - public String getType() { - return this.type; - } - - public void setType(String type) { - this.type = type; - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public int getId() { - return this.id; - } - - public void setId(int id) { - this.id = id; - } - - public String getLocationUrl() { - return this.locationUrl; - } - - public void setLocationUrl(String locationUrl) { - this.locationUrl = locationUrl; - } - - public String getImageUrl() { - return this.imageUrl; - } - - public void setImageUrl(String imageUrl) { - this.imageUrl = imageUrl; - } - - public String getVersion() { - return this.version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getPlatform() { - return this.platform; - } - - public void setPlatform(String platform) { - this.platform = platform; - } - - public String getCategory() { - return this.category; - } - - public void setCategory(String category) { - this.category = category; - } - - public String getApplicationIdentifier() { - return this.applicationIdentifier; - } - - public void setApplicationIdentifier(String applicationIdentifier) { - this.applicationIdentifier = applicationIdentifier; - } - - public int getMemoryUsage() { - return this.memoryUsage; - } - - public void setMemoryUsage(int memoryUsage) { - this.memoryUsage = memoryUsage; - } - - public boolean equals(Object o) { - if(this == o) { - return true; - } else if(o != null && this.getClass() == o.getClass()) { - AndroidApplication that = (AndroidApplication)o; - if(this.applicationIdentifier != null) { - if(!this.applicationIdentifier.equals(that.applicationIdentifier)) { - return false; - } - } else if(that.applicationIdentifier != null) { - return false; - } - - return true; - } else { - return false; - } - } - - public int hashCode() { - int result = this.id; - result = 31 * result + (this.applicationIdentifier != null?this.applicationIdentifier.hashCode():0); - return result; - } - - public Properties getAppProperties() { - return this.appProperties; - } - - public void setAppProperties(Properties appProperties) { - this.appProperties = appProperties; - } - - public boolean isActive() { - return this.isActive; - } - - public void setActive(boolean active) { - this.isActive = active; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidDevice.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidDevice.java deleted file mode 100644 index d3a63f137..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidDevice.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.EnrolmentInfo; -import org.wso2.carbon.device.mgt.common.Feature; -import org.wso2.carbon.device.mgt.common.app.mgt.Application; -import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; -import javax.validation.constraints.Size; -import java.io.Serializable; -import java.util.List; - -public class AndroidDevice implements Serializable { - private static final long serialVersionUID = 1998101711L; - - @ApiModelProperty( - name = "name", - value = "The device name that can be set on the device by the device user.", - required = true - ) - @Size(min = 2, max = 45) - private String name; - @ApiModelProperty( - name = "description", - value = "Additional information on the device.", - required = true - ) - private String description; - @ApiModelProperty( - name = "deviceIdentifier", - value = "This is a 64-bit number (as a hex string) that is randomly generated when the user first sets up the device and should remain constant for the lifetime of the user\'s device. The value may change if a factory reset is performed on the device.", - required = true - ) - @NotNull - @Size(min = 2, max = 45) - private String deviceIdentifier; - @ApiModelProperty( - name = "enrolmentInfo", - value = "This defines the device registration related information. It is mandatory to define this information.", - required = true - ) - private EnrolmentInfo enrolmentInfo; - @ApiModelProperty( - name = "features", - value = "List of features.", - required = true - ) - private List features; - private List properties; - @ApiModelProperty( - name = "advanceInfo", - value = "This defines the device registration related information. It is mandatory to define this information.", - required = false - ) - private DeviceInfo deviceInfo; - @ApiModelProperty( - name = "applications", - value = "This represents the application list installed into the device", - required = false - ) - private List applications; - - public AndroidDevice() { - } - - public AndroidDevice(String name, String description, String deviceId, EnrolmentInfo enrolmentInfo, List features, List properties) { - this.name = name; - this.description = description; - this.deviceIdentifier = deviceId; - this.enrolmentInfo = enrolmentInfo; - this.features = features; - this.properties = properties; - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getDeviceIdentifier() { - return this.deviceIdentifier; - } - - public void setDeviceIdentifier(String deviceIdentifier) { - this.deviceIdentifier = deviceIdentifier; - } - - public EnrolmentInfo getEnrolmentInfo() { - return this.enrolmentInfo; - } - - public void setEnrolmentInfo(EnrolmentInfo enrolmentInfo) { - this.enrolmentInfo = enrolmentInfo; - } - - public List getFeatures() { - return this.features; - } - - public void setFeatures(List features) { - this.features = features; - } - - public List getProperties() { - return this.properties; - } - - public void setProperties(List properties) { - this.properties = properties; - } - - public DeviceInfo getDeviceInfo() { - return this.deviceInfo; - } - - public void setDeviceInfo(DeviceInfo deviceInfo) { - this.deviceInfo = deviceInfo; - } - - public List getApplications() { - return this.applications; - } - - public void setApplications(List applications) { - this.applications = applications; - } - - public String toString() { - return "device [name=" + this.name + ";" + ";" + "description=" + this.description + ";" + "identifier=" + this.deviceIdentifier + ";" + "]"; - } - - public boolean equals(Object o) { - if (this == o) { - return true; - } else if (!(o instanceof AndroidDevice)) { - return false; - } else { - AndroidDevice device = (AndroidDevice) o; - return this.getDeviceIdentifier().equals(device.getDeviceIdentifier()); - } - } - - public int hashCode() { - return this.getDeviceIdentifier().hashCode(); - } - - public static class Property { - private String name; - private String value; - - public Property() { - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public String getValue() { - return this.value; - } - - public void setValue(String value) { - this.value = value; - } - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidDeviceInfo.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidDeviceInfo.java deleted file mode 100644 index f28a99610..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AndroidDeviceInfo.java +++ /dev/null @@ -1,338 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo; -import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; - -import java.io.Serializable; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -@ApiModel( - value = "DeviceInfo", - description = "This class carries all information related to the device information provided by a device." -) -public class AndroidDeviceInfo extends DeviceInfo implements Serializable { - private static final long serialVersionUID = 1998101733L; - @ApiModelProperty( - name = "IMEI", - value = "IMEI number of the device.", - required = true - ) - private String IMEI; - @ApiModelProperty( - name = "IMSI", - value = "IMSI number of the device.", - required = true - ) - private String IMSI; - @ApiModelProperty( - name = "deviceModel", - value = "Model of the device.", - required = true - ) - private String deviceModel; - @ApiModelProperty( - name = "vendor", - value = "Vendor of the device.", - required = true - ) - private String vendor; - @ApiModelProperty( - name = "osVersion", - value = "Operating system version.", - required = true - ) - private String osVersion; - @ApiModelProperty( - name = "batteryLevel", - value = "Battery level of the device.", - required = true - ) - private Double batteryLevel; - @ApiModelProperty( - name = "internalTotalMemory", - value = "Total internal memory of the device.", - required = true - ) - private Double internalTotalMemory; - @ApiModelProperty( - name = "internalAvailableMemory", - value = "Total available memory of the device.", - required = true - ) - private Double internalAvailableMemory; - @ApiModelProperty( - name = "externalTotalMemory", - value = "Total external memory of the device.", - required = true - ) - private Double externalTotalMemory; - @ApiModelProperty( - name = "externalAvailableMemory", - value = "Total external memory avilable of the device.", - required = true - ) - private Double externalAvailableMemory; - @ApiModelProperty( - name = "operator", - value = "Mobile operator of the device.", - required = true - ) - private String operator; - @ApiModelProperty( - name = "connectionType", - value = "How the device is connected to the network.", - required = true - ) - private String connectionType; - @ApiModelProperty( - name = "mobileSignalStrength", - value = "Current mobile signal strength.", - required = true - ) - private Double mobileSignalStrength; - @ApiModelProperty( - name = "ssid", - value = "ssid of the connected WiFi.", - required = true - ) - private String ssid; - @ApiModelProperty( - name = "cpuUsage", - value = "Current total cpu usage.", - required = true - ) - private Double cpuUsage; - @ApiModelProperty( - name = "totalRAMMemory", - value = "Total Ram memory size.", - required = true - ) - private Double totalRAMMemory; - @ApiModelProperty( - name = "availableRAMMemory", - value = "Available total memory of RAM.", - required = true - ) - private Double availableRAMMemory; - @ApiModelProperty( - name = "pluggedIn", - value = "Whether the device is plugged into power or not.", - required = true - ) - private boolean pluggedIn; - @ApiModelProperty( - name = "updatedTime", - value = "Device updated time.", - required = true - ) - private Date updatedTime; - @ApiModelProperty( - name = "location", - value = "Last updated location of the device", - required = false - ) - private DeviceLocation location; - @ApiModelProperty( - name = "deviceDetailsMap", - value = ".", - required = true - ) - private Map deviceDetailsMap = new HashMap(); - - public AndroidDeviceInfo() { - } - - public DeviceLocation getLocation() { - return this.location; - } - - public void setLocation(DeviceLocation location) { - this.location = location; - } - - public String getIMEI() { - return this.IMEI != null?this.IMEI:""; - } - - public void setIMEI(String IMEI) { - this.IMEI = IMEI; - } - - public String getIMSI() { - return this.IMSI != null?this.IMSI:""; - } - - public void setIMSI(String IMSI) { - this.IMSI = IMSI; - } - - public String getDeviceModel() { - return this.deviceModel != null?this.deviceModel:""; - } - - public void setDeviceModel(String deviceModel) { - this.deviceModel = deviceModel; - } - - public String getVendor() { - return this.vendor != null?this.vendor:""; - } - - public void setVendor(String vendor) { - this.vendor = vendor; - } - - public String getOsVersion() { - return this.osVersion != null?this.osVersion:""; - } - - public void setOsVersion(String osVersion) { - this.osVersion = osVersion; - } - - public Double getBatteryLevel() { - return this.batteryLevel != null?this.batteryLevel:Double.valueOf(0.0D); - } - - public void setBatteryLevel(Double batteryLevel) { - this.batteryLevel = batteryLevel; - } - - public Double getInternalTotalMemory() { - return this.internalTotalMemory != null?this.internalTotalMemory:Double.valueOf(0.0D); - } - - public void setInternalTotalMemory(Double internalTotalMemory) { - this.internalTotalMemory = internalTotalMemory; - } - - public Double getInternalAvailableMemory() { - return this.internalAvailableMemory != null?this.internalAvailableMemory:Double.valueOf(0.0D); - } - - public void setInternalAvailableMemory(Double internalAvailableMemory) { - this.internalAvailableMemory = internalAvailableMemory; - } - - public Double getExternalTotalMemory() { - return this.externalTotalMemory != null?this.externalTotalMemory:Double.valueOf(0.0D); - } - - public void setExternalTotalMemory(Double externalTotalMemory) { - this.externalTotalMemory = externalTotalMemory; - } - - public Double getExternalAvailableMemory() { - return this.externalAvailableMemory != null?this.externalAvailableMemory:Double.valueOf(0.0D); - } - - public void setExternalAvailableMemory(Double externalAvailableMemory) { - this.externalAvailableMemory = externalAvailableMemory; - } - - public String getOperator() { - return this.operator != null?this.operator:""; - } - - public void setOperator(String operator) { - this.operator = operator; - } - - public String getConnectionType() { - return this.connectionType != null?this.connectionType:""; - } - - public void setConnectionType(String connectionType) { - this.connectionType = connectionType; - } - - public Double getMobileSignalStrength() { - return this.mobileSignalStrength != null?this.mobileSignalStrength:Double.valueOf(0.0D); - } - - public void setMobileSignalStrength(Double mobileSignalStrength) { - this.mobileSignalStrength = mobileSignalStrength; - } - - public String getSsid() { - return this.ssid != null?this.ssid:""; - } - - public void setSsid(String ssid) { - this.ssid = ssid; - } - - public Double getCpuUsage() { - return this.cpuUsage != null?this.cpuUsage:Double.valueOf(0.0D); - } - - public void setCpuUsage(Double cpuUsage) { - this.cpuUsage = cpuUsage; - } - - public Double getTotalRAMMemory() { - return this.totalRAMMemory != null?this.totalRAMMemory:Double.valueOf(0.0D); - } - - public void setTotalRAMMemory(Double totalRAMMemory) { - this.totalRAMMemory = totalRAMMemory; - } - - public Double getAvailableRAMMemory() { - return this.availableRAMMemory != null?this.availableRAMMemory:Double.valueOf(0.0D); - } - - public void setAvailableRAMMemory(Double availableRAMMemory) { - this.availableRAMMemory = availableRAMMemory; - } - - public boolean isPluggedIn() { - return this.pluggedIn; - } - - public void setPluggedIn(boolean pluggedIn) { - this.pluggedIn = pluggedIn; - } - - public Date getUpdatedTime() { - if(this.updatedTime == null) { - this.updatedTime = new Date(); - } - - return this.updatedTime; - } - - public void setUpdatedTime(Date updatedTime) { - this.updatedTime = updatedTime; - } - - public void setDeviceDetailsMap(Map deviceDetailsMap) { - this.deviceDetailsMap = deviceDetailsMap; - } - - public Map getDeviceDetailsMap() { - return this.deviceDetailsMap; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AppRestrictionBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AppRestrictionBeanWrapper.java deleted file mode 100644 index 79ff28942..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/AppRestrictionBeanWrapper.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.AppRestriction; - -import java.util.List; - -/** - * This class is used to wrap AppRestriction bean with devices - */ -@ApiModel(value = "AppRestrictionBeanWrapper", - description = "Application Restriction related information.") -public class AppRestrictionBeanWrapper { - - @ApiModelProperty(name = "operation", value = "AppRestriction related information.", required = true) - private AppRestriction operation; - @ApiModelProperty(name = "deviceIDs", value = "Device id list of the operation to be executed.", required = true) - private List deviceIDs; - - public AppRestriction getOperation() { - return operation; - } - - public void setOperation(AppRestriction operation) { - this.operation = operation; - } - - public List getDeviceIDs() { - return deviceIDs; - } - - public void setDeviceIDs(List deviceIDs) { - this.deviceIDs = deviceIDs; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationInstallationBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationInstallationBeanWrapper.java deleted file mode 100644 index 6e91ec441..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationInstallationBeanWrapper.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.ApplicationInstallation; - -import java.util.List; - -/** - * This class is used to wrap the InstallApplication bean with devices. - */ - -@ApiModel(value = "ApplicationInstallationBeanWrapper", - description = "This class carries all information related to a InstallApplication") -public class ApplicationInstallationBeanWrapper { - - @ApiModelProperty(name = "deviceIDs", value = "List of Devices", required = true) - private List deviceIDs; - @ApiModelProperty(name = "operation", value = "App Installation property", required = true) - private ApplicationInstallation operation; - - public List getDeviceIDs() { - return deviceIDs; - } - - public void setDeviceIDs(List deviceIDs) { - this.deviceIDs = deviceIDs; - } - - public ApplicationInstallation getOperation() { - return operation; - } - - public void setOperation(ApplicationInstallation operation) { - this.operation = operation; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUninstallationBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUninstallationBeanWrapper.java deleted file mode 100644 index 6b9e1bc42..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUninstallationBeanWrapper.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.ApplicationUninstallation; - -import java.util.List; - -/** - * This class is used to wrap the UninstallApplication bean with devices. - */ -@ApiModel(value = "ApplicationUninstallationBeanWrapper", - description = "This class carries all information related to Uninstall Application") -public class ApplicationUninstallationBeanWrapper { - - @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true) - private List deviceIDs; - - @ApiModelProperty(name = "operation", value = "Name of the device", required = true) - private ApplicationUninstallation operation; - - public List getDeviceIDs() { - return deviceIDs; - } - - public void setDeviceIDs(List deviceIDs) { - this.deviceIDs = deviceIDs; - } - - public ApplicationUninstallation getOperation() { - return operation; - } - - public void setOperation(ApplicationUninstallation operation) { - this.operation = operation; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUpdateBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUpdateBeanWrapper.java deleted file mode 100644 index ee5da4222..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/ApplicationUpdateBeanWrapper.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.ApplicationUpdate; - -import java.util.List; - -/** - * This class is used to wrap the UpdateApplication bean with devices. - */ -@ApiModel(value = "ApplicationUpdateBeanWrapper", - description = "Application Update related Info.") -public class ApplicationUpdateBeanWrapper { - - @ApiModelProperty(name = "deviceIDs", value = "Device id list of the operation to be executed.", required = true) - private List deviceIDs; - @ApiModelProperty(name = "operation", value = "Application Update related information.", required = true) - private ApplicationUpdate operation; - - public List getDeviceIDs() { - return deviceIDs; - } - - public void setDeviceIDs(List deviceIDs) { - this.deviceIDs = deviceIDs; - } - - public ApplicationUpdate getOperation() { - return operation; - } - - public void setOperation(ApplicationUpdate operation) { - this.operation = operation; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/BlacklistApplicationsBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/BlacklistApplicationsBeanWrapper.java deleted file mode 100644 index ecb07fd21..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/BlacklistApplicationsBeanWrapper.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.BlacklistApplications; - -import javax.validation.Valid; -import java.util.List; - -/** - * This class is used to wrap the BlacklistApplications bean with devices. - */ -@ApiModel(value = "BlacklistApplicationsBeanWrapper", - description = "Mapping between blacklist application and the device ids.") -public class BlacklistApplicationsBeanWrapper { - - @ApiModelProperty(name = "operation", value = "Blacklist applications information", required = true) - private @Valid BlacklistApplications operation; - @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true) - private List deviceIDs; - - public @Valid BlacklistApplications getOperation() { - return operation; - } - - public void setOperation(@Valid BlacklistApplications operation) { - this.operation = operation; - } - - public List getDeviceIDs() { - return deviceIDs; - } - - public void setDeviceIDs(List deviceIDs) { - this.deviceIDs = deviceIDs; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/CameraBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/CameraBeanWrapper.java deleted file mode 100644 index fe34b91f1..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/CameraBeanWrapper.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.Camera; - -import java.util.List; - -/** - * This class is used to wrap the Camera bean with devices. - */ - -@ApiModel(value = "CameraBeanWrapper", - description = "Mapping between camera operation and device list to be applied.") -public class CameraBeanWrapper { - - @ApiModelProperty(name = "operation", value = "Information of camera operation", required = true) - private Camera operation; - @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true) - private List deviceIDs; - - public Camera getOperation() { - return operation; - } - - public void setOperation(Camera operation) { - this.operation = operation; - } - - public List getDeviceIDs() { - return deviceIDs; - } - - public void setDeviceIDs(List deviceIDs) { - this.deviceIDs = deviceIDs; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DeviceEnrollmentInfo.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DeviceEnrollmentInfo.java deleted file mode 100644 index ba477d4fa..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DeviceEnrollmentInfo.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.EnrolmentInfo; - -import java.io.Serializable; - -@ApiModel(value = "EnrolmentInfo", description = "This class carries all information related to a devices enrollment" + - " status.") -public class DeviceEnrollmentInfo extends EnrolmentInfo implements Serializable { - private static final long serialVersionUID = 1998101712L; - - @ApiModelProperty(name = "device", value = "Enrolled device.", required = true) - private Device device; - @ApiModelProperty(name = "dateOfEnrolment", value = "Date of the device enrollment.", required = true) - private Long dateOfEnrolment; - @ApiModelProperty(name = "dateOfLastUpdate", value = "Date of the device's last update.", required = true) - private Long dateOfLastUpdate; - @ApiModelProperty(name = "ownership", value = "Defines the ownership details. The ownership type can be any of the" + - " following values.\n" + - "BYOD - Bring your own device (BYOD).\n" + - "COPE - Corporate owned personally enabled (COPE).", required = true) - private OwnerShip ownership; - @ApiModelProperty(name = "status", value = "Current status of the device, such as whether the device " + - "is active, removed etc.", required = true) - private Status status; - @ApiModelProperty(name = "owner", value = "The device owner's name.", required = true) - private String owner; - - public DeviceEnrollmentInfo() { - } - - public DeviceEnrollmentInfo(Device device, String owner, OwnerShip ownership, Status status) { - this.device = device; - this.owner = owner; - this.ownership = ownership; - this.status = status; - } - - public Long getDateOfEnrolment() { - return dateOfEnrolment; - } - - public void setDateOfEnrolment(Long dateOfEnrolment) { - this.dateOfEnrolment = dateOfEnrolment; - } - - public Long getDateOfLastUpdate() { - return dateOfLastUpdate; - } - - public void setDateOfLastUpdate(Long dateOfLastUpdate) { - this.dateOfLastUpdate = dateOfLastUpdate; - } - - public OwnerShip getOwnership() { - return ownership; - } - - public void setOwnership(OwnerShip ownership) { - this.ownership = ownership; - } - - public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } - - public String getOwner() { - return owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public Device getDevice() { - return device; - } - - public void setDevice(Device device) { - this.device = device; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof DeviceEnrollmentInfo) { - DeviceEnrollmentInfo tempInfo = (DeviceEnrollmentInfo) obj; - if (this.owner != null && this.ownership != null) { - if (this.owner.equals(tempInfo.getOwner()) && this.ownership.equals(tempInfo.getOwnership())) { - return true; - } - } - } - return false; - } - - @Override - public int hashCode() { - return owner.hashCode() ^ ownership.hashCode(); - } - - -} \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DeviceLockBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DeviceLockBeanWrapper.java deleted file mode 100644 index 6c8d91a81..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DeviceLockBeanWrapper.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.DeviceLock; - -import java.util.List; - -/** - * This class is used to wrap the Notification bean with devices. - */ -@ApiModel(value = "DeviceLockBeanWrapper", - description = "DeviceLock related Information.") -public class DeviceLockBeanWrapper { - - @ApiModelProperty(name = "deviceIDs", value = "Device id list of the operation to be executed.", required = true) - private List deviceIDs; - @ApiModelProperty(name = "operation", value = "Information of the Device lock operation.", required = true) - private DeviceLock operation; - - public List getDeviceIDs() { - return deviceIDs; - } - - public void setDeviceIDs(List deviceIDs) { - this.deviceIDs = deviceIDs; - } - - public DeviceLock getOperation() { - return operation; - } - - public void setOperation(DeviceLock operation) { - this.operation = operation; - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DisenrollmentBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DisenrollmentBeanWrapper.java deleted file mode 100644 index 0bd219235..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DisenrollmentBeanWrapper.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.Disenrollment; - -import java.util.List; - -@ApiModel(value = "DisenrollmentBeanWrapper", description = "Disenrollment details are mapped to devices list.") -public class DisenrollmentBeanWrapper { - - @ApiModelProperty(name = "operation", value = "Disenrollment operation.", required = true) - private Disenrollment operation; - @ApiModelProperty(name = "deviceIDs", value = "Device id list of the operation to be executed.", required = true) - private List deviceIDs; - - public Disenrollment getOperation() { - return operation; - } - - public void setOperation(Disenrollment operation) { - this.operation = operation; - } - - public List getDeviceIDs() { - return deviceIDs; - } - - public void setDeviceIDs(List deviceIDs) { - this.deviceIDs = deviceIDs; - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EncryptionBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EncryptionBeanWrapper.java deleted file mode 100644 index a2c61a244..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EncryptionBeanWrapper.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.DeviceEncryption; - -import java.util.List; - -/** - * This class is used to wrap the Encrypt bean with devices. - */ -@ApiModel(value = "EncryptionBeanWrapper", - description = "Mapping between encryption operation and device list to be applied.") -public class EncryptionBeanWrapper { - - @ApiModelProperty(name = "operation", value = "The information of encrypt operation", required = true) - private DeviceEncryption operation; - @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true) - private List deviceIDs; - - public DeviceEncryption getOperation() { - return operation; - } - - public void setOperation(DeviceEncryption operation) { - this.operation = operation; - } - - public List getDeviceIDs() { - return deviceIDs; - } - - public void setDeviceIDs(List deviceIDs) { - this.deviceIDs = deviceIDs; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EventBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EventBeanWrapper.java deleted file mode 100644 index 10c98ea46..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EventBeanWrapper.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import javax.validation.constraints.Size; - -/** - * This class is used to wrap the events which receive from the agent application. - */ -@ApiModel(value = "EventBeanWrapper", - description = "Android agent's event related Information.") -public class EventBeanWrapper { - - @ApiModelProperty(name = "deviceIdentifier", value = "DeviceIdentifier to be need to retrieve/publish Event.", required = true) - @Size(min = 2, max = 45) - private String deviceIdentifier; - @ApiModelProperty(name = "payload", value = "Event payload.", required = true) - private String payload; - @ApiModelProperty(name = "type", value = "Type of the event.", required = true) - @Size(min = 2, max = 20) - private String type; - - public String getPayload() { - return payload; - } - - public void setPayload(String payload) { - this.payload = payload; - } - - public String getDeviceIdentifier() { - return deviceIdentifier; - } - - public void setDeviceIdentifier(String deviceIdentifier) { - this.deviceIdentifier = deviceIdentifier; - } - - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/FileTransferBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/FileTransferBeanWrapper.java deleted file mode 100644 index 221ce6fde..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/FileTransferBeanWrapper.java +++ /dev/null @@ -1,67 +0,0 @@ -/* -* 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.FileTransfer; - -import java.util.List; - -/** - * This class is used to wrap the File Transfer bean with devices. - */ -@ApiModel(value = "FileTransferBeanWrapper", - description = "FileTransfer related Information.") -public class FileTransferBeanWrapper { - - @ApiModelProperty(name = "deviceIDs", value = "Device id list of the operation to be executed.", required = true) - private List deviceIDs; - - @ApiModelProperty(name = "upload", value = "Upload / Download w.r.t device.", - notes = "upload = true , If file is to be uploaded to the device.", required = true) - private boolean upload; - - @ApiModelProperty(name = "operation", value = "Information of the File Transfer Operation.", required = true) - private FileTransfer operation; - - public List getDeviceIDs() { - return deviceIDs; - } - - public void setDeviceIDs(List deviceIDs) { - this.deviceIDs = deviceIDs; - } - - public FileTransfer getOperation() { - return operation; - } - - public void setOperation(FileTransfer operation) { - this.operation = operation; - } - - public boolean isUpload() { - return upload; - } - - public void setUpload(boolean upload) { - this.upload = upload; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/LockCodeBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/LockCodeBeanWrapper.java deleted file mode 100644 index 9f0b204c9..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/LockCodeBeanWrapper.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.LockCode; - -import java.util.List; - -/** - * This class is used to wrap the LockCode bean with devices. - */ - -@ApiModel(value = "LockCodeBeanWrapper", - description = "Mapping between lock operation and device list to be applied.") -public class LockCodeBeanWrapper { - - @ApiModelProperty(name = "operation", value = "The information of device lock operation", required = true) - private LockCode operation; - @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true) - private List deviceIDs; - - public LockCode getOperation() { - return operation; - } - - public void setOperation(LockCode operation) { - this.operation = operation; - } - - public List getDeviceIDs() { - return deviceIDs; - } - - public void setDeviceIDs(List deviceIDs) { - this.deviceIDs = deviceIDs; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/NotificationBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/NotificationBeanWrapper.java deleted file mode 100644 index 9e618e2a0..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/NotificationBeanWrapper.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.Notification; - -import java.util.List; - -/** - * This class is used to wrap the Notification bean with devices. - */ - -@ApiModel(value = "NotificationBeanWrapper", - description = "Mapping between notification operation and device list to be applied.") -public class NotificationBeanWrapper { - - @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true) - private List deviceIDs; - @ApiModelProperty(name = "operation", value = "The information of notification operation", required = true) - private Notification operation; - - public List getDeviceIDs() { - return deviceIDs; - } - - public void setDeviceIDs(List deviceIDs) { - this.deviceIDs = deviceIDs; - } - - public Notification getOperation() { - return operation; - } - - public void setOperation(Notification operation) { - this.operation = operation; - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/PasswordPolicyBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/PasswordPolicyBeanWrapper.java deleted file mode 100644 index 639417736..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/PasswordPolicyBeanWrapper.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.PasscodePolicy; - -import java.util.List; - -/** - * This class is used to wrap the PasswordPolicy bean with devices. - */ - -@ApiModel(value = "PasswordPolicyBeanWrapper", - description = "Mapping between passcode policy and device list to be applied.") -public class PasswordPolicyBeanWrapper { - - @ApiModelProperty(name = "operation", value = "The information of setting up password policy", required = true) - private PasscodePolicy operation; - @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true) - private List deviceIDs; - - public PasscodePolicy getOperation() { - return operation; - } - - public void setOperation(PasscodePolicy operation) { - this.operation = operation; - } - - public List getDeviceIDs() { - return deviceIDs; - } - - public void setDeviceIDs(List deviceIDs) { - this.deviceIDs = deviceIDs; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/UpgradeFirmwareBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/UpgradeFirmwareBeanWrapper.java deleted file mode 100644 index 9454e64d0..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/UpgradeFirmwareBeanWrapper.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.UpgradeFirmware; - -import java.util.List; - -/** - * This class is used to wrap the UpgradeFirmware bean with devices. - */ -@ApiModel(value = "UpgradeFirmwareBeanWrapper", - description = "Information related to UpgradeFirmware.") -public class UpgradeFirmwareBeanWrapper { - @ApiModelProperty(name = "deviceIDs", - value = "List of device Ids to be need to execute UpgradeFirmware operation.", required = true) - private List deviceIDs; - @ApiModelProperty(name = "operation", value = "Information related to UpgradeFirmware operation.", required = true) - private UpgradeFirmware operation; - - public List getDeviceIDs() { - return deviceIDs; - } - - public void setDeviceIDs(List deviceIDs) { - this.deviceIDs = deviceIDs; - } - - public UpgradeFirmware getOperation() { - return operation; - } - - public void setOperation(UpgradeFirmware operation) { - this.operation = operation; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/VpnBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/VpnBeanWrapper.java deleted file mode 100644 index f390476f4..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/VpnBeanWrapper.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.Vpn; - -import java.util.List; - -/** - * This class is used to wrap the Vpn bean with devices. - */ -@ApiModel(value = "VpnBeanWrapper", - description = "Information related to VPN Configuration.") -public class VpnBeanWrapper { - @ApiModelProperty(name = "operation", - value = "List of device Ids to be need to execute VPN operation.", required = true) - private Vpn operation; - @ApiModelProperty(name = "deviceIDs", - value = "List of device Ids to be need to execute VPN operation.", required = true) - private List deviceIDs; - - public Vpn getOperation() { - return operation; - } - - public void setOperation(Vpn operation) { - this.operation = operation; - } - - public List getDeviceIDs() { - return deviceIDs; - } - - public void setDeviceIDs(List deviceIDs) { - this.deviceIDs = deviceIDs; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WebClipBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WebClipBeanWrapper.java deleted file mode 100644 index 8c400f454..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WebClipBeanWrapper.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.WebClip; - -import java.util.List; - -/** - * This class is used to wrap the WebClip bean with devices. - */ - -@ApiModel(value = "WebClipBeanWrapper", - description = "Mapping between web clip operation and device list to be applied.") -public class WebClipBeanWrapper { - - @ApiModelProperty(name = "operation", value = "the information of setting up webclip.", required = true) - private WebClip operation; - @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true) - private List deviceIDs; - - public WebClip getOperation() { - return operation; - } - - public void setOperation(WebClip operation) { - this.operation = operation; - } - - public List getDeviceIDs() { - return deviceIDs; - } - - public void setDeviceIDs(List deviceIDs) { - this.deviceIDs = deviceIDs; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WifiBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WifiBeanWrapper.java deleted file mode 100644 index 63ff3d54d..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WifiBeanWrapper.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.Wifi; - -import java.util.List; - -/** - * This class is used to wrap the Wifi bean with devices. - */ -@ApiModel(value = "WifiBeanWrapper", - description = "Mapping between wifi operation and device list to be applied.") -public class WifiBeanWrapper { - - @ApiModelProperty(name = "operation", value = "Information of configuring wifi operation", required = true) - private Wifi operation; - @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true) - private List deviceIDs; - - public Wifi getOperation() { - return operation; - } - - public void setOperation(Wifi operation) { - this.operation = operation; - } - - public List getDeviceIDs() { - return deviceIDs; - } - - public void setDeviceIDs(List deviceIDs) { - this.deviceIDs = deviceIDs; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WipeDataBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WipeDataBeanWrapper.java deleted file mode 100644 index ea8cbcb97..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/WipeDataBeanWrapper.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.mdm.services.android.bean.wrapper; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.mdm.services.android.bean.WipeData; - -import java.util.List; - -/** - * This class is used to wrap the WipeData bean with devices. - */ -@ApiModel(value = "WipeDataBeanWrapper", - description = "Mapping between wipe operation and device list to be applied.") -public class WipeDataBeanWrapper { - - @ApiModelProperty(name = "operation", value = "The information of wipedata operation", required = true) - private WipeData operation; - @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true) - private List deviceIDs; - - public WipeData getOperation() { - return operation; - } - - public void setOperation(WipeData operation) { - this.operation = operation; - } - - public List getDeviceIDs() { - return deviceIDs; - } - - public void setDeviceIDs(List deviceIDs) { - this.deviceIDs = deviceIDs; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ErrorHandler.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ErrorHandler.java deleted file mode 100644 index 551987c11..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ErrorHandler.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.mdm.services.android.common; - -import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; - -import javax.ws.rs.Produces; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; - - -@Produces({ "application/json", "application/xml" }) -public class ErrorHandler implements ExceptionMapper { - - public Response toResponse(AndroidAgentException exception) { - ErrorMessage errorMessage = new ErrorMessage(); - errorMessage.setErrorMessage(exception.getErrorMessage()); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build(); - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ErrorMessage.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ErrorMessage.java deleted file mode 100644 index 92ec885ce..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ErrorMessage.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.mdm.services.android.common; - - -public class ErrorMessage { - - private String errorMessage; - private String errorCode; - - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - - public String getErrorCode() { - return errorCode; - } - - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/common/GsonMessageBodyHandler.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/common/GsonMessageBodyHandler.java deleted file mode 100644 index eb9006a10..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/common/GsonMessageBodyHandler.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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.mdm.services.android.common; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -import javax.ws.rs.Consumes; -import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.ext.MessageBodyReader; -import javax.ws.rs.ext.MessageBodyWriter; -import javax.ws.rs.ext.Provider; - -import java.io.*; -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; - -import static javax.ws.rs.core.MediaType.APPLICATION_JSON; - -@Provider -@Produces(APPLICATION_JSON) -@Consumes(APPLICATION_JSON) -public class GsonMessageBodyHandler implements MessageBodyWriter, MessageBodyReader { - - private Gson gson; - private static final String UTF_8 = "UTF-8"; - - public boolean isReadable(Class aClass, Type type, Annotation[] annotations, MediaType mediaType) { - return true; - } - - private Gson getGson() { - if (gson == null) { - final GsonBuilder gsonBuilder = new GsonBuilder(); - gson = gsonBuilder.create(); - } - return gson; - } - - public Object readFrom(Class objectClass, Type type, Annotation[] annotations, MediaType mediaType, - MultivaluedMap stringStringMultivaluedMap, InputStream entityStream) - throws IOException, WebApplicationException { - - InputStreamReader reader = new InputStreamReader(entityStream, "UTF-8"); - - try { - return getGson().fromJson(reader, type); - } finally { - reader.close(); - } - } - - public boolean isWriteable(Class aClass, Type type, Annotation[] annotations, MediaType mediaType) { - return true; - } - - public long getSize(Object o, Class aClass, Type type, Annotation[] annotations, MediaType mediaType) { - return -1; - } - - public void writeTo(Object object, Class aClass, Type type, Annotation[] annotations, MediaType mediaType, - MultivaluedMap stringObjectMultivaluedMap, OutputStream entityStream) - throws IOException, WebApplicationException { - - OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8); - try { - getGson().toJson(object, type, writer); - } finally { - writer.close(); - } - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ValidationInterceptor.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ValidationInterceptor.java deleted file mode 100644 index eb76d1e51..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/common/ValidationInterceptor.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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.mdm.services.android.common; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.cxf.interceptor.Fault; -import org.apache.cxf.jaxrs.lifecycle.ResourceProvider; -import org.apache.cxf.jaxrs.model.ClassResourceInfo; -import org.apache.cxf.jaxrs.model.OperationResourceInfo; -import org.apache.cxf.message.Message; -import org.apache.cxf.message.MessageContentsList; -import org.apache.cxf.phase.AbstractPhaseInterceptor; -import org.apache.cxf.phase.Phase; - -import javax.validation.*; -import javax.validation.executable.ExecutableValidator; -import java.lang.reflect.Method; -import java.util.List; -import java.util.Set; - -public class ValidationInterceptor extends AbstractPhaseInterceptor { - - private Log log = LogFactory.getLog(getClass()); - private Validator validator = null; //validator interface is thread-safe - - public ValidationInterceptor() { - super(Phase.PRE_INVOKE); - ValidatorFactory defaultFactory = Validation.buildDefaultValidatorFactory(); - validator = defaultFactory.getValidator(); - if (validator == null) { - log.warn("Bean Validation provider could not be found, no validation will be performed"); - } else { - log.debug("Validation In-Interceptor initialized successfully"); - } - } - @Override - public void handleMessage(Message message) throws Fault { - final OperationResourceInfo operationResource = message.getExchange().get(OperationResourceInfo.class); - if (operationResource == null) { - log.info("OperationResourceInfo is not available, skipping validation"); - return; - } - - final ClassResourceInfo classResource = operationResource.getClassResourceInfo(); - if (classResource == null) { - log.info("ClassResourceInfo is not available, skipping validation"); - return; - } - - final ResourceProvider resourceProvider = classResource.getResourceProvider(); - if (resourceProvider == null) { - log.info("ResourceProvider is not available, skipping validation"); - return; - } - - final List arguments = MessageContentsList.getContentsList(message); - final Method method = operationResource.getAnnotatedMethod(); - final Object instance = resourceProvider.getInstance(message); - if (method != null && arguments != null) { - //validate the parameters(arguments) over the invoked method - validate(method, arguments.toArray(), instance); - - //validate the fields of each argument - for (Object arg : arguments) { - if (arg != null) - validate(arg); - } - } - - } - public void validate(final Method method, final Object[] arguments, final T instance) { - if (validator == null) { - log.warn("Bean Validation provider could not be found, no validation will be performed"); - return; - } - - ExecutableValidator methodValidator = validator.forExecutables(); - Set> violations = methodValidator.validateParameters(instance, - method, arguments); - - if (!violations.isEmpty()) { - throw new ConstraintViolationException(violations); - } - } - - public void validate(final T object) { - if (validator == null) { - log.warn("Bean Validation provider could be found, no validation will be performed"); - return; - } - - Set> violations = validator.validate(object); - - if (!violations.isEmpty()) { - throw new ConstraintViolationException(violations); - } - } - - public void handleFault(Message messageParam) { - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/AndroidAgentException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/AndroidAgentException.java deleted file mode 100644 index c129456ec..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/AndroidAgentException.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.mdm.services.android.exception; - -/** - * - * Custom exception class for Android API related exceptions. - * - */ -public class AndroidAgentException extends Exception{ - - private static final long serialVersionUID = 7950151650447893900L; - private String errorMessage; - - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - - public AndroidAgentException(String msg, Exception nestedEx) { - super(msg, nestedEx); - setErrorMessage(msg); - } - - public AndroidAgentException(String message, Throwable cause) { - super(message, cause); - setErrorMessage(message); - } - - public AndroidAgentException(String msg) { - super(msg); - setErrorMessage(msg); - } - - public AndroidAgentException() { - super(); - } - - public AndroidAgentException(Throwable cause) { - super(cause); - } - - - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/AndroidOperationException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/AndroidOperationException.java deleted file mode 100644 index 360ba4b1d..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/AndroidOperationException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.mdm.services.android.exception; - -import org.wso2.carbon.mdm.services.android.util.Message; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -/** - * Custom exception class for wrapping Android Operation related exceptions. - */ -public class AndroidOperationException extends WebApplicationException { - - public AndroidOperationException(Message message, MediaType mediaType) { - super(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message). - type(mediaType).build()); - } -} - diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/BadRequestException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/BadRequestException.java deleted file mode 100644 index 04ce0e141..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/BadRequestException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.mdm.services.android.exception; - -import org.wso2.carbon.mdm.services.android.bean.ErrorResponse; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; - -/** - * Custom exception class for wrapping BadRequest related exceptions. - */ -public class BadRequestException extends WebApplicationException { - - public BadRequestException(ErrorResponse error) { - super(Response.status(Response.Status.BAD_REQUEST).entity(error).build()); - } -} \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ErrorDTO.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ErrorDTO.java deleted file mode 100644 index 4a8d45a56..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ErrorDTO.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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.mdm.services.android.exception; - -import java.util.ArrayList; -import java.util.List; - -public class ErrorDTO { - - private Long code = null; - private String message = null; - private String description = null; - - public void setMoreInfo(String moreInfo) { - this.moreInfo = moreInfo; - } - - public void setCode(Long code) { - this.code = code; - } - - public void setMessage(String message) { - this.message = message; - } - - public void setDescription(String description) { - this.description = description; - } - - public void setError(List error) { - this.error = error; - } - - private String moreInfo = null; - - public String getMessage() { - return message; - } - - public Long getCode() { - return code; - } - - public String getDescription() { - return description; - } - - public String getMoreInfo() { - return moreInfo; - } - - public List getError() { - return error; - } - - public String toString() { - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("class ErrorDTO {\n"); - stringBuilder.append(" code: ").append(code).append("\n"); - stringBuilder.append(" message: ").append(message).append("\n"); - stringBuilder.append(" description: ").append(description).append("\n"); - stringBuilder.append(" moreInfo: ").append(moreInfo).append("\n"); - stringBuilder.append(" error: ").append(error).append("\n"); - stringBuilder.append("}\n"); - return stringBuilder.toString(); - } - - private List error = new ArrayList<>(); - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ForbiddenException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ForbiddenException.java deleted file mode 100644 index be91aafe1..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ForbiddenException.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.mdm.services.android.exception; - -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; - -/** - * Exception class that is corresponding to 401 Forbidden response - */ - -public class ForbiddenException extends WebApplicationException { - - private String message; - - public ForbiddenException() { - super(Response.status(Response.Status.FORBIDDEN) - .build()); - } - - public ForbiddenException(ErrorDTO errorDTO) { - super(Response.status(Response.Status.FORBIDDEN) - .entity(errorDTO) - .header(AndroidConstants.HEADER_CONTENT_TYPE, AndroidConstants.APPLICATION_JSON) - .build()); - message = errorDTO.getDescription(); - } - - @Override - public String getMessage() { - return message; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/GlobalThrowableMapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/GlobalThrowableMapper.java deleted file mode 100644 index 928022d1c..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/GlobalThrowableMapper.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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.mdm.services.android.exception; - -import com.google.gson.JsonParseException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils; - -import javax.naming.AuthenticationException; -import javax.validation.ConstraintViolationException; -import javax.ws.rs.ClientErrorException; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; - -/** - * Handle the cxf level exceptions. - */ -public class GlobalThrowableMapper implements ExceptionMapper { - private static final Log log = LogFactory.getLog(GlobalThrowableMapper.class); - - private ErrorDTO e500 = new ErrorDTO(); - - GlobalThrowableMapper() { - e500.setCode((long) 500); - e500.setMessage("Internal server error."); - e500.setMoreInfo(""); - e500.setDescription("The server encountered an internal error. Please contact administrator."); - - } - - @Override - public Response toResponse(Throwable e) { - - if (e instanceof JsonParseException) { - String errorMessage = "Malformed request body."; - if (log.isDebugEnabled()) { - log.debug(errorMessage, e); - } - return AndroidDeviceUtils.buildBadRequestException(errorMessage).getResponse(); - } - if (e instanceof NotFoundException) { - return ((NotFoundException) e).getResponse(); - } - if (e instanceof BadRequestException) { - return ((BadRequestException) e).getResponse(); - } - if (e instanceof UnexpectedServerErrorException) { - if (log.isDebugEnabled()) { - log.debug("Unexpected server error", e); - } - return ((UnexpectedServerErrorException) e).getResponse(); - } - if (e instanceof ConstraintViolationException) { - if (log.isDebugEnabled()) { - log.debug("Constraint violation issue.", e); - return ((ParameterValidationException) e).getResponse(); - } - } - if (e instanceof IllegalArgumentException) { - ErrorDTO errorDetail = new ErrorDTO(); - errorDetail.setCode((long) 400); - errorDetail.setMoreInfo(""); - errorDetail.setMessage(""); - errorDetail.setDescription(e.getMessage()); - return Response - .status(Response.Status.BAD_REQUEST) - .entity(errorDetail) - .build(); - } - if (e instanceof ClientErrorException) { - if (log.isDebugEnabled()) { - log.debug("Client error", e); - } - return ((ClientErrorException) e).getResponse(); - } - if (e instanceof AuthenticationException) { - ErrorDTO errorDetail = new ErrorDTO(); - errorDetail.setCode((long) 401); - errorDetail.setMoreInfo(""); - errorDetail.setMessage(""); - errorDetail.setDescription(e.getMessage()); - return Response - .status(Response.Status.UNAUTHORIZED) - .entity(errorDetail) - .build(); - } - if (e instanceof ForbiddenException) { - if (log.isDebugEnabled()) { - log.debug("Resource forbidden", e); - } - return ((ForbiddenException) e).getResponse(); - } - //unknown exception log and return - log.error("An Unknown exception has been captured by global exception mapper.", e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).header("Content-Type", "application/json") - .entity(e500).build(); - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/NotFoundException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/NotFoundException.java deleted file mode 100644 index 3556e4db6..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/NotFoundException.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.mdm.services.android.exception; - -import org.wso2.carbon.mdm.services.android.bean.ErrorResponse; -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; - -public class NotFoundException extends WebApplicationException { - private String message; - private static final long serialVersionUID = 147943572342342340L; - - public NotFoundException(ErrorResponse error) { - super(Response.status(Response.Status.NOT_FOUND).entity(error).build()); - } - public NotFoundException(ErrorDTO errorDTO) { - super(Response.status(Response.Status.NOT_FOUND) - .entity(errorDTO) - .header(AndroidConstants.HEADER_CONTENT_TYPE, AndroidConstants.APPLICATION_JSON) - .build()); - message = errorDTO.getDescription(); - } - - @Override - public String getMessage() { - return message; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/OperationConfigurationException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/OperationConfigurationException.java deleted file mode 100644 index a8d3b46e3..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/OperationConfigurationException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.mdm.services.android.exception; - -/** - * - * Custom exception class for operation configuration related exceptions. - * - */ -public class OperationConfigurationException extends Exception { - - private static final long serialVersionUID = 7435543643747623629L; - - public OperationConfigurationException(String errorMessage) { - super(errorMessage); - } - - public OperationConfigurationException(String errorMessage, Throwable throwable) { - super(errorMessage, throwable); - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ParameterValidationException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ParameterValidationException.java deleted file mode 100644 index 6fbdd52b8..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/ParameterValidationException.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.mdm.services.android.exception; - -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; -import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils; - -import javax.validation.ConstraintViolation; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; -import java.util.Set; - -public class ParameterValidationException extends WebApplicationException { - - private String message; - public ParameterValidationException(Set> violations) { - super(Response.status(Response.Status.BAD_REQUEST) - .entity(AndroidDeviceUtils.getConstraintViolationErrorDTO(violations)) - .header(AndroidConstants.HEADER_CONTENT_TYPE, AndroidConstants.APPLICATION_JSON) - .build()); - - //Set the error message - StringBuilder stringBuilder = new StringBuilder(); - for (ConstraintViolation violation : violations) { - stringBuilder.append(violation.getRootBeanClass().getSimpleName()); - stringBuilder.append("."); - stringBuilder.append(violation.getPropertyPath()); - stringBuilder.append(": "); - stringBuilder.append(violation.getMessage()); - stringBuilder.append(", "); - } - message = stringBuilder.toString(); - } - - @Override - public String getMessage() { - return message; - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/UnexpectedServerErrorException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/UnexpectedServerErrorException.java deleted file mode 100644 index baf255033..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/UnexpectedServerErrorException.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.mdm.services.android.exception; - -import org.wso2.carbon.mdm.services.android.bean.ErrorResponse; -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; - -public class UnexpectedServerErrorException extends WebApplicationException { - private String message; - private static final long serialVersionUID = 147943579458906890L; - - public UnexpectedServerErrorException(ErrorResponse error) { - super(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build()); - } - public UnexpectedServerErrorException(ErrorDTO errorDTO) { - super(Response.status(Response.Status.INTERNAL_SERVER_ERROR) - .entity(errorDTO) - .header(AndroidConstants.HEADER_CONTENT_TYPE, AndroidConstants.APPLICATION_JSON) - .build()); - message = errorDTO.getDescription(); - } - - @Override - public String getMessage() { - return message; - } - - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java deleted file mode 100644 index c75ba1f9e..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java +++ /dev/null @@ -1,1840 +0,0 @@ -/* - * - * 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.mdm.services.android.services; - -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Info; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Extension; -import io.swagger.annotations.Tag; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.ResponseHeader; -import org.wso2.carbon.apimgt.annotations.api.Scope; -import org.wso2.carbon.apimgt.annotations.api.Scopes; -import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; -import org.wso2.carbon.mdm.services.android.bean.wrapper.*; -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; - -import javax.validation.Valid; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.List; - -@SwaggerDefinition( - info = @Info( - version = "0.9.0", - title = "", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", - value = "Android Device Management Administrative Service"), - @ExtensionProperty(name = "context", - value = "/api/device-mgt/android/v0.9/admin/devices"), - }) - } - ), - tags = { - @Tag(name = "android,device_management", description = "") - } -) -@Path("/admin/devices") -@Api(value = "Android Device Management Administrative Service", description = "Device management related admin APIs.") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -@Scopes( - scopes = { - @Scope( - name = "Lock Device", - description = "Hard lock own device", - key = "perm:android:lock-devices", - permissions = {"/device-mgt/devices/owning-device/operations/android/lock"} - ), - @Scope( - name = "Unlock Device", - description = "Unlock permanently locked device", - key = "perm:android:unlock-devices", - permissions = {"/device-mgt/devices/owning-device/operations/android/unlock"} - ), - @Scope( - name = "Get Location", - description = "Request device location coordinates", - key = "perm:android:location", - permissions = {"/device-mgt/devices/owning-device/operations/android/location"} - ), - @Scope( - name = "Clear Password", - description = "Clear the password on Android devices", - key = "perm:android:clear-password", - permissions = {"/device-mgt/devices/owning-device/operations/android/clear-password"} - ), - @Scope( - name = "Control Camera", - description = "Enabling or Disabling the Camera on Android Devices", - key = "perm:android:control-camera", - permissions = {"/device-mgt/devices/owning-device/operations/android/camera"} - ), - @Scope( - name = "Get Info", - description = "Requesting device information from Android Devices", - key = "perm:android:info", - permissions = {"/device-mgt/devices/owning-device/operations/android/info"} - ), - @Scope( - name = "Get Logs", - description = "Requesting Logcat Details from Android Devices", - key = "perm:android:logcat", - permissions = {"/device-mgt/devices/owning-device/operations/android/logcat"} - ), - @Scope( - name = "Enterprise Wipe", - description = "Enterprise Wiping Android Devices", - key = "perm:android:enterprise-wipe", - permissions = {"/device-mgt/devices/owning-device/operations/android/enterprise-wipe"} - ), - @Scope( - name = "Factory Reset", - description = "Factory Resetting Android Devices", - key = "perm:android:wipe", - permissions = {"/device-mgt/devices/owning-device/operations/android/wipe"} - ), - @Scope( - name = "Get Installed Applications", - description = "Get list of installed applications", - key = "perm:android:applications", - permissions = {"/device-mgt/devices/owning-device/operations/android/applications"} - ), - @Scope( - name = "Ring Device", - description = "Ring Android devices", - key = "perm:android:ring", - permissions = {"/device-mgt/devices/owning-device/operations/android/ring"} - ), - @Scope( - name = "Reboot Device", - description = "Reboot Android devices", - key = "perm:android:reboot", - permissions = {"/device-mgt/devices/owning-device/operations/android/reboot"} - ), - @Scope( - name = "Mute Device", - description = "Mute Android devices", - key = "perm:android:mute", - permissions = {"/device-mgt/devices/owning-device/operations/android/mute"} - ), - @Scope( - name = "Install Applications", - description = "Installing an Application on Android Devices", - key = "perm:android:install-application", - permissions = {"/device-mgt/devices/owning-device/operations/android/install-app"} - ), - @Scope( - name = "Update Applications", - description = "Updating an Application on Android Devices", - key = "perm:android:update-application", - permissions = {"/device-mgt/devices/owning-device/operations/android/update-app"} - ), - @Scope( - name = "Uninstall Applications", - description = "Uninstalling an Application on Android Devices", - key = "perm:android:uninstall-application", - permissions = {"/device-mgt/devices/owning-device/operations/android/uninstall-app"} - ), - @Scope( - name = "Blacklist Applications", - description = "Blacklisting applications on Android Devices", - key = "perm:android:blacklist-applications", - permissions = {"/device-mgt/devices/owning-device/operations/android/blacklist-app"} - ), - @Scope( - name = "Upgrade Firmware", - description = "Upgrading Firmware of Android Devices", - key = "perm:android:upgrade-firmware", - permissions = {"/device-mgt/devices/owning-device/operations/android/upgrade"} - ), - @Scope( - name = "Configure VPN", - description = "Configure VPN on Android Device", - key = "perm:android:configure-vpn", - permissions = {"/device-mgt/devices/owning-device/operations/android/vpn"} - ), - @Scope( - name = "Send Notification", - description = "Sending a notification to Android Device", - key = "perm:android:send-notification", - permissions = {"/device-mgt/devices/owning-device/operations/android/send-notification"} - ), - @Scope( - name = "Configure Wi-Fi", - description = "Configure Wi-Fi on Android Device", - key = "perm:android:configure-wifi", - permissions = {"/device-mgt/devices/owning-device/operations/android/wifi"} - ), - @Scope( - name = "Encrypt Storage", - description = "Encrypting storage on Android Device", - key = "perm:android:encrypt-storage", - permissions = {"/device-mgt/devices/owning-device/operations/android/encrypt"} - ), - @Scope( - name = "Change Password", - description = "Changing the lock code of an Android Device", - key = "perm:android:change-lock-code", - permissions = {"/device-mgt/devices/owning-device/operations/android/change-lock-code"} - ), - @Scope( - name = "Password Policy", - description = "Set password policy of an Android Device", - key = "perm:android:set-password-policy", - permissions = {"/device-mgt/devices/owning-device/operations/android/password-policy"} - ), - @Scope( - name = "Add Web clip", - description = "Setting a Web Clip on Android Devices", - key = "perm:android:set-webclip", - permissions = {"/device-mgt/devices/owning-device/operations/android/webclip"} - ), - @Scope( - name = "File Transfer", - description = "Transferring a file to android devices", - key = "perm:android:file-transfer", - permissions = {"/device-mgt/devices/owning-device/operations/android/file-transfer"} - ) - } -) -public interface DeviceManagementAdminService { - - @POST - @Path("/file-transfer") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Transferring file to the device.", - notes = "Using this API you have the option to transfer a file from SFTP/FTP server or using an " + - "HTTP link to the device or retrieve file from the device to FTP/SFTP server .", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:file-transfer") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "File transferred.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified. \n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while file transfer operation.") - }) - Response fileTransfer( - @ApiParam( - name = "fileTransfer", - value = "Provide the ID of the Android device. Multiple device IDs can be added by using " + - "comma separated values.", - required = true) FileTransferBeanWrapper fileTransferBeanWrapper); - - @POST - @Path("/lock-devices") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Adding a Screen Lock on Android devices", - notes = "Using this API you have the option of hard locking an Android device, where the Administrator " + - "permanently locks the device or screen locking an Android device.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:lock-devices") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the device lock operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified. \n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while locking the device.") - }) - Response configureDeviceLock( - @ApiParam( - name = "deviceLock", - value = "Provide the ID of the Android device, the message that needs to be sent out when locking the device, " + - "and define true as the value if you need to hard lock the device or define false as the value to " + - "screen lock the device." + - "Multiple device IDs can be added by using comma separated values. ", - required = true) DeviceLockBeanWrapper deviceLockBeanWrapper); - - @POST - @Path("/unlock-devices") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Unlocking Android Devices", - responseContainer = "List", - notes = "Unlock devices that were locked permanently using the hard lock operation. Devices that are hard locked can only be unlocked by the EMM administrator.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:unlock-devices") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the device unlock operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while unlocking the device.") - }) - Response configureDeviceUnlock( - @ApiParam( - name = "deviceIDs", - value = "Provide the ID of the Android device. Multiple device IDs can be added by using comma separated values. ", - required = true) - List deviceIDs); - - - @POST - @Path("/location") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Requesting Location Coordinates", - responseContainer = "List", - notes = "Request location coordinates of Android devices. \n" + - "Example: In situations where you have lost your device and need to find out where it is, you can use this REST API to get the location of the device.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:location") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Get-location operation has successfully been scheduled", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding a new get-location operation.")}) - Response getDeviceLocation( - @ApiParam( - name = "deviceIDs", - value = "Provide the ID of the Android device. Multiple device IDs can be added by using comma separated values. ", - required = true) - List deviceIDs); - - @POST - @Path("/clear-password") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Clearing the Password on Android Devices", - notes = "Clear the password on Android devices", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:clear-password") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the clear password operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified the last time.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding a new clear password operation.") - }) - Response removePassword( - @ApiParam(name = "deviceIDs", - value = "Provide the ID of the Android device. Multiple device IDs can be added by using comma separated values. ", - required = true) List deviceIDs); - - @POST - @Path("/control-camera") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Enabling or Disabling the Camera on Android Devices", - notes = "Enable or disable the camera on Android devices.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:control-camera") - }) - }) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the camera control operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding the new camera control operation.") - }) - Response configureCamera( - @ApiParam( - name = "cameraControl", - value = "Define the properties to enable/disable the camera. " + - "Disable the camera on the device by assigning true as the value or enable the " + - "camera on the device to function by defining false as the value and the ID of the Android device. " + - "Multiple device IDs can be added by using comma separated values. ", - required = true) - CameraBeanWrapper cameraBeanWrapper); - - @POST - @Path("/info") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Requesting Information from Android Devices", - notes = "Using this REST API you are able to request for Android device details. Once this REST API is" + - " executed it will be in the Android operation queue until the device calls the server to retrieve " + - "the list of operations that needs to be executed on the device", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:info") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the device info operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding a new device info operation.") - }) - Response getDeviceInformation( - @ApiParam( - name = "deviceIds", - value = "Provide the device ID of the Android device. Multiple device IDs can be added by using comma separated values.", - required = true) - List deviceIDs); - - @POST - @Path("/logcat") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Requesting Logcat Details from Android Devices", - notes = "Using this REST API you are able to request for Android device log details. Once this REST API is" + - " executed it will be in the Android operation queue until the device calls the server to retrieve " + - "the list of operations that needs to be executed on the device.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:logcat") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the operation to get the logcat details.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding a new device logcat operation.") - }) - Response getDeviceLogcat( - @ApiParam( - name = "deviceIds", - value = "Provide the ID of the Android device. Multiple device IDs can be added by using comma separated values.", - required = true) - List deviceIDs); - - @POST - @Path("/enterprise-wipe") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Enterprise Wiping Android Devices", - notes = "Enterprise wipe is the process of deleting enterprise related data on a device while keeping the " + - "personal data intact. You are able to enterprise wipe Android devices using this REST API.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enterprise-wipe") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the enterprise wipe operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified." + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding the enterprise wipe operation.")}) - Response wipeDevice( - @ApiParam( - name = "deviceIDs", - value = "Provide the ID of the Android device. Multiple device IDs can be added by using comma separated values. ", - required = true) - List deviceIDs); - - @POST - @Path("/wipe") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Factory Resetting an Android Device", - notes = "Factory rest or erase all the data stored on the Android devices " + - "to restore them back to the original system.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:wipe") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the device wipe/factory reset operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding the device wipe operation.")}) - Response wipeData( - @ApiParam( - name = "wipeData", - value = "Provide the the passcode, which is the passcode that the Android agent prompts the device owner to set at the time of device enrollment, " + - "to enable the factory reset operation, and the ID of the Android device. Multiple device IDs can be added by using comma separated values. ", - required = true) - WipeDataBeanWrapper wipeDataBeanWrapper); - - @POST - @Path("/applications") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Getting the List of Installed Applications on Android Devices", - notes = "Using this REST API the server requests for the list of applications that are installed on" + - " the Android devices. Once this REST API is executed it will be in the Android operation queue " + - "until the device calls the server to retrieve the list of operations that needs to be executed " + - "on the device.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:applications") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the get-applications operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding the new get-applications operation.") - }) - Response getApplications( - @ApiParam( - name = "deviceIDs", - value = "Provide the ID of the Android device. Multiple device IDs can be added using comma separated values.", - required = true) - List deviceIDs); - - @POST - @Path("/ring") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Ringing Android Devices", - notes = "Ring Android devices.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:ring") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the device ring operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding a new device ring operation.") - }) - Response ringDevice( - @ApiParam( - name = "deviceIDs", - value = "Provide the ID of the Android device. Multiple device IDs can be added using comma separated values.", - required = true) - List deviceIDs); - - @POST - @Path("/reboot") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Rebooting Android Devices", - notes = "Reboot or restart your Android devices.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:reboot") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the device reboot operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding the new device reboot operation.") - }) - Response rebootDevice( - @ApiParam( - name = "deviceIDs", - value = "Provide the ID of the Android device. Multiple device IDs can be added using comma separated values. ", - required = true) - List deviceIDs); - - @POST - @Path("/mute") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Muting Android Devices", - notes = "Mute or enable a silent profile for Android devices.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:mute") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the device mute operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding a new device mute operation.") - }) - Response muteDevice( - @ApiParam( - name = "deviceIDs", - value = "Provide the ID of the Android device. Multiple device IDs can be added using comma separated values. ", - required = true) - List deviceIDs); - - @POST - @Path("/install-application") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Installing an Application on Android Devices", - notes = "Install an application on an Android device. If the device you are installing the application has the WSO2 system service application installed," + - " the application installation will happen in silent mode, else the device user's consent will be required.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:install-application") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the install application operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding a new install-application operation.") - }) - Response installApplication( - @ApiParam( - name = "applicationInstallation", - value = "Properties required to install an application on Android devices. Provide the the package name, type," + - " URL and name of the application, the date and time for the scheduled installation, and the ID of the " + - "Android device. Multiple device IDs can be added by using comma separated values.", - required = true) - ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper); - - @POST - @Path("/update-application") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Updating an Application on Android Devices", - notes = "Update an application on an Android device. If the device" + - " has the WSO2 system service application installed, the application update will happen in silent " + - "mode, else the device user's consent is required.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:update-application") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the update-application operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding the new update-application operation.") - }) - Response updateApplication( - @ApiParam( - name = "applicationUpdate", - value = "Properties required to update an application on Android devices. Provide the the package name, type," + - "URL and name of the application, the date and time for the scheduled installation, and the ID of the" + - "Android device. Multiple device IDs can be added by using comma separated values.", - required = true) - ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper); - - @POST - @Path("/uninstall-application") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Uninstalling an Application from Android Devices", - notes = "Uninstall an application from Android devices.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:uninstall-application") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the uninstall-application operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding a new uninstall-application operation.") - }) - Response uninstallApplication( - @ApiParam( - name = "applicationUninstallation", - value = "Properties required to uninstall an application. Provide the the package name, type," + - "URL and name of the application, the date and time for the scheduled installation, and the ID of the" + - "Android device. Multiple device IDs can be added by using comma separated values.", - required = true) - ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper); - - @POST - @Path("/blacklist-applications") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "BlackListing Applications for Android Devices", - notes = "Prevents you from using specific applications. For Android operation systems before Lollipop," + - " when a blacklisted application is clicked a screen is displayed to prevent you from using the app. For the Lollipop" + - " Android operating systems and after, the blacklisted apps will be hidden. Blacklisting can be used on both BYOD and " + - "COPE devices. Applications can be blacklisted via the application restriction policy too.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:blacklist-applications") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the application blacklist operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding the new blacklist-applications operation.") - }) - Response blacklistApplications( - @ApiParam( - name = "blacklistApplications", - value = "The properties required to blacklist applications. Provide the package name of the application to be blacklisted," + - " and the ID of the Android device. Multiple device IDs can be added by using comma separated values. ", - required = true) - @Valid BlacklistApplicationsBeanWrapper blacklistApplicationsBeanWrapper); - - @POST - @Path("/upgrade-firmware") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Upgrading Firmware of Android Devices", - notes = "Upgrade the firmware of Android devices.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:upgrade-firmware") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the firmware upgrade operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding a new upgrade firmware operation.") - }) - Response upgradeFirmware( - @ApiParam( - name = "upgradeFirmware", - value = "Properties required to upgrade the firmware. Provide the date and time to schedule the firmware update in the " + - "yyyy-MM-dd'T'HH:mm:ss.SSSXXX format, the OTA upgrade server URL in one of the following formats " + - "(example: http//abc.com, http://abc.com/ota), " + - "and the ID of the Android device. Multiple device IDs can be added by using comma separated values.", - required = true) - UpgradeFirmwareBeanWrapper upgradeFirmwareBeanWrapper); - - @POST - @Path("/configure-vpn") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Configuring VPN on Android devices", - notes = "Configure VPN on Android devices.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:configure-vpn") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the configure VPN operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified." + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while configuring the VPN.") - }) - Response configureVPN( - @ApiParam( - name = "vpnBean", - value = "VPN configuration and DeviceIds", - required = true) - VpnBeanWrapper vpnBeanWrapper); - - @POST - @Path("/send-notification") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Sending a Notification to Android Devices", - notes = "Send a notification or message to Android devices.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:send-notification") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully sent the notification.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding a new send notification operation.") - }) - Response sendNotification( - @ApiParam( - name = "notification", - value = "The properties required to send a notification. Provide the message you wish to send and the ID of the " + - "Android device. Multiple device IDs can be added by using comma separated values.", - required = true) - NotificationBeanWrapper notificationBeanWrapper); - - @POST - @Path("/configure-wifi") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Configuring Wi-Fi on Android Devices", - notes = "Configure Wi-Fi on Android devices.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:configure-wifi") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the configure Wi-Fi operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified." + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while configuring Wi-Fi.") - }) - Response configureWifi( - @ApiParam( - name = "wifi", - value = "The properties required to configure Wi-Fi. Provide the password to connect to the specified Wi-Fi network," + - "the ssid or the name of the Wi-Fi network that you wish to configure and the ID of the Android device." + - " Multiple device IDs can be added by using comma separated values.", - required = true) - WifiBeanWrapper wifiBeanWrapper); - - @POST - @Path("/encrypt-storage") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Encrypting Storage on Android Devices", - notes = "Encrypt the data stored on Android devices.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:encrypt-storage") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the encrypt storage operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified." + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding a new encrypt storage operation.") - }) - Response encryptStorage( - @ApiParam( - name = "encryption", - value = "Properties required to encrypt the storage. Encrypt the storage on the device by assigning " + - "true as the value or do not encrypt the storage on the device by assigning false as the value and " + - "provide the ID of the Android device. Multiple device IDs can be added by using comma separated values.", - required = true) - EncryptionBeanWrapper encryptionBeanWrapper); - - @POST - @Path("/change-lock-code") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Changing the Lock Code on Android Devices", - notes = "Change the lock code on Android devices.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:change-lock-code") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the change lock code operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding a new change lock code operation.") - }) - Response changeLockCode( - @ApiParam( - name = "lockCode", - value = "The properties to change th lock code. Provide the lock code that will replace the current lock code on Android devices and " + - "the ID of the Android device. Multiple device IDs can be added by using comma separated values. " + - "If a passcode policy has been set in EMM, the lock code should comply to the passcode policy.\t", - required = true) - LockCodeBeanWrapper lockCodeBeanWrapper); - - @POST - @Path("/set-password-policy") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Setting a Password Policy on Android Devices", - notes = "Set a password policy on Android devices.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:set-password-policy") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the set password policy operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The entity of the request was in a not supported format."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding a new set password policy operation.") - }) - Response setPasswordPolicy( - @ApiParam( - name = "passwordPolicy", - value = "The properties required to set a password policy.", - required = true) - PasswordPolicyBeanWrapper passwordPolicyBeanWrapper); - - @POST - @Path("/set-webclip") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Setting a Web Clip on Android Devices", - notes = "Set a web clip on Android devices. A web clip is used to add a bookmark to a web application.", - response = Activity.class, - tags = "Android Device Management Administrative Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:set-webclip") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the set web clip operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding adding a the set web clip operation.") - }) - Response setWebClip( - @ApiParam( - name = "webClip", - value = "The properties to set the web clip.", - required = true) - WebClipBeanWrapper webClipBeanWrapper); - - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java deleted file mode 100644 index ec88434ae..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java +++ /dev/null @@ -1,413 +0,0 @@ -/* - * - * 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.mdm.services.android.services; - -import io.swagger.annotations.*; - -import org.wso2.carbon.apimgt.annotations.api.Scope; -import org.wso2.carbon.apimgt.annotations.api.Scopes; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidApplication; -import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice; -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; -import javax.validation.constraints.Size; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.List; - -@SwaggerDefinition( - info = @Info( - version = "0.9.0", - title = "", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", value = "Android Device Management"), - @ExtensionProperty(name = "context", value = "/api/device-mgt/android/v0.9/devices"), - }) - } - ), - tags = { - @Tag(name = "android,device_management", description = "") - } -) -@Api(value = "Android Device Management", - description = "This carries all the resources related to the Android device management functionalities.") -@Path("/devices") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -@Scopes( - scopes = { - @Scope( - name = "Enroll Device", - description = "Register an Android device", - key = "perm:android:enroll", - permissions = {"/device-mgt/devices/enroll/android"} - ), - @Scope( - name = "Un-enroll Device", - description = "Unregister an Android device", - key = "perm:android:disenroll", - permissions = {"/device-mgt/devices/disenroll/android"} - ) - } -) -public interface DeviceManagementService { - - @PUT - @Path("/{id}/applications") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - consumes = MediaType.APPLICATION_JSON, - httpMethod = "PUT", - value = "Updating the Application Details on Android Devices", - notes = "Update the details of the applications that are installed on Android devices.", - tags = "Android Device Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully updated the application details.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The URL of the updated application list."), - @ResponseHeader( - name = "Content-Type", - description = "The content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 404, - message = "Not Found. \n The specified resource does not exist."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while updating the application list.") - }) - Response updateApplicationList( - @ApiParam( - name = "id", - value = "The unique device identifier.") - @NotNull - @Size(min = 2 , max = 45) - @Pattern(regexp = "^[A-Za-z0-9]*$") - @PathParam("id") String id, - @ApiParam( - name = "applications", - value = "The properties to update application details. Multiple applications can be updated using comma separated values.") - List androidApplications); - - @PUT - @Path("/{id}/pending-operations") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "PUT", - value = "Getting the Pending Operation List", - responseContainer = "List", - notes = "The Android agent communicates with the server to get the operations that are queued up " + - "at the server end via this REST API." + - " While getting the pending operations the details of the operations executed at the device end is shared with the server. " + - "The server then updates the status of the operations that were carried out on the device.", - response = Operation.class, - tags = "Android Device Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully fetched the pending operations of the Android device.", - response = Operation.class, - responseContainer = "List", - responseHeaders = { - @ResponseHeader( - name = "Content-Type", - description = "The content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.") - }), - @ApiResponse( - code = 304, - message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource."), - @ApiResponse( - code = 406, - message = "Not Acceptable.\n The requested media type is not supported"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Server error occurred while fetching the list of pending operations.") - }) - Response getPendingOperations( - @ApiParam( - name = "id", - value = "The unique device identifier.", - required = true) - @PathParam("id") String id, - @ApiParam( - name = "If-Modified-Since", - value = "Checks if the requested variant was modified, since the specified date-time.\n" + - "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" + - "Example: Mon, 05 Jan 2014 15:10:00 +0200.", - required = false) - @HeaderParam("If-Modified-Since") String ifModifiedSince, - @ApiParam( - name = "resultOperations", - value = "Properties to update the device operations and their status.") - List resultOperations); - - @POST - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Registering an Android Device", - notes = "When registering an Android device, you need to install" + - " the Android Agent on the device, before being able to register the device with WSO2 EMM. Instead," + - " you can use this REST API to register an Android device with WSO2 EMM, without having to install" + - " an Android Agent. This API can be mainly used to test the device enrollment process.", - tags = "Android Device Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully created an instance of the device.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the added device enrollment."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding a new device.") - }) - Response enrollDevice(@ApiParam( - name = "device", - value = "The properties required to enroll a device.") - @Valid AndroidDevice device); - - @GET - @Path("/{id}/status") - @ApiOperation( - httpMethod = "GET", - value = "Getting the Registration Status of an Android Device", - notes = "Use this REST API to retrieve the registration status of an Android device.", - tags = "Android Device Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully fetched the status of the Android device enrollment.", - responseHeaders = { - @ResponseHeader( - name = "Content-Type", - description = "The content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests."), - }), - @ApiResponse( - code = 304, - message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource."), - @ApiResponse( - code = 406, - message = "Not Acceptable.\n The requested media type is not supported"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Server error occurred while fetching the enrollment status of the Android device.") - }) - Response isEnrolled( - @ApiParam( - name = "id", - value = "The unique device identifier") - @PathParam("id") String id, - @ApiParam( - name = "If-Modified-Since", - value = "Checks if the requested variant was modified, since the specified date-time.\n" + - "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" + - "Example: Mon, 05 Jan 2014 15:10:00 +0200", - required = false) - @HeaderParam("If-Modified-Since") String ifModifiedSince); - - @PUT - @Path("/{id}") - @ApiOperation( - httpMethod = "PUT", - value = "Updating the Registration Details of an Android Device", - notes = "Use this REST API to update the registration details of an Android device.", - tags = "Android Device Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully updated the device enrollment details.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the updated device enrollment."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 404, - message = "Not Found. \n The specified resource does not exist."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while updating the device enrollment.") - }) - Response modifyEnrollment( - @ApiParam( - name = "id", - value = "The unique device identifier.") - @PathParam("id") String id, - @ApiParam( - name = "device", - value = "The properties of required to update device enrollment details.") @Valid AndroidDevice androidDevice); - - @DELETE - @Path("/{id}") - @ApiOperation( - httpMethod = "DELETE", - value = "Unregistering an Android Device", - notes = "Use this REST API to unregister an Android device.", - tags = "Android Device Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:disenroll") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully disenrolled the device."), - @ApiResponse( - code = 404, - message = "Not Found. \n The specified resource does not exist."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while dis-enrolling the device.") - }) - Response disEnrollDevice( - @ApiParam( - name = "id", - value = "The unique device identifier.") - @PathParam("id") String id); - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java deleted file mode 100644 index d96da0d3a..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java +++ /dev/null @@ -1,254 +0,0 @@ -/* - * - * 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.mdm.services.android.services; - -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Info; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Extension; -import io.swagger.annotations.Tag; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.ResponseHeader; -import org.wso2.carbon.apimgt.annotations.api.Scope; -import org.wso2.carbon.apimgt.annotations.api.Scopes; -import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; -import org.wso2.carbon.mdm.services.android.bean.AndroidPlatformConfiguration; -import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; - -import javax.validation.Valid; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -@SwaggerDefinition( - info = @Info( - version = "0.9.0", - title = "", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", - value = "Android Configuration Management"), - @ExtensionProperty(name = "context", - value = "/api/device-mgt/android/v0.9/configuration"), - }) - } - ), - tags = { - @Tag(name = "android,device_management", description = "") - } -) -@Api(value = "Android Configuration Management", description = "This API carries all the resource used to mange the Android platform configurations.") -@Path("/configuration") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -@Scopes( - scopes = { - @Scope( - name = "Enroll Device", - description = "Register an Android device", - key = "perm:android:enroll", - permissions = {"/device-mgt/devices/enroll/android"} - ), - @Scope( - name = "View Configurations", - description = "Getting Android Platform Configurations", - key = "perm:android:view-configuration", - permissions = {"/device-mgt/devices/enroll/android"} - ), - @Scope( - name = "Manage Configurations", - description = "Updating Android Platform Configurations", - key = "perm:android:manage-configuration", - permissions = {"/device-mgt/platform-configurations/manage"} - ) - } -) -public interface DeviceTypeConfigurationService { - - @GET - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "Getting Android Platform Configurations", - notes = "Get the Android platform configuration details using this REST API.", - response = PlatformConfiguration.class, - tags = "Android Configuration Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:view-configuration") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully fetched the Android platform configurations.", - response = PlatformConfiguration.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests."), - }), - @ApiResponse( - code = 304, - message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource."), - @ApiResponse( - code = 404, - message = "Not Found. \n The specified resource does not exist."), - @ApiResponse( - code = 406, - message = "Not Acceptable.\n The requested media type is not supported"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Server error occurred while fetching the Android platform configuration.") - }) - Response getConfiguration( - @ApiParam( - name = "If-Modified-Since", - value = "Checks if the requested variant was modified, since the specified date-time.\n" + - "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" + - "Example: Mon, 05 Jan 2014 15:10:00 +0200", - required = false) - @HeaderParam("If-Modified-Since") String ifModifiedSince); - - @PUT - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "PUT", - value = "Updating Android Platform Configurations", - notes = "Update the Android platform configurations using this REST API.", - tags = "Android Configuration Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:manage-configuration") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully updated the Android platform configurations.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the updated Android platform configuration."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 404, - message = "Not Found. \n The specified resource does not exist."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while modifying the Android platform configuration.") - }) - Response updateConfiguration( - @ApiParam(name = "configuration", - value = "The properties to update the Android platform configurations.") - @Valid AndroidPlatformConfiguration androidPlatformConfiguration); - - @GET - @Path("license") - @Produces(MediaType.TEXT_PLAIN) - @ApiOperation( - produces = MediaType.TEXT_PLAIN, - httpMethod = "GET", - value = "Getting the License Agreement for the Android Device Registration", - notes = "Use this REST API to retrieve the license agreement that is used for the Android device " + - "registration process.", - response = String.class, - tags = "Android Configuration Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully fetched Android license configuration.", - response = String.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests."), - }), - @ApiResponse( - code = 304, - message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource."), - @ApiResponse( - code = 404, - message = "Not Found. \n The specified resource does not exist."), - @ApiResponse( - code = 406, - message = "Not Acceptable.\n The requested media type is not supported"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Server error occurred while fetching the Android license configuration.") - }) - Response getLicense( - @ApiParam( - name = "If-Modified-Since", - value = "Checks if the requested variant was modified, since the specified date-time.\n" + - "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" + - "Example: Mon, 05 Jan 2014 15:10:00 +0200.", - required = false) - @HeaderParam("If-Modified-Since") String ifModifiedSince) throws AndroidAgentException; - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java deleted file mode 100644 index f9ea69cad..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * - * 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.mdm.services.android.services; - -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Info; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Extension; -import io.swagger.annotations.Tag; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.ResponseHeader; -import org.wso2.carbon.apimgt.annotations.api.Scope; -import org.wso2.carbon.apimgt.annotations.api.Scopes; -import org.wso2.carbon.mdm.services.android.bean.DeviceState; -import org.wso2.carbon.mdm.services.android.bean.wrapper.EventBeanWrapper; -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; - -import javax.validation.Valid; -import javax.validation.constraints.Size; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -@SwaggerDefinition( - info = @Info( - version = "0.9.0", - title = "", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", value = "Android Event Receiver"), - @ExtensionProperty(name = "context", value = "/api/device-mgt/android/v0.9/events"), - }) - } - ), - tags = { - @Tag(name = "android,device_management", description = "") - } -) -@Api(value = "Event Receiver", description = "Event publishing/retrieving related APIs. To enable event publishing/retrieving you need to" + - " configure WSO2 EMM as explained in https://docs.wso2.com/display/EMM220/Managing+Event+Publishing+with+WSO2+Data+Analytics+Server, " + - "https://docs.wso2.com/display/EMM220/Creating+a+New+Event+Stream+and+Receiver") -@Path("/events") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -@Scopes( - scopes = { - @Scope( - name = "Enroll Device", - description = "Register an Android device", - key = "perm:android:enroll", - permissions = {"/device-mgt/devices/enroll/android"} - ) - } -) -public interface EventReceiverService { - - @POST - @Path("/publish") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Publishing Events", - notes = "Publish events received by the WSO2 EMM Android client to the WSO2 Data Analytics Server (DAS) using this API.", - tags = "Event Receiver", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse(code = 201, message = "Created. \n Successfully published the event. Location header " + - "contains URL of newly enrolled device", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The URL of the added policy."), - @ResponseHeader( - name = "Content-Type", - description = "The content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.") - }), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while publishing events.") - }) - Response publishEvents( - @ApiParam( - name = "eventBeanWrapper", - value = "Information of the agent event to be published on DAS.") - @Valid - EventBeanWrapper eventBeanWrapper); - - @GET - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "Getting event details for a given time period.", - notes = "Get the event details of a device for a given time duration using this API. The request must contain " + - "the device identifier. Optionally, both date from and date to value should be present to get " + - "alerts between a specified time. Filtering can also be done based on the device type and the device identifier." + - "(This cannot be combined with the to and from parameters).", - response = DeviceState.class, - responseContainer = "List", - tags = "Event Receiver", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully fetched the event details of the specified device for a given time duration.", - response = DeviceState.class, responseContainer = "List"), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader(name = "Content-Location", description = "Source URL of the document.") - }), - @ApiResponse( - code = 304, - message = "Not Modified. \n " + - "Empty body because the client already has the latest version of the requested resource."), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error. You must provide" + - " the device identifier. Additionally, the device identifier can be combined with either the device type" + - " OR the from and to date."), - @ApiResponse( - code = 404, - message = "Not Found. \n The specified resource does not exist."), - @ApiResponse( - code = 500, - message = "Error occurred while getting the published events for the specified device.") - }) - Response retrieveAlerts( - @ApiParam( - name = "id", - value = "The unique device identifier.", - required = true) - @Size(min = 2, max = 45) - @QueryParam("id") String deviceId, - @ApiParam( - name = "from", - value = "Specify the time and date from when you want to get the data." + - "Provide the time and date format in the unix/epoch format as the value for {unixTimestamp}. Use a Epoch convertor, to convert the time and date to this format.") - @QueryParam("from") long from, - @ApiParam( - name = "to", - value = "Specify the time and date up to when you require the data." + - "Provide the time and date format in the unix/epoch format as the value for {unixTimestamp}. Use a Epoch convertor, to convert the time and date to this format.") - @QueryParam("to") long to, - @ApiParam( - name = "type", - value = "The alert type to retrieve the events." + - "Provide APPLICATION_STATE or RUNTIME_STATE as the value.") - @Size(min = 2, max = 45) - @QueryParam("type") String type, - @ApiParam( - name = "If-Modified-Since", - value = "Checks if the requested variant was modified, since the specified date-time.\n" + - "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" + - "Example: Mon, 05 Jan 2014 15:10:00 +0200", - required = false) - @HeaderParam("If-Modified-Since") String ifModifiedSince); - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java deleted file mode 100644 index de6876ea9..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java +++ /dev/null @@ -1,1018 +0,0 @@ -/* - * 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.mdm.services.android.services.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.JSONException; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.InvalidDeviceException; -import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; -import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; -import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; -import org.wso2.carbon.mdm.services.android.bean.ApplicationInstallation; -import org.wso2.carbon.mdm.services.android.bean.ApplicationUninstallation; -import org.wso2.carbon.mdm.services.android.bean.ApplicationUpdate; -import org.wso2.carbon.mdm.services.android.bean.BlacklistApplications; -import org.wso2.carbon.mdm.services.android.bean.Camera; -import org.wso2.carbon.mdm.services.android.bean.DeviceEncryption; -import org.wso2.carbon.mdm.services.android.bean.DeviceLock; -import org.wso2.carbon.mdm.services.android.bean.ErrorResponse; -import org.wso2.carbon.mdm.services.android.bean.FileTransfer; -import org.wso2.carbon.mdm.services.android.bean.LockCode; -import org.wso2.carbon.mdm.services.android.bean.Notification; -import org.wso2.carbon.mdm.services.android.bean.PasscodePolicy; -import org.wso2.carbon.mdm.services.android.bean.UpgradeFirmware; -import org.wso2.carbon.mdm.services.android.bean.Vpn; -import org.wso2.carbon.mdm.services.android.bean.WebClip; -import org.wso2.carbon.mdm.services.android.bean.Wifi; -import org.wso2.carbon.mdm.services.android.bean.WipeData; -import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationInstallationBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationUninstallationBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationUpdateBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.BlacklistApplicationsBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.CameraBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.DeviceLockBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.EncryptionBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.FileTransferBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.LockCodeBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.NotificationBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.PasswordPolicyBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.UpgradeFirmwareBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.VpnBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.WebClipBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.WifiBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.WipeDataBeanWrapper; -import org.wso2.carbon.mdm.services.android.exception.BadRequestException; -import org.wso2.carbon.mdm.services.android.exception.UnexpectedServerErrorException; -import org.wso2.carbon.mdm.services.android.services.DeviceManagementAdminService; -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; -import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils; - -import javax.validation.Valid; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.List; - -@Path("/admin/devices") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminService { - - private static final Log log = LogFactory.getLog(DeviceManagementAdminServiceImpl.class); - private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ"; - - @POST - @Path("/file-transfer") - @Override - public Response fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper) { - try { - if (fileTransferBeanWrapper == null || fileTransferBeanWrapper.getOperation() == null - || fileTransferBeanWrapper.getDeviceIDs() == null) { - String errorMessage = "The payload of the file transfer operation is incorrect."; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - if (log.isDebugEnabled()) { - log.debug("Invoking Android file transfer operation for " + fileTransferBeanWrapper.getDeviceIDs()); - } - FileTransfer file = fileTransferBeanWrapper.getOperation(); - ProfileOperation operation = new ProfileOperation(); - if (fileTransferBeanWrapper.isUpload()) { - operation.setCode(AndroidConstants.OperationCodes.FILE_DOWNLOAD); - } else { - operation.setCode(AndroidConstants.OperationCodes.FILE_UPLOAD); - } - operation.setType(Operation.Type.PROFILE); - operation.setEnabled(true); - operation.setPayLoad(file.toJSON()); - Activity activity = AndroidDeviceUtils.getOperationResponse(fileTransferBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers ( " + fileTransferBeanWrapper.getDeviceIDs() + " ) found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance for file transfer operation"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/lock-devices") - @Override - public Response configureDeviceLock(DeviceLockBeanWrapper deviceLockBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android device lock operation"); - } - - try { - if (deviceLockBeanWrapper == null || deviceLockBeanWrapper.getOperation() == null) { - String errorMessage = "Lock bean is empty."; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - DeviceLock lock = deviceLockBeanWrapper.getOperation(); - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCK); - operation.setType(Operation.Type.PROFILE); - operation.setEnabled(true); - operation.setPayLoad(lock.toJSON()); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceLockBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/unlock-devices") - @Override - public Response configureDeviceUnlock(List deviceIDs) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android device unlock operation."); - } - - try { - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.DEVICE_UNLOCK); - operation.setType(Operation.Type.COMMAND); - operation.setEnabled(true); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/location") - @Override - public Response getDeviceLocation(List deviceIDs) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android device location operation."); - } - - try { - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCATION); - operation.setType(Operation.Type.COMMAND); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/clear-password") - @Override - public Response removePassword(List deviceIDs) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android clear password operation."); - } - - try { - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.CLEAR_PASSWORD); - operation.setType(Operation.Type.COMMAND); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance."; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/control-camera") - @Override - public Response configureCamera(CameraBeanWrapper cameraBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android Camera operation"); - } - - try { - if (cameraBeanWrapper == null || cameraBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the configure camera operation is incorrect."; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - Camera camera = cameraBeanWrapper.getOperation(); - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.CAMERA); - operation.setType(Operation.Type.COMMAND); - operation.setEnabled(camera.isEnabled()); - Activity activity = AndroidDeviceUtils.getOperationResponse(cameraBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/info") - @Override - public Response getDeviceInformation(List deviceIDs) { - if (log.isDebugEnabled()) { - log.debug("Invoking get Android device information operation"); - } - - try { - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.DEVICE_INFO); - operation.setType(Operation.Type.COMMAND); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build(); - } - } - - @POST - @Path("/logcat") - @Override - public Response getDeviceLogcat(List deviceIDs) { - if (log.isDebugEnabled()) { - log.debug("Invoking get Android device logcat operation"); - } - - try { - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.LOGCAT); - operation.setType(Operation.Type.COMMAND); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build(); - } - } - - @POST - @Path("/enterprise-wipe") - @Override - public Response wipeDevice(List deviceIDs) { - if (log.isDebugEnabled()) { - log.debug("Invoking enterprise-wipe device operation"); - } - - try { - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.ENTERPRISE_WIPE); - operation.setType(Operation.Type.COMMAND); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/wipe") - @Override - public Response wipeData(WipeDataBeanWrapper wipeDataBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android wipe-data device operation"); - } - - try { - if (wipeDataBeanWrapper == null || wipeDataBeanWrapper.getOperation() == null) { - String errorMessage = "WipeData bean is empty."; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - WipeData wipeData = wipeDataBeanWrapper.getOperation(); - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.WIPE_DATA); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(wipeData.toJSON()); - Activity activity = AndroidDeviceUtils.getOperationResponse(wipeDataBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/applications") - @Override - public Response getApplications(List deviceIDs) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android getApplicationList device operation"); - } - - try { - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.APPLICATION_LIST); - operation.setType(Operation.Type.COMMAND); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/ring") - @Override - public Response ringDevice(List deviceIDs) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android ring-device device operation"); - } - - try { - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.DEVICE_RING); - operation.setType(Operation.Type.COMMAND); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/reboot") - @Override - public Response rebootDevice(List deviceIDs) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android reboot-device device operation"); - } - - try { - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.DEVICE_REBOOT); - operation.setType(Operation.Type.COMMAND); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/mute") - @Override - public Response muteDevice(List deviceIDs) { - if (log.isDebugEnabled()) { - log.debug("Invoking mute device operation"); - } - - try { - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.DEVICE_MUTE); - operation.setType(Operation.Type.COMMAND); - operation.setEnabled(true); - Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/install-application") - @Override - public Response installApplication(ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'InstallApplication' operation"); - } - - try { - if (applicationInstallationBeanWrapper == null || applicationInstallationBeanWrapper.getOperation() == - null) { - String errorMessage = "The payload of the application installing operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - - ApplicationInstallation applicationInstallation = applicationInstallationBeanWrapper.getOperation(); - validateApplicationUrl(applicationInstallation.getUrl()); - validateApplicationType(applicationInstallation.getType()); - validateScheduleDate(applicationInstallation.getSchedule()); - - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.INSTALL_APPLICATION); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(applicationInstallation.toJSON()); - Activity activity = AndroidDeviceUtils - .getOperationResponse(applicationInstallationBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (JSONException e) { - String errorMessage = "Invalid payload for the operation."; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/update-application") - @Override - public Response updateApplication(ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'UpdateApplication' operation"); - } - - try { - if (applicationUpdateBeanWrapper == null || applicationUpdateBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the application update operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - ApplicationUpdate applicationUpdate = applicationUpdateBeanWrapper.getOperation(); - validateApplicationUrl(applicationUpdate.getUrl()); - validateApplicationType(applicationUpdate.getType()); - validateScheduleDate(applicationUpdate.getSchedule()); - - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.UPDATE_APPLICATION); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(applicationUpdate.toJSON()); - - Activity activity = AndroidDeviceUtils - .getOperationResponse(applicationUpdateBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/uninstall-application") - @Override - public Response uninstallApplication(ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'UninstallApplication' operation"); - } - - try { - if (applicationUninstallationBeanWrapper == null || - applicationUninstallationBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the application uninstalling operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - ApplicationUninstallation applicationUninstallation = applicationUninstallationBeanWrapper.getOperation(); - validateApplicationType(applicationUninstallation.getType()); - - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.UNINSTALL_APPLICATION); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(applicationUninstallation.toJSON()); - Activity activity = AndroidDeviceUtils - .getOperationResponse(applicationUninstallationBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/blacklist-applications") - @Override - public Response blacklistApplications(@Valid BlacklistApplicationsBeanWrapper blacklistApplicationsBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'Blacklist-Applications' operation"); - } - - try { - if (blacklistApplicationsBeanWrapper == null || blacklistApplicationsBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the blacklisting apps operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - BlacklistApplications blacklistApplications = blacklistApplicationsBeanWrapper.getOperation(); - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.BLACKLIST_APPLICATIONS); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(blacklistApplications.toJSON()); - Activity activity = AndroidDeviceUtils - .getOperationResponse(blacklistApplicationsBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/upgrade-firmware") - @Override - public Response upgradeFirmware(UpgradeFirmwareBeanWrapper upgradeFirmwareBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android upgrade-firmware device operation"); - } - - try { - if (upgradeFirmwareBeanWrapper == null || upgradeFirmwareBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the upgrade firmware operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - UpgradeFirmware upgradeFirmware = upgradeFirmwareBeanWrapper.getOperation(); - validateScheduleDate(upgradeFirmware.getSchedule()); - - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.UPGRADE_FIRMWARE); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(upgradeFirmware.toJSON()); - Activity activity = AndroidDeviceUtils - .getOperationResponse(upgradeFirmwareBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/configure-vpn") - @Override - public Response configureVPN(VpnBeanWrapper vpnConfiguration) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android VPN device operation"); - } - - try { - if (vpnConfiguration == null || vpnConfiguration.getOperation() == null) { - String errorMessage = "The payload of the VPN operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - Vpn vpn = vpnConfiguration.getOperation(); - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.VPN); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(vpn.toJSON()); - Activity activity = AndroidDeviceUtils.getOperationResponse(vpnConfiguration.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/send-notification") - @Override - public Response sendNotification(NotificationBeanWrapper notificationBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'notification' operation"); - } - - try { - if (notificationBeanWrapper == null || notificationBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the notification operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - Notification notification = notificationBeanWrapper.getOperation(); - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.NOTIFICATION); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(notification.toJSON()); - Activity activity = AndroidDeviceUtils.getOperationResponse(notificationBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/configure-wifi") - @Override - public Response configureWifi(WifiBeanWrapper wifiBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'configure wifi' operation"); - } - - try { - if (wifiBeanWrapper == null || wifiBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the wifi operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - Wifi wifi = wifiBeanWrapper.getOperation(); - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.WIFI); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(wifi.toJSON()); - - Activity activity = AndroidDeviceUtils.getOperationResponse(wifiBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/encrypt-storage") - @Override - public Response encryptStorage(EncryptionBeanWrapper encryptionBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'encrypt' operation"); - } - - try { - if (encryptionBeanWrapper == null || encryptionBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the device encryption operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - DeviceEncryption deviceEncryption = encryptionBeanWrapper.getOperation(); - CommandOperation operation = new CommandOperation(); - operation.setCode(AndroidConstants.OperationCodes.ENCRYPT_STORAGE); - operation.setType(Operation.Type.COMMAND); - operation.setEnabled(deviceEncryption.isEncrypted()); - Activity activity = AndroidDeviceUtils.getOperationResponse(encryptionBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/change-lock-code") - @Override - public Response changeLockCode(LockCodeBeanWrapper lockCodeBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'change lock code' operation"); - } - - try { - if (lockCodeBeanWrapper == null || lockCodeBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the change lock code operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - LockCode lockCode = lockCodeBeanWrapper.getOperation(); - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.CHANGE_LOCK_CODE); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(lockCode.toJSON()); - Activity activity = AndroidDeviceUtils.getOperationResponse(lockCodeBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("/set-password-policy") - @Override - public Response setPasswordPolicy(PasswordPolicyBeanWrapper passwordPolicyBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'password policy' operation"); - } - - try { - if (passwordPolicyBeanWrapper == null || passwordPolicyBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the change password policy operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - PasscodePolicy passcodePolicy = passwordPolicyBeanWrapper.getOperation(); - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.PASSCODE_POLICY); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(passcodePolicy.toJSON()); - - Activity activity = AndroidDeviceUtils - .getOperationResponse(passwordPolicyBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - @POST - @Path("set-webclip") - @Override - public Response setWebClip(WebClipBeanWrapper webClipBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking 'webclip' operation"); - } - - try { - - if (webClipBeanWrapper == null || webClipBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the add webclip operation is incorrect"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - WebClip webClip = webClipBeanWrapper.getOperation(); - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.WEBCLIP); - operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(webClip.toJSON()); - - Activity activity = AndroidDeviceUtils.getOperationResponse(webClipBeanWrapper.getDeviceIDs(), operation); - return Response.status(Response.Status.CREATED).entity(activity).build(); - } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } - } - - private static void validateApplicationUrl(String apkUrl) { - try { - URL url = new URL(apkUrl); - URLConnection conn = url.openConnection(); - if (((HttpURLConnection) conn).getResponseCode() != HttpURLConnection.HTTP_OK) { - String errorMessage = "URL is not pointed to a downloadable file."; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - } catch (MalformedURLException e) { - String errorMessage = "Malformed application url."; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } catch (IOException e) { - String errorMessage = "Invalid application url."; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - } - - private static void validateApplicationType(String type) { - if (type != null) { - if (!"enterprise".equalsIgnoreCase(type) - && !"public".equalsIgnoreCase(type) - && !"webapp".equalsIgnoreCase(type)) { - String errorMessage = "Invalid application type."; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - } else { - String errorMessage = "Application type is missing."; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - } - - private static void validateScheduleDate(String dateString) { - try { - if (dateString != null && !dateString.isEmpty()) { - SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); - sdf.setLenient(false); - sdf.parse(dateString); - } - } catch (ParseException e) { - String errorMessage = "Issue in validating the schedule date"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java deleted file mode 100644 index fd53b11fc..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java +++ /dev/null @@ -1,482 +0,0 @@ -/* - * 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.mdm.services.android.services.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.InvalidDeviceException; -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.device.details.DeviceLocation; -import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; -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.policy.mgt.monitor.PolicyComplianceException; -import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException; -import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; -import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; -import org.wso2.carbon.mdm.services.android.bean.ErrorResponse; -import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidApplication; -import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice; -import org.wso2.carbon.mdm.services.android.exception.UnexpectedServerErrorException; -import org.wso2.carbon.mdm.services.android.services.DeviceManagementService; -import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils; -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; -import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils; -import org.wso2.carbon.mdm.services.android.util.Message; -import org.wso2.carbon.policy.mgt.common.PolicyManagementException; -import org.wso2.carbon.policy.mgt.core.PolicyManagerService; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; -import javax.validation.constraints.Size; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.ArrayList; -import java.util.List; - -@Path("/devices") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class DeviceManagementServiceImpl implements DeviceManagementService { - - private static final String OPERATION_ERROR_STATUS = "ERROR"; - private static final Log log = LogFactory.getLog(DeviceManagementServiceImpl.class); - - @PUT - @Path("/{id}/applications") - @Override - public Response updateApplicationList(@PathParam("id") - @NotNull - @Size(min = 2, max = 45) - @Pattern(regexp = "^[A-Za-z0-9]*$") - String id, List androidApplications) { - Application application; - List applications = new ArrayList<>(); - for (AndroidApplication androidApplication : androidApplications) { - application = new Application(); - application.setPlatform(androidApplication.getPlatform()); - application.setCategory(androidApplication.getCategory()); - application.setName(androidApplication.getName()); - application.setLocationUrl(androidApplication.getLocationUrl()); - application.setImageUrl(androidApplication.getImageUrl()); - application.setVersion(androidApplication.getVersion()); - application.setType(androidApplication.getType()); - application.setAppProperties(androidApplication.getAppProperties()); - application.setApplicationIdentifier(androidApplication.getApplicationIdentifier()); - application.setMemoryUsage(androidApplication.getMemoryUsage()); - applications.add(application); - } - Message responseMessage = new Message(); - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setId(id); - deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - try { - AndroidAPIUtils.getApplicationManagerService(). - updateApplicationListInstalledInDevice(deviceIdentifier, applications); - responseMessage.setResponseMessage("Device information has modified successfully."); - return Response.status(Response.Status.ACCEPTED).entity(responseMessage).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while modifying the application list."; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - } - - @PUT - @Path("/{id}/pending-operations") - @Override - public Response getPendingOperations(@PathParam("id") String id, - @HeaderParam("If-Modified-Since") String ifModifiedSince, - List resultOperations) { - if (id == null || id.isEmpty()) { - String msg = "Device identifier is null or empty, hence returning device not found"; - log.error(msg); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } - DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(id); - try { - if (!AndroidDeviceUtils.isValidDeviceIdentifier(deviceIdentifier)) { - String msg = "Device not found for identifier '" + id + "'"; - log.error(msg); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } - if (log.isDebugEnabled()) { - log.debug("Invoking Android pending operations:" + id); - } - if (resultOperations != null && !resultOperations.isEmpty()) { - updateOperations(id, resultOperations); - } - } catch (OperationManagementException e) { - String msg = "Issue in retrieving operation management service instance"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } catch (PolicyComplianceException e) { - String msg = "Issue in updating Monitoring operation"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } catch (DeviceManagementException e) { - String msg = "Issue in retrieving device management service instance"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } catch (ApplicationManagementException e) { - String msg = "Issue in retrieving application management service instance"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } catch (NotificationManagementException e) { - String msg = "Issue in retrieving Notification management service instance"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - - List pendingOperations; - try { - pendingOperations = AndroidDeviceUtils.getPendingOperations(deviceIdentifier); - } catch (OperationManagementException e) { - String msg = "Issue in retrieving operation management service instance"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - return Response.status(Response.Status.CREATED).entity(pendingOperations).build(); - } - - private void updateOperations(String deviceId, List operations) - throws OperationManagementException, PolicyComplianceException, - ApplicationManagementException, NotificationManagementException, DeviceManagementException { - for (org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation : operations) { - AndroidDeviceUtils.updateOperation(deviceId, operation); - if (OPERATION_ERROR_STATUS.equals(operation.getStatus().toString())) { - org.wso2.carbon.device.mgt.common.notification.mgt.Notification notification = new - org.wso2.carbon.device.mgt.common.notification.mgt.Notification(); - DeviceIdentifier id = new DeviceIdentifier(); - id.setId(deviceId); - id.setType(AndroidConstants.DEVICE_TYPE_ANDROID); - String deviceName = AndroidAPIUtils.getDeviceManagementService().getDevice(id, false).getName(); - notification.setOperationId(operation.getId()); - notification.setStatus(org.wso2.carbon.device.mgt.common.notification.mgt.Notification. - Status.NEW.toString()); - notification.setDescription(operation.getCode() + " operation failed to execute on device " + - deviceName + " (ID: " + deviceId + ")"); - AndroidAPIUtils.getNotificationManagementService().addNotification(id, notification); - } - if (log.isDebugEnabled()) { - log.debug("Updating operation '" + operation.toString() + "'"); - } - } - } - - @POST - @Override - public Response enrollDevice(@Valid AndroidDevice androidDevice) { - if (androidDevice == null) { - String errorMessage = "The payload of the android device enrollment is incorrect."; - log.error(errorMessage); - throw new org.wso2.carbon.mdm.services.android.exception.BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - try { - Device device = new Device(); - device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - device.setEnrolmentInfo(androidDevice.getEnrolmentInfo()); - device.getEnrolmentInfo().setOwner(AndroidAPIUtils.getAuthenticatedUser()); - device.setDeviceInfo(androidDevice.getDeviceInfo()); - device.setDeviceIdentifier(androidDevice.getDeviceIdentifier()); - device.setDescription(androidDevice.getDescription()); - device.setName(androidDevice.getName()); - device.setFeatures(androidDevice.getFeatures()); - device.setProperties(androidDevice.getProperties()); - - boolean status = AndroidAPIUtils.getDeviceManagementService().enrollDevice(device); - if (status) { - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(androidDevice.getDeviceIdentifier(), - device.getType()); - - //Immediately update location information from initial payload - DeviceLocation deviceLocation = extractLocation(deviceIdentifier, androidDevice.getProperties()); - if (deviceLocation != null) { - try { - DeviceInformationManager informationManager = AndroidAPIUtils - .getDeviceInformationManagerService(); - informationManager.addDeviceLocation(deviceLocation); - } catch (DeviceDetailsMgtException e) { - String msg = "Error occurred while updating the device location upon android " + - "', which carries the id '" + androidDevice.getDeviceIdentifier() + "'"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - } - - //Adding Tasks to get device information - List deviceIdentifiers = new ArrayList<>(); - deviceIdentifiers.add(deviceIdentifier); - - List taskOperaions = new ArrayList<>(); - taskOperaions.add(AndroidConstants.OperationCodes.APPLICATION_LIST); - taskOperaions.add(AndroidConstants.OperationCodes.DEVICE_INFO); - taskOperaions.add(AndroidConstants.OperationCodes.DEVICE_LOCATION); - - for (String str : taskOperaions) { - CommandOperation operation = new CommandOperation(); - operation.setEnabled(true); - operation.setType(Operation.Type.COMMAND); - operation.setCode(str); - AndroidAPIUtils.getDeviceManagementService(). - addOperation(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, - operation, deviceIdentifiers); - } - PolicyManagerService policyManagerService = AndroidAPIUtils.getPolicyManagerService(); - policyManagerService.getEffectivePolicy(new DeviceIdentifier(androidDevice.getDeviceIdentifier(), device.getType())); - - Message responseMessage = new Message(); - responseMessage.setResponseCode(Response.Status.OK.toString()); - responseMessage.setResponseMessage("Android device, which carries the id '" + - androidDevice.getDeviceIdentifier() + "' has successfully been enrolled"); - return Response.status(Response.Status.OK).entity(responseMessage).build(); - } else { - Message responseMessage = new Message(); - responseMessage.setResponseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()); - responseMessage.setResponseMessage("Failed to enroll '" + - device.getType() + "' device, which carries the id '" + - androidDevice.getDeviceIdentifier() + "'"); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(responseMessage).build(); - } - } catch (DeviceManagementException e) { - String msg = "Error occurred while enrolling the android, which carries the id '" + - androidDevice.getDeviceIdentifier() + "'"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } catch (PolicyManagementException e) { - String msg = "Error occurred while enforcing default enrollment policy upon android " + - "', which carries the id '" + - androidDevice.getDeviceIdentifier() + "'"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } catch (OperationManagementException e) { - String msg = "Error occurred while enforcing default enrollment policy upon android " + - "', which carries the id '" + - androidDevice.getDeviceIdentifier() + "'"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } catch (InvalidDeviceException e) { - String msg = "Error occurred while enforcing default enrollment policy upon android " + - "', which carries the id '" + - androidDevice.getDeviceIdentifier() + "'"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - } - - @GET - @Path("/{id}/status") - @Override - public Response isEnrolled(@PathParam("id") String id, @HeaderParam("If-Modified-Since") String ifModifiedSince) { - DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(id); - try { - Device device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); - if (device != null) { - String status = String.valueOf(device.getEnrolmentInfo().getStatus()); - Message responseMessage = new Message(); - responseMessage.setResponseCode(Response.Status.OK.toString()); - responseMessage - .setResponseMessage("Status of android device that carries the id '" + id + "' is " + status); - return Response.status(Response.Status.OK).entity(responseMessage).build(); - } else { - Message responseMessage = new Message(); - responseMessage.setResponseCode(Response.Status.NOT_FOUND.toString()); - responseMessage.setResponseMessage("No Android device is found upon the id '" + id + "'"); - return Response.status(Response.Status.NOT_FOUND).entity(responseMessage).build(); - } - } catch (DeviceManagementException e) { - String msg = "Error occurred while checking enrollment status of the device."; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - } - - @PUT - @Path("/{id}") - @Override - public Response modifyEnrollment(@PathParam("id") String id, @Valid AndroidDevice androidDevice) { - Device device; - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setId(id); - deviceIdentifier.setType(AndroidConstants.DEVICE_TYPE_ANDROID); - try { - device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); - } catch (DeviceManagementException e) { - String msg = "Error occurred while getting enrollment details of the Android device that carries the id '" + - id + "'"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - - if (androidDevice == null) { - String errorMessage = "The payload of the android device enrollment is incorrect."; - log.error(errorMessage); - throw new org.wso2.carbon.mdm.services.android.exception.BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - if (device == null) { - String errorMessage = "The device to be modified doesn't exist."; - log.error(errorMessage); - throw new org.wso2.carbon.mdm.services.android.exception.NotFoundException( - new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage(errorMessage).build()); - } - if(androidDevice.getEnrolmentInfo() != null){ - device.setEnrolmentInfo(device.getEnrolmentInfo()); - } - device.getEnrolmentInfo().setOwner(AndroidAPIUtils.getAuthenticatedUser()); - if(androidDevice.getDeviceInfo() != null) { - device.setDeviceInfo(androidDevice.getDeviceInfo()); - } - device.setDeviceIdentifier(androidDevice.getDeviceIdentifier()); - if(androidDevice.getDescription() != null) { - device.setDescription(androidDevice.getDescription()); - } - if(androidDevice.getName() != null) { - device.setName(androidDevice.getName()); - } - if(androidDevice.getFeatures() != null) { - device.setFeatures(androidDevice.getFeatures()); - } - if(androidDevice.getProperties() != null) { - device.setProperties(androidDevice.getProperties()); - } - boolean result; - try { - device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - result = AndroidAPIUtils.getDeviceManagementService().modifyEnrollment(device); - if (result) { - Message responseMessage = new Message(); - responseMessage.setResponseCode(Response.Status.ACCEPTED.toString()); - responseMessage.setResponseMessage("Enrollment of Android device that " + - "carries the id '" + id + "' has successfully updated"); - return Response.status(Response.Status.ACCEPTED).entity(responseMessage).build(); - } else { - Message responseMessage = new Message(); - responseMessage.setResponseCode(Response.Status.NOT_MODIFIED.toString()); - responseMessage.setResponseMessage("Enrollment of Android device that " + - "carries the id '" + id + "' has not been updated"); - return Response.status(Response.Status.NOT_MODIFIED).entity(responseMessage).build(); - } - } catch (DeviceManagementException e) { - String msg = "Error occurred while modifying enrollment of the Android device that carries the id '" + - id + "'"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - } - - @DELETE - @Path("/{id}") - @Override - public Response disEnrollDevice(@PathParam("id") String id) { - boolean result; - DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(id); - try { - result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier); - if (result) { - Message responseMessage = new Message(); - responseMessage.setResponseCode(Response.Status.OK.toString()); - responseMessage.setResponseMessage("Android device that carries id '" + id + - "' has successfully dis-enrolled"); - return Response.status(Response.Status.OK).entity(responseMessage).build(); - } else { - Message responseMessage = new Message(); - responseMessage.setResponseCode(Response.Status.NOT_FOUND.toString()); - responseMessage.setResponseMessage("Android device that carries id '" + id + - "' has not been dis-enrolled"); - return Response.status(Response.Status.NOT_FOUND).entity(responseMessage).build(); - } - } catch (DeviceManagementException e) { - String msg = "Error occurred while dis-enrolling the Android device that carries the id '" + id + "'"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - } - - /** - * Extracts the device location - * - * @param deviceIdentifier - * @param properties - * @return returns null when location not found - */ - private DeviceLocation extractLocation(DeviceIdentifier deviceIdentifier, List properties) - throws DeviceManagementException { - - DeviceLocation location = null; - String latitude = "", longitude = ""; - - if (properties == null) return null; - - for (Device.Property property : properties) { - String propertyName = property.getName(); - if (propertyName == null) continue; - if (propertyName.equals("LATITUDE")) { - latitude = property.getValue(); - if (!longitude.isEmpty()) break; - } else if (propertyName.equals("LONGITUDE")) { - longitude = property.getValue(); - if (!latitude.isEmpty()) break; - } - } - - if (!latitude.isEmpty() && !longitude.isEmpty()) { - location = new DeviceLocation(); - location.setLatitude(Double.valueOf(latitude)); - location.setLongitude(Double.valueOf(longitude)); - location.setDeviceIdentifier(deviceIdentifier); - Device savedDevice = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier, false); - location.setDeviceId(savedDevice.getId()); - } - return location; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceTypeConfigurationServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceTypeConfigurationServiceImpl.java deleted file mode 100644 index 71c213426..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceTypeConfigurationServiceImpl.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * 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.mdm.services.android.services.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.EnrolmentInfo; -import org.wso2.carbon.device.mgt.common.InvalidDeviceException; -import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; -import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; -import org.wso2.carbon.device.mgt.common.license.mgt.License; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; -import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; -import org.wso2.carbon.mdm.services.android.bean.AndroidPlatformConfiguration; -import org.wso2.carbon.mdm.services.android.bean.ErrorResponse; -import org.wso2.carbon.mdm.services.android.bean.NotifierFrequency; -import org.wso2.carbon.mdm.services.android.exception.UnexpectedServerErrorException; -import org.wso2.carbon.mdm.services.android.services.DeviceTypeConfigurationService; -import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils; -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; - -import javax.validation.Valid; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.ArrayList; -import java.util.List; - -@Path("/configuration") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurationService { - - private static final Log log = LogFactory.getLog(DeviceTypeConfigurationServiceImpl.class); - - @GET - @Override - public Response getConfiguration( - @HeaderParam("If-Modified-Since") String ifModifiedSince) { - String msg; - PlatformConfiguration platformConfiguration; - List configs; - try { - platformConfiguration = AndroidAPIUtils.getDeviceManagementService(). - getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - if (platformConfiguration != null) { - configs = platformConfiguration.getConfiguration(); - } else { - platformConfiguration = new PlatformConfiguration(); - configs = new ArrayList<>(); - } - ConfigurationEntry entry = new ConfigurationEntry(); - License license = AndroidAPIUtils.getDeviceManagementService().getLicense( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, AndroidConstants. - TenantConfigProperties.LANGUAGE_US); - - if (license != null && configs != null) { - entry.setContentType(AndroidConstants.TenantConfigProperties.CONTENT_TYPE_TEXT); - entry.setName(AndroidConstants.TenantConfigProperties.LICENSE_KEY); - entry.setValue(license.getText()); - configs.add(entry); - platformConfiguration.setConfiguration(configs); - } - } catch (DeviceManagementException e) { - msg = "Error occurred while retrieving the Android tenant configuration"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - return Response.status(Response.Status.OK).entity(platformConfiguration).build(); - } - - @PUT - @Override - public Response updateConfiguration(@Valid AndroidPlatformConfiguration androidPlatformConfiguration) { - String msg; - ConfigurationEntry licenseEntry = null; - PlatformConfiguration configuration = new PlatformConfiguration(); - if (androidPlatformConfiguration == null) { - String errorMessage = "The payload of the android platform configuration is incorrect."; - log.error(errorMessage); - throw new org.wso2.carbon.mdm.services.android.exception.BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - configuration.setConfiguration(androidPlatformConfiguration.getConfiguration()); - try { - configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - List configs = configuration.getConfiguration(); - for (ConfigurationEntry entry : configs) { - if (AndroidConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())) { - License license = new License(); - license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - license.setLanguage(AndroidConstants.TenantConfigProperties.LANGUAGE_US); - license.setVersion("1.0.0"); - license.setText(entry.getValue().toString()); - AndroidAPIUtils.getDeviceManagementService().addLicense(DeviceManagementConstants. - MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, license); - licenseEntry = entry; - } else if (AndroidConstants.TenantConfigProperties.NOTIFIER_FREQUENCY.equals(entry.getName())) { - List deviceList = AndroidAPIUtils. - getDeviceManagementService(). - getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, false); - List deviceIdList = new ArrayList<>(); - for (Device device : deviceList) { - if (EnrolmentInfo.Status.REMOVED != device.getEnrolmentInfo().getStatus()) { - deviceIdList.add(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType())); - } - } - if (!deviceIdList.isEmpty()) { - if (entry.getValue() != null) { - NotifierFrequency notifierFrequency = new NotifierFrequency(); - notifierFrequency.setValue(Integer.parseInt(entry.getValue().toString())); - ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.NOTIFIER_FREQUENCY); - operation.setPayLoad(notifierFrequency.toJSON()); - operation.setEnabled(true); - AndroidAPIUtils.getDeviceManagementService().addOperation( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, - operation, deviceIdList); - } else { - return Response.status(Response.Status.BAD_REQUEST) - .entity("No value specified for notifierFrequency.").build(); - } - } - } - } - - if (licenseEntry != null) { - configs.remove(licenseEntry); - } - configuration.setConfiguration(configs); - AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration); - //AndroidAPIUtils.getGCMService().resetTenantConfigCache(); - } catch (DeviceManagementException e) { - msg = "Error occurred while modifying configuration settings of Android platform"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } catch (NumberFormatException e) { - msg = "Error occurred while reading notification frequency."; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } catch (OperationManagementException e) { - msg = "Error occurred while modifying configuration settings of Android platform."; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } catch (InvalidDeviceException e) { - msg = "Error occurred with the device."; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - return Response.status(Response.Status.OK) - .entity("Android platform configuration has been updated successfully.").build(); - } - - - @GET - @Path("/license") - @Produces(MediaType.TEXT_PLAIN) - public Response getLicense( - @HeaderParam("If-Modified-Since") String ifModifiedSince) { - License license; - try { - license = - AndroidAPIUtils.getDeviceManagementService().getLicense( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, - DeviceManagementConstants.LanguageCodes.LANGUAGE_CODE_ENGLISH_US); - } catch (DeviceManagementException e) { - String msg = "Error occurred while retrieving the license configured for Android device enrolment"; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - return Response.status(Response.Status.OK).entity((license == null) ? null : license.getText()).build(); - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/EventReceiverServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/EventReceiverServiceImpl.java deleted file mode 100644 index 308b78417..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/EventReceiverServiceImpl.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * 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.mdm.services.android.services.impl; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; -import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; -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.EnrolmentInfo; -import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; -import org.wso2.carbon.mdm.services.android.bean.DeviceState; -import org.wso2.carbon.mdm.services.android.bean.ErrorResponse; -import org.wso2.carbon.mdm.services.android.bean.wrapper.EventBeanWrapper; -import org.wso2.carbon.mdm.services.android.exception.BadRequestException; -import org.wso2.carbon.mdm.services.android.exception.NotFoundException; -import org.wso2.carbon.mdm.services.android.exception.UnexpectedServerErrorException; -import org.wso2.carbon.mdm.services.android.services.EventReceiverService; -import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils; -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; -import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils; -import org.wso2.carbon.mdm.services.android.util.Message; - -import javax.validation.Valid; -import javax.validation.constraints.Size; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Response; -import java.util.List; - -@Path("/events") -public class EventReceiverServiceImpl implements EventReceiverService { - private static final String EVENT_STREAM_DEFINITION = "org.wso2.iot.LocationStream"; - private static final Log log = LogFactory.getLog(EventReceiverServiceImpl.class); - private Gson gson = new Gson(); - - private static final String LONGITUDE = "longitude"; - private static final String LATITUDE = "latitude"; - private static final String TIME_STAMP = "timeStamp"; - private static final String LOCATION_EVENT_TYPE = "location"; - - @POST - @Path("/publish") - @Override - public Response publishEvents(@Valid EventBeanWrapper eventBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android device event logging."); - } - Device device; - try { - if (!DeviceManagerUtil.isPublishLocationResponseEnabled()) { - return Response.status(Response.Status.ACCEPTED).entity("Event is publishing has not enabled.").build(); - } - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(eventBeanWrapper.getDeviceIdentifier(), - AndroidConstants.DEVICE_TYPE_ANDROID); - device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); - if (device != null && EnrolmentInfo.Status.ACTIVE != device.getEnrolmentInfo().getStatus()){ - return Response.status(Response.Status.ACCEPTED).entity("Device is not in Active state.").build(); - } else if (device == null){ - return Response.status(Response.Status.ACCEPTED).entity("Device is not enrolled yet.").build(); - } - } catch (DeviceManagementException e) { - log.error("Error occurred while checking Operation Analytics is Enabled.", e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); - } - String eventType = eventBeanWrapper.getType(); - if (!LOCATION_EVENT_TYPE.equals(eventType)) { - String msg = "Dropping Android " + eventType + " Event.Only Location Event Type is supported."; - log.warn(msg); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } - Message message = new Message(); - Object[] metaData = {eventBeanWrapper.getDeviceIdentifier(), device.getEnrolmentInfo().getOwner(), - AndroidConstants.DEVICE_TYPE_ANDROID}; - String eventPayload = eventBeanWrapper.getPayload(); - JsonObject jsonObject = gson.fromJson(eventPayload, JsonObject.class); - Object[] payload = { - jsonObject.get(TIME_STAMP).getAsLong(), - jsonObject.get(LATITUDE).getAsDouble(), - jsonObject.get(LONGITUDE).getAsDouble() - }; - try { - if (AndroidAPIUtils.getEventPublisherService().publishEvent( - EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload)) { - message.setResponseCode("Event is published successfully."); - return Response.status(Response.Status.CREATED).entity(message).build(); - } else { - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage("Error occurred while " + - "publishing the event.").build()); - } - } catch (DataPublisherConfigurationException e) { - String msg = "Error occurred while getting the Data publisher Service instance."; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - } - - @GET - @Override - public Response retrieveAlerts(@QueryParam("id") - @Size(min = 2, max = 45) - String deviceId, - @QueryParam("from") long from, - @QueryParam("to") long to, - @Size(min = 2, max = 45) - @QueryParam("type") String type, - @HeaderParam("If-Modified-Since") String ifModifiedSince) { - - if (from != 0l && to != 0l && deviceId != null) { - return retrieveAlertFromDate(deviceId, from, to); - } else if (deviceId != null && type != null) { - return retrieveAlertByType(deviceId, type); - } else if (deviceId != null) { - return retrieveAlert(deviceId); - } else { - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request must contain " + - "the device identifier. Optionally, both from and to value should be present to get " + - "alerts between times.").build()); - } - } - - private Response retrieveAlert(String deviceId) { - if (log.isDebugEnabled()) { - log.debug("Retrieving events for given device Identifier."); - } - String query = "deviceIdentifier:" + deviceId; - List deviceStates; - try { - deviceStates = AndroidDeviceUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query); - if (deviceStates == null) { - throw new NotFoundException( - new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No any alerts are " + - "published for Device: " + deviceId + ".").build()); - } else { - return Response.status(Response.Status.OK).entity(deviceStates).build(); - } - } catch (AnalyticsException e) { - String msg = "Error occurred while getting published events for specific device: " + deviceId + "."; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - } - - private Response retrieveAlertFromDate(String deviceId, long from, long to) { - String fromDate = String.valueOf(from); - String toDate = String.valueOf(to); - if (log.isDebugEnabled()) { - log.debug("Retrieving events for given device Identifier and time period."); - } - - String query = "deviceIdentifier:" + deviceId + " AND _timestamp: [" + fromDate + " TO " + toDate + "]"; - List deviceStates; - try { - deviceStates = AndroidDeviceUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query); - if (deviceStates == null) { - throw new NotFoundException( - new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No any alerts are " + - "published on given date for given Device: " + deviceId + ".").build()); - - } else { - return Response.status(Response.Status.OK).entity(deviceStates).build(); - } - } catch (AnalyticsException e) { - String msg = "Error occurred while getting published events for specific " + - "Device: " + deviceId + " on given Date."; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - } - - private Response retrieveAlertByType(String deviceId, String type) { - if (log.isDebugEnabled()) { - log.debug("Retrieving events for given device identifier and type."); - } - String query = "deviceIdentifier:" + deviceId + " AND type:" + type; - List deviceStates; - try { - deviceStates = AndroidDeviceUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query); - if (deviceStates == null) { - throw new NotFoundException( - new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No any alerts are " + - "published for given Device: '" + deviceId + "' and given specific Type.").build()); - - } else { - return Response.status(Response.Status.OK).entity(deviceStates).build(); - } - } catch (AnalyticsException e) { - String msg = "Error occurred while getting published events for specific " + - "Device: " + deviceId + "and given specific Type."; - log.error(msg, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); - } - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java deleted file mode 100644 index 2f438b4d6..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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.mdm.services.android.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.analytics.api.AnalyticsDataAPI; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService; -import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService; -import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService; -import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; -import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; -import org.wso2.carbon.policy.mgt.core.PolicyManagerService; - -/** - * AndroidAPIUtil class provides utility functions used by Android REST-API classes. - */ -public class AndroidAPIUtils { - - private static Log log = LogFactory.getLog(AndroidAPIUtils.class); - - private AndroidAPIUtils(){ - throw new IllegalStateException("Utility class"); - } - - public static String getAuthenticatedUser() { - PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - String username = threadLocalCarbonContext.getUsername(); - String tenantDomain = threadLocalCarbonContext.getTenantDomain(); - if (username != null && username.endsWith(tenantDomain)) { - return username.substring(0, username.lastIndexOf("@")); - } - return username; - } - - public static DeviceManagementProviderService getDeviceManagementService() { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - DeviceManagementProviderService deviceManagementProviderService = - (DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null); - if (deviceManagementProviderService == null) { - String msg = "Device Management service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - return deviceManagementProviderService; - } - - public static DeviceInformationManager getDeviceInformationManagerService() { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - DeviceInformationManager informationManager = - (DeviceInformationManager) ctx.getOSGiService(DeviceInformationManager.class, null); - if (informationManager == null) { - String msg = "Information Manager service not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - return informationManager; - } - - public static PolicyManagerService getPolicyManagerService() { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - PolicyManagerService policyManagerService = (PolicyManagerService) ctx.getOSGiService( - PolicyManagerService.class, null); - if (policyManagerService == null) { - String msg = "Policy Manager service has not initialized"; - log.error(msg); - throw new IllegalStateException(msg); - } - return policyManagerService; - } - - public static ApplicationManagementProviderService getApplicationManagerService() { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - ApplicationManagementProviderService applicationManagementProviderService = - (ApplicationManagementProviderService) ctx.getOSGiService(ApplicationManagementProviderService.class, null); - if (applicationManagementProviderService == null) { - String msg = "Application Management provider service has not initialized"; - log.error(msg); - throw new IllegalStateException(msg); - } - return applicationManagementProviderService; - } - - public static NotificationManagementService getNotificationManagementService() { - NotificationManagementService notificationManagementService; - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - notificationManagementService = (NotificationManagementService) ctx.getOSGiService( - NotificationManagementService.class, null); - if (notificationManagementService == null) { - String msg = "Notification Management service not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - return notificationManagementService; - } - - public static EventsPublisherService getEventPublisherService() { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - EventsPublisherService eventsPublisherService = - (EventsPublisherService) ctx.getOSGiService(EventsPublisherService.class, null); - if (eventsPublisherService == null) { - String msg = "Event Publisher service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - return eventsPublisherService; - } - - public static AnalyticsDataAPI getAnalyticsDataAPI() { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - AnalyticsDataAPI analyticsDataAPI = - (AnalyticsDataAPI) ctx.getOSGiService(AnalyticsDataAPI.class, null); - if (analyticsDataAPI == null) { - String msg = "Analytics api service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - return analyticsDataAPI; - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidConstants.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidConstants.java deleted file mode 100644 index b5a28c1ee..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidConstants.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * 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.mdm.services.android.util; - -/** - * Defines constants used in Android-REST API bundle. - */ -public final class AndroidConstants { - - public static final String DEVICE_TYPE_ANDROID = "android"; - public static final String HEADER_CONTENT_TYPE = "Content-Type"; - public static final String APPLICATION_JSON = "application/json"; - public static final String SCOPE = "scope"; - - public final class DeviceProperties { - private DeviceProperties() { - throw new AssertionError(); - } - - public static final String PROPERTY_USER_KEY = "username"; - public static final String PROPERTY_DEVICE_KEY = "device"; - } - - public final class DeviceFeatures { - private DeviceFeatures() { - throw new AssertionError(); - } - } - - public final class DeviceConstants { - private DeviceConstants() { - throw new AssertionError(); - } - - public static final String DEVICE_MAC_KEY = "mac"; - public static final String DEVICE_DESCRIPTION_KEY = "description"; - public static final String DEVICE_OWNERSHIP_KEY = "ownership"; - public static final String DEVICE_PROPERTIES_KEY = "properties"; - public static final String DEVICE_FEATURES_KEY = "features"; - public static final String DEVICE_DATA = "data"; - public static final String DEVICE_ID_NOT_FOUND = "Device not found for device id: %s"; - public static final String DEVICE_ID_SERVICE_NOT_FOUND = - "Issue in retrieving device management service instance for device found at %s"; - } - - public final class Messages { - private Messages() { - throw new AssertionError(); - } - - public static final String DEVICE_MANAGER_SERVICE_NOT_AVAILABLE = - "Device Manager service not available"; - } - - public final class OperationCodes { - private OperationCodes() { - throw new AssertionError(); - } - - public static final String DEVICE_LOCK = "DEVICE_LOCK"; - public static final String FILE_DOWNLOAD = "FILE_UPLOAD_TO_THE_DEVICE"; - public static final String FILE_UPLOAD = "FILE_DOWNLOAD_FROM_THE_DEVICE"; - public static final String DEVICE_UNLOCK = "DEVICE_UNLOCK"; - public static final String DEVICE_LOCATION = "DEVICE_LOCATION"; - public static final String WIFI = "WIFI"; - public static final String CAMERA = "CAMERA"; - public static final String DEVICE_MUTE = "DEVICE_MUTE"; - public static final String PASSCODE_POLICY = "PASSCODE_POLICY"; - public static final String DEVICE_INFO = "DEVICE_INFO"; - public static final String ENTERPRISE_WIPE = "ENTERPRISE_WIPE"; - public static final String CLEAR_PASSWORD = "CLEAR_PASSWORD"; - public static final String WIPE_DATA = "WIPE_DATA"; - public static final String APPLICATION_LIST = "APPLICATION_LIST"; - public static final String CHANGE_LOCK_CODE = "CHANGE_LOCK_CODE"; - public static final String INSTALL_APPLICATION = "INSTALL_APPLICATION"; - public static final String UPDATE_APPLICATION = "UPDATE_APPLICATION"; - public static final String UNINSTALL_APPLICATION = "UNINSTALL_APPLICATION"; - public static final String BLACKLIST_APPLICATIONS = "BLACKLIST_APPLICATIONS"; - public static final String ENCRYPT_STORAGE = "ENCRYPT_STORAGE"; - public static final String DEVICE_RING = "DEVICE_RING"; - public static final String DEVICE_REBOOT = "REBOOT"; - public static final String UPGRADE_FIRMWARE = "UPGRADE_FIRMWARE"; - public static final String NOTIFICATION = "NOTIFICATION"; - public static final String WEBCLIP = "WEBCLIP"; - public static final String DISENROLL = "DISENROLL"; - public static final String MONITOR = "MONITOR"; - public static final String VPN = "VPN"; - public static final String LOGCAT = "LOGCAT"; - public static final String APP_RESTRICTION = "APP-RESTRICTION"; - public static final String WORK_PROFILE = "WORK_PROFILE"; - public static final String NOTIFIER_FREQUENCY = "NOTIFIER_FREQUENCY"; - } - - public final class StatusCodes { - private StatusCodes() { - throw new AssertionError(); - } - - public static final int MULTI_STATUS_HTTP_CODE = 207; - } - - public final class TenantConfigProperties { - private TenantConfigProperties() { - throw new AssertionError(); - } - - public static final String LICENSE_KEY = "androidEula"; - public static final String LANGUAGE_US = "en_US"; - public static final String CONTENT_TYPE_TEXT = "text"; - public static final String NOTIFIER_FREQUENCY = "notifierFrequency"; - } - - public final class ApplicationProperties { - private ApplicationProperties() { - throw new AssertionError(); - } - - public static final String NAME = "name"; - public static final String IDENTIFIER = "package"; - public static final String USS = "USS"; - public static final String VERSION = "version"; - public static final String ICON = "icon"; - public static final String IS_ACTIVE = "isActive"; - } - - public final class ErrorMessages { - private ErrorMessages () { throw new AssertionError(); } - - public static final String STATUS_BAD_REQUEST_MESSAGE_DEFAULT = "Bad Request"; - - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java deleted file mode 100644 index 48d9a08c8..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java +++ /dev/null @@ -1,493 +0,0 @@ -/* - * 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.mdm.services.android.util; - -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonNull; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.analytics.api.AnalyticsDataAPI; -import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil; -import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse; -import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry; -import org.wso2.carbon.analytics.datasource.commons.Record; -import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.EnrolmentInfo; -import org.wso2.carbon.device.mgt.common.InvalidDeviceException; -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.device.details.DeviceInfo; -import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; -import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; -import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature; -import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; -import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException; -import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; -import org.wso2.carbon.device.mgt.core.search.mgt.impl.Utils; -import org.wso2.carbon.mdm.services.android.bean.DeviceState; -import org.wso2.carbon.mdm.services.android.bean.ErrorListItem; -import org.wso2.carbon.mdm.services.android.bean.ErrorResponse; -import org.wso2.carbon.mdm.services.android.exception.BadRequestException; - -import javax.validation.ConstraintViolation; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * Util class for holding Android device related util methods. - */ -public class AndroidDeviceUtils { - - private static Log log = LogFactory.getLog(AndroidDeviceUtils.class); - - private AndroidDeviceUtils() { - throw new IllegalStateException("Utility class"); - } - - public static boolean isValidDeviceIdentifier(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { - Device device = AndroidAPIUtils.getDeviceManagementService(). - getDevice(deviceIdentifier, false); - return !(device == null || device.getDeviceIdentifier() == null || - device.getDeviceIdentifier().isEmpty() || - device.getEnrolmentInfo() == null || - EnrolmentInfo.Status.REMOVED.equals(device.getEnrolmentInfo().getStatus())); - } - - public static DeviceIdentifier convertToDeviceIdentifierObject(String deviceId) { - DeviceIdentifier identifier = new DeviceIdentifier(); - identifier.setId(deviceId); - identifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - return identifier; - } - - public static Activity getOperationResponse(List deviceIDs, Operation operation) - throws OperationManagementException, InvalidDeviceException { - if (deviceIDs == null || deviceIDs.isEmpty()) { - String errorMessage = "Device identifier list is empty"; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - DeviceIdentifier deviceIdentifier; - List deviceIdentifiers = new ArrayList<>(); - for (String deviceId : deviceIDs) { - deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setId(deviceId); - deviceIdentifier.setType(AndroidConstants.DEVICE_TYPE_ANDROID); - deviceIdentifiers.add(deviceIdentifier); - } - return AndroidAPIUtils.getDeviceManagementService().addOperation( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, operation, deviceIdentifiers); - } - - public static List getAllEventsForDevice(String tableName, String query) throws AnalyticsException { - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - AnalyticsDataAPI analyticsDataAPI = AndroidAPIUtils.getAnalyticsDataAPI(); - int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query); - if (eventCount == 0) { - return null; - } - List resultEntries = analyticsDataAPI.search(tenantId, tableName, query, 0, eventCount); - List recordIds = getRecordIds(resultEntries); - AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds); - Map deviceStateses = createDeviceStatusData(AnalyticsDataAPIUtil.listRecords( - analyticsDataAPI, response)); - return getSortedDeviceStateData(deviceStateses, resultEntries); - } - - private static List getRecordIds(List searchResults) { - List ids = new ArrayList<>(); - for (SearchResultEntry searchResult : searchResults) { - ids.add(searchResult.getId()); - } - return ids; - } - - public static Map createDeviceStatusData(List records) { - Map deviceStatuses = new HashMap<>(); - for (Record record : records) { - DeviceState deviceState = createDeviceStatusData(record); - deviceStatuses.put(deviceState.getId(), deviceState); - } - return deviceStatuses; - } - - private static DeviceState createDeviceStatusData(Record record) { - DeviceState deviceState = new DeviceState(); - deviceState.setId(record.getId()); - deviceState.setValues(record.getValues()); - return deviceState; - } - - public static List getSortedDeviceStateData(Map sensorDatas, - List searchResults) { - List sortedRecords = new ArrayList<>(); - for (SearchResultEntry searchResultEntry : searchResults) { - sortedRecords.add(sensorDatas.get(searchResultEntry.getId())); - } - return sortedRecords; - } - - public static void updateOperation(String deviceId, Operation operation) - throws OperationManagementException, PolicyComplianceException, ApplicationManagementException { - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setId(deviceId); - deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - - if (!Operation.Status.ERROR.equals(operation.getStatus()) && - AndroidConstants.OperationCodes.MONITOR.equals(operation.getCode())) { - if (log.isDebugEnabled()) { - log.debug("Received compliance status from MONITOR operation ID: " + operation.getId()); - } - AndroidAPIUtils.getPolicyManagerService().checkPolicyCompliance(deviceIdentifier, - getComplianceFeatures(operation.getPayLoad())); - } else if (!Operation.Status.ERROR.equals(operation.getStatus()) && AndroidConstants. - OperationCodes.APPLICATION_LIST.equals(operation.getCode())) { - if (log.isDebugEnabled()) { - log.debug("Received applications list from device '" + deviceId + "'"); - } - updateApplicationList(operation, deviceIdentifier); - - } else if (!Operation.Status.ERROR.equals(operation.getStatus()) && AndroidConstants. - OperationCodes.DEVICE_INFO.equals(operation.getCode())) { - - try { - if (log.isDebugEnabled()) { - log.debug("Operation response: " + operation.getOperationResponse()); - } - Device device = new Gson().fromJson(operation.getOperationResponse(), Device.class); - org.wso2.carbon.device.mgt.common.device.details.DeviceInfo deviceInfo = convertDeviceToInfo(device); - updateDeviceInfo(deviceIdentifier, deviceInfo); - } catch (DeviceDetailsMgtException e) { - throw new OperationManagementException("Error occurred while updating the device information.", e); - } - - } else if (!Operation.Status.ERROR.equals(operation.getStatus()) && - AndroidConstants.OperationCodes.DEVICE_LOCATION.equals(operation.getCode())) { - try { - DeviceLocation location = new Gson().fromJson(operation.getOperationResponse(), DeviceLocation.class); - // reason for checking "location.getLatitude() != null" because when device fails to provide - // device location and send status instead, above Gson converter create new location object - // with null attributes - if (location != null && location.getLatitude() != null) { - location.setDeviceIdentifier(deviceIdentifier); - updateDeviceLocation(location); - } - } catch (DeviceDetailsMgtException e) { - throw new OperationManagementException("Error occurred while updating the device location.", e); - } - } - AndroidAPIUtils.getDeviceManagementService().updateOperation(deviceIdentifier, operation); - } - - public static List getPendingOperations - (DeviceIdentifier deviceIdentifier) throws OperationManagementException { - - List operations; - operations = AndroidAPIUtils.getDeviceManagementService().getPendingOperations(deviceIdentifier); - return operations; - } - - private static void updateApplicationList(Operation operation, DeviceIdentifier deviceIdentifier) - throws ApplicationManagementException { - // Parsing json string to get applications list. - if (operation.getOperationResponse() != null) { - if (operation.getOperationResponse().equals("SAME_APPLICATION_LIST")) { - return; - } - JsonElement jsonElement = new JsonParser().parse(operation.getOperationResponse()); - JsonArray jsonArray = jsonElement.getAsJsonArray(); - Application app; - List applications = new ArrayList<>(jsonArray.size()); - for (JsonElement element : jsonArray) { - app = new Application(); - app.setName(element.getAsJsonObject(). - get(AndroidConstants.ApplicationProperties.NAME).getAsString()); - app.setApplicationIdentifier(element.getAsJsonObject(). - get(AndroidConstants.ApplicationProperties.IDENTIFIER).getAsString()); - app.setPlatform(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - if (element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.USS) != null) { - app.setMemoryUsage(element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.USS).getAsInt()); - } - if (element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.VERSION) != null) { - app.setVersion(element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.VERSION).getAsString()); - } - if (element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.IS_ACTIVE) != null) { - app.setActive(element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.IS_ACTIVE).getAsBoolean()); - } - applications.add(app); - } - AndroidAPIUtils.getApplicationManagerService().updateApplicationListInstalledInDevice(deviceIdentifier, applications); - } else { - if (log.isDebugEnabled()) { - log.debug("Operation Response is null."); - } - } - - } - - private static void updateDeviceLocation(DeviceLocation deviceLocation) throws DeviceDetailsMgtException { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - DeviceInformationManager informationManager = - (DeviceInformationManager) ctx.getOSGiService(DeviceInformationManager.class, null); - - informationManager.addDeviceLocation(deviceLocation); - } - - private static void updateDeviceInfo(DeviceIdentifier deviceId, DeviceInfo deviceInfo) - throws DeviceDetailsMgtException { - DeviceInformationManager informationManager = AndroidAPIUtils.getDeviceInformationManagerService(); - informationManager.addDeviceInfo(deviceId, deviceInfo); - } - - private static org.wso2.carbon.device.mgt.common.device.details.DeviceInfo convertDeviceToInfo(Device device) { - - org.wso2.carbon.device.mgt.common.device.details.DeviceInfo deviceInfo = - new org.wso2.carbon.device.mgt.common.device.details.DeviceInfo(); - if (deviceInfo.getDeviceDetailsMap() == null) { - deviceInfo.setDeviceDetailsMap(new HashMap<>()); - } - List props = device.getProperties(); - - for (Device.Property prop : props) { - if (Utils.getDeviceDetailsColumnNames().containsValue(prop.getName())) { - extractDefinedProperties(deviceInfo, prop); - } else { - extractMapProperties(deviceInfo, prop); - } - } - return deviceInfo; - } - - private static void extractMapProperties(DeviceInfo deviceInfo, Device.Property prop) { - if (prop.getName().equalsIgnoreCase("CPU_INFO")) { - deviceInfo.getDeviceDetailsMap().put("cpuUser", getProperty(prop.getValue(), "User")); - deviceInfo.getDeviceDetailsMap().put("cpuSystem", getProperty(prop.getValue(), "System")); - deviceInfo.getDeviceDetailsMap().put("IOW", getProperty(prop.getValue(), "IOW")); - deviceInfo.getDeviceDetailsMap().put("IRQ", getProperty(prop.getValue(), "IRQ")); - } else if (prop.getName().equalsIgnoreCase("RAM_INFO")) { - if (!getProperty(prop.getValue(), "TOTAL_MEMORY").isEmpty()) { - deviceInfo.setTotalRAMMemory(Double.parseDouble(getProperty(prop.getValue(), "TOTAL_MEMORY"))); - } else { - deviceInfo.setTotalRAMMemory(-1D); - } - if (!getProperty(prop.getValue(), "AVAILABLE_MEMORY").isEmpty()) { - deviceInfo.setAvailableRAMMemory(Double.parseDouble( - getProperty(prop.getValue(), "AVAILABLE_MEMORY"))); - } else { - deviceInfo.setAvailableRAMMemory(-1D); - } - deviceInfo.getDeviceDetailsMap().put("ramThreshold", getProperty(prop.getValue(), "THRESHOLD")); - deviceInfo.getDeviceDetailsMap().put("ramLowMemory", getProperty(prop.getValue(), "LOW_MEMORY")); - } else if (prop.getName().equalsIgnoreCase("BATTERY_INFO")) { - deviceInfo.setPluggedIn(Boolean.parseBoolean(getProperty(prop.getValue(), "PLUGGED"))); - - deviceInfo.getDeviceDetailsMap().put("batteryLevel", getProperty(prop.getValue(), "BATTERY_LEVEL")); - deviceInfo.getDeviceDetailsMap().put("batteryScale", getProperty(prop.getValue(), "SCALE")); - deviceInfo.getDeviceDetailsMap().put("batteryVoltage", - getProperty(prop.getValue(), "BATTERY_VOLTAGE")); - deviceInfo.getDeviceDetailsMap().put("batteryTemperature", - getProperty(prop.getValue(), "TEMPERATURE")); - deviceInfo.getDeviceDetailsMap().put("batteryCurrentTemperature", - getProperty(prop.getValue(), "CURRENT_AVERAGE")); - deviceInfo.getDeviceDetailsMap().put("batteryTechnology", - getProperty(prop.getValue(), "TECHNOLOGY")); - deviceInfo.getDeviceDetailsMap().put("batteryHealth", getProperty(prop.getValue(), "HEALTH")); - deviceInfo.getDeviceDetailsMap().put("batteryStatus", getProperty(prop.getValue(), "STATUS")); - } else if (prop.getName().equalsIgnoreCase("NETWORK_INFO")) { - deviceInfo.setSsid(getProperty(prop.getValue(), "WIFI_SSID")); - deviceInfo.setConnectionType(getProperty(prop.getValue(), "CONNECTION_TYPE")); - - deviceInfo.getDeviceDetailsMap().put("mobileSignalStrength", - getProperty(prop.getValue(), "MOBILE_SIGNAL_STRENGTH")); - deviceInfo.getDeviceDetailsMap().put("wifiSignalStrength", - getProperty(prop.getValue(), "WIFI_SIGNAL_STRENGTH")); - } else if (prop.getName().equalsIgnoreCase("DEVICE_INFO")) { - if (!getProperty(prop.getValue(), "BATTERY_LEVEL").isEmpty()) { - deviceInfo.setBatteryLevel(Double.parseDouble( - getProperty(prop.getValue(), "BATTERY_LEVEL"))); - } else { - deviceInfo.setBatteryLevel(-1D); - } - if (!getProperty(prop.getValue(), "INTERNAL_TOTAL_MEMORY").isEmpty()) { - deviceInfo.setInternalTotalMemory(Double.parseDouble( - getProperty(prop.getValue(), "INTERNAL_TOTAL_MEMORY"))); - } else { - deviceInfo.setInternalTotalMemory(-1D); - } - if (!getProperty(prop.getValue(), "INTERNAL_AVAILABLE_MEMORY").isEmpty()) { - deviceInfo.setInternalAvailableMemory(Double.parseDouble( - getProperty(prop.getValue(), "INTERNAL_AVAILABLE_MEMORY"))); - } else { - deviceInfo.setInternalAvailableMemory(-1D); - } - if (!getProperty(prop.getValue(), "EXTERNAL_TOTAL_MEMORY").isEmpty()) { - deviceInfo.setExternalTotalMemory(Double.parseDouble( - getProperty(prop.getValue(), "EXTERNAL_TOTAL_MEMORY"))); - } else { - deviceInfo.setExternalTotalMemory(-1D); - } - if (!getProperty(prop.getValue(), "EXTERNAL_AVAILABLE_MEMORY").isEmpty()) { - deviceInfo.setExternalAvailableMemory(Double.parseDouble( - getProperty(prop.getValue(), "EXTERNAL_AVAILABLE_MEMORY"))); - } else { - deviceInfo.setExternalAvailableMemory(-1D); - } - deviceInfo.getDeviceDetailsMap().put("encryptionEnabled", - getProperty(prop.getValue(), "ENCRYPTION_ENABLED")); - deviceInfo.getDeviceDetailsMap().put("passcodeEnabled", - getProperty(prop.getValue(), "PASSCODE_ENABLED")); - deviceInfo.getDeviceDetailsMap().put("operator", - getProperty(prop.getValue(), "OPERATOR")); - deviceInfo.getDeviceDetailsMap().put("PhoneNumber", - getProperty(prop.getValue(), "PHONE_NUMBER")); - } else if (prop.getName().equalsIgnoreCase("IMEI")) { - deviceInfo.getDeviceDetailsMap().put("IMEI", prop.getValue()); - } else if (prop.getName().equalsIgnoreCase("IMSI")) { - deviceInfo.getDeviceDetailsMap().put("IMSI", prop.getValue()); - } else if (prop.getName().equalsIgnoreCase("MAC")) { - deviceInfo.getDeviceDetailsMap().put("mac", prop.getValue()); - } else if (prop.getName().equalsIgnoreCase("SERIAL")) { - deviceInfo.getDeviceDetailsMap().put("serial", prop.getValue()); - } - } - - private static void extractDefinedProperties(DeviceInfo deviceInfo, Device.Property prop) { - if (prop.getName().equalsIgnoreCase("DEVICE_MODEL")) { - deviceInfo.setDeviceModel(prop.getValue()); - } else if (prop.getName().equalsIgnoreCase("VENDOR")) { - deviceInfo.setVendor(prop.getValue()); - } else if (prop.getName().equalsIgnoreCase("OS_VERSION")) { - deviceInfo.setOsVersion(prop.getValue()); - } else if (prop.getName().equalsIgnoreCase("OS_BUILD_DATE")) { - deviceInfo.setOsBuildDate(prop.getValue()); - } - } - - private static String getProperty(String properties, String needed) { - // This is not a key value pair. value is the immediate element to its filed name. - // Ex: - // [{"name":"ENCRYPTION_ENABLED","value":"false"},{"name":"PASSCODE_ENABLED","value":"true"}, - // {"name":"BATTERY_LEVEL","value":"100"},{"name":"INTERNAL_TOTAL_MEMORY","value":"0.76"}] - JsonElement jsonElement = new JsonParser().parse(properties); - JsonArray jsonArray = jsonElement.getAsJsonArray(); - for (JsonElement element : jsonArray) { - if (element.isJsonObject()) { - JsonObject jsonObject = element.getAsJsonObject(); - if (jsonObject.has("name") - && jsonObject.get("name").getAsString().equalsIgnoreCase(needed)) { - if (jsonObject.has("value") && jsonObject.get("value") != JsonNull.INSTANCE) { - return jsonObject.get("value").getAsString().replace("%", ""); - } else { - return ""; - } - } - } - } - return ""; - } - - private static List getComplianceFeatures(Object compliancePayload) - throws PolicyComplianceException { - String compliancePayloadString = new Gson().toJson(compliancePayload); - if (compliancePayload == null) { - return null; - } - // Parsing json string to get compliance features. - JsonElement jsonElement; - if (compliancePayloadString instanceof String) { - jsonElement = new JsonParser().parse(compliancePayloadString); - } else { - throw new PolicyComplianceException("Invalid policy compliance payload"); - } - - JsonArray jsonArray = jsonElement.getAsJsonArray(); - Gson gson = new Gson(); - ComplianceFeature complianceFeature; - List complianceFeatures = new ArrayList(jsonArray.size()); - - for (JsonElement element : jsonArray) { - complianceFeature = gson.fromJson(element, ComplianceFeature.class); - complianceFeatures.add(complianceFeature); - } - return complianceFeatures; - } - - /** - * Returns a new BadRequestException - * - * @param description description of the exception - * @return a new BadRequestException with the specified details as a response DTO - */ - public static BadRequestException buildBadRequestException(String description) { - ErrorResponse errorResponse = getErrorResponse(AndroidConstants. - ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT, 400l, description); - return new BadRequestException(errorResponse); - } - - /** - * Returns generic ErrorResponse. - * - * @param message specific error message - * @param code error code - * @param description error description - * @return generic Response with error specific details. - */ - public static ErrorResponse getErrorResponse(String message, Long code, String description) { - ErrorResponse errorResponse = new ErrorResponse(); - errorResponse.setCode(code); - errorResponse.setMoreInfo(""); - errorResponse.setMessage(message); - errorResponse.setDescription(description); - return errorResponse; - } - - public static ErrorResponse getConstraintViolationErrorDTO(Set> violations) { - ErrorResponse errorResponse = new ErrorResponse(); - errorResponse.setDescription("Validation Error"); - errorResponse.setMessage("Bad Request"); - errorResponse.setCode(400l); - errorResponse.setMoreInfo(""); - List errorListItems = new ArrayList<>(); - for (ConstraintViolation violation : violations) { - ErrorListItem errorListItemDTO = new ErrorListItem(); - errorListItemDTO.setCode(400 + "_" + violation.getPropertyPath()); - errorListItemDTO.setMessage(violation.getPropertyPath() + ": " + violation.getMessage()); - errorListItems.add(errorListItemDTO); - } - errorResponse.setErrorItems(errorListItems); - return errorResponse; - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/util/ApiOriginFilter.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/util/ApiOriginFilter.java deleted file mode 100644 index 44d7895d0..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/util/ApiOriginFilter.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.mdm.services.android.util; - -import javax.servlet.*; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -public class ApiOriginFilter implements Filter { - - public void doFilter(ServletRequest request, ServletResponse response, - FilterChain chain) throws IOException, ServletException { - HttpServletResponse res = (HttpServletResponse) response; - res.addHeader("Access-Control-Allow-Origin", "*"); - res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); - res.addHeader("Access-Control-Allow-Headers", "Content-Type"); - chain.doFilter(request, response); - } - - public void destroy() { - //do nothing - } - - public void init(FilterConfig filterConfig) throws ServletException { - //do nothing - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/util/DeviceIDHolder.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/util/DeviceIDHolder.java deleted file mode 100644 index 2831deb5e..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/util/DeviceIDHolder.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.mdm.services.android.util; - -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; - -import java.util.List; - -/** - * Holder class for storing valid & invalid device-ids. - */ -public class DeviceIDHolder { - - private List errorDeviceIdList; - private List validDeviceIDList; - - public List getErrorDeviceIdList() { - return errorDeviceIdList; - } - - public void setErrorDeviceIdList(List errorDeviceIdList) { - this.errorDeviceIdList = errorDeviceIdList; - } - - public List getValidDeviceIDList() { - return validDeviceIDList; - } - - public void setValidDeviceIDList(List validDeviceIDList) { - this.validDeviceIDList = validDeviceIDList; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/util/Message.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/util/Message.java deleted file mode 100644 index e481a1f78..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/java/org/wso2/carbon/mdm/services/android/util/Message.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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.mdm.services.android.util; - -import javax.ws.rs.core.MediaType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * This class contains the information of response message. - */ -@XmlRootElement -public class Message { - - private String responseCode; - private String responseMessage; - - @XmlElement - public String getResponseMessage() { - return responseMessage; - } - - public void setResponseMessage(String responseMessage) { - this.responseMessage = responseMessage; - } - - @XmlElement - public String getResponseCode() { - return responseCode; - } - - public void setResponseCode(String responseCode) { - this.responseCode = responseCode; - } - - private Message.MessageBuilder getBuilder() { - return new Message.MessageBuilder(); - } - - public static Message.MessageBuilder responseCode(String responseCode) { - Message message = new Message(); - return message.getBuilder().responseCode(responseCode); - } - - public static Message.MessageBuilder responseMessage(String responseMessage) { - Message message = new Message(); - return message.getBuilder().responseMessage(responseMessage); - } - - public class MessageBuilder { - - private String responseCode; - private String responseMessage; - - public MessageBuilder responseCode(String responseCode) { - this.responseCode = responseCode; - return this; - } - - public MessageBuilder responseMessage(String responseMessage) { - this.responseMessage = responseMessage; - return this; - } - - public Message build() { - Message message = new Message(); - message.setResponseCode(responseCode); - message.setResponseMessage(responseMessage); - return message; - } - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/webapp/META-INF/permissions.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/webapp/META-INF/permissions.xml deleted file mode 100644 index d7ca73b05..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/webapp/META-INF/permissions.xml +++ /dev/null @@ -1,317 +0,0 @@ - - - - - - - - - - - View Tenant configuration - /device-mgt/admin/platform-configs/view - /configuration - GET - - - - Modify Tenant configuration - /device-mgt/admin/platform-configs/add - /configuration - PUT - - - - Add Tenant configuration - /device-mgt/admin/platform-configs/add - /configuration - PUT - - - - Enroll - /device-mgt/user/device/enroll/android - /configuration/license - GET - - - - - - - - Enroll - /device-mgt/user/device/enroll/android - /devices - POST - - - - Enroll - /device-mgt/user/device/enroll/android - /devices/* - DELETE - - - - Enroll - /device-mgt/user/device/enroll/android - /devices/* - PUT - - - - Enroll - /device-mgt/user/device/enroll/android - /devices/*/applications - PUT - - - - Enroll - /device-mgt/user/device/enroll/android - /devices/*/pending-operations - PUT - - - - Enroll - /device-mgt/user/device/enroll/android - /devices/*/status - GET - - - - - - - - Enroll - /device-mgt/user/device/enroll/android - /events/publish - POST - - - - View Events - /device-mgt/admin/events/view - /events/publish - POST - - - - GET Events - /device-mgt/admin/events/get - /events - GET - - - - - - - - - - Get installed applications - /device-mgt/admin/device/android/operation/get-installed-applications - /admin/devices/applications - POST - - - - Blacklist applications - /device-mgt/admin/device/android/operation/blacklist-applications - /admin/devices/blacklist-applications - POST - - - - Change lock code - /device-mgt/admin/device/android/operation/change-lock-code - /admin/devices/change-lock-code - POST - - - - Clear password - /device-mgt/admin/device/android/operation/clear-password - /admin/devices/clear-password - POST - - - - Logcat - /device-mgt/admin/device/android/operation/logcat - /admin/devices/logcat - POST - - - - Configure VPN - /device-mgt/admin/device/android/operation/configure-vpn - /admin/devices/configure-vpn - POST - - - - Configure WiFi - /device-mgt/admin/device/android/operation/configure-wifi - /admin/devices/configure-wifi - POST - - - - Control camera - /device-mgt/admin/device/android/operation/control-camera - /admin/devices/control-camera - POST - - - - Encrypt storage - /device-mgt/admin/device/android/operation/encrypt-storage - /admin/devices/encrypt-storage - POST - - - - Enterprise wipe - /device-mgt/admin/device/android/operation/enterprise-wipe - /admin/devices/enterprise-wipe - POST - - - - Get device info - /device-mgt/admin/device/android/operation/get-info - /admin/devices/info - POST - - - - Install application - /device-mgt/admin/device/android/operation/install-application - /admin/devices/install-application - POST - - - - Get location details - /device-mgt/admin/device/android/operation/location - /admin/devices/location - POST - - - - Lock device - /device-mgt/admin/device/android/operation/lock-device - /admin/devices/lock-devices - POST - - - - Mute device - /device-mgt/admin/device/android/operation/mute - /admin/devices/mute - POST - - - - Reboot device - /device-mgt/admin/device/android/operation/reboot - /admin/devices/reboot - POST - - - - Ring device - /device-mgt/admin/device/android/operation/ring - /admin/devices/ring - POST - - - - Send notification - /device-mgt/admin/device/android/operation/send-notification - /admin/devices/send-notification - POST - - - - Set password policy - /device-mgt/admin/device/android/operation/set-password-policy - /admin/devices/set-password-policy - POST - - - - Set web clip - /device-mgt/admin/device/android/operation/set-webclip - /admin/devices/set-webclip - POST - - - - Uninstall application - /device-mgt/admin/device/android/operation/uninstall-application - /admin/devices/uninstall-application - POST - - - - Unlock device - /device-mgt/admin/device/android/operation/unlock-device - /admin/devices/unlock-devices - POST - - - - Update applications - /device-mgt/admin/device/android/operation/update-application - /admin/devices/update-application - POST - - - - Upgrade firmware - /device-mgt/admin/device/android/operation/upgrade-firmware - /admin/devices/upgrade-firmware - POST - - - - Wipe device - /device-mgt/admin/device/android/operation/wipe - /admin/devices/wipe - POST - - - - - \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/webapp/META-INF/webapp-classloading.xml deleted file mode 100644 index 9e5725d6d..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/webapp/META-INF/webapp-classloading.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - false - - - CXF,Carbon - diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/webapp/WEB-INF/cxf-servlet.xml deleted file mode 100644 index 9d741c61f..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/webapp/WEB-INF/web.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 9cc18d201..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,91 +0,0 @@ - - - - - Android-Agent-Webapp - - JAX-WS/JAX-RS MDM Android Endpoint - JAX-WS/JAX-RS Servlet - CXFServlet - - org.apache.cxf.transport.servlet.CXFServlet - - - - swagger.security.filter - ApiAuthorizationFilterImpl - - 1 - - - CXFServlet - /* - - - 60 - - - managed-api-enabled - true - - - doAuthentication - true - - - isSharedWithAllTenants - true - - - isDefault - false - - - - - - - - - - - - - - - ApiOriginFilter - org.wso2.carbon.mdm.services.android.util.ApiOriginFilter - - - ApiOriginFilter - /* - - - diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/webapp/servicelist.css b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/webapp/servicelist.css deleted file mode 100644 index c8a0eb201..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/webapp/servicelist.css +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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. - */ - -@CHARSET "ISO-8859-1"; - -/* http://meyerweb.com/eric/tools/css/reset/ - v2.0 | 20110126 - License: none (public domain) -*/ - -html, body, div, span, applet, object, iframe, -h1, h2, h3, h4, h5, h6, p, blockquote, pre, -a, abbr, acronym, address, big, cite, code, -del, dfn, em, img, ins, kbd, q, s, samp, -small, strike, strong, sub, sup, tt, var, -b, u, i, center, -dl, dt, dd, ol, ul, li, -fieldset, form, label, legend, -table, caption, tbody, tfoot, thead, tr, th, td, -article, aside, canvas, details, embed, -figure, figcaption, footer, header, hgroup, -menu, nav, output, ruby, section, summary, -time, mark, audio, video { - margin: 0; - padding: 0; - border: 0; - font-size: 100%; - font: inherit; - vertical-align: baseline; -} -/* HTML5 display-role reset for older browsers */ -article, aside, details, figcaption, figure, -footer, header, hgroup, menu, nav, section { - display: block; -} - -html { - background: #efefef; -} - -body { - line-height: 1; - width:960px; - margin:auto; - background:white; - padding:10px; - box-shadow:0px 0px 5px #CCC; - font-family:"Lucida Grande","Lucida Sans","Microsoft Sans Serif", "Lucida Sans Unicode","Verdana","Sans-serif","trebuchet ms" !important; - -} -ol, ul { - list-style: none; -} -blockquote, q { - quotes: none; -} -blockquote:before, blockquote:after, -q:before, q:after { - content: ''; - content: none; -} -table { - border-collapse: collapse; - border-spacing: 0; - width:960px; - border:solid 1px #ccc; -} - -table a { - font-size:12px; - color:#1e90ff; - padding:7px; -float:left; -; -} - -.heading { - font-size: 18px; - margin-top: 20px; - float:left; - color:#0067B1; - margin-bottom:20px; - padding-top:20px; -} - -.field { - font-weight: normal; - width:120px; - font-size:12px; - float:left; - padding:7px; - clear:left; -} -.value { - font-weight: bold; - font-size:12px; - float:left; - padding:7px; - clear:right; -} -.porttypename { - font-weight: bold; - font-size:14px; -} -UL { - margin-top: 0; -} -LI { - font-weight: normal; - font-size:12px; - margin-top:10px; -} - -TD { - border:1px solid #ccc; - vertical-align: text-top; - padding: 5px; -} - - diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementAdminServiceTests.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementAdminServiceTests.java deleted file mode 100644 index c60de18bc..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementAdminServiceTests.java +++ /dev/null @@ -1,303 +0,0 @@ -/* - * 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.mdm.services.android; - -import org.mockito.MockitoAnnotations; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockObjectFactory; -import org.testng.Assert; -import org.testng.IObjectFactory; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.ObjectFactory; -import org.testng.annotations.Test; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.InvalidDeviceException; -import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; -import org.wso2.carbon.mdm.services.android.mocks.DeviceManagementProviderServiceMock; -import org.wso2.carbon.mdm.services.android.services.impl.DeviceManagementAdminServiceImpl; -import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils; -import org.wso2.carbon.mdm.services.android.utils.TestUtils; - -import javax.ws.rs.core.Response; - -@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"}) -@PrepareForTest(AndroidAPIUtils.class) -public class DeviceManagementAdminServiceTests { - - private DeviceManagementAdminServiceImpl deviceManagementAdminService; - - @ObjectFactory - public IObjectFactory getObjectFactory() { - return new PowerMockObjectFactory(); - } - - @BeforeClass - public void init() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - MockitoAnnotations.initMocks(this); - deviceManagementAdminService = new DeviceManagementAdminServiceImpl(); - } - - private void mockDeviceManagementService() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getDeviceManagementService")) - .toReturn(new DeviceManagementProviderServiceMock()); - } - - @Test - public void testConfigureDeviceLock() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.configureDeviceLock(TestUtils.getDeviceLockBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testConfigureDeviceUnlock() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.configureDeviceUnlock(TestUtils.getDeviceIds()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testGetDeviceLocation() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.getDeviceLocation(TestUtils.getDeviceIds()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testRemovePassword() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.removePassword(TestUtils.getDeviceIds()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testConfigureCamera() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.configureCamera(TestUtils.getCamerabeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testGetDeviceInformation() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.getDeviceInformation(TestUtils.getDeviceIds()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testGetDeviceLogcat() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.getDeviceLogcat(TestUtils.getDeviceIds()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testWipeDevice() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.wipeDevice(TestUtils.getDeviceIds()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testWipeData() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.wipeData(TestUtils.getWipeDataBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testGetApplications() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.getApplications(TestUtils.getDeviceIds()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testRingDevice() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.ringDevice(TestUtils.getDeviceIds()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testRebootDevice() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.rebootDevice(TestUtils.getDeviceIds()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testMuteDevice() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.muteDevice(TestUtils.getDeviceIds()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testInstallApplication() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService - .installApplication(TestUtils.getApplicationInstallationBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testUpdateApplication() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.updateApplication(TestUtils.getApplicationUpdateBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testUninstallApplicationPublic() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService - .uninstallApplication(TestUtils.getApplicationUninstallationBeanWrapperPublic()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testUninstallApplicationWebApp() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService - .uninstallApplication(TestUtils.getApplicationUninstallationBeanWrapperWebApp()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testBlacklistApplications() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService - .blacklistApplications(TestUtils.getBlacklistApplicationsBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testUpgradeFirmware() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.upgradeFirmware(TestUtils.getUpgradeFirmwareBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testConfigureVPN() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.configureVPN(TestUtils.getVpnBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testSendNotification() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.sendNotification(TestUtils.getNotificationBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testConfigureWifi() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.configureWifi(TestUtils.getWifiBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testEncryptStorage() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.encryptStorage(TestUtils.getEncryptionBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testChangeLockCode() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.changeLockCode(TestUtils.getLockCodeBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testSetPasswordPolicy() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.setPasswordPolicy(TestUtils.getPasswordPolicyBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testSetWebClip() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementAdminService.setWebClip(TestUtils.getWebClipBeanWrapper()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - -} - diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementServiceTests.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementServiceTests.java deleted file mode 100644 index dc16b5d43..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementServiceTests.java +++ /dev/null @@ -1,318 +0,0 @@ -/* - * 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.mdm.services.android; - -import org.mockito.MockitoAnnotations; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockObjectFactory; -import org.testng.Assert; -import org.testng.IObjectFactory; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.ObjectFactory; -import org.testng.annotations.Test; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.InvalidDeviceException; -import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; -import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice; -import org.wso2.carbon.mdm.services.android.mocks.ApplicationManagementProviderServiceMock; -import org.wso2.carbon.mdm.services.android.mocks.DeviceInformationManagerServiceMock; -import org.wso2.carbon.mdm.services.android.mocks.DeviceManagementProviderServiceMock; -import org.wso2.carbon.mdm.services.android.mocks.NotificationManagementServiceMock; -import org.wso2.carbon.mdm.services.android.mocks.PolicyManagerServiceMock; -import org.wso2.carbon.mdm.services.android.services.impl.DeviceManagementServiceImpl; -import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils; -import org.wso2.carbon.mdm.services.android.utils.TestUtils; - -import javax.ws.rs.core.Response; -import java.util.ArrayList; -import java.util.List; - -@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"}) -@PrepareForTest(AndroidAPIUtils.class) -public class DeviceManagementServiceTests { - - private DeviceManagementServiceImpl deviceManagementService; - - @ObjectFactory - public IObjectFactory getObjectFactory() { - return new PowerMockObjectFactory(); - } - - @BeforeClass - public void init() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - MockitoAnnotations.initMocks(this); - deviceManagementService = new DeviceManagementServiceImpl(); - } - - private void mockDeviceManagementService() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getDeviceManagementService")) - .toReturn(new DeviceManagementProviderServiceMock()); - } - - private void mockApplicationManagerService() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getApplicationManagerService")) - .toReturn(new ApplicationManagementProviderServiceMock()); - } - - private void mockPolicyManagerService() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getPolicyManagerService")) - .toReturn(new PolicyManagerServiceMock()); - } - - private void mockDeviceInformationManagerService() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getDeviceInformationManagerService")) - .toReturn(new DeviceInformationManagerServiceMock()); - } - - private void mockNotificationManagementService() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getNotificationManagementService")) - .toReturn(new NotificationManagementServiceMock()); - } - - private void mockUser() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - PowerMockito.stub(PowerMockito.method(AndroidAPIUtils.class, "getAuthenticatedUser")) - .toReturn("admin"); - } - - @Test - public void testUpdateApplicationList() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockApplicationManagerService(); - Response response = deviceManagementService - .updateApplicationList(TestUtils.getDeviceId(), TestUtils.getAndroidApplications()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.ACCEPTED.getStatusCode()); - } - - @Test - public void testGetPendingOperationsForNullDevice() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - Response response = deviceManagementService - .getPendingOperations(null, null, null); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); - } - - @Test - public void testGetPendingOperationsInvalidDevice() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementService - .getPendingOperations("1234", null, null); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); - } - - @Test - public void testGetPendingOperationsNullResponse() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementService - .getPendingOperations(TestUtils.getDeviceId(), null, null); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testGetPendingOperationsWithMonitorResponse() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - mockPolicyManagerService(); - Response response = deviceManagementService - .getPendingOperations(TestUtils.getDeviceId(), null, - TestUtils.getSuccessMonitorOperationResponse()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testGetPendingOperationsWithApplicationResponse() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - mockApplicationManagerService(); - Response response = deviceManagementService - .getPendingOperations(TestUtils.getDeviceId(), null, - TestUtils.getSuccessApplicationOperationResponse()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testGetPendingOperationsWithDeviceInfoResponse() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - mockDeviceInformationManagerService(); - Response response = deviceManagementService - .getPendingOperations(TestUtils.getDeviceId(), null, - TestUtils.getSuccessInfoOperationResponse()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testGetPendingOperationsWithInProgressResponse() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementService - .getPendingOperations(TestUtils.getDeviceId(), null, - TestUtils.getInProgressOperationResponse()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testGetPendingOperationsWithErrorResponse() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - mockNotificationManagementService(); - Response response = deviceManagementService - .getPendingOperations(TestUtils.getDeviceId(), null, - TestUtils.getErrorOperationResponse()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); - } - - @Test - public void testEnrollDeviceWithoutLocationSuccess() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - mockPolicyManagerService(); - mockUser(); - Response response = deviceManagementService.enrollDevice(TestUtils.getBasicAndroidDevice()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); - } - - @Test - public void testEnrollDeviceWithLocationSuccess() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - mockDeviceInformationManagerService(); - mockPolicyManagerService(); - mockUser(); - AndroidDevice androidDevice = TestUtils.getBasicAndroidDevice(); - - List properties = new ArrayList<>(); - Device.Property property = new Device.Property(); - property.setName("LATITUDE"); - property.setValue("79.5"); - properties.add(property); - property = new Device.Property(); - property.setName("LONGITUDE"); - property.setValue("6.9"); - properties.add(property); - androidDevice.setProperties(properties); - - Response response = deviceManagementService.enrollDevice(androidDevice); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); - } - - @Test - public void testEnrollDeviceUnSuccess() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - mockUser(); - AndroidDevice androidDevice = TestUtils.getBasicAndroidDevice(); - androidDevice.setDeviceIdentifier("1234"); - Response response = deviceManagementService.enrollDevice(androidDevice); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - } - - @Test - public void testIsEnrolledExists() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementService.isEnrolled(TestUtils.getDeviceId(), null); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); - } - - @Test - public void testIsEnrolledNonExist() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementService.isEnrolled("1234", null); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); - } - - @Test - public void testIsEnrolledNull() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementService.isEnrolled(null, null); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); - } - - @Test - public void testModifyEnrollmentSuccess() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - mockUser(); - Response response = deviceManagementService - .modifyEnrollment(TestUtils.getDeviceId(), TestUtils.getBasicAndroidDevice()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.ACCEPTED.getStatusCode()); - } - - @Test - public void testModifyEnrollmentUnSuccess() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - mockUser(); - AndroidDevice androidDevice = TestUtils.getBasicAndroidDevice(); - androidDevice.setDeviceIdentifier("1234"); - Response response = deviceManagementService - .modifyEnrollment(TestUtils.getDeviceId(), androidDevice); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.NOT_MODIFIED.getStatusCode()); - } - - @Test - public void testDisEnrollDeviceSuccess() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementService.disEnrollDevice(TestUtils.getDeviceId()); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); - } - - @Test - public void testDisenrollUnSuccess() - throws DeviceManagementException, OperationManagementException, InvalidDeviceException { - mockDeviceManagementService(); - Response response = deviceManagementService.disEnrollDevice("1234"); - Assert.assertNotNull(response); - Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); - } - -} - diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/ApplicationManagementProviderServiceMock.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/ApplicationManagementProviderServiceMock.java deleted file mode 100644 index 563258b3c..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/ApplicationManagementProviderServiceMock.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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.mdm.services.android.mocks; - -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -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.operation.mgt.Activity; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService; - -import java.util.List; - -public class ApplicationManagementProviderServiceMock implements ApplicationManagementProviderService { - @Override - public void updateApplicationListInstalledInDevice(DeviceIdentifier deviceIdentifier, List list) - throws ApplicationManagementException { - - } - - @Override - public List getApplicationListForDevice(DeviceIdentifier deviceIdentifier) - throws ApplicationManagementException { - return null; - } - - @Override - public Application[] getApplications(String s, int i, int i1) throws ApplicationManagementException { - return new Application[0]; - } - - @Override - public void updateApplicationStatus(DeviceIdentifier deviceIdentifier, Application application, String s) - throws ApplicationManagementException { - - } - - @Override - public String getApplicationStatus(DeviceIdentifier deviceIdentifier, Application application) - throws ApplicationManagementException { - return null; - } - - @Override - public Activity installApplicationForDevices(Operation operation, List list) - throws ApplicationManagementException { - return null; - } - - @Override - public Activity installApplicationForUsers(Operation operation, List list) - throws ApplicationManagementException { - return null; - } - - @Override - public Activity installApplicationForUserRoles(Operation operation, List list) - throws ApplicationManagementException { - return null; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceInformationManagerServiceMock.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceInformationManagerServiceMock.java deleted file mode 100644 index 4a10e7b1f..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceInformationManagerServiceMock.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.mdm.services.android.mocks; - -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo; -import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; -import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException; -import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; - -import java.util.List; - -public class DeviceInformationManagerServiceMock implements DeviceInformationManager { - @Override - public void addDeviceInfo(DeviceIdentifier deviceIdentifier, DeviceInfo deviceInfo) - throws DeviceDetailsMgtException { - - } - - @Override - public DeviceInfo getDeviceInfo(DeviceIdentifier deviceIdentifier) throws DeviceDetailsMgtException { - return null; - } - - @Override - public List getDevicesInfo(List list) throws DeviceDetailsMgtException { - return null; - } - - @Override - public void addDeviceLocation(DeviceLocation deviceLocation) throws DeviceDetailsMgtException { - - } - - @Override - public DeviceLocation getDeviceLocation(DeviceIdentifier deviceIdentifier) throws DeviceDetailsMgtException { - return null; - } - - @Override - public List getDeviceLocations(List list) throws DeviceDetailsMgtException { - return null; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceManagementProviderServiceMock.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceManagementProviderServiceMock.java deleted file mode 100644 index 970a25cb4..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceManagementProviderServiceMock.java +++ /dev/null @@ -1,633 +0,0 @@ -/* - * 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.mdm.services.android.mocks; - -import org.wso2.carbon.device.mgt.common.*; -import org.wso2.carbon.device.mgt.common.configuration.mgt.AmbiguousConfigurationException; -import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException; -import org.wso2.carbon.device.mgt.common.configuration.mgt.DeviceConfiguration; -import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; -import org.wso2.carbon.device.mgt.common.device.details.DeviceData; -import org.wso2.carbon.device.mgt.common.license.mgt.License; -import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; -import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; -import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager; -import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationExecutionFailedException; -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.core.dto.DeviceType; -import org.wso2.carbon.device.mgt.core.geo.GeoCluster; -import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate; -import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; -import org.wso2.carbon.device.mgt.core.service.EmailMetaInfo; -import org.wso2.carbon.mdm.services.android.utils.TestUtils; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class DeviceManagementProviderServiceMock implements DeviceManagementProviderService { - @Override - public List getAllDevices(String s) throws DeviceManagementException { - return null; - } - - @Override - public List getAllDevices(String s, boolean b) throws DeviceManagementException { - return null; - } - - @Override - public List getAllDevices() throws DeviceManagementException { - return null; - } - - @Override - public List getAllDevices(boolean b) throws DeviceManagementException { - return null; - } - - @Override - public List getDevices(Date date) throws DeviceManagementException { - return null; - } - - @Override - public List getDevices(Date date, boolean b) throws DeviceManagementException { - return null; - } - - @Override - public PaginationResult getDevicesByType(PaginationRequest paginationRequest) throws DeviceManagementException { - return null; - } - - @Override - public PaginationResult getDevicesByType(PaginationRequest paginationRequest, boolean b) - throws DeviceManagementException { - return null; - } - - @Override - public PaginationResult getAllDevices(PaginationRequest paginationRequest) throws DeviceManagementException { - return null; - } - - @Override - public PaginationResult getAllDevices(PaginationRequest paginationRequest, boolean b) - throws DeviceManagementException { - return null; - } - - @Override - public Device getDevice(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { - if (TestUtils.getDeviceId().equals(deviceIdentifier.getId())) { - return TestUtils.getDevice(); - } else { - return null; - } - } - - @Override - public Device getDeviceWithTypeProperties(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { - return null; - } - - @Override - public Device getDevice(DeviceIdentifier deviceIdentifier, boolean b) throws DeviceManagementException { - if (TestUtils.getDeviceId().equals(deviceIdentifier.getId())) { - return TestUtils.getDevice(); - } else { - return null; - } - } - - @Override - public Device getDevice(String s, boolean b) throws DeviceManagementException { - if (TestUtils.getDeviceId().equals(s)) { - return TestUtils.getDevice(); - } else { - return null; - } - } - - @Override - public Device getDevice(DeviceIdentifier deviceIdentifier, String s, boolean b) throws DeviceManagementException { - return null; - } - - @Override - public Device getDevice(DeviceIdentifier deviceIdentifier, Date date) throws DeviceManagementException { - return null; - } - - @Override - public Device getDevice(DeviceIdentifier deviceIdentifier, Date date, boolean b) throws DeviceManagementException { - return null; - } - - @Override public Device getDevice(DeviceData deviceData, boolean b) throws DeviceManagementException { - return null; - } - - @Override - public List getDevicesBasedOnProperties(Map map) throws DeviceManagementException { - return null; - } - - @Override - public Device getDevice(String s, Date date, boolean b) throws DeviceManagementException { - if (TestUtils.getDeviceId().equals(s)) { - return TestUtils.getDevice(); - } else { - return null; - } } - - @Override - public Device getDevice(DeviceIdentifier deviceIdentifier, String s, Date date, boolean b) - throws DeviceManagementException { - return null; - } - - @Override - public Device getDevice(DeviceIdentifier deviceIdentifier, EnrolmentInfo.Status status) - throws DeviceManagementException { - return null; - } - - @Override - public Device getDevice(DeviceIdentifier deviceIdentifier, EnrolmentInfo.Status status, boolean b) - throws DeviceManagementException { - return null; - } - - @Override - public PaginationResult getDevicesOfUser(PaginationRequest paginationRequest) throws DeviceManagementException { - return null; - } - - @Override - public PaginationResult getDevicesOfUser(PaginationRequest paginationRequest, boolean b) - throws DeviceManagementException { - return null; - } - - @Override - public PaginationResult getDevicesByOwnership(PaginationRequest paginationRequest) - throws DeviceManagementException { - return null; - } - - @Override - public PaginationResult getDevicesByOwnership(PaginationRequest paginationRequest, boolean b) - throws DeviceManagementException { - return null; - } - - @Override - public List getDevicesOfUser(String s) throws DeviceManagementException { - return null; - } - - @Override - public List getDevicesOfUser(String s, boolean b) throws DeviceManagementException { - return null; - } - - @Override - public List getDevicesOfUser(String s, String s1) throws DeviceManagementException { - return null; - } - - @Override - public List getDevicesOfUser(String s, String s1, boolean b) throws DeviceManagementException { - return null; - } - - @Override - public List getAllDevicesOfRole(String s) throws DeviceManagementException { - return null; - } - - @Override - public List getAllDevicesOfRole(String s, boolean b) throws DeviceManagementException { - return null; - } - - @Override - public PaginationResult getDevicesByStatus(PaginationRequest paginationRequest) throws DeviceManagementException { - return null; - } - - @Override - public PaginationResult getDevicesByStatus(PaginationRequest paginationRequest, boolean b) - throws DeviceManagementException { - return null; - } - - @Override - public List getDevicesByNameAndType(PaginationRequest paginationRequest, boolean b) - throws DeviceManagementException { - return null; - } - - @Override - public PaginationResult getDevicesByName(PaginationRequest paginationRequest) throws DeviceManagementException { - return null; - } - - @Override - public PaginationResult getDevicesByName(PaginationRequest paginationRequest, boolean b) - throws DeviceManagementException { - return null; - } - - @Override - public List getDevicesByStatus(EnrolmentInfo.Status status) throws DeviceManagementException { - return null; - } - - @Override - public List getDevicesByStatus(EnrolmentInfo.Status status, boolean b) throws DeviceManagementException { - return null; - } - - @Override - public int getDeviceCount(String s) throws DeviceManagementException { - return 0; - } - - @Override - public int getDeviceCount() throws DeviceManagementException { - return 0; - } - - @Override - public int getDeviceCount(String s, EnrolmentInfo.Status status) throws DeviceManagementException { - return 0; - } - - @Override - public int getDeviceCount(EnrolmentInfo.Status status) throws DeviceManagementException { - return 0; - } - - @Override - public HashMap getTenantedDevice(DeviceIdentifier deviceIdentifier) - throws DeviceManagementException { - return null; - } - - @Override - public void sendEnrolmentInvitation(String s, EmailMetaInfo emailMetaInfo) - throws DeviceManagementException, ConfigurationManagementException { - - } - - @Override - public void sendRegistrationEmail(EmailMetaInfo emailMetaInfo) - throws DeviceManagementException, ConfigurationManagementException { - - } - - @Override - public FeatureManager getFeatureManager(String s) throws DeviceTypeNotFoundException { - return null; - } - - @Override - public PlatformConfiguration getConfiguration(String s) throws DeviceManagementException { - return null; - } - - @Override - public boolean isEnrolled(DeviceIdentifier deviceIdentifier, String s) throws DeviceManagementException { - return false; - } - - @Override - public NotificationStrategy getNotificationStrategyByDeviceType(String s) throws DeviceManagementException { - return null; - } - - @Override - public License getLicense(String s, String s1) throws DeviceManagementException { - return null; - } - - @Override - public void addLicense(String s, License license) throws DeviceManagementException { - - } - - @Override - public boolean modifyEnrollment(Device device) throws DeviceManagementException { - return TestUtils.getDeviceId().equals(device.getDeviceIdentifier()); - } - - @Override - public boolean enrollDevice(Device device) throws DeviceManagementException { - return TestUtils.getDeviceId().equals(device.getDeviceIdentifier()); - } - - @Override - public boolean saveConfiguration(PlatformConfiguration platformConfiguration) throws DeviceManagementException { - return false; - } - - @Override - public boolean disenrollDevice(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { - return TestUtils.getDeviceId().equals(deviceIdentifier.getId()); - } - - - @Override - public boolean isEnrolled(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { - return false; - } - - @Override - public boolean isActive(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { - return false; - } - - @Override - public boolean setActive(DeviceIdentifier deviceIdentifier, boolean b) throws DeviceManagementException { - return false; - } - - @Override - public List getAvailableDeviceTypes() throws DeviceManagementException { - return null; - } - - @Override - public List getPolicyMonitoringEnableDeviceTypes() throws DeviceManagementException { - return null; - } - - @Override - public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException { - return false; - } - - @Override - public boolean setOwnership(DeviceIdentifier deviceIdentifier, String s) throws DeviceManagementException { - return false; - } - - @Override - public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { - return false; - } - - @Override - public boolean setStatus(DeviceIdentifier deviceIdentifier, String s, EnrolmentInfo.Status status) - throws DeviceManagementException { - return false; - } - - @Override - public boolean setStatus(String s, EnrolmentInfo.Status status) throws DeviceManagementException { - return false; - } - - @Override - public void notifyOperationToDevices(Operation operation, List list) - throws DeviceManagementException { - - } - - @Override - public Activity addOperation(String s, Operation operation, List list) - throws OperationManagementException, InvalidDeviceException { - return TestUtils.getActivity(); - } - - @Override - public List getOperations(DeviceIdentifier deviceIdentifier) - throws OperationManagementException { - return null; - } - - @Override - public PaginationResult getOperations(DeviceIdentifier deviceIdentifier, PaginationRequest paginationRequest) - throws OperationManagementException { - return null; - } - - @Override - public List getPendingOperations(DeviceIdentifier deviceIdentifier) - throws OperationManagementException { - return null; - } - - @Override - public Operation getNextPendingOperation(DeviceIdentifier deviceIdentifier) throws OperationManagementException { - return null; - } - - @Override - public Operation getNextPendingOperation(DeviceIdentifier deviceIdentifier, long l) - throws OperationManagementException { - return null; - } - - @Override - public void updateOperation(DeviceIdentifier deviceIdentifier, Operation operation) - throws OperationManagementException { - - } - - @Override - public boolean updateProperties(DeviceIdentifier deviceIdentifier, List list) throws DeviceManagementException { - return false; - } - - @Override - public Operation getOperationByDeviceAndOperationId(DeviceIdentifier deviceIdentifier, int i) - throws OperationManagementException { - return null; - } - - @Override - public List getOperationsByDeviceAndStatus(DeviceIdentifier deviceIdentifier, - Operation.Status status) - throws OperationManagementException, DeviceManagementException { - return null; - } - - @Override - public Operation getOperation(String s, int i) throws OperationManagementException { - return null; - } - - @Override - public Activity getOperationByActivityId(String s) throws OperationManagementException { - return null; - } - - @Override - public List getOperationByActivityIds(List list) throws OperationManagementException { - return null; - } - - @Override - public Activity getOperationByActivityIdAndDevice(String s, DeviceIdentifier deviceIdentifier) - throws OperationManagementException { - return null; - } - - @Override - public List getActivitiesUpdatedAfter(long l, int i, int i1) throws OperationManagementException { - return null; - } - - @Override public List getFilteredActivities(String operationCode, int limit, int offset) - throws OperationManagementException { - return null; - } - - @Override public int getTotalCountOfFilteredActivities(String operationCode) throws OperationManagementException { - return 0; - } - - @Override - public List getActivitiesUpdatedAfterByUser(long l, String s, int i, int i1) throws OperationManagementException { - return null; - } - - @Override - public int getActivityCountUpdatedAfter(long l) throws OperationManagementException { - return 0; - } - - @Override - public int getActivityCountUpdatedAfterByUser(long l, String s) throws OperationManagementException { - return 0; - } - - @Override - public List getMonitoringOperationList(String s) { - return null; - } - - @Override - public List getStartupOperations(String s) { - return null; - } - - @Override - public int getDeviceMonitoringFrequency(String s) { - return 0; - } - - @Override - public OperationMonitoringTaskConfig getDeviceMonitoringConfig(String s) { - return null; - } - - @Override - public StartupOperationConfig getStartupOperationConfig(String s) { - return null; - } - - @Override - public boolean isDeviceMonitoringEnabled(String s) { - return false; - } - - @Override - public PolicyMonitoringManager getPolicyMonitoringManager(String s) { - return null; - } - - @Override - public boolean changeDeviceStatus(DeviceIdentifier deviceIdentifier, EnrolmentInfo.Status status) - throws DeviceManagementException { - return false; - } - - @Override - public void registerDeviceType(DeviceManagementService deviceManagementService) throws DeviceManagementException { - - } - - @Override - public DeviceType getDeviceType(String s) throws DeviceManagementException { - return null; - } - - @Override - public List getDeviceTypes() throws DeviceManagementException { - return null; - } - - @Override - public void notifyPullNotificationSubscriber(DeviceIdentifier deviceIdentifier, Operation operation) - throws PullNotificationExecutionFailedException { - - } - - @Override - public List getDeviceEnrolledTenants() throws DeviceManagementException { - return null; - } - - @Override - public List findGeoClusters(String deviceType, GeoCoordinate geoCoordinate, - GeoCoordinate geoCoordinate1, int i) throws DeviceManagementException { - return null; - } - - @Override - public int getDeviceCountOfTypeByStatus(String deviceType, String deviceStatus) throws DeviceManagementException { - return 0; - } - - @Override - public List getDeviceIdentifiersByStatus(String deviceType, String deviceStatus) - throws DeviceManagementException { - return null; - } - - @Override - public boolean bulkUpdateDeviceStatus(String deviceType, List deviceList, String status) - throws DeviceManagementException { - return false; - } - - @Override - public boolean updateEnrollment(String owner, List deviceIdentifiers) { - return false; - } - - @Override - public DeviceConfiguration getDeviceConfiguration(Map propertyMap) - throws DeviceManagementException, DeviceNotFoundException, UnauthorizedDeviceAccessException, - AmbiguousConfigurationException{ - return null; - } - - @Override - public boolean deleteDevices(List deviceIdentifiers) throws DeviceManagementException, InvalidDeviceException {return false;} -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/NotificationManagementServiceMock.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/NotificationManagementServiceMock.java deleted file mode 100644 index 4fd989de6..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/NotificationManagementServiceMock.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.mdm.services.android.mocks; - -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.PaginationRequest; -import org.wso2.carbon.device.mgt.common.PaginationResult; -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.NotificationManagementService; - -import java.util.List; - -public class NotificationManagementServiceMock implements NotificationManagementService { - @Override - public boolean addNotification(DeviceIdentifier deviceIdentifier, Notification notification) - throws NotificationManagementException { - return false; - } - - @Override - public boolean updateNotification(Notification notification) throws NotificationManagementException { - return false; - } - - @Override - public boolean updateNotificationStatus(int i, Notification.Status status) throws NotificationManagementException { - return false; - } - - @Override public boolean updateAllNotifications(Notification.Status status, int tenantID) - throws NotificationManagementException { - return false; - } - - @Override - public List getAllNotifications() throws NotificationManagementException { - return null; - } - - @Override - public Notification getNotification(int i) throws NotificationManagementException { - return null; - } - - @Override - public PaginationResult getAllNotifications(PaginationRequest paginationRequest) - throws NotificationManagementException { - return null; - } - - @Override - public List getNotificationsByStatus(Notification.Status status) - throws NotificationManagementException { - return null; - } - - @Override - public PaginationResult getNotificationsByStatus(Notification.Status status, PaginationRequest paginationRequest) - throws NotificationManagementException { - return null; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/PolicyManagerServiceMock.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/PolicyManagerServiceMock.java deleted file mode 100644 index a71dafebf..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/PolicyManagerServiceMock.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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.mdm.services.android.mocks; - -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.Feature; -import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; -import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; -import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; -import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature; -import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData; -import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; -import org.wso2.carbon.policy.mgt.common.FeatureManagementException; -import org.wso2.carbon.policy.mgt.common.PolicyAdministratorPoint; -import org.wso2.carbon.policy.mgt.common.PolicyEvaluationPoint; -import org.wso2.carbon.policy.mgt.common.PolicyInformationPoint; -import org.wso2.carbon.policy.mgt.common.PolicyManagementException; -import org.wso2.carbon.policy.mgt.common.PolicyMonitoringTaskException; -import org.wso2.carbon.policy.mgt.core.PolicyManagerService; -import org.wso2.carbon.policy.mgt.core.task.TaskScheduleService; - -import java.util.List; - -public class PolicyManagerServiceMock implements PolicyManagerService { - - @Override - public Profile addProfile(Profile profile) throws PolicyManagementException { - return null; - } - - @Override - public Profile updateProfile(Profile profile) throws PolicyManagementException { - return null; - } - - @Override - public Policy addPolicy(Policy policy) throws PolicyManagementException { - return null; - } - - @Override - public Policy updatePolicy(Policy policy) throws PolicyManagementException { - return null; - } - - @Override - public boolean deletePolicy(Policy policy) throws PolicyManagementException { - return false; - } - - @Override - public boolean deletePolicy(int i) throws PolicyManagementException { - return false; - } - - @Override - public Policy getEffectivePolicy(DeviceIdentifier deviceIdentifier) throws PolicyManagementException { - return null; - } - - @Override - public List getEffectiveFeatures(DeviceIdentifier deviceIdentifier) - throws FeatureManagementException { - return null; - } - - @Override - public List getPolicies(String s) throws PolicyManagementException { - return null; - } - - @Override - public List getFeatures() throws FeatureManagementException { - return null; - } - - @Override - public PolicyAdministratorPoint getPAP() throws PolicyManagementException { - return null; - } - - @Override - public PolicyInformationPoint getPIP() throws PolicyManagementException { - return null; - } - - @Override - public PolicyEvaluationPoint getPEP() throws PolicyManagementException { - return null; - } - - @Override - public TaskScheduleService getTaskScheduleService() throws PolicyMonitoringTaskException { - return null; - } - - @Override - public int getPolicyCount() throws PolicyManagementException { - return 0; - } - - @Override - public Policy getAppliedPolicyToDevice(DeviceIdentifier deviceIdentifier) throws PolicyManagementException { - return null; - } - - @Override - public List checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Object o) - throws PolicyComplianceException { - return null; - } - - @Override - public boolean checkCompliance(DeviceIdentifier deviceIdentifier, Object o) throws PolicyComplianceException { - return false; - } - - @Override - public NonComplianceData getDeviceCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { - return null; - } - - @Override - public boolean isCompliant(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { - return false; - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/utils/TestUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/utils/TestUtils.java deleted file mode 100644 index 994cb9423..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/java/org/wso2/carbon/mdm/services/android/utils/TestUtils.java +++ /dev/null @@ -1,425 +0,0 @@ -/* - * 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.mdm.services.android.utils; - -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.EnrolmentInfo; -import org.wso2.carbon.device.mgt.common.app.mgt.Application; -import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo; -import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; -import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.mdm.services.android.bean.ApplicationInstallation; -import org.wso2.carbon.mdm.services.android.bean.ApplicationUninstallation; -import org.wso2.carbon.mdm.services.android.bean.ApplicationUpdate; -import org.wso2.carbon.mdm.services.android.bean.BlacklistApplications; -import org.wso2.carbon.mdm.services.android.bean.Camera; -import org.wso2.carbon.mdm.services.android.bean.DeviceEncryption; -import org.wso2.carbon.mdm.services.android.bean.DeviceLock; -import org.wso2.carbon.mdm.services.android.bean.LockCode; -import org.wso2.carbon.mdm.services.android.bean.Notification; -import org.wso2.carbon.mdm.services.android.bean.PasscodePolicy; -import org.wso2.carbon.mdm.services.android.bean.UpgradeFirmware; -import org.wso2.carbon.mdm.services.android.bean.Vpn; -import org.wso2.carbon.mdm.services.android.bean.WebClip; -import org.wso2.carbon.mdm.services.android.bean.Wifi; -import org.wso2.carbon.mdm.services.android.bean.WipeData; -import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidApplication; -import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice; -import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationInstallationBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationUninstallationBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationUpdateBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.BlacklistApplicationsBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.CameraBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.DeviceLockBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.EncryptionBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.LockCodeBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.NotificationBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.PasswordPolicyBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.UpgradeFirmwareBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.VpnBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.WebClipBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.WifiBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.WipeDataBeanWrapper; -import org.wso2.carbon.mdm.services.android.util.AndroidConstants; -import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils; - -import java.util.ArrayList; -import java.util.List; - -public class TestUtils { - - public static Activity getActivity() { - Activity activity = new Activity(); - activity.setActivityId("ACTIVITY_1"); - activity.setCode("CODE"); - return activity; - } - - public static String getDeviceId() { - return "1a2b3c4d5e"; - } - - public static List getDeviceIds() { - List deviceIds = new ArrayList<>(); - deviceIds.add(getDeviceId()); - return deviceIds; - } - - public static Device getDevice() { - Device device = new Device(); - device.setId(1); - device.setName("Test"); - device.setDeviceIdentifier(getDeviceId()); - device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - EnrolmentInfo enrolmentInfo = new EnrolmentInfo(); - enrolmentInfo.setId(1); - enrolmentInfo.setOwner("admin"); - enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD); - enrolmentInfo.setStatus(EnrolmentInfo.Status.ACTIVE); - device.setEnrolmentInfo(enrolmentInfo); - return device; - } - - public static DeviceLockBeanWrapper getDeviceLockBeanWrapper() { - DeviceLockBeanWrapper deviceLockBeanWrapper = new DeviceLockBeanWrapper(); - deviceLockBeanWrapper.setDeviceIDs(getDeviceIds()); - DeviceLock deviceLockOperation = new DeviceLock(); - deviceLockOperation.setHardLockEnabled(true); - deviceLockOperation.setMessage("Test Operation"); - deviceLockBeanWrapper.setOperation(deviceLockOperation); - return deviceLockBeanWrapper; - } - - public static CameraBeanWrapper getCamerabeanWrapper() { - CameraBeanWrapper cameraBeanWrapper = new CameraBeanWrapper(); - cameraBeanWrapper.setDeviceIDs(getDeviceIds()); - Camera camera = new Camera(); - camera.setEnabled(false); - cameraBeanWrapper.setOperation(camera); - return cameraBeanWrapper; - } - - public static WipeDataBeanWrapper getWipeDataBeanWrapper() { - WipeDataBeanWrapper wipeDataBeanWrapper = new WipeDataBeanWrapper(); - wipeDataBeanWrapper.setDeviceIDs(getDeviceIds()); - WipeData wipeData = new WipeData(); - wipeData.setPin("1234"); - wipeDataBeanWrapper.setOperation(wipeData); - return wipeDataBeanWrapper; - } - - public static ApplicationInstallationBeanWrapper getApplicationInstallationBeanWrapper() { - ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper = new ApplicationInstallationBeanWrapper(); - applicationInstallationBeanWrapper.setDeviceIDs(getDeviceIds()); - ApplicationInstallation applicationInstallation = new ApplicationInstallation(); - applicationInstallation.setAppIdentifier("org.wso2.iot.agent"); - applicationInstallation.setUrl("https://github.com/wso2/cdmf-agent-android/releases/download/v3.1.21/client-standalone.apk"); - applicationInstallation.setType("enterprise"); - applicationInstallation.setSchedule("2017-10-11T18:46:19-0530"); - applicationInstallationBeanWrapper.setOperation(applicationInstallation); - return applicationInstallationBeanWrapper; - } - - public static ApplicationUpdateBeanWrapper getApplicationUpdateBeanWrapper() { - ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper = new ApplicationUpdateBeanWrapper(); - applicationUpdateBeanWrapper.setDeviceIDs(getDeviceIds()); - ApplicationUpdate applicationUpdate = new ApplicationUpdate(); - applicationUpdate.setAppIdentifier("org.wso2.iot.agent"); - applicationUpdate.setUrl("https://github.com/wso2/cdmf-agent-android/releases/download/v3.1.21/client-standalone.apk"); - applicationUpdate.setType("enterprise"); - applicationUpdate.setSchedule("2017-10-11T18:46:19-0530"); - applicationUpdateBeanWrapper.setOperation(applicationUpdate); - return applicationUpdateBeanWrapper; - } - - public static ApplicationUninstallationBeanWrapper getApplicationUninstallationBeanWrapperPublic() { - ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper = new ApplicationUninstallationBeanWrapper(); - applicationUninstallationBeanWrapper.setDeviceIDs(getDeviceIds()); - ApplicationUninstallation applicationUninstallation = new ApplicationUninstallation(); - applicationUninstallation.setAppIdentifier("org.wso2.iot.agent"); - applicationUninstallation.setType("public"); - applicationUninstallationBeanWrapper.setOperation(applicationUninstallation); - return applicationUninstallationBeanWrapper; - } - - public static ApplicationUninstallationBeanWrapper getApplicationUninstallationBeanWrapperWebApp() { - ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper = new ApplicationUninstallationBeanWrapper(); - applicationUninstallationBeanWrapper.setDeviceIDs(getDeviceIds()); - ApplicationUninstallation applicationUninstallation = new ApplicationUninstallation(); - applicationUninstallation.setAppIdentifier("org.wso2.iot.agent"); - applicationUninstallation.setType("webapp"); - applicationUninstallationBeanWrapper.setOperation(applicationUninstallation); - return applicationUninstallationBeanWrapper; - } - - public static BlacklistApplicationsBeanWrapper getBlacklistApplicationsBeanWrapper() { - BlacklistApplicationsBeanWrapper blacklistApplicationsBeanWrapper = new BlacklistApplicationsBeanWrapper(); - blacklistApplicationsBeanWrapper.setDeviceIDs(getDeviceIds()); - BlacklistApplications blacklistApplications = new BlacklistApplications(); - List appIds = new ArrayList<>(); - appIds.add("org.wso2.iot.agent"); - blacklistApplications.setAppIdentifier(appIds); - blacklistApplicationsBeanWrapper.setOperation(blacklistApplications); - return blacklistApplicationsBeanWrapper; - } - - public static UpgradeFirmwareBeanWrapper getUpgradeFirmwareBeanWrapper() { - UpgradeFirmwareBeanWrapper upgradeFirmwareBeanWrapper = new UpgradeFirmwareBeanWrapper(); - upgradeFirmwareBeanWrapper.setDeviceIDs(getDeviceIds()); - UpgradeFirmware upgradeFirmware = new UpgradeFirmware(); - upgradeFirmware.setServer("https://github.com/wso2/cdmf-agent-android/releases/download/"); - upgradeFirmware.setSchedule("2017-10-11T18:46:19-0530"); - upgradeFirmwareBeanWrapper.setOperation(upgradeFirmware); - return upgradeFirmwareBeanWrapper; - } - - public static VpnBeanWrapper getVpnBeanWrapper() { - VpnBeanWrapper vpnBeanWrapper = new VpnBeanWrapper(); - vpnBeanWrapper.setDeviceIDs(getDeviceIds()); - Vpn vpn = new Vpn(); - vpnBeanWrapper.setOperation(vpn); - return vpnBeanWrapper; - } - - public static NotificationBeanWrapper getNotificationBeanWrapper() { - NotificationBeanWrapper notificationBeanWrapper = new NotificationBeanWrapper(); - notificationBeanWrapper.setDeviceIDs(getDeviceIds()); - Notification notification = new Notification(); - notification.setMessageText("Message"); - notification.setMessageTitle("Title"); - notificationBeanWrapper.setOperation(notification); - return notificationBeanWrapper; - } - - public static WifiBeanWrapper getWifiBeanWrapper() { - WifiBeanWrapper wifiBeanWrapper = new WifiBeanWrapper(); - wifiBeanWrapper.setDeviceIDs(getDeviceIds()); - Wifi wifi = new Wifi(); - wifiBeanWrapper.setOperation(wifi); - return wifiBeanWrapper; - } - - public static EncryptionBeanWrapper getEncryptionBeanWrapper() { - EncryptionBeanWrapper encryptionBeanWrapper = new EncryptionBeanWrapper(); - encryptionBeanWrapper.setDeviceIDs(getDeviceIds()); - DeviceEncryption deviceEncryption = new DeviceEncryption(); - deviceEncryption.setEncrypted(true); - encryptionBeanWrapper.setOperation(deviceEncryption); - return encryptionBeanWrapper; - } - - public static LockCodeBeanWrapper getLockCodeBeanWrapper() { - LockCodeBeanWrapper lockCodeBeanWrapper = new LockCodeBeanWrapper(); - lockCodeBeanWrapper.setDeviceIDs(getDeviceIds()); - LockCode lockCode = new LockCode(); - lockCode.setLockCode("1234"); - lockCodeBeanWrapper.setOperation(lockCode); - return lockCodeBeanWrapper; - } - - public static PasswordPolicyBeanWrapper getPasswordPolicyBeanWrapper() { - PasswordPolicyBeanWrapper passwordPolicyBeanWrapper = new PasswordPolicyBeanWrapper(); - passwordPolicyBeanWrapper.setDeviceIDs(getDeviceIds()); - PasscodePolicy passcodePolicy = new PasscodePolicy(); - passwordPolicyBeanWrapper.setOperation(passcodePolicy); - return passwordPolicyBeanWrapper; - } - - public static WebClipBeanWrapper getWebClipBeanWrapper() { - WebClipBeanWrapper webClipBeanWrapper = new WebClipBeanWrapper(); - webClipBeanWrapper.setDeviceIDs(getDeviceIds()); - WebClip webClip = new WebClip(); - webClipBeanWrapper.setOperation(webClip); - return webClipBeanWrapper; - } - - public static List getAndroidApplications() { - List androidApplications = new ArrayList<>(); - AndroidApplication androidApplication = new AndroidApplication(); - androidApplications.add(androidApplication); - return androidApplications; - } - - public static List getSuccessMonitorOperationResponse() { - List operations = new ArrayList<>(); - Operation operation = new Operation(); - operation.setActivityId(getActivity().getActivityId()); - operation.setCode(AndroidConstants.OperationCodes.MONITOR); - operation.setId(1); - operation.setOperationResponse("Operation success."); - operation.setStatus(Operation.Status.COMPLETED); - operations.add(operation); - return operations; - } - - public static List getSuccessApplicationOperationResponse() { - List operations = new ArrayList<>(); - Operation operation = new Operation(); - operation.setActivityId(getActivity().getActivityId()); - operation.setCode(AndroidConstants.OperationCodes.APPLICATION_LIST); - operation.setId(1); - operation.setOperationResponse("[{\"name\":\"Widget%20Preview\",\"package\":\"com.android.widgetpreview\"," + - "\"version\":\"7.1.1\",\"isSystemApp\":false,\"isActive\":false}," + - "{\"name\":\"com.android.gesture.builder\"," + - "\"package\":\"com.android.gesture.builder\",\"version\":\"7.1.1\"," + - "\"isSystemApp\":false,\"isActive\":false},{\"name\":\"API%20Demos\"," + - "\"package\":\"com.example.android.apis\",\"version\":\"7.1.1\"," + - "\"isSystemApp\":false,\"isActive\":false}," + - "{\"name\":\"WSO2%20Device%20Management%20Agent\"," + - "\"package\":\"org.wso2.iot.agent\",\"version\":\"3.1.21\"," + - "\"isSystemApp\":false,\"isActive\":true}," + - "{\"name\":\"com.android.smoketest.tests\"," + - "\"package\":\"com.android.smoketest.tests\",\"version\":\"7.1.1\"," + - "\"isSystemApp\":false,\"isActive\":false}," + - "{\"name\":\"Sample%20Soft%20Keyboard\"," + - "\"package\":\"com.example.android.softkeyboard\",\"version\":\"7.1.1\"," + - "\"isSystemApp\":false,\"isActive\":false},{\"name\":\"Example%20Wallpapers\"," + - "\"package\":\"com.example.android.livecubes\",\"version\":\"7.1.1\"," + - "\"isSystemApp\":false,\"isActive\":false},{\"name\":\"com.android.smoketest\"," + - "\"package\":\"com.android.smoketest\",\"version\":\"7.1.1\"," + - "\"isSystemApp\":false,\"isActive\":false}]"); - operation.setStatus(Operation.Status.COMPLETED); - operations.add(operation); - return operations; - } - - public static List getSuccessInfoOperationResponse() { - List operations = new ArrayList<>(); - Operation operation = new Operation(); - operation.setActivityId(getActivity().getActivityId()); - operation.setCode(AndroidConstants.OperationCodes.DEVICE_INFO); - operation.setId(1); - operation.setOperationResponse("{\"description\":\"generic_x86\",\"deviceIdentifier\":\"1d9612def9d205f9\"," + - "\"enrolmentInfo\":null,\"name\":\"generic_x86\",\"properties\":[" + - "{\"name\":\"SERIAL\",\"value\":\"unknown\"}," + - "{\"name\":\"IMEI\",\"value\":null}," + - "{\"name\":\"IMSI\",\"value\":\"310260000000000\"}," + - "{\"name\":\"MAC\",\"value\":\"02:00:00:00:00:00\"}," + - "{\"name\":\"DEVICE_MODEL\",\"value\":\"Android SDK built for x86\"}," + - "{\"name\":\"VENDOR\",\"value\":\"unknown\"}," + - "{\"name\":\"OS_VERSION\",\"value\":\"7.1.1\"}," + - "{\"name\":\"OS_BUILD_DATE\",\"value\":\"1487782847000\"}," + - "{\"name\":\"DEVICE_NAME\",\"value\":\"generic_x86\"}," + - "{\"name\":\"LATITUDE\",\"value\":\"6.90988\"}," + - "{\"name\":\"LONGITUDE\",\"value\":\"79.85249999999999\"}," + - "{\"name\":\"NETWORK_INFO\",\"value\":\"[" + - "{\\\"name\\\":\\\"CONNECTION_TYPE\\\",\\\"value\\\":\\\"MOBILE\\\"}," + - "{\\\"name\\\":\\\"MOBILE_CONNECTION_TYPE\\\",\\\"value\\\":\\\"LTE\\\"}," + - "{\\\"name\\\":\\\"MOBILE_SIGNAL_STRENGTH\\\",\\\"value\\\":\\\"-89\\\"}]\"}," + - "{\"name\":\"CPU_INFO\",\"value\":\"[]\"},{\"name\":\"RAM_INFO\",\"value\":\"[" + - "{\\\"name\\\":\\\"TOTAL_MEMORY\\\",\\\"value\\\":\\\"1055113216\\\"}," + - "{\\\"name\\\":\\\"AVAILABLE_MEMORY\\\",\\\"value\\\":\\\"708997120\\\"}," + - "{\\\"name\\\":\\\"THRESHOLD\\\",\\\"value\\\":\\\"150994944\\\"}," + - "{\\\"name\\\":\\\"LOW_MEMORY\\\",\\\"value\\\":\\\"false\\\"}]\"}," + - "{\"name\":\"BATTERY_INFO\",\"value\":\"[" + - "{\\\"name\\\":\\\"BATTERY_LEVEL\\\",\\\"value\\\":\\\"100\\\"}," + - "{\\\"name\\\":\\\"SCALE\\\",\\\"value\\\":\\\"100\\\"}," + - "{\\\"BATTERY_VOLTAGE\\\":\\\"0\\\"}," + - "{\\\"name\\\":\\\"HEALTH\\\",\\\"value\\\":\\\"GOOD_CONDITION\\\"}," + - "{\\\"name\\\":\\\"STATUS\\\"}," + - "{\\\"name\\\":\\\"PLUGGED\\\",\\\"value\\\":\\\"AC\\\"}]\"}," + - "{\"name\":\"DEVICE_INFO\",\"value\":\"[" + - "{\\\"name\\\":\\\"ENCRYPTION_ENABLED\\\",\\\"value\\\":\\\"false\\\"}," + - "{\\\"name\\\":\\\"PASSCODE_ENABLED\\\",\\\"value\\\":\\\"true\\\"}," + - "{\\\"name\\\":\\\"BATTERY_LEVEL\\\",\\\"value\\\":\\\"100\\\"}," + - "{\\\"name\\\":\\\"INTERNAL_TOTAL_MEMORY\\\",\\\"value\\\":\\\"0.76\\\"}," + - "{\\\"name\\\":\\\"INTERNAL_AVAILABLE_MEMORY\\\",\\\"value\\\":\\\"0.67\\\"}," + - "{\\\"name\\\":\\\"EXTERNAL_TOTAL_MEMORY\\\",\\\"value\\\":\\\"0.1\\\"}," + - "{\\\"name\\\":\\\"EXTERNAL_AVAILABLE_MEMORY\\\",\\\"value\\\":\\\"0.1\\\"}," + - "{\\\"name\\\":\\\"OPERATOR\\\",\\\"value\\\":\\\"Android\\\"}," + - "{\\\"name\\\":\\\"PHONE_NUMBER\\\",\\\"value\\\":\\\"15555215554\\\"}]\"}]}"); - operation.setStatus(Operation.Status.COMPLETED); - operations.add(operation); - return operations; - } - - public static List getInProgressOperationResponse() { - List operations = new ArrayList<>(); - Operation operation = new Operation(); - operation.setActivityId(getActivity().getActivityId()); - operation.setCode(AndroidConstants.OperationCodes.NOTIFICATION); - operation.setId(1); - operation.setOperationResponse("Operation in progress."); - operation.setStatus(Operation.Status.IN_PROGRESS); - operations.add(operation); - return operations; - } - - public static List getErrorOperationResponse() { - List operations = new ArrayList<>(); - Operation operation = new Operation(); - operation.setActivityId(getActivity().getActivityId()); - operation.setCode(AndroidConstants.OperationCodes.DEVICE_INFO); - operation.setId(1); - operation.setOperationResponse("Operation failure."); - operation.setStatus(Operation.Status.ERROR); - operations.add(operation); - return operations; - } - - public static DeviceLocation getDeviceLocation() { - DeviceLocation location = new DeviceLocation(); - location.setCity("Colombo"); - location.setCountry("Sri Lanka"); - location.setLatitude(6.9); - location.setLongitude(79.5); - location.setDeviceIdentifier(AndroidDeviceUtils.convertToDeviceIdentifierObject(getDeviceId())); - return location; - } - - public static DeviceInfo getDeviceInfo() { - DeviceInfo deviceInfo = new DeviceInfo(); - deviceInfo.setDeviceModel("nexus"); - deviceInfo.setAvailableRAMMemory(2.0); - deviceInfo.setBatteryLevel(100.0); - deviceInfo.setConnectionType("4G"); - deviceInfo.setCpuUsage(1.0); - deviceInfo.setExternalAvailableMemory(2.3); - deviceInfo.setExternalTotalMemory(4.0); - deviceInfo.setInternalAvailableMemory(1.0); - deviceInfo.setInternalTotalMemory(4.0); - deviceInfo.setLocation(getDeviceLocation()); - return deviceInfo; - } - - public static List getApplications() { - List applications = new ArrayList<>(); - Application app = new Application(); - app.setName("Entgra IoT Agent"); - app.setApplicationIdentifier("org.wos2.iot.agent"); - app.setVersion("1.0.0"); - app.setPlatform("Android"); - applications.add(app); - return applications; - } - - public static AndroidDevice getBasicAndroidDevice() { - AndroidDevice androidDevice = new AndroidDevice(); - androidDevice.setName(getDevice().getName()); - androidDevice.setDescription(getDevice().getDescription()); - androidDevice.setDeviceIdentifier(getDeviceId()); - androidDevice.setDeviceInfo(getDeviceInfo()); - androidDevice.setApplications(getApplications()); - androidDevice.setEnrolmentInfo(getDevice().getEnrolmentInfo()); - return androidDevice; - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/resources/log4j.properties b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/resources/log4j.properties deleted file mode 100644 index 90c5d0edc..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/resources/log4j.properties +++ /dev/null @@ -1,34 +0,0 @@ -# -# 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. -# - -# -# This is the log4j configuration file used by WSO2 Carbon -# -# IMPORTANT : Please do not remove or change the names of any -# of the Appender defined here. The layout pattern & log file -# can be changed using the WSO2 Carbon Management Console, and those -# settings will override the settings in this file. -# - -log4j.rootLogger=DEBUG, STD_OUT - -# Redirect log messages to console -log4j.appender.STD_OUT=org.apache.log4j.ConsoleAppender -log4j.appender.STD_OUT.Target=System.out -log4j.appender.STD_OUT.layout=org.apache.log4j.PatternLayout -log4j.appender.STD_OUT.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/resources/testng.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/resources/testng.xml deleted file mode 100644 index 865a1e85b..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/test/resources/testng.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/AndroidPluginService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/AndroidPluginService.java new file mode 100644 index 000000000..7bc4ad3be --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/AndroidPluginService.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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.android; + +import org.wso2.carbon.device.mgt.mobile.android.impl.EnterpriseServiceException; +import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseManagedConfig; +import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseUser; + +import java.util.List; + +public interface AndroidPluginService { + + void addEnterpriseUser(AndroidEnterpriseUser androidEnterpriseUser) throws EnterpriseServiceException; + + List getEnterpriseUser(String username) throws EnterpriseServiceException; + + AndroidEnterpriseUser getEnterpriseUserByDevice(String deviceId) throws EnterpriseServiceException; + + AndroidEnterpriseManagedConfig getConfigByPackageName(String packageName) throws EnterpriseServiceException; + + void addConfig(AndroidEnterpriseManagedConfig managedConfig) throws EnterpriseServiceException; + + boolean updateMobileDevice(AndroidEnterpriseManagedConfig managedConfig) throws EnterpriseServiceException; + + boolean deleteMobileDevice(String id) throws EnterpriseServiceException; +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java index fc0364aff..bccceedbb 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java @@ -36,7 +36,6 @@ package org.wso2.carbon.device.mgt.mobile.android.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManager; import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; import org.wso2.carbon.device.mgt.common.ProvisioningConfig; @@ -46,11 +45,13 @@ import org.wso2.carbon.device.mgt.common.StartupOperationConfig; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.general.GeneralConfig; import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager; import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationSubscriber; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; +import org.wso2.carbon.device.mgt.common.type.mgt.DeviceTypePlatformDetails; import org.wso2.carbon.device.mgt.mobile.android.impl.util.AndroidPluginConstants; import org.wso2.carbon.device.mgt.mobile.android.internal.AndroidDeviceManagementDataHolder; @@ -83,8 +84,7 @@ public class AndroidDeviceManagementService implements DeviceManagementService { @Override public void init() throws DeviceManagementException { - this.deviceManager = new AndroidDeviceManager(); - this.policyMonitoringManager = new AndroidPolicyMonitoringManager(); + } @Override @@ -104,29 +104,6 @@ public class AndroidDeviceManagementService implements DeviceManagementService { @Override public PushNotificationConfig getPushNotificationConfig() { - try { - DeviceManagementService deviceManagementService = AndroidDeviceManagementDataHolder.getInstance(). - getAndroidDeviceManagementService(); - if (deviceManagementService != null && deviceManagementService.getDeviceManager() != null) { - PlatformConfiguration androidConfig = deviceManagementService.getDeviceManager().getConfiguration(); - if (androidConfig != null) { - List configuration = androidConfig.getConfiguration(); - String notifierValue = this.getConfigProperty(configuration, NOTIFIER_PROPERTY); - if (notifierValue != null && !notifierValue.isEmpty()) { - int notifierType = Integer.parseInt(notifierValue); - if (notifierType == 2) { - HashMap config = new HashMap<>(); - config.put(FCM_API_KEY, this.getConfigProperty(configuration, FCM_API_KEY)); - config.put(FCM_SENDER_ID, this.getConfigProperty(configuration, FCM_SENDER_ID)); - return new PushNotificationConfig(AndroidPluginConstants.NotifierType.FCM, false, - config); - } - } - } - } - } catch (DeviceManagementException e) { - log.error("Unable to get the Android platform configuration from registry."); - } return null; } @@ -160,6 +137,9 @@ public class AndroidDeviceManagementService implements DeviceManagementService { return null; } + @Override + public DeviceTypePlatformDetails getDeviceTypePlatformDetails() { return null; } + private String getConfigProperty(List configs, String propertyName) { for (ConfigurationEntry entry : configs) { if (propertyName.equals(entry.getName())) { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManager.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManager.java deleted file mode 100644 index 9ac1f1f4f..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManager.java +++ /dev/null @@ -1,377 +0,0 @@ -/* - * 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.android.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.DeviceManager; -import org.wso2.carbon.device.mgt.common.EnrolmentInfo; -import org.wso2.carbon.device.mgt.common.FeatureManager; -import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; -import org.wso2.carbon.device.mgt.common.license.mgt.License; -import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; -import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; -import org.wso2.carbon.device.mgt.extensions.license.mgt.registry.RegistryBasedLicenseManager; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AbstractMobileDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AndroidDAOFactory; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl.AndroidDeviceMgtPluginException; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileDevice; -import org.wso2.carbon.device.mgt.mobile.android.impl.util.AndroidPluginConstants; -import org.wso2.carbon.device.mgt.mobile.android.impl.util.AndroidPluginUtils; -import org.wso2.carbon.device.mgt.mobile.android.impl.util.MobileDeviceManagementUtil; -import org.wso2.carbon.registry.api.RegistryException; -import org.wso2.carbon.registry.api.Resource; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import java.io.StringReader; -import java.io.StringWriter; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.List; - -public class AndroidDeviceManager implements DeviceManager { - - private AbstractMobileDeviceManagementDAOFactory daoFactory; - private static final Log log = LogFactory.getLog(AndroidDeviceManagementService.class); - private FeatureManager featureManager = new AndroidFeatureManager(); - private LicenseManager licenseManager; - - public AndroidDeviceManager() { - this.daoFactory = new AndroidDAOFactory(); - this.licenseManager = new RegistryBasedLicenseManager(); - License defaultLicense; - - try { - if (licenseManager.getLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, - AndroidPluginConstants.MobilePluginConstants.LANGUAGE_CODE_ENGLISH_US) == - null) { - defaultLicense = AndroidPluginUtils.getDefaultLicense(); - licenseManager.addLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, defaultLicense); - } - featureManager.addSupportedFeaturesToDB(); - } catch (LicenseManagementException e) { - log.error("Error occurred while adding default license for Android devices", e); - } catch (DeviceManagementException e) { - log.error("Error occurred while adding supported device features for Android platform", e); - } - } - - @Override - public FeatureManager getFeatureManager() { - return featureManager; - } - - @Override - public boolean saveConfiguration(PlatformConfiguration tenantConfiguration) - throws DeviceManagementException { - boolean status; - try { - if (log.isDebugEnabled()) { - log.debug("Persisting android configurations in Registry"); - } - String resourcePath = MobileDeviceManagementUtil.getPlatformConfigPath( - DeviceManagementConstants. - MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - StringWriter writer = new StringWriter(); - JAXBContext context = JAXBContext.newInstance(PlatformConfiguration.class); - Marshaller marshaller = context.createMarshaller(); - marshaller.marshal(tenantConfiguration, writer); - - Resource resource = MobileDeviceManagementUtil.getConfigurationRegistry().newResource(); - resource.setContent(writer.toString()); - resource.setMediaType(AndroidPluginConstants.MobilePluginConstants.MEDIA_TYPE_XML); - MobileDeviceManagementUtil.putRegistryResource(resourcePath, resource); - status = true; - } catch (AndroidDeviceMgtPluginException e) { - throw new DeviceManagementException( - "Error occurred while retrieving the Registry instance : " + e.getMessage(), e); - } catch (RegistryException e) { - throw new DeviceManagementException( - "Error occurred while persisting the Registry resource of Android Configuration : " + e.getMessage(), e); - } catch (JAXBException e) { - throw new DeviceManagementException( - "Error occurred while parsing the Android configuration : " + e.getMessage(), e); - } - return status; - } - - @Override - public PlatformConfiguration getConfiguration() throws DeviceManagementException { - Resource resource; - try { - String androidRegPath = - MobileDeviceManagementUtil.getPlatformConfigPath(DeviceManagementConstants. - MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - resource = MobileDeviceManagementUtil.getRegistryResource(androidRegPath); - if (resource != null) { - XMLInputFactory factory = XMLInputFactory.newInstance(); - factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false); - factory.setProperty(XMLInputFactory.SUPPORT_DTD, false); - XMLStreamReader reader = factory.createXMLStreamReader( - new StringReader(new String((byte[]) resource.getContent(), Charset. - forName(AndroidPluginConstants.MobilePluginConstants.CHARSET_UTF8)))); - JAXBContext context = JAXBContext.newInstance(PlatformConfiguration.class); - Unmarshaller unmarshaller = context.createUnmarshaller(); - return (PlatformConfiguration) unmarshaller.unmarshal(reader); - } - return null; - } catch (AndroidDeviceMgtPluginException e) { - throw new DeviceManagementException( - "Error occurred while retrieving the Registry instance : " + e.getMessage(), e); - } catch (JAXBException | XMLStreamException e) { - throw new DeviceManagementException( - "Error occurred while parsing the Android configuration : " + e.getMessage(), e); - } catch (RegistryException e) { - throw new DeviceManagementException( - "Error occurred while retrieving the Registry resource of Android Configuration : " + e.getMessage(), e); - } - } - - @Override - public boolean enrollDevice(Device device) throws DeviceManagementException { - boolean status = false; - boolean isEnrolled = this.isEnrolled( - new DeviceIdentifier(device.getDeviceIdentifier(), device.getType())); - - try { - if (log.isDebugEnabled()) { - log.debug("Enrolling a new Android device : " + device.getDeviceIdentifier()); - } - - if (isEnrolled) { - this.modifyEnrollment(device); - } else { - MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); - AndroidDAOFactory.beginTransaction(); - status = daoFactory.getMobileDeviceDAO().addMobileDevice(mobileDevice); - AndroidDAOFactory.commitTransaction(); - } - } catch (MobileDeviceManagementDAOException e) { - try { - AndroidDAOFactory.rollbackTransaction(); - } catch (MobileDeviceManagementDAOException mobileDAOEx) { - String msg = "Error occurred while roll back the device enrol transaction :" + - device.toString(); - log.warn(msg, mobileDAOEx); - } - String msg = - "Error while enrolling the Android device : " + device.getDeviceIdentifier(); - throw new DeviceManagementException(msg, e); - } - return status; - } - - @Override - public boolean modifyEnrollment(Device device) throws DeviceManagementException { - boolean status; - MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); - try { - if (log.isDebugEnabled()) { - log.debug("Modifying the Android device enrollment data"); - } - AndroidDAOFactory.beginTransaction(); - status = daoFactory.getMobileDeviceDAO().updateMobileDevice(mobileDevice); - AndroidDAOFactory.commitTransaction(); - } catch (MobileDeviceManagementDAOException e) { - try { - AndroidDAOFactory.rollbackTransaction(); - } catch (MobileDeviceManagementDAOException mobileDAOEx) { - String msg = "Error occurred while roll back the update device transaction :" + - device.toString(); - log.warn(msg, mobileDAOEx); - } - String msg = "Error while updating the enrollment of the Android device : " + - device.getDeviceIdentifier(); - throw new DeviceManagementException(msg, e); - } - return status; - } - - @Override - public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - //Here we don't have anything specific to do. Hence returning. - return true; - } - - - @Override - public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { - boolean isEnrolled = false; - try { - if (log.isDebugEnabled()) { - log.debug("Checking the enrollment of Android device : " + deviceId.getId()); - } - MobileDevice mobileDevice = - daoFactory.getMobileDeviceDAO().getMobileDevice(deviceId.getId()); - if (mobileDevice != null) { - isEnrolled = true; - } - } catch (MobileDeviceManagementDAOException e) { - String msg = "Error while checking the enrollment status of Android device : " + - deviceId.getId(); - throw new DeviceManagementException(msg, e); - } - return isEnrolled; - } - - @Override - public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException { - return true; - } - - @Override - public boolean setActive(DeviceIdentifier deviceId, boolean status) - throws DeviceManagementException { - return true; - } - - @Override - public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - Device device; - try { - if (log.isDebugEnabled()) { - log.debug("Getting the details of Android device : '" + deviceId.getId() + "'"); - } - MobileDevice mobileDevice = daoFactory.getMobileDeviceDAO(). - getMobileDevice(deviceId.getId()); - device = MobileDeviceManagementUtil.convertToDevice(mobileDevice); - } catch (MobileDeviceManagementDAOException e) { - throw new DeviceManagementException( - "Error occurred while fetching the Android device: '" + - deviceId.getId() + "'", e); - } - return device; - } - - @Override - public boolean updateDeviceProperties(DeviceIdentifier deviceIdentifier, List list) throws DeviceManagementException { - return false; - } - - @Override - public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) - throws DeviceManagementException { - return true; - } - - @Override - public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { - return false; - } - - @Override - public boolean setStatus(DeviceIdentifier deviceIdentifier, String currentUser, - EnrolmentInfo.Status status) throws DeviceManagementException { - return false; - } - - @Override - public License getLicense(String languageCode) throws LicenseManagementException { - return licenseManager. - getLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, languageCode); - } - - @Override - public void addLicense(License license) throws LicenseManagementException { - licenseManager.addLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, license); - } - - @Override - public boolean requireDeviceAuthorization() { - return true; - } - - @Override - public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) - throws DeviceManagementException { - boolean status; - Device existingDevice = this.getDevice(deviceIdentifier); - // This object holds the current persisted device object - MobileDevice existingMobileDevice = - MobileDeviceManagementUtil.convertToMobileDevice(existingDevice); - - // This object holds the newly received device object from response - MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); - - // Updating current object features using newer ones - existingMobileDevice.setLatitude(mobileDevice.getLatitude()); - existingMobileDevice.setLongitude(mobileDevice.getLongitude()); - existingMobileDevice.setDeviceProperties(mobileDevice.getDeviceProperties()); - - try { - if (log.isDebugEnabled()) { - log.debug( - "updating the details of Android device : " + device.getDeviceIdentifier()); - } - AndroidDAOFactory.beginTransaction(); - status = daoFactory.getMobileDeviceDAO().updateMobileDevice(existingMobileDevice); - AndroidDAOFactory.commitTransaction(); - } catch (MobileDeviceManagementDAOException e) { - try { - AndroidDAOFactory.rollbackTransaction(); - } catch (MobileDeviceManagementDAOException e1) { - log.warn("Error occurred while roll back the update device info transaction : '" + - device.toString() + "'", e1); - } - throw new DeviceManagementException( - "Error occurred while updating the Android device: '" + - device.getDeviceIdentifier() + "'", e); - } - return status; - } - - @Override - public List getAllDevices() throws DeviceManagementException { - List devices = null; - try { - if (log.isDebugEnabled()) { - log.debug("Fetching the details of all Android devices"); - } - List mobileDevices = - daoFactory.getMobileDeviceDAO().getAllMobileDevices(); - if (mobileDevices != null) { - devices = new ArrayList<>(mobileDevices.size()); - for (MobileDevice mobileDevice : mobileDevices) { - devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevice)); - } - } - } catch (MobileDeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while fetching all Android devices", - e); - } - return devices; - } - - @Override - public void deleteDevices(List deviceIdentifiers) throws DeviceManagementException { - //Does nothing since AndroidDeviceManager is not used instead DeviceTypeManager is used. - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidFeatureManager.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidFeatureManager.java deleted file mode 100644 index 33d6a3a83..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidFeatureManager.java +++ /dev/null @@ -1,580 +0,0 @@ -/* - * 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. - * - */ - -/* - * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. 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.android.impl; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.Feature; -import org.wso2.carbon.device.mgt.common.FeatureManager; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AndroidDAOFactory; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileFeatureDAO; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileFeature; -import org.wso2.carbon.device.mgt.mobile.android.impl.util.MobileDeviceManagementUtil; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -public class AndroidFeatureManager implements FeatureManager { - - private MobileFeatureDAO featureDAO; - private static final Log log = LogFactory.getLog(AndroidFeatureManager.class); - - public AndroidFeatureManager() { - MobileDeviceManagementDAOFactory daoFactory = new AndroidDAOFactory(); - this.featureDAO = daoFactory.getMobileFeatureDAO(); - } - - @Override - public boolean addFeature(Feature feature) throws DeviceManagementException { - try { - AndroidDAOFactory.beginTransaction(); - MobileFeature mobileFeature = MobileDeviceManagementUtil.convertToMobileFeature(feature); - featureDAO.addFeature(mobileFeature); - AndroidDAOFactory.commitTransaction(); - return true; - } catch (MobileDeviceManagementDAOException e) { - try { - AndroidDAOFactory.rollbackTransaction(); - } catch (MobileDeviceManagementDAOException e1) { - log.warn("Error occurred while roll-backing the transaction", e); - } - throw new DeviceManagementException("Error occurred while adding the feature", e); - } - } - - @Override - public boolean addFeatures(List features) throws DeviceManagementException { - List mobileFeatures = new ArrayList(features.size()); - for (Feature feature : features) { - mobileFeatures.add(MobileDeviceManagementUtil.convertToMobileFeature(feature)); - } - try { - AndroidDAOFactory.beginTransaction(); - featureDAO.addFeatures(mobileFeatures); - AndroidDAOFactory.commitTransaction(); - return true; - } catch (MobileDeviceManagementDAOException e) { - try { - AndroidDAOFactory.rollbackTransaction(); - } catch (MobileDeviceManagementDAOException e1) { - log.warn("Error occurred while roll-backing the transaction", e); - } - throw new DeviceManagementException("Error occurred while adding the features", e); - } - } - - @Override - public Feature getFeature(String name) throws DeviceManagementException { - try { - MobileFeature mobileFeature = featureDAO.getFeatureByCode(name); - Feature feature = MobileDeviceManagementUtil.convertToFeature(mobileFeature); - return feature; - } catch (MobileDeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while retrieving the feature", e); - } - } - - @Override - public List getFeatures() throws DeviceManagementException { - try { - List mobileFeatures = featureDAO.getAllFeatures(); - return mobileFeatures.stream().map(MobileDeviceManagementUtil::convertToFeature).collect( - Collectors.toList()); - } catch (MobileDeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while retrieving the list of features registered for " + - "Android platform", e); - } - } - - @Override - public List getFeatures(String featureType) throws DeviceManagementException { - if (StringUtils.isEmpty(featureType)) { - return this.getFeatures(); - } - try { - List mobileFeatures = featureDAO.getFeaturesByFeatureType(featureType); - return mobileFeatures.stream().map(MobileDeviceManagementUtil::convertToFeature).collect( - Collectors.toList()); - } catch (MobileDeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while retrieving the list of features registered for " + - "Android platform", e); - } - } - - @Override - public List getFeatures(String featureType, boolean isHidden) throws DeviceManagementException { - try { - List mobileFeatures; - if (StringUtils.isNotEmpty(featureType)) { - mobileFeatures = featureDAO.getFeaturesByFeatureType(featureType, isHidden); - } else { - mobileFeatures = featureDAO.getAllFeatures(isHidden); - } - return mobileFeatures.stream().map(MobileDeviceManagementUtil::convertToFeature).collect( - Collectors.toList()); - } catch (MobileDeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while retrieving the list of features registered for " + - "Android platform", e); - } - } - - @Override - public boolean removeFeature(String code) throws DeviceManagementException { - boolean status; - try { - AndroidDAOFactory.beginTransaction(); - featureDAO.deleteFeatureByCode(code); - AndroidDAOFactory.commitTransaction(); - status = true; - } catch (MobileDeviceManagementDAOException e) { - try { - AndroidDAOFactory.rollbackTransaction(); - } catch (MobileDeviceManagementDAOException e1) { - log.warn("Error occurred while roll-backing the transaction", e); - } - throw new DeviceManagementException("Error occurred while removing the feature", e); - } - return status; - } - - @Override - public boolean addSupportedFeaturesToDB() throws DeviceManagementException { - synchronized (this) { - List supportedFeatures = getSupportedFeatures(); - List existingFeatures = this.getFeatures(); - List missingFeatures = MobileDeviceManagementUtil. - getMissingFeatures(supportedFeatures, existingFeatures); - if (missingFeatures.size() > 0) { - return this.addFeatures(missingFeatures); - } - return true; - } - } - - //Get the supported feature list. - private static List getSupportedFeatures() { - List supportedFeatures = new ArrayList(); - Feature feature = new Feature(); - feature.setCode("DEVICE_LOCK"); - feature.setName("Device Lock"); - feature.setDescription("Lock the device"); - supportedFeatures.add(feature); - feature = new Feature(); - feature.setCode("DEVICE_LOCATION"); - feature.setName("Location"); - feature.setDescription("Request coordinates of device location"); - supportedFeatures.add(feature); - feature = new Feature(); - feature.setCode("WIFI"); - feature.setName("wifi"); - feature.setDescription("Setting up wifi configuration"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("CAMERA"); - feature.setName("camera"); - feature.setDescription("Enable or disable camera"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("BACKUP_SERVICE"); - feature.setName("Set Backup Service"); - feature.setDescription("set backup service"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("EMAIL"); - feature.setName("Email"); - feature.setDescription("Configure email settings"); - supportedFeatures.add(feature); - feature = new Feature(); - feature.setCode("DEVICE_MUTE"); - feature.setName("mute"); - feature.setDescription("Enable mute in the device"); - supportedFeatures.add(feature); - feature = new Feature(); - feature.setCode("DEVICE_INFO"); - feature.setName("Device info"); - feature.setDescription("Request device information"); - supportedFeatures.add(feature); - feature = new Feature(); - feature.setCode("ENTERPRISE_WIPE"); - feature.setName("Enterprise Wipe"); - feature.setDescription("Remove enterprise applications"); - supportedFeatures.add(feature); - feature = new Feature(); - feature.setCode("CLEAR_PASSWORD"); - feature.setName("Clear Password"); - feature.setDescription("Clear current password"); - supportedFeatures.add(feature); - feature = new Feature(); - feature.setCode("WIPE_DATA"); - feature.setName("Wipe Data"); - feature.setDescription("Factory reset the device"); - supportedFeatures.add(feature); - feature = new Feature(); - feature.setCode("APPLICATION_LIST"); - feature.setName("Application List"); - feature.setDescription("Request list of current installed applications"); - supportedFeatures.add(feature); - feature = new Feature(); - feature.setCode("CHANGE_LOCK_CODE"); - feature.setName("Change Lock-code"); - feature.setDescription("Change current lock code"); - supportedFeatures.add(feature); - feature = new Feature(); - feature.setCode("INSTALL_APPLICATION"); - feature.setName("Install App"); - feature.setDescription("Install Enterprise or Market application"); - supportedFeatures.add(feature); - feature = new Feature(); - feature.setCode("UNINSTALL_APPLICATION"); - feature.setName("Uninstall App"); - feature.setDescription("Uninstall application"); - supportedFeatures.add(feature); - feature = new Feature(); - feature.setCode("BLACKLIST_APPLICATIONS"); - feature.setName("Blacklist app"); - feature.setDescription("Blacklist applications"); - supportedFeatures.add(feature); - feature = new Feature(); - feature.setCode("ENCRYPT_STORAGE"); - feature.setName("Encrypt storage"); - feature.setDescription("Encrypt storage"); - supportedFeatures.add(feature); - feature = new Feature(); - feature.setCode("DEVICE_RING"); - feature.setName("Ring"); - feature.setDescription("Ring the device"); - supportedFeatures.add(feature); - feature = new Feature(); - feature.setCode("PASSCODE_POLICY"); - feature.setName("Password Policy"); - feature.setDescription("Set passcode policy"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("NOTIFICATION"); - feature.setName("Message"); - feature.setDescription("Send message"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DEVICE_REBOOT"); - feature.setName("Reboot"); - feature.setDescription("Reboot the device"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("UPGRADE_FIRMWARE"); - feature.setName("Upgrade Firmware"); - feature.setDescription("Upgrade Firmware"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("VPN"); - feature.setName("Configure VPN"); - feature.setDescription("Configure VPN settings"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_ADJUST_VOLUME"); - feature.setName("Adjust Volume"); - feature.setDescription("allow or disallow user to change volume"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_CONFIG_BLUETOOTH"); - feature.setName("Disallow bluetooth configuration"); - feature.setDescription("allow or disallow user to change bluetooth configurations"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_CONFIG_CELL_BROADCASTS"); - feature.setName("Disallow cell broadcast configuration"); - feature.setDescription("allow or disallow user to change cell broadcast configurations"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_CONFIG_CREDENTIALS"); - feature.setName("Disallow credential configuration"); - feature.setDescription("allow or disallow user to change user credentials"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_CONFIG_MOBILE_NETWORKS"); - feature.setName("Disallow mobile network configure"); - feature.setDescription("allow or disallow user to change mobile networks configurations"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_CONFIG_TETHERING"); - feature.setName("Disallow tethering configuration"); - feature.setDescription("allow or disallow user to change tethering configurations"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_CONFIG_VPN"); - feature.setName("Disallow VPN configuration"); - feature.setDescription("allow or disallow user to change VPN configurations"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_CONFIG_WIFI"); - feature.setName("Disallow WIFI configuration"); - feature.setDescription("allow or disallow user to change WIFI configurations"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_APPS_CONTROL"); - feature.setName("Disallow APP control configuration"); - feature.setDescription("allow or disallow user to change app control"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_CREATE_WINDOWS"); - feature.setName("Disallow window creation"); - feature.setDescription("allow or disallow window creation"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_APPS_CONTROL"); - feature.setName("Disallow APP control configuration"); - feature.setDescription("allow or disallow user to change app control configurations"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_CROSS_PROFILE_COPY_PASTE"); - feature.setName("Disallow cross profile copy paste"); - feature.setDescription("allow or disallow cross profile copy paste"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_DEBUGGING_FEATURES"); - feature.setName("Disallow debugging features"); - feature.setDescription("allow or disallow debugging features"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_FACTORY_RESET"); - feature.setName("Disallow factory reset"); - feature.setDescription("allow or disallow factory reset"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_ADD_USER"); - feature.setName("Disallow add user"); - feature.setDescription("allow or disallow add user"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_INSTALL_APPS"); - feature.setName("Disallow install apps"); - feature.setDescription("allow or disallow install apps"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_INSTALL_UNKNOWN_SOURCES"); - feature.setName("Disallow install unknown sources"); - feature.setDescription("allow or disallow install unknown sources"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_MODIFY_ACCOUNTS"); - feature.setName("Disallow modify account"); - feature.setDescription("allow or disallow modify account"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_MOUNT_PHYSICAL_MEDIA"); - feature.setName("Disallow mount physical media"); - feature.setDescription("allow or disallow mount physical media."); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_NETWORK_RESET"); - feature.setName("Disallow network reset"); - feature.setDescription("allow or disallow network reset"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_OUTGOING_BEAM"); - feature.setName("Disallow outgoing beam"); - feature.setDescription("allow or disallow outgoing beam."); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_OUTGOING_CALLS"); - feature.setName("Disallow outgoing calls"); - feature.setDescription("allow or disallow outgoing calls"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_REMOVE_USER"); - feature.setName("Disallow remove users"); - feature.setDescription("allow or disallow remove users"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_SAFE_BOOT"); - feature.setName("Disallow safe boot"); - feature.setDescription("allow or disallow safe boot"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_SHARE_LOCATION"); - feature.setName("Disallow share location"); - feature.setDescription("allow or disallow share location."); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_SMS"); - feature.setName("Disallow sms"); - feature.setDescription("allow or disallow sms"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_UNINSTALL_APPS"); - feature.setName("Disallow uninstall app"); - feature.setDescription("allow or disallow uninstall app"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_UNMUTE_MICROPHONE"); - feature.setName("Disallow unmute mic"); - feature.setDescription("allow or disallow unmute mic"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_USB_FILE_TRANSFER"); - feature.setName("Disallow usb file transfer"); - feature.setDescription("allow or disallow usb file transfer"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("ALLOW_PARENT_PROFILE_APP_LINKING"); - feature.setName("Disallow parent profile app linking"); - feature.setDescription("allow or disallow parent profile app linking"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("ENSURE_VERIFY_APPS"); - feature.setName("Disallow ensure verify apps"); - feature.setDescription("allow or disallow ensure verify apps"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("AUTO_TIME"); - feature.setName("Allow auto timing"); - feature.setDescription("allow or disallow auto timing"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("REMOVE_DEVICE_OWNER"); - feature.setName("Remove device owner"); - feature.setDescription("remove device owner"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("LOGCAT"); - feature.setName("Fetch Logcat"); - feature.setDescription("Fetch device logcat"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DEVICE_UNLOCK"); - feature.setName("Device Unlock"); - feature.setDescription("Unlock the device"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_SET_WALLPAPER"); - feature.setName("Device Unlock"); - feature.setDescription("Unlock the device"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_SET_USER_ICON"); - feature.setName("Device Unlock"); - feature.setDescription("Unlock the device"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_REMOVE_MANAGEMENT_PROFILE"); - feature.setName("Device Unlock"); - feature.setDescription("Unlock the device"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_AUTOFILL"); - feature.setName("Device Unlock"); - feature.setDescription("Unlock the device"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_BLUETOOTH"); - feature.setName("Device Unlock"); - feature.setDescription("Unlock the device"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_BLUETOOTH_SHARING"); - feature.setName("Device Unlock"); - feature.setDescription("Unlock the device"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_REMOVE_USER"); - feature.setName("Device Unlock"); - feature.setDescription("Unlock the device"); - supportedFeatures.add(feature); - - feature = new Feature(); - feature.setCode("DISALLOW_DATA_ROAMING"); - feature.setName("Device Unlock"); - feature.setDescription("Unlock the device"); - supportedFeatures.add(feature); - - return supportedFeatures; - } -} \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidPluginServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidPluginServiceImpl.java new file mode 100644 index 000000000..1fc0754f9 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidPluginServiceImpl.java @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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.android.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.device.mgt.mobile.android.AndroidPluginService; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AndroidDAOFactory; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.EnterpriseDAO; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.EnterpriseManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseManagedConfig; +import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseUser; + +import java.util.List; + +/** + * This represents the Android implementation of DeviceManagerService. + */ +public class AndroidPluginServiceImpl implements AndroidPluginService { + + private static final Log log = LogFactory.getLog(AndroidPluginServiceImpl.class); + private EnterpriseDAO enterpriseDAO; + + public AndroidPluginServiceImpl() { + enterpriseDAO = AndroidDAOFactory.getEnterpriseDAO(); + } + + @Override + public void addEnterpriseUser(AndroidEnterpriseUser androidEnterpriseUser) throws EnterpriseServiceException { + if (log.isDebugEnabled()) { + log.debug("Calling add user service by device identifier: " + androidEnterpriseUser.getEmmDeviceId()); + } + try { + AndroidDAOFactory.beginTransaction(); + this.enterpriseDAO.addUser(androidEnterpriseUser); + AndroidDAOFactory.commitTransaction(); + } catch (EnterpriseManagementDAOException e) { + String msg = "Error occurred while adding the user " + + CarbonContext.getThreadLocalCarbonContext().getUsername(); + log.error(msg, e); + AndroidDAOFactory.rollbackTransaction(); + throw new EnterpriseServiceException(msg, e); + } finally { + AndroidDAOFactory.closeConnection(); + } + } + + @Override + public List getEnterpriseUser(String username) throws EnterpriseServiceException { + + List androidEnterpriseUsers; + if (log.isDebugEnabled()) { + log.debug("Calling get user service by device identifier: " + CarbonContext + .getThreadLocalCarbonContext().getUsername()); + } + try { + AndroidDAOFactory.openConnection(); + androidEnterpriseUsers = this.enterpriseDAO.getUser(username, CarbonContext.getThreadLocalCarbonContext() + .getTenantId()); + + } catch (EnterpriseManagementDAOException e) { + String msg = "Error occurred while adding the user " + + CarbonContext.getThreadLocalCarbonContext().getUsername(); + log.error(msg, e); + throw new EnterpriseServiceException(msg, e); + } finally { + AndroidDAOFactory.closeConnection(); + } + return androidEnterpriseUsers; + } + + @Override + public AndroidEnterpriseUser getEnterpriseUserByDevice(String deviceId) throws EnterpriseServiceException { + + AndroidEnterpriseUser androidEnterpriseUsers; + if (log.isDebugEnabled()) { + log.debug("Calling get user service by device identifier: " + CarbonContext + .getThreadLocalCarbonContext().getUsername()); + } + try { + AndroidDAOFactory.openConnection(); + androidEnterpriseUsers = this.enterpriseDAO.getUserByDevice(deviceId, CarbonContext.getThreadLocalCarbonContext() + .getTenantId()); + + } catch (EnterpriseManagementDAOException e) { + String msg = "Error occurred while adding the user " + + CarbonContext.getThreadLocalCarbonContext().getUsername(); + log.error(msg, e); + throw new EnterpriseServiceException(msg, e); + } finally { + AndroidDAOFactory.closeConnection(); + } + return androidEnterpriseUsers; + } + + @Override + public AndroidEnterpriseManagedConfig getConfigByPackageName(String packageName) throws EnterpriseServiceException { + AndroidEnterpriseManagedConfig enterpriseManagedConfig; + if (log.isDebugEnabled()) { + log.debug("Calling get user service by device identifier: " + CarbonContext + .getThreadLocalCarbonContext().getUsername()); + } + try { + AndroidDAOFactory.openConnection(); + enterpriseManagedConfig = this.enterpriseDAO.getConfigByPackageName(packageName, CarbonContext + .getThreadLocalCarbonContext().getTenantId()); + + } catch (EnterpriseManagementDAOException e) { + String msg = "Error occurred while getting configs for the package " + packageName; + log.error(msg, e); + throw new EnterpriseServiceException(msg, e); + } finally { + AndroidDAOFactory.closeConnection(); + } + return enterpriseManagedConfig; + } + + @Override + public void addConfig(AndroidEnterpriseManagedConfig managedConfig) throws EnterpriseServiceException { + if (log.isDebugEnabled()) { + log.debug("Calling add managed config for package : " + managedConfig.getPackageName()); + } + + // Block from fetching other tenants data. + managedConfig.setTenantID(CarbonContext.getThreadLocalCarbonContext().getTenantId()); + try { + AndroidDAOFactory.beginTransaction(); + this.enterpriseDAO.addConfig(managedConfig); + AndroidDAOFactory.commitTransaction(); + } catch (EnterpriseManagementDAOException e) { + String msg = "Error occurred while adding managed configs for package " + managedConfig.getPackageName(); + log.error(msg, e); + AndroidDAOFactory.rollbackTransaction(); + throw new EnterpriseServiceException(msg, e); + } finally { + AndroidDAOFactory.closeConnection(); + } + } + + @Override + public boolean updateMobileDevice(AndroidEnterpriseManagedConfig managedConfig) throws EnterpriseServiceException { + boolean status; + if (log.isDebugEnabled()) { + log.debug("Calling update managed config for mcm id : " + managedConfig.getMcmId()); + } + + // Block from fetching other tenants data. + managedConfig.setTenantID(CarbonContext.getThreadLocalCarbonContext().getTenantId()); + try { + AndroidDAOFactory.beginTransaction(); + status = this.enterpriseDAO.updateConfig(managedConfig); + AndroidDAOFactory.commitTransaction(); + } catch (EnterpriseManagementDAOException e) { + String msg = "Error occurred while updating managed configs for mcm id " + managedConfig.getMcmId(); + log.error(msg, e); + AndroidDAOFactory.rollbackTransaction(); + throw new EnterpriseServiceException(msg, e); + } finally { + AndroidDAOFactory.closeConnection(); + } + return status; + } + + @Override + public boolean deleteMobileDevice(String id) throws EnterpriseServiceException { + boolean status; + if (log.isDebugEnabled()) { + log.debug("Calling update managed config for mcm id : " + id); + } + + try { + AndroidDAOFactory.beginTransaction(); + status = this.enterpriseDAO.deleteConfig(id,CarbonContext.getThreadLocalCarbonContext().getTenantId()); + AndroidDAOFactory.commitTransaction(); + } catch (EnterpriseManagementDAOException e) { + String msg = "Error occurred while updating managed configs for mcm id " + id; + log.error(msg, e); + AndroidDAOFactory.rollbackTransaction(); + throw new EnterpriseServiceException(msg, e); + } finally { + AndroidDAOFactory.closeConnection(); + } + return status; + } +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidPolicyMonitoringManager.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidPolicyMonitoringManager.java deleted file mode 100644 index 11d2f5332..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidPolicyMonitoringManager.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.android.impl; - -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager; -import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; -import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData; -import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature; -import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; - -import java.util.ArrayList; -import java.util.List; - -public class AndroidPolicyMonitoringManager implements PolicyMonitoringManager { - - private static Log log = LogFactory.getLog(AndroidPolicyMonitoringManager.class); - - @Override - public NonComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, - Object compliancePayload) throws PolicyComplianceException { - if (log.isDebugEnabled()) { - log.debug("Checking policy compliance status of device '" + deviceIdentifier.getId() + "'"); - } - NonComplianceData complianceData = new NonComplianceData(); - if (compliancePayload == null || policy == null) { - return complianceData; - } - String compliancePayloadString = new Gson().toJson(compliancePayload); - // Parsing json string to get compliance features. - JsonElement jsonElement; - if (compliancePayloadString instanceof String) { - jsonElement = new JsonParser().parse(compliancePayloadString); - } else { - throw new PolicyComplianceException("Invalid policy compliance payload"); - } - - JsonArray jsonArray = jsonElement.getAsJsonArray(); - Gson gson = new Gson(); - ComplianceFeature complianceFeature; - List complianceFeatures = new ArrayList(jsonArray.size()); - List nonComplianceFeatures = new ArrayList<>(); - - for (JsonElement element : jsonArray) { - complianceFeature = gson.fromJson(element, ComplianceFeature.class); - complianceFeatures.add(complianceFeature); - } - - for (ComplianceFeature cf : complianceFeatures) { - if (!cf.isCompliant()) { - complianceData.setStatus(false); - nonComplianceFeatures.add(cf); - break; - } - } - - complianceData.setComplianceFeatures(nonComplianceFeatures); - return complianceData; - } - -} \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/EnterpriseServiceException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/EnterpriseServiceException.java new file mode 100644 index 000000000..d8b5e80df --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/EnterpriseServiceException.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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.android.impl; + +/** + * Custom exception class for enterprise specific data access related exceptions. + */ +public class EnterpriseServiceException extends Exception { + + private String message; + private static final long serialVersionUID = 2021891706072918865L; + + /** + * Constructs a new EnterpriseServiceException with the specified detail message and + * nested exception. + * + * @param message error message + * @param nestedException exception + */ + public EnterpriseServiceException(String message, Exception nestedException) { + super(message, nestedException); + setErrorMessage(message); + } + + /** + * Constructs a new EnterpriseServiceException with the specified detail message + * and cause. + * + * @param message the detail message. + * @param cause the cause of this exception. + */ + public EnterpriseServiceException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + /** + * Constructs a new EnterpriseServiceException with the specified detail message. + * + * @param message the detail message. + */ + public EnterpriseServiceException(String message) { + super(message); + setErrorMessage(message); + } + + /** + * Constructs a new EnterpriseServiceException with the specified and cause. + * + * @param cause the cause of this exception. + */ + public EnterpriseServiceException(Throwable cause) { + super(cause); + } + + public String getMessage() { + return message; + } + + public void setErrorMessage(String errorMessage) { + this.message = errorMessage; + } + +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceConfigurationManager.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceConfigurationManager.java index e57ff1359..ded87ad71 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceConfigurationManager.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceConfigurationManager.java @@ -19,7 +19,7 @@ package org.wso2.carbon.device.mgt.mobile.android.impl.config; import org.w3c.dom.Document; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.mobile.android.impl.util.MobileDeviceManagementUtil; import org.wso2.carbon.utils.CarbonUtils; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/AndroidDataSourceConfigurations.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/AndroidDataSourceConfigurations.java new file mode 100644 index 000000000..9409bab13 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/AndroidDataSourceConfigurations.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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.android.impl.config.datasource; + + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "iosDBConfigurations") +public class AndroidDataSourceConfigurations { + + private MobileDataSourceConfig iosDataSourceConfiguration; + @XmlElement(name = "DataSourceConfiguration") + public MobileDataSourceConfig getIosDataSourceConfiguration() { + return iosDataSourceConfiguration; + } + + public void setIosDataSourceConfiguration(MobileDataSourceConfig iosDataSourceConfiguration) { + this.iosDataSourceConfiguration = iosDataSourceConfiguration; + } +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AbstractMobileDeviceManagementDAOFactory.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AbstractMobileDeviceManagementDAOFactory.java index c96b603a8..634951826 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AbstractMobileDeviceManagementDAOFactory.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AbstractMobileDeviceManagementDAOFactory.java @@ -34,7 +34,7 @@ import java.util.Map; /** * Factory class used to create MobileDeviceManagement related DAO objects. */ -public abstract class AbstractMobileDeviceManagementDAOFactory implements MobileDeviceManagementDAOFactory { +public abstract class AbstractMobileDeviceManagementDAOFactory { private static final Log log = LogFactory.getLog(AbstractMobileDeviceManagementDAOFactory.class); private static Map dataSourceMap = new HashMap<>(); diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidDAOFactory.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidDAOFactory.java index e3949b16a..2ccd09374 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidDAOFactory.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidDAOFactory.java @@ -21,8 +21,7 @@ package org.wso2.carbon.device.mgt.mobile.android.impl.dao; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl.AndroidDeviceDAOImpl; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl.AndroidFeatureDAOImpl; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl.EnterpriseDAOImpl; import javax.sql.DataSource; import java.sql.Connection; @@ -38,38 +37,52 @@ public class AndroidDAOFactory extends AbstractMobileDeviceManagementDAOFactory this.dataSource = getDataSourceMap().get(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); } - @Override - public MobileDeviceDAO getMobileDeviceDAO() { - return new AndroidDeviceDAOImpl(); - } + public static EnterpriseDAO getEnterpriseDAO() { + if (dataSource == null) { + dataSource = getDataSourceMap().get(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); + } - public MobileFeatureDAO getMobileFeatureDAO() { - return new AndroidFeatureDAOImpl(); + return new EnterpriseDAOImpl(); } - public static void beginTransaction() throws MobileDeviceManagementDAOException { + public static void beginTransaction() throws EnterpriseManagementDAOException { try { Connection conn = dataSource.getConnection(); conn.setAutoCommit(false); currentConnection.set(conn); } catch (SQLException e) { - throw new MobileDeviceManagementDAOException("Error occurred while retrieving datasource connection", e); + throw new EnterpriseManagementDAOException("Error occurred while retrieving datasource connection", e); + } + } + + public static void openConnection() throws EnterpriseManagementDAOException { + Connection conn = currentConnection.get(); + if (conn != null) { + throw new EnterpriseManagementDAOException("A transaction is already active within the context of " + + "this particular thread. Therefore, calling 'beginTransaction/openConnection' while another " + + "transaction is already active is a sign of improper transaction handling"); + } + try { + conn = dataSource.getConnection(); + } catch (SQLException e) { + throw new EnterpriseManagementDAOException("Error occurred while opening connection", e); } + currentConnection.set(conn); } - public static Connection getConnection() throws MobileDeviceManagementDAOException { + public static Connection getConnection() throws EnterpriseManagementDAOException { if (currentConnection.get() == null) { try { currentConnection.set(dataSource.getConnection()); } catch (SQLException e) { - throw new MobileDeviceManagementDAOException("Error occurred while retrieving data source connection", + throw new EnterpriseManagementDAOException("Error occurred while retrieving data source connection", e); } } return currentConnection.get(); } - public static void commitTransaction() throws MobileDeviceManagementDAOException { + public static void commitTransaction() throws EnterpriseManagementDAOException { try { Connection conn = currentConnection.get(); if (conn != null) { @@ -81,11 +94,11 @@ public class AndroidDAOFactory extends AbstractMobileDeviceManagementDAOFactory } } } catch (SQLException e) { - throw new MobileDeviceManagementDAOException("Error occurred while committing the transaction", e); + throw new EnterpriseManagementDAOException("Error occurred while committing the transaction", e); } } - public static void closeConnection() throws MobileDeviceManagementDAOException { + public static void closeConnection() { Connection conn = currentConnection.get(); try { if (conn != null) { @@ -97,7 +110,7 @@ public class AndroidDAOFactory extends AbstractMobileDeviceManagementDAOFactory currentConnection.remove(); } - public static void rollbackTransaction() throws MobileDeviceManagementDAOException { + public static void rollbackTransaction() { try { Connection conn = currentConnection.get(); if (conn != null) { @@ -109,7 +122,7 @@ public class AndroidDAOFactory extends AbstractMobileDeviceManagementDAOFactory } } } catch (SQLException e) { - throw new MobileDeviceManagementDAOException("Error occurred while rollback the transaction", e); + log.warn("Error occurred while roll-backing the transaction", e); } } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidFeatureManagementDAOException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidFeatureManagementDAOException.java deleted file mode 100644 index 61db0cc04..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidFeatureManagementDAOException.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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.android.impl.dao; - -public class AndroidFeatureManagementDAOException extends MobileDeviceManagementDAOException { - - private String message; - private static final long serialVersionUID = 2021891706072918865L; - - /** - * Constructs a new MobileDeviceManagementDAOException with the specified detail message and - * nested exception. - * - * @param message error message - * @param nestedException exception - */ - public AndroidFeatureManagementDAOException(String message, Exception nestedException) { - super(message, nestedException); - setErrorMessage(message); - } - - /** - * Constructs a new MobileDeviceManagementDAOException with the specified detail message - * and cause. - * - * @param message the detail message. - * @param cause the cause of this exception. - */ - public AndroidFeatureManagementDAOException(String message, Throwable cause) { - super(message, cause); - setErrorMessage(message); - } - - /** - * Constructs a new MobileDeviceManagementDAOException with the specified detail message. - * - * @param message the detail message. - */ - public AndroidFeatureManagementDAOException(String message) { - super(message); - setErrorMessage(message); - } - - /** - * Constructs a new MobileDeviceManagementDAOException with the specified and cause. - * - * @param cause the cause of this exception. - */ - public AndroidFeatureManagementDAOException(Throwable cause) { - super(cause); - } - - public String getMessage() { - return message; - } - - public void setErrorMessage(String errorMessage) { - this.message = errorMessage; - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/EnterpriseDAO.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/EnterpriseDAO.java new file mode 100644 index 000000000..87aafb814 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/EnterpriseDAO.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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.android.impl.dao; + +import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseManagedConfig; +import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseUser; + +import java.util.List; + +/** + * This class represents the key operations associated with working with Enterprise data + */ +public interface EnterpriseDAO { + + /** + * Add a new user to Enterprise. + * + * @param androidEnterpriseUser Enterprise user and device details. + * @return User addition status. + * @throws EnterpriseManagementDAOException + */ + boolean addUser(AndroidEnterpriseUser androidEnterpriseUser) throws EnterpriseManagementDAOException; + + List getUser(String username, int tenantId) throws EnterpriseManagementDAOException; + + AndroidEnterpriseUser getUserByDevice(String deviceId, int tenantId) throws EnterpriseManagementDAOException; + + AndroidEnterpriseManagedConfig getConfigByPackageName(String packageName, int tenantId) + throws EnterpriseManagementDAOException; + + boolean addConfig(AndroidEnterpriseManagedConfig managedConfig) throws EnterpriseManagementDAOException; + + boolean updateConfig(AndroidEnterpriseManagedConfig managedConfig) throws EnterpriseManagementDAOException; + + boolean deleteConfig(String id, int tenantId) throws EnterpriseManagementDAOException; +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/EnterpriseManagementDAOException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/EnterpriseManagementDAOException.java new file mode 100644 index 000000000..86af32e80 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/EnterpriseManagementDAOException.java @@ -0,0 +1,97 @@ +/* + * 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. + */ +/* + * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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.android.impl.dao; + +/** + * Custom exception class for enterprise specific data access related exceptions. + */ +public class EnterpriseManagementDAOException extends Exception { + + private String message; + private static final long serialVersionUID = 2021891702072938865L; + + /** + * Constructs a new EnterpriseManagementDAOException with the specified detail message and + * nested exception. + * + * @param message error message + * @param nestedException exception + */ + public EnterpriseManagementDAOException(String message, Exception nestedException) { + super(message, nestedException); + setErrorMessage(message); + } + + /** + * Constructs a new EnterpriseManagementDAOException with the specified detail message + * and cause. + * + * @param message the detail message. + * @param cause the cause of this exception. + */ + public EnterpriseManagementDAOException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + /** + * Constructs a new EnterpriseManagementDAOException with the specified detail message. + * + * @param message the detail message. + */ + public EnterpriseManagementDAOException(String message) { + super(message); + setErrorMessage(message); + } + + /** + * Constructs a new EnterpriseManagementDAOException with the specified and cause. + * + * @param cause the cause of this exception. + */ + public EnterpriseManagementDAOException(Throwable cause) { + super(cause); + } + + public String getMessage() { + return message; + } + + public void setErrorMessage(String errorMessage) { + this.message = errorMessage; + } + +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceDAO.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceDAO.java deleted file mode 100644 index d9209a1cb..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceDAO.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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.android.impl.dao; - -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileDevice; -import java.util.List; - -/** - * This class represents the key operations associated with persisting mobile-device related - * information. - */ -public interface MobileDeviceDAO { - - /** - * Fetches a MobileDevice from MDM database. - * - * @param mblDeviceId Id of the Mobile-Device. - * @return MobileDevice corresponding to given device-id. - * @throws MobileDeviceManagementDAOException - */ - MobileDevice getMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException; - - /** - * Adds a new MobileDevice to the MDM database. - * - * @param mobileDevice MobileDevice to be added. - * @return The status of the operation. - * @throws MobileDeviceManagementDAOException - */ - boolean addMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException; - - /** - * Updates MobileDevice information in MDM database. - * - * @param mobileDevice MobileDevice to be updated. - * @return The status of the operation. - * @throws MobileDeviceManagementDAOException - */ - boolean updateMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException; - - /** - * Deletes a given MobileDevice from MDM database. - * - * @param mblDeviceId Id of MobileDevice to be deleted. - * @return The status of the operation. - * @throws MobileDeviceManagementDAOException - */ - boolean deleteMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException; - - /** - * Fetches all MobileDevices from MDM database. - * - * @return List of MobileDevices. - * @throws MobileDeviceManagementDAOException - */ - List getAllMobileDevices() throws MobileDeviceManagementDAOException; - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceManagementDAOFactory.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceManagementDAOFactory.java index 1b28ac285..d4746f623 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceManagementDAOFactory.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceManagementDAOFactory.java @@ -20,8 +20,5 @@ package org.wso2.carbon.device.mgt.mobile.android.impl.dao; public interface MobileDeviceManagementDAOFactory { - MobileDeviceDAO getMobileDeviceDAO(); - - MobileFeatureDAO getMobileFeatureDAO(); } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileFeatureDAO.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileFeatureDAO.java deleted file mode 100644 index aba4c13b3..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileFeatureDAO.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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. - */ - -/* - * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. 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.android.impl.dao; - -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileFeature; - -import java.util.List; - -/** - * This class represents the key operations associated with persisting mobile feature related - * information. - */ -public interface MobileFeatureDAO { - - /** - * Adds a new MobileFeature to Mobile-Feature table. - * - * @param mobileFeature MobileFeature object that holds data related to the feature to be inserted. - * @return boolean status of the operation. - * @throws MobileDeviceManagementDAOException - */ - boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException; - - /** - * Adda a list of MobileFeatures to Mobile-Feature table. - * - * @param mobileFeatures List of MobileFeature objects. - * @return boolean status of the operation. - * @throws MobileDeviceManagementDAOException - */ - boolean addFeatures(List mobileFeatures) throws MobileDeviceManagementDAOException; - - /** - * Updates a MobileFeature in Mobile-Feature table. - * - * @param mobileFeature MobileFeature object that holds data has to be updated. - * @return The status of the operation. - * @throws MobileDeviceManagementDAOException - */ - boolean updateFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException; - - /** - * Deletes a MobileFeature from Mobile-Feature table when the feature id is given. - * - * @param mblFeatureId MobileFeature id of the MobileFeature to be deleted. - * @return The status of the operation. - * @throws MobileDeviceManagementDAOException - */ - boolean deleteFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException; - - /** - * Deletes a MobileFeature from Mobile-Feature table when the feature code is given. - * - * @param mblFeatureCode MobileFeature code of the feature to be deleted. - * @return The status of the operation. - * @throws MobileDeviceManagementDAOException - */ - boolean deleteFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException; - - /** - * Retrieves a given MobileFeature from Mobile-Feature table when the feature id is given. - * - * @param mblFeatureId Feature id of the feature to be retrieved. - * @return MobileFeature object that holds data of the feature represented by featureId. - * @throws MobileDeviceManagementDAOException - */ - MobileFeature getFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException; - - /** - * Retrieves a given MobileFeature from Mobile-Feature table when the feature code is given. - * - * @param mblFeatureCode Feature code of the feature to be retrieved. - * @return MobileFeature object that holds data of the feature represented by featureCode. - * @throws MobileDeviceManagementDAOException - */ - MobileFeature getFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException; - - /** - * Retrieves all MobileFeatures of a MobileDevice type from Mobile-Feature table. - * - * @param deviceType MobileDevice type of the MobileFeatures to be retrieved - * @return MobileFeature object list. - * @throws MobileDeviceManagementDAOException - */ - List getFeatureByDeviceType(String deviceType) throws MobileDeviceManagementDAOException; - - /** - * Retrieve all the MobileFeatures from Mobile-Feature table. - * - * @return MobileFeature object list. - * @throws MobileDeviceManagementDAOException - */ - List getAllFeatures() throws MobileDeviceManagementDAOException; - - /** - * Get all the MobileFeatures by a given ui visibility - * - * @param isHidden Whether the operation is hidden from UI or not. - * @return {@link MobileFeature} object list. - * @throws MobileDeviceManagementDAOException If an error occurred while retrieving the Feature list - */ - List getAllFeatures(boolean isHidden) throws MobileDeviceManagementDAOException; - - /** - * Retrieve all MobileFeatures of a given feature type - * - * @param featureType Feature type. - * @return {@link MobileFeature} object list. - * @throws MobileDeviceManagementDAOException If an error occurred while retrieving the Feature list - */ - List getFeaturesByFeatureType(String featureType) throws MobileDeviceManagementDAOException; - - /** - * Retrieve all MobileFeatures of a given feature type and ui visibility - * - * @param featureType Feature type. - * @param isHidden Whether the operation is hidden from UI or not. - * @return {@link MobileFeature} object list. - * @throws MobileDeviceManagementDAOException If an error occurred while retrieving the Feature list - */ - List getFeaturesByFeatureType(String featureType, boolean isHidden) throws MobileDeviceManagementDAOException; -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceDAOImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceDAOImpl.java deleted file mode 100644 index 416a4d90d..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceDAOImpl.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * 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.android.impl.dao.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AndroidDAOFactory; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceDAO; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.util.MobileDeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileDevice; -import org.wso2.carbon.device.mgt.mobile.android.impl.util.AndroidPluginConstants; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Implements MobileDeviceDAO for Android Devices. - */ -public class AndroidDeviceDAOImpl implements MobileDeviceDAO{ - - private static final Log log = LogFactory.getLog(AndroidDeviceDAOImpl.class); - - @Override - public MobileDevice getMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - MobileDevice mobileDevice = null; - ResultSet rs = null; - try { - conn = AndroidDAOFactory.getConnection(); - String selectDBQuery = - "SELECT DEVICE_ID, FCM_TOKEN, DEVICE_INFO, DEVICE_MODEL, SERIAL, " + - "VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, OS_VERSION, OS_BUILD_DATE" + - " FROM AD_DEVICE WHERE DEVICE_ID = ?"; - stmt = conn.prepareStatement(selectDBQuery); - stmt.setString(1, mblDeviceId); - rs = stmt.executeQuery(); - - if (rs.next()) { - mobileDevice = new MobileDevice(); - mobileDevice.setMobileDeviceId(rs.getString(AndroidPluginConstants.DEVICE_ID)); - mobileDevice.setModel(rs.getString(AndroidPluginConstants.DEVICE_MODEL)); - mobileDevice.setSerial(rs.getString(AndroidPluginConstants.SERIAL)); - mobileDevice.setVendor(rs.getString(AndroidPluginConstants.VENDOR)); - mobileDevice.setLatitude(rs.getString(AndroidPluginConstants.LATITUDE)); - mobileDevice.setLongitude(rs.getString(AndroidPluginConstants.LONGITUDE)); - mobileDevice.setImei(rs.getString(AndroidPluginConstants.IMEI)); - mobileDevice.setImsi(rs.getString(AndroidPluginConstants.IMSI)); - mobileDevice.setOsVersion(rs.getString(AndroidPluginConstants.OS_VERSION)); - mobileDevice.setOsBuildDate(rs.getString(AndroidPluginConstants.OS_BUILD_DATE)); - - Map propertyMap = new HashMap(); - propertyMap.put(AndroidPluginConstants.FCM_TOKEN, rs.getString(AndroidPluginConstants.FCM_TOKEN)); - propertyMap.put(AndroidPluginConstants.DEVICE_INFO, rs.getString(AndroidPluginConstants.DEVICE_INFO)); - propertyMap.put(AndroidPluginConstants.DEVICE_NAME, rs.getString(AndroidPluginConstants.DEVICE_NAME)); - mobileDevice.setDeviceProperties(propertyMap); - - if (log.isDebugEnabled()) { - log.debug("Android device " + mblDeviceId + " data has been fetched from " + - "Android database."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while fetching Android device : '" + mblDeviceId + "'"; - log.error(msg, e); - throw new MobileDeviceManagementDAOException(msg, e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); - AndroidDAOFactory.closeConnection(); - } - - return mobileDevice; - } - - @Override - public boolean addMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException { - boolean status = false; - Connection conn; - PreparedStatement stmt = null; - try { - conn = AndroidDAOFactory.getConnection(); - String createDBQuery = - "INSERT INTO AD_DEVICE(DEVICE_ID, FCM_TOKEN, DEVICE_INFO, SERIAL, " + - "VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, " + - "OS_VERSION, DEVICE_MODEL, OS_BUILD_DATE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; - - stmt = conn.prepareStatement(createDBQuery); - stmt.setString(1, mobileDevice.getMobileDeviceId()); - - Map properties = mobileDevice.getDeviceProperties(); - stmt.setString(2, properties.get(AndroidPluginConstants.FCM_TOKEN)); - stmt.setString(3, properties.get(AndroidPluginConstants.DEVICE_INFO)); - stmt.setString(4, mobileDevice.getSerial()); - stmt.setString(5, mobileDevice.getVendor()); - stmt.setString(6, mobileDevice.getMobileDeviceId()); - stmt.setString(7, properties.get(AndroidPluginConstants.DEVICE_NAME)); - stmt.setString(8, mobileDevice.getLatitude()); - stmt.setString(9, mobileDevice.getLongitude()); - stmt.setString(10, mobileDevice.getImei()); - stmt.setString(11, mobileDevice.getImsi()); - stmt.setString(12, mobileDevice.getOsVersion()); - stmt.setString(13, mobileDevice.getModel()); - stmt.setString(14, mobileDevice.getOsBuildDate()); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Android device " + mobileDevice.getMobileDeviceId() + " data has been" + - " added to the Android database."); - } - } - } catch (SQLException e) { - throw new MobileDeviceManagementDAOException("Error occurred while adding the Android device '" + - mobileDevice.getMobileDeviceId() + "' information to the Android plugin data store.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public boolean updateMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException { - boolean status = false; - Connection conn; - PreparedStatement stmt = null; - try { - conn = AndroidDAOFactory.getConnection(); - String updateDBQuery = - "UPDATE AD_DEVICE SET FCM_TOKEN = ?, DEVICE_INFO = ?, SERIAL = ?, VENDOR = ?, " + - "MAC_ADDRESS = ?, DEVICE_NAME = ?, LATITUDE = ?, LONGITUDE = ?, IMEI = ?, " + - "IMSI = ?, OS_VERSION = ?, DEVICE_MODEL = ?, OS_BUILD_DATE = ? WHERE DEVICE_ID = ?"; - stmt = conn.prepareStatement(updateDBQuery); - - Map properties = mobileDevice.getDeviceProperties(); - stmt.setString(1, properties.get(AndroidPluginConstants.FCM_TOKEN)); - stmt.setString(2, properties.get(AndroidPluginConstants.DEVICE_INFO)); - stmt.setString(3, mobileDevice.getSerial()); - stmt.setString(4, mobileDevice.getVendor()); - stmt.setString(5, properties.get(AndroidPluginConstants.MAC_ADDRESS)); - stmt.setString(6, properties.get(AndroidPluginConstants.DEVICE_NAME)); - stmt.setString(7, mobileDevice.getLatitude()); - stmt.setString(8, mobileDevice.getLongitude()); - stmt.setString(9, mobileDevice.getImei()); - stmt.setString(10, mobileDevice.getImsi()); - stmt.setString(11, mobileDevice.getOsVersion()); - stmt.setString(12, mobileDevice.getModel()); - stmt.setString(13, mobileDevice.getOsBuildDate()); - stmt.setString(14, mobileDevice.getMobileDeviceId()); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Android device " + mobileDevice.getMobileDeviceId() + " data has been" + - " modified."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while modifying the Android device '" + - mobileDevice.getMobileDeviceId() + "' data."; - log.error(msg, e); - throw new MobileDeviceManagementDAOException(msg, e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public boolean deleteMobileDevice(String mblDeviceId) - throws MobileDeviceManagementDAOException { - boolean status = false; - Connection conn; - PreparedStatement stmt = null; - try { - conn = AndroidDAOFactory.getConnection(); - String deleteDBQuery = - "DELETE FROM AD_DEVICE WHERE DEVICE_ID = ?"; - stmt = conn.prepareStatement(deleteDBQuery); - stmt.setString(1, mblDeviceId); - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Android device " + mblDeviceId + " data has deleted" + - " from the Android database."); - } - } - } catch (SQLException e) { - throw new MobileDeviceManagementDAOException("Error occurred while deleting android device '" + - mblDeviceId + "'", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public List getAllMobileDevices() throws MobileDeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - MobileDevice mobileDevice; - List mobileDevices = new ArrayList(); - try { - conn = AndroidDAOFactory.getConnection(); - String selectDBQuery = - "SELECT DEVICE_ID, FCM_TOKEN, DEVICE_INFO, DEVICE_MODEL, SERIAL, " + - "VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, OS_VERSION, OS_BUILD_DATE " + - "FROM AD_DEVICE"; - stmt = conn.prepareStatement(selectDBQuery); - rs = stmt.executeQuery(); - - while (rs.next()) { - mobileDevice = new MobileDevice(); - mobileDevice.setMobileDeviceId(rs.getString(AndroidPluginConstants.DEVICE_ID)); - mobileDevice.setModel(rs.getString(AndroidPluginConstants.DEVICE_MODEL)); - mobileDevice.setSerial(rs.getString(AndroidPluginConstants.SERIAL)); - mobileDevice.setVendor(rs.getString(AndroidPluginConstants.VENDOR)); - mobileDevice.setLatitude(rs.getString(AndroidPluginConstants.LATITUDE)); - mobileDevice.setLongitude(rs.getString(AndroidPluginConstants.LONGITUDE)); - mobileDevice.setImei(rs.getString(AndroidPluginConstants.IMEI)); - mobileDevice.setImsi(rs.getString(AndroidPluginConstants.IMSI)); - mobileDevice.setOsVersion(rs.getString(AndroidPluginConstants.OS_VERSION)); - mobileDevice.setOsBuildDate(rs.getString(AndroidPluginConstants.OS_BUILD_DATE)); - - Map propertyMap = new HashMap<>(); - propertyMap.put(AndroidPluginConstants.FCM_TOKEN, rs.getString(AndroidPluginConstants.FCM_TOKEN)); - propertyMap.put(AndroidPluginConstants.DEVICE_INFO, rs.getString(AndroidPluginConstants.DEVICE_INFO)); - propertyMap.put(AndroidPluginConstants.DEVICE_NAME, rs.getString(AndroidPluginConstants.DEVICE_NAME)); - mobileDevice.setDeviceProperties(propertyMap); - - mobileDevices.add(mobileDevice); - } - if (log.isDebugEnabled()) { - log.debug("All Android device details have fetched from Android database."); - } - return mobileDevices; - } catch (SQLException e) { - throw new MobileDeviceManagementDAOException("Error occurred while fetching all Android device data", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); - AndroidDAOFactory.closeConnection(); - } - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidFeatureDAOImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidFeatureDAOImpl.java deleted file mode 100644 index 2d9fe21d0..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidFeatureDAOImpl.java +++ /dev/null @@ -1,397 +0,0 @@ -/* - * 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. - * - */ - -/* - * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. 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.android.impl.dao.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AndroidDAOFactory; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AndroidFeatureManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileFeatureDAO; -import org.wso2.carbon.device.mgt.mobile.android.impl.dao.util.MobileDeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileFeature; -import org.wso2.carbon.device.mgt.mobile.android.impl.util.AndroidPluginConstants; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -public class AndroidFeatureDAOImpl implements MobileFeatureDAO { - - private static final Log log = LogFactory.getLog(AndroidFeatureDAOImpl.class); - - public AndroidFeatureDAOImpl() { - - } - - @Override - public boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - boolean status = false; - Connection conn; - try { - conn = AndroidDAOFactory.getConnection(); - String sql = "INSERT INTO AD_FEATURE(CODE, NAME, TYPE, HIDDEN, DESCRIPTION) VALUES (?, ?, ?, ?, ?)"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, mobileFeature.getCode()); - stmt.setString(2, mobileFeature.getName()); - stmt.setString(3, mobileFeature.getType()); - stmt.setBoolean(4, mobileFeature.isHidden()); - stmt.setString(5, mobileFeature.getDescription()); - stmt.executeUpdate(); - status = true; - } catch (SQLException e) { - throw new AndroidFeatureManagementDAOException( - "Error occurred while adding android feature '" + - mobileFeature.getName() + "' into the metadata repository", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public boolean addFeatures(List mobileFeatures) throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - Connection conn; - try { - conn = AndroidDAOFactory.getConnection(); - stmt = conn.prepareStatement("INSERT INTO AD_FEATURE(CODE, NAME, TYPE, HIDDEN, DESCRIPTION) " + - "VALUES (?, ?, ?, ?, ?)"); - for (MobileFeature mobileFeature : mobileFeatures) { - stmt.setString(1, mobileFeature.getCode()); - stmt.setString(2, mobileFeature.getName()); - stmt.setString(3, mobileFeature.getType()); - stmt.setBoolean(4, mobileFeature.isHidden()); - stmt.setString(5, mobileFeature.getDescription()); - stmt.addBatch(); - } - stmt.executeBatch(); - return true; - } catch (SQLException e) { - throw new AndroidFeatureManagementDAOException( - "Error occurred while adding android features into the metadata repository", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - } - - @Override - public boolean updateFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException { - boolean status = false; - Connection conn; - PreparedStatement stmt = null; - try { - conn = AndroidDAOFactory.getConnection(); - String updateDBQuery = - "UPDATE AD_FEATURE SET NAME = ?, TYPE = ?, HIDDEN = ? ,DESCRIPTION = ?" + - "WHERE CODE = ?"; - - stmt = conn.prepareStatement(updateDBQuery); - stmt.setString(1, mobileFeature.getName()); - stmt.setString(2, mobileFeature.getType()); - stmt.setBoolean(3, mobileFeature.isHidden()); - stmt.setString(4, mobileFeature.getDescription()); - stmt.setString(5, mobileFeature.getCode()); - - int rows = stmt.executeUpdate(); - if (rows > 0) { - status = true; - if (log.isDebugEnabled()) { - log.debug("Android Feature " + mobileFeature.getCode() + " data has been " + - "modified."); - } - } - } catch (SQLException e) { - String msg = "Error occurred while updating the Android Feature '" + - mobileFeature.getCode() + "' to the Android db."; - log.error(msg, e); - throw new AndroidFeatureManagementDAOException(msg, e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public boolean deleteFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException { - - PreparedStatement stmt = null; - boolean status = false; - Connection conn; - try { - conn = AndroidDAOFactory.getConnection(); - String sql = "DELETE FROM AD_FEATURE WHERE ID = ?"; - stmt = conn.prepareStatement(sql); - stmt.setInt(1, mblFeatureId); - stmt.execute(); - status = true; - } catch (SQLException e) { - throw new AndroidFeatureManagementDAOException( - "Error occurred while deleting android feature '" + - mblFeatureId + "' from Android database.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public boolean deleteFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - boolean status; - Connection conn; - try { - conn = AndroidDAOFactory.getConnection(); - String sql = "DELETE FROM AD_FEATURE WHERE CODE = ?"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, mblFeatureCode); - stmt.execute(); - status = true; - } catch (SQLException e) { - throw new AndroidFeatureManagementDAOException( - "Error occurred while deleting android feature '" + - mblFeatureCode + "' from Android database.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return status; - } - - @Override - public MobileFeature getFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - ResultSet rs = null; - Connection conn; - try { - conn = AndroidDAOFactory.getConnection(); - String sql = "SELECT ID, CODE, NAME, TYPE, HIDDEN, DESCRIPTION FROM AD_FEATURE WHERE ID = ?"; - stmt = conn.prepareStatement(sql); - stmt.setInt(1, mblFeatureId); - rs = stmt.executeQuery(); - - MobileFeature mobileFeature = null; - if (rs.next()) { - mobileFeature = new MobileFeature(); - mobileFeature.setId(rs.getInt(AndroidPluginConstants.ANDROID_FEATURE_ID)); - mobileFeature.setCode(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_CODE)); - mobileFeature.setName(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_NAME)); - mobileFeature.setType(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_TYPE)); - mobileFeature.setHidden(rs.getBoolean(AndroidPluginConstants.ANDROID_FEATURE_HIDDEN)); - mobileFeature.setDescription(rs.getString(AndroidPluginConstants. - ANDROID_FEATURE_DESCRIPTION)); - mobileFeature.setDeviceType( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - } - return mobileFeature; - } catch (SQLException e) { - throw new AndroidFeatureManagementDAOException( - "Error occurred while retrieving android feature '" + - mblFeatureId + "' from the Android database.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); - AndroidDAOFactory.closeConnection(); - } - } - - @Override - public MobileFeature getFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - ResultSet rs = null; - Connection conn; - - try { - conn = AndroidDAOFactory.getConnection(); - String sql = "SELECT ID, CODE, NAME, TYPE, HIDDEN, DESCRIPTION FROM AD_FEATURE WHERE CODE = ?"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, mblFeatureCode); - rs = stmt.executeQuery(); - - MobileFeature mobileFeature = null; - if (rs.next()) { - mobileFeature = populateMobileFeature(rs); - } - return mobileFeature; - } catch (SQLException e) { - throw new AndroidFeatureManagementDAOException( - "Error occurred while retrieving android feature '" + - mblFeatureCode + "' from the Android database.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); - AndroidDAOFactory.closeConnection(); - } - } - - @Override - public List getFeatureByDeviceType(String deviceType) - throws MobileDeviceManagementDAOException { - return this.getAllFeatures(); - } - - @Override - public List getAllFeatures() throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - ResultSet rs = null; - Connection conn = null; - List features = new ArrayList<>(); - try { - conn = AndroidDAOFactory.getConnection(); - String sql = "SELECT ID, CODE, NAME, TYPE, HIDDEN, DESCRIPTION FROM AD_FEATURE"; - stmt = conn.prepareStatement(sql); - rs = stmt.executeQuery(); - - while (rs.next()) { - features.add(populateMobileFeature(rs)); - } - return features; - } catch (SQLException e) { - throw new AndroidFeatureManagementDAOException("Error occurred while retrieving all android features " + - "from the android database.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); - AndroidDAOFactory.closeConnection(); - } - } - - @Override - public List getAllFeatures(boolean isHidden) throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - ResultSet rs = null; - Connection conn = null; - List features = new ArrayList<>(); - try { - conn = AndroidDAOFactory.getConnection(); - String sql = "SELECT ID, CODE, NAME, TYPE, HIDDEN, DESCRIPTION FROM AD_FEATURE WHERE HIDDEN = ?"; - stmt = conn.prepareStatement(sql); - stmt.setBoolean(1, isHidden); - rs = stmt.executeQuery(); - - while (rs.next()) { - features.add(populateMobileFeature(rs)); - } - return features; - } catch (SQLException e) { - throw new AndroidFeatureManagementDAOException("Error occurred while retrieving all android features " + - "from the android database.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); - AndroidDAOFactory.closeConnection(); - } - } - - @Override - public List getFeaturesByFeatureType(String featureType) throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - ResultSet rs = null; - Connection conn; - List features = new ArrayList<>(); - try { - conn = AndroidDAOFactory.getConnection(); - String sql = "SELECT ID, CODE, NAME, TYPE, HIDDEN, DESCRIPTION FROM AD_FEATURE WHERE TYPE = ?"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, featureType); - rs = stmt.executeQuery(); - - while (rs.next()) { - features.add(populateMobileFeature(rs)); - } - return features; - } catch (SQLException e) { - throw new AndroidFeatureManagementDAOException("Error occurred while retrieving all android features of " + - "type " + featureType + " from the android database.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); - AndroidDAOFactory.closeConnection(); - } - } - - @Override - public List getFeaturesByFeatureType(String featureType, boolean isHidden) throws MobileDeviceManagementDAOException { - PreparedStatement stmt = null; - ResultSet rs = null; - Connection conn; - List features = new ArrayList<>(); - try { - conn = AndroidDAOFactory.getConnection(); - String sql = "SELECT ID, CODE, NAME, TYPE, HIDDEN, DESCRIPTION " + - "FROM AD_FEATURE " + - "WHERE TYPE = ? AND HIDDEN = ?"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, featureType); - stmt.setBoolean(2, isHidden); - rs = stmt.executeQuery(); - - while (rs.next()) { - features.add(populateMobileFeature(rs)); - } - return features; - } catch (SQLException e) { - throw new AndroidFeatureManagementDAOException("Error occurred while retrieving all android features of " + - "[type: " + featureType + " & hidden: " + isHidden + "] from the android database.", e); - } finally { - MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); - AndroidDAOFactory.closeConnection(); - } - } - - /** - * Generate {@link MobileFeature} from the SQL {@link ResultSet} - * - * @param rs Result set - * @return populated {@link MobileFeature} - * @throws SQLException if unable to extract data from {@link ResultSet} - */ - private MobileFeature populateMobileFeature(ResultSet rs) throws SQLException { - MobileFeature mobileFeature = new MobileFeature(); - mobileFeature.setId(rs.getInt(AndroidPluginConstants.ANDROID_FEATURE_ID)); - mobileFeature.setCode(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_CODE)); - mobileFeature.setName(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_NAME)); - mobileFeature.setDescription(rs.getString(AndroidPluginConstants. - ANDROID_FEATURE_DESCRIPTION)); - mobileFeature.setType(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_TYPE)); - mobileFeature.setHidden(rs.getBoolean(AndroidPluginConstants.ANDROID_FEATURE_HIDDEN)); - mobileFeature.setDeviceType( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); - - return mobileFeature; - } -} \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/EnterpriseDAOImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/EnterpriseDAOImpl.java new file mode 100644 index 000000000..8dbdb6e29 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/EnterpriseDAOImpl.java @@ -0,0 +1,294 @@ +/* + * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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.android.impl.dao.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AndroidDAOFactory; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.EnterpriseDAO; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.EnterpriseManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.util.MobileDeviceManagementDAOUtil; +import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseManagedConfig; +import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseUser; +import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileDevice; +import org.wso2.carbon.device.mgt.mobile.android.impl.util.AndroidPluginConstants; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Implements EnterpriseDAO for Android Devices. + */ +public class EnterpriseDAOImpl implements EnterpriseDAO { + + private static final Log log = LogFactory.getLog(EnterpriseDAOImpl.class); + + public List getUser(String username, int tenantId) throws EnterpriseManagementDAOException { + Connection conn; + PreparedStatement stmt = null; + List enterpriseUsers = new ArrayList<>(); + ResultSet rs = null; + try { + conn = AndroidDAOFactory.getConnection(); + String selectDBQuery = + "SELECT * FROM AD_ENTERPRISE_USER_DEVICE WHERE EMM_USERNAME = ? AND TENANT_ID = ?"; + stmt = conn.prepareStatement(selectDBQuery); + stmt.setString(1, username); + stmt.setInt(2, tenantId); + + rs = stmt.executeQuery(); + + while (rs.next()) { + AndroidEnterpriseUser enterpriseUser = new AndroidEnterpriseUser(); + enterpriseUser.setEmmUsername(rs.getString("EMM_USERNAME")); + enterpriseUser.setTenantId(rs.getInt("TENANT_ID")); + enterpriseUser.setLastUpdatedTime(rs.getString("LAST_UPDATED_TIMESTAMP")); + enterpriseUser.setAndroidPlayDeviceId(rs.getString("ANDROID_PLAY_DEVICE_ID")); + enterpriseUser.setEnterpriseId(rs.getString("ENTERPRISE_ID")); + enterpriseUser.setGoogleUserId(rs.getString("GOOGLE_USER_ID")); + enterpriseUser.setEmmDeviceId(rs.getString("EMM_DEVICE_ID")); + enterpriseUsers.add(enterpriseUser); + } + } catch (SQLException e) { + String msg = "Error occurred while fetching user : '" + username + "'"; + log.error(msg, e); + throw new EnterpriseManagementDAOException(msg, e); + } finally { + MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); + AndroidDAOFactory.closeConnection(); + } + + return enterpriseUsers; + } + + public AndroidEnterpriseUser getUserByDevice(String deviceId, int tenantId) throws + EnterpriseManagementDAOException { + Connection conn; + PreparedStatement stmt = null; + AndroidEnterpriseUser enterpriseUser = null; + ResultSet rs = null; + try { + conn = AndroidDAOFactory.getConnection(); + String selectDBQuery = + "SELECT * FROM AD_ENTERPRISE_USER_DEVICE WHERE EMM_DEVICE_ID = ? AND TENANT_ID = ? " + + "ORDER BY LAST_UPDATED_TIMESTAMP DESC"; + stmt = conn.prepareStatement(selectDBQuery); + stmt.setString(1, deviceId); + stmt.setInt(2, tenantId); + + rs = stmt.executeQuery(); + + if (rs.next()) { + enterpriseUser = new AndroidEnterpriseUser(); + enterpriseUser.setEmmUsername(rs.getString("EMM_USERNAME")); + enterpriseUser.setTenantId(rs.getInt("TENANT_ID")); + enterpriseUser.setLastUpdatedTime(rs.getString("LAST_UPDATED_TIMESTAMP")); + enterpriseUser.setAndroidPlayDeviceId(rs.getString("ANDROID_PLAY_DEVICE_ID")); + enterpriseUser.setEnterpriseId(rs.getString("ENTERPRISE_ID")); + enterpriseUser.setGoogleUserId(rs.getString("GOOGLE_USER_ID")); + enterpriseUser.setEmmDeviceId(rs.getString("EMM_DEVICE_ID")); + } + } catch (SQLException e) { + String msg = "Error occurred while fetching user for device : '" + deviceId + "'"; + log.error(msg, e); + throw new EnterpriseManagementDAOException(msg, e); + } finally { + MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); + AndroidDAOFactory.closeConnection(); + } + + return enterpriseUser; + } + + public boolean addUser(AndroidEnterpriseUser androidEnterpriseUser) throws EnterpriseManagementDAOException { + boolean status = false; + Connection conn; + PreparedStatement stmt = null; + try { + conn = AndroidDAOFactory.getConnection(); + String createDBQuery = + "INSERT INTO AD_ENTERPRISE_USER_DEVICE(EMM_USERNAME, TENANT_ID, LAST_UPDATED_TIMESTAMP" + + ", ANDROID_PLAY_DEVICE_ID, ENTERPRISE_ID, GOOGLE_USER_ID, EMM_DEVICE_ID)" + + " VALUES (?, ?, ?, ?, ?, ?, ?)"; + + stmt = conn.prepareStatement(createDBQuery); + stmt.setString(1, androidEnterpriseUser.getEmmUsername()); + stmt.setInt(2, androidEnterpriseUser.getTenantId()); + stmt.setTimestamp(3, new Timestamp(new Date().getTime())); + stmt.setString(4, androidEnterpriseUser.getAndroidPlayDeviceId()); + stmt.setString(5, androidEnterpriseUser.getEnterpriseId()); + stmt.setString(6, androidEnterpriseUser.getGoogleUserId()); + stmt.setString(7, androidEnterpriseUser.getEmmDeviceId()); + + int rows = stmt.executeUpdate(); + if (rows > 0) { + status = true; + if (log.isDebugEnabled()) { + log.debug("Added user " + androidEnterpriseUser.getEmmUsername()); + } + } + } catch (SQLException e) { + throw new EnterpriseManagementDAOException("Error occurred while adding the user " + + androidEnterpriseUser.getEmmUsername(), e); + } finally { + MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); + } + return status; + } + + public AndroidEnterpriseManagedConfig getConfigByPackageName(String packageName, int tenantId) + throws EnterpriseManagementDAOException { + Connection conn; + PreparedStatement stmt = null; + ResultSet rs = null; + AndroidEnterpriseManagedConfig managedConfig = null; + try { + conn = AndroidDAOFactory.getConnection(); + String selectDBQuery = + "SELECT * FROM AD_ENTERPRISE_MANAGED_CONFIGS WHERE PACKAGE_NAME = ? AND TENANT_ID = ?"; + stmt = conn.prepareStatement(selectDBQuery); + stmt.setString(1, packageName); + stmt.setInt(2, tenantId); + + rs = stmt.executeQuery(); + + if (rs.next()) { + managedConfig = new AndroidEnterpriseManagedConfig(); + managedConfig.setId(rs.getInt("ID")); + managedConfig.setMcmId(rs.getString("MCM_ID")); + managedConfig.setProfileName(rs.getString("PROFILE_NAME")); + managedConfig.setPackageName(rs.getString("PACKAGE_NAME")); + managedConfig.setTenantID(rs.getInt("TENANT_ID")); + managedConfig.setLastUpdatedTime(rs.getString("LAST_UPDATED_TIMESTAMP")); + } + } catch (SQLException e) { + String msg = "Error occurred while fetching config for package name : '" + packageName + "'"; + log.error(msg, e); + throw new EnterpriseManagementDAOException(msg, e); + } finally { + MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); + AndroidDAOFactory.closeConnection(); + } + return managedConfig; + } + + public boolean addConfig(AndroidEnterpriseManagedConfig managedConfig) throws EnterpriseManagementDAOException { + boolean status = false; + Connection conn; + PreparedStatement stmt = null; + try { + conn = AndroidDAOFactory.getConnection(); + String createDBQuery = + "INSERT INTO AD_ENTERPRISE_MANAGED_CONFIGS(MCM_ID, PROFILE_NAME, PACKAGE_NAME" + + ", TENANT_ID, LAST_UPDATED_TIMESTAMP) VALUES (?, ?, ?, ?, ?)"; + + stmt = conn.prepareStatement(createDBQuery); + stmt.setString(1, managedConfig.getMcmId()); + stmt.setString(2, managedConfig.getProfileName()); + stmt.setString(3, managedConfig.getPackageName()); + stmt.setInt(4, managedConfig.getTenantID()); + stmt.setTimestamp(5, new Timestamp(new Date().getTime())); + + int rows = stmt.executeUpdate(); + if (rows > 0) { + status = true; + if (log.isDebugEnabled()) { + log.debug("Added config for package " + managedConfig.getPackageName()); + } + } + } catch (SQLException e) { + throw new EnterpriseManagementDAOException("Error occurred while adding the config for package " + + managedConfig.getPackageName(), e); + } finally { + MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); + } + return status; + } + + public boolean updateConfig(AndroidEnterpriseManagedConfig managedConfig) throws EnterpriseManagementDAOException { + boolean status = false; + Connection conn; + PreparedStatement stmt = null; + try { + conn = AndroidDAOFactory.getConnection(); + String updateDBQuery = + "UPDATE AD_ENTERPRISE_MANAGED_CONFIGS SET PROFILE_NAME = ?, LAST_UPDATED_TIMESTAMP = ?" + + " WHERE MCM_ID = ? AND TENANT_ID = ?"; + stmt = conn.prepareStatement(updateDBQuery); + + stmt.setString(1, managedConfig.getProfileName()); + stmt.setString(2, managedConfig.getLastUpdatedTime()); + stmt.setString(3, managedConfig.getMcmId()); + stmt.setInt(4, managedConfig.getTenantID()); + int rows = stmt.executeUpdate(); + if (rows > 0) { + status = true; + if (log.isDebugEnabled()) { + log.debug("Managed config for mcm id " + managedConfig.getMcmId() + " data has been" + + " modified."); + } + } + } catch (SQLException e) { + String msg = "Error occurred while modifying the details for mcm id '" + + managedConfig.getMcmId() + "' data."; + log.error(msg, e); + throw new EnterpriseManagementDAOException(msg, e); + } finally { + MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); + } + return status; + } + + public boolean deleteConfig(String id, int tenantId) + throws EnterpriseManagementDAOException { + boolean status = false; + Connection conn; + PreparedStatement stmt = null; + try { + conn = AndroidDAOFactory.getConnection(); + String deleteDBQuery = + "DELETE FROM AD_ENTERPRISE_MANAGED_CONFIGS WHERE MCM_ID = ? AND TENANT_ID = ?"; + stmt = conn.prepareStatement(deleteDBQuery); + stmt.setString(1, id); + stmt.setInt(2, tenantId); + int rows = stmt.executeUpdate(); + if (rows > 0) { + status = true; + if (log.isDebugEnabled()) { + log.debug("Error when deleting MCM ID " + id); + } + } + } catch (SQLException e) { + throw new EnterpriseManagementDAOException("Error occurred while deleting MCM ID '" + id + "'", e); + } finally { + MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); + } + return status; + } + +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/util/MobileDeviceManagementDAOUtil.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/util/MobileDeviceManagementDAOUtil.java index 0251c13aa..1892ddecb 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/util/MobileDeviceManagementDAOUtil.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/util/MobileDeviceManagementDAOUtil.java @@ -28,7 +28,6 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Hashtable; -import java.util.List; /** * Utility method required by MobileDeviceManagement DAO classes. diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/AndroidEnterpriseManagedConfig.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/AndroidEnterpriseManagedConfig.java new file mode 100644 index 000000000..687327d6d --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/AndroidEnterpriseManagedConfig.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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.android.impl.dto; + +public class AndroidEnterpriseManagedConfig { + + String mcmId; + String profileName; + String packageName; + int tenantID; + String lastUpdatedTime; + int id; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getMcmId() { + return mcmId; + } + + public void setMcmId(String mcmId) { + this.mcmId = mcmId; + } + + public String getProfileName() { + return profileName; + } + + public void setProfileName(String profileName) { + this.profileName = profileName; + } + + public String getPackageName() { + return packageName; + } + + public void setPackageName(String packageName) { + this.packageName = packageName; + } + + public int getTenantID() { + return tenantID; + } + + public void setTenantID(int tenantID) { + this.tenantID = tenantID; + } + + public String getLastUpdatedTime() { + return lastUpdatedTime; + } + + public void setLastUpdatedTime(String lastUpdatedTime) { + this.lastUpdatedTime = lastUpdatedTime; + } + +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/AndroidEnterpriseUser.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/AndroidEnterpriseUser.java new file mode 100644 index 000000000..48bddbb03 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/AndroidEnterpriseUser.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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.android.impl.dto; + +public class AndroidEnterpriseUser { + String emmUsername; + int tenantId; + String enterpriseId;//from configs + String googleUserId;// generated internally + String androidPlayDeviceId; //sent by device + String emmDeviceId; //set internally + String lastUpdatedTime; //set internally + + public String getLastUpdatedTime() { + return lastUpdatedTime; + } + + public void setLastUpdatedTime(String lastUpdatedTime) { + this.lastUpdatedTime = lastUpdatedTime; + } + + public String getEmmUsername() { + return emmUsername; + } + + public void setEmmUsername(String emmUsername) { + this.emmUsername = emmUsername; + } + + public int getTenantId() { + return tenantId; + } + + public void setTenantId(int tenantId) { + this.tenantId = tenantId; + } + + public String getEnterpriseId() { + return enterpriseId; + } + + public void setEnterpriseId(String enterpriseId) { + this.enterpriseId = enterpriseId; + } + + public String getGoogleUserId() { + return googleUserId; + } + + public void setGoogleUserId(String googleUserId) { + this.googleUserId = googleUserId; + } + + public String getAndroidPlayDeviceId() { + return androidPlayDeviceId; + } + + public void setAndroidPlayDeviceId(String androidPlayDeviceId) { + this.androidPlayDeviceId = androidPlayDeviceId; + } + + public String getEmmDeviceId() { + return emmDeviceId; + } + + public void setEmmDeviceId(String emmDeviceId) { + this.emmDeviceId = emmDeviceId; + } +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileDevice.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileDevice.java index daadfa824..2b064452a 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileDevice.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileDevice.java @@ -34,6 +34,10 @@ public class MobileDevice implements Serializable { private String vendor; private String latitude; private String longitude; + private String altitude; + private String speed; + private String bearing; + private String distance; private String imei; private String imsi; private String serial; @@ -93,6 +97,38 @@ public class MobileDevice implements Serializable { this.longitude = longitude; } + public String getSpeed() { + return speed; + } + + public void setSpeed(String speed) { + this.speed = speed; + } + + public String getBearing() { + return bearing; + } + + public String getDistance() { + return distance; + } + + public void setDistance(String distance) { + this.distance = distance; + } + + public void setBearing(String bearing) { + this.bearing = bearing; + } + + public String getAltitude() { + return altitude; + } + + public void setAltitude(String altitude) { + this.altitude = altitude; + } + public String getImei() { return imei; } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileFeatureProperty.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileFeatureProperty.java deleted file mode 100644 index fb226d107..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileFeatureProperty.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.android.impl.dto; - -/** - * DTO of Mobile feature property. Represents a property of a mobile feature. - */ -public class MobileFeatureProperty { - - private String property; - private Integer featureID; - - public Integer getFeatureID() { - return featureID; - } - - public void setFeatureID(Integer featureID) { - this.featureID = featureID; - } - - public String getProperty() { - return property; - } - - public void setProperty(String property) { - this.property = property; - } - -} \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidPluginUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidPluginUtils.java deleted file mode 100644 index 40ea3c18b..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidPluginUtils.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.android.impl.util; - -import org.wso2.carbon.device.mgt.common.license.mgt.License; -import org.wso2.carbon.device.mgt.mobile.android.impl.AndroidDeviceManagementService; - -/** - * Contains utility methods used by Android plugin. - */ -public class AndroidPluginUtils { - - public static License getDefaultLicense() { - License license = new License(); - license.setName(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID); - license.setLanguage("en_US"); - license.setVersion("1.0.0"); - license.setText("This End User License Agreement (\"Agreement\") is a legal agreement between you (\"You\") " + - "and WSO2, Inc., regarding the enrollment of Your personal mobile device (\"Device\") in SoR's " + - "mobile device management program, and the loading to and removal from Your Device and Your use " + - "of certain applications and any associated software and user documentation, whether provided in " + - "\"online\" or electronic format, used in connection with the operation of or provision of services " + - "to WSO2, Inc., BY SELECTING \"I ACCEPT\" DURING INSTALLATION, YOU ARE ENROLLING YOUR DEVICE, AND " + - "THEREBY AUTHORIZING SOR OR ITS AGENTS TO INSTALL, UPDATE AND REMOVE THE APPS FROM YOUR DEVICE AS " + - "DESCRIBED IN THIS AGREEMENT. YOU ARE ALSO EXPLICITLY ACKNOWLEDGING AND AGREEING THAT (1) THIS IS " + - "A BINDING CONTRACT AND (2) YOU HAVE READ AND AGREE TO THE TERMS OF THIS AGREEMENT.\n" + - "\n" + - "IF YOU DO NOT ACCEPT THESE TERMS, DO NOT ENROLL YOUR DEVICE AND DO NOT PROCEED ANY FURTHER.\n" + - "\n" + - "You agree that: (1) You understand and agree to be bound by the terms and conditions contained " + - "in this Agreement, and (2) You are at least 21 years old and have the legal capacity to enter " + - "into this Agreement as defined by the laws of Your jurisdiction. SoR shall have the right, " + - "without prior notice, to terminate or suspend (i) this Agreement, (ii) the enrollment of Your " + - "Device, or (iii) the functioning of the Apps in the event of a violation of this Agreement or " + - "the cessation of Your relationship with SoR (including termination of Your employment if You are " + - "an employee or expiration or termination of Your applicable franchise or supply agreement if You " + - "are a franchisee of or supplier to the WSO2 WSO2, Inc., system). SoR expressly reserves all " + - "rights not expressly granted herein."); - return license; - } - -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidUtils.java deleted file mode 100644 index 583a6cef0..000000000 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidUtils.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.android.impl.util; - -import java.util.Map; - -/** - * Contains utility methods used by Android plugin. - */ -public class AndroidUtils { - - public static String getDeviceProperty(Map deviceProperties, String property) { - return deviceProperties.get(property); - } -} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/MobileDeviceManagementUtil.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/MobileDeviceManagementUtil.java index 376bc0dff..1ea1543a4 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/MobileDeviceManagementUtil.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/MobileDeviceManagementUtil.java @@ -42,9 +42,12 @@ import org.w3c.dom.Document; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.Feature; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; +import org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource.AndroidDataSourceConfigurations; +import org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource.MobileDataSourceConfig; +import org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource.MobileDataSourceConfigurations; import org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl.AndroidDeviceMgtPluginException; import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileDevice; import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileDeviceOperationMapping; @@ -55,8 +58,11 @@ import org.wso2.carbon.device.mgt.mobile.android.internal.AndroidDeviceManagemen import org.wso2.carbon.registry.api.RegistryException; import org.wso2.carbon.registry.api.Resource; import org.wso2.carbon.registry.core.Registry; +import org.wso2.carbon.utils.CarbonUtils; import javax.xml.XMLConstants; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Unmarshaller; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import java.io.File; @@ -81,6 +87,10 @@ public class MobileDeviceManagementUtil { private static final String MOBILE_DEVICE_MODEL = "DEVICE_MODEL"; private static final String MOBILE_DEVICE_LATITUDE = "LATITUDE"; private static final String MOBILE_DEVICE_LONGITUDE = "LONGITUDE"; + private static final String MOBILE_DEVICE_ALTITUDE = "ALTITUDE"; + private static final String MOBILE_DEVICE_DISTANCE = "DISTANCE"; + private static final String MOBILE_DEVICE_SPEED = "SPEED"; + private static final String MOBILE_DEVICE_BEARING = "BEARING"; private static final String MOBILE_DEVICE_SERIAL = "SERIAL"; private static final String MOBILE_DEVICE_OS_BUILD_DATE = "OS_BUILD_DATE"; @@ -132,6 +142,10 @@ public class MobileDeviceManagementUtil { mobileDevice.setVendor(getPropertyValue(device, MOBILE_DEVICE_VENDOR)); mobileDevice.setLatitude(getPropertyValue(device, MOBILE_DEVICE_LATITUDE)); mobileDevice.setLongitude(getPropertyValue(device, MOBILE_DEVICE_LONGITUDE)); + mobileDevice.setAltitude(getPropertyValue(device, MOBILE_DEVICE_ALTITUDE)); + mobileDevice.setDistance(getPropertyValue(device, MOBILE_DEVICE_DISTANCE)); + mobileDevice.setSpeed(getPropertyValue(device, MOBILE_DEVICE_SPEED)); + mobileDevice.setBearing(getPropertyValue(device, MOBILE_DEVICE_BEARING)); mobileDevice.setSerial(getPropertyValue(device, MOBILE_DEVICE_SERIAL)); mobileDevice.setOsBuildDate(getPropertyValue(device, MOBILE_DEVICE_OS_BUILD_DATE)); @@ -160,12 +174,19 @@ public class MobileDeviceManagementUtil { propertyList.add(getProperty(MOBILE_DEVICE_OS_VERSION, mobileDevice.getOsVersion())); propertyList.add(getProperty(MOBILE_DEVICE_OS_BUILD_DATE, mobileDevice.getOsBuildDate())); propertyList.add(getProperty(MOBILE_DEVICE_VENDOR, mobileDevice.getVendor())); + propertyList.add(getProperty(MOBILE_DEVICE_BEARING, mobileDevice.getBearing())); + propertyList.add(getProperty(MOBILE_DEVICE_SPEED, mobileDevice.getSpeed())); + propertyList.add(getProperty(MOBILE_DEVICE_DISTANCE, mobileDevice.getDistance())); + if(mobileDevice.getLatitude() != null) { propertyList.add(getProperty(MOBILE_DEVICE_LATITUDE, mobileDevice.getLatitude())); } if(mobileDevice.getLongitude() != null) { propertyList.add(getProperty(MOBILE_DEVICE_LONGITUDE, mobileDevice.getLongitude())); } + if(mobileDevice.getAltitude() != null) { + propertyList.add(getProperty(MOBILE_DEVICE_ALTITUDE, mobileDevice.getAltitude())); + } propertyList.add(getProperty(MOBILE_DEVICE_SERIAL, mobileDevice.getSerial())); if (mobileDevice.getDeviceProperties() != null) { @@ -358,4 +379,37 @@ public class MobileDeviceManagementUtil { } return missingFeatures; } + + public static final String IOS_DB_CONFIG_PATH = CarbonUtils.getCarbonConfigDirPath() + File.separator + + "/android-dbconfig.xml"; + + public static AndroidDataSourceConfigurations iosDataSourceConfigurations; + public static AndroidDataSourceConfigurations getIosDataSourceConfigurations() { + return iosDataSourceConfigurations; + } + + public static synchronized void initConfig() throws DeviceManagementException { + try { + File mobileDeviceMgtConfig = new File(IOS_DB_CONFIG_PATH); + Document doc = convertToDocuments(mobileDeviceMgtConfig); + JAXBContext iosDeviceMgtContext = JAXBContext.newInstance(AndroidDataSourceConfigurations.class); + Unmarshaller unmarshaller = iosDeviceMgtContext.createUnmarshaller(); + iosDataSourceConfigurations = (AndroidDataSourceConfigurations) unmarshaller.unmarshal(doc); + } catch (Exception e) { + throw new DeviceManagementException( + "Error occurred while initializing Mobile Device Management config", e); + } + } + + public static Document convertToDocuments(File file) throws DeviceManagementException { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); + try { + DocumentBuilder docBuilder = factory.newDocumentBuilder(); + return docBuilder.parse(file); + } catch (Exception e) { + throw new DeviceManagementException("Error occurred while parsing file, while converting " + + "to a org.w3c.dom.Document : " + e.getMessage(), e); + } + } } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementDataHolder.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementDataHolder.java index 94efdfbf7..09d111fca 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementDataHolder.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementDataHolder.java @@ -19,6 +19,7 @@ package org.wso2.carbon.device.mgt.mobile.android.internal; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; +import org.wso2.carbon.device.mgt.mobile.android.AndroidPluginService; import org.wso2.carbon.registry.core.service.RegistryService; /** @@ -27,7 +28,7 @@ import org.wso2.carbon.registry.core.service.RegistryService; public class AndroidDeviceManagementDataHolder { private RegistryService registryService; - private DeviceManagementService androidDeviceManagementService; + private AndroidPluginService androidDeviceManagementService; private static AndroidDeviceManagementDataHolder thisInstance = new AndroidDeviceManagementDataHolder(); @@ -46,12 +47,12 @@ public class AndroidDeviceManagementDataHolder { this.registryService = registryService; } - public DeviceManagementService getAndroidDeviceManagementService() { + public AndroidPluginService getAndroidDeviceManagementService() { return androidDeviceManagementService; } public void setAndroidDeviceManagementService( - DeviceManagementService androidDeviceManagementService) { + AndroidPluginService androidDeviceManagementService) { this.androidDeviceManagementService = androidDeviceManagementService; } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementServiceComponent.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidPluginServiceComponent.java similarity index 77% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementServiceComponent.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidPluginServiceComponent.java index 84fbb3c17..08f0c1c95 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementServiceComponent.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidPluginServiceComponent.java @@ -20,14 +20,17 @@ package org.wso2.carbon.device.mgt.mobile.android.internal; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; -import org.wso2.carbon.device.mgt.mobile.android.impl.AndroidDeviceManagementService; +import org.wso2.carbon.device.mgt.mobile.android.AndroidPluginService; +import org.wso2.carbon.device.mgt.mobile.android.impl.AndroidPluginServiceImpl; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AbstractMobileDeviceManagementDAOFactory; +import org.wso2.carbon.device.mgt.mobile.android.impl.util.MobileDeviceManagementUtil; import org.wso2.carbon.ndatasource.core.DataSourceService; import org.wso2.carbon.registry.core.service.RegistryService; /** - * @scr.component name="org.wso2.carbon.device.mgt.mobile.android.impl.internal.AndroidDeviceManagementServiceComponent" + * @scr.component name="org.wso2.carbon.device.mgt.mobile.android.impl.internal.AndroidPluginServiceComponent" * immediate="true" * @scr.reference name="org.wso2.carbon.ndatasource" * interface="org.wso2.carbon.ndatasource.core.DataSourceService" @@ -43,9 +46,9 @@ import org.wso2.carbon.registry.core.service.RegistryService; * initializing APIMgtDAOs attempting to register APIs programmatically. APIMgtDAO needs to be proper cleaned up * to avoid as an ideal fix */ -public class AndroidDeviceManagementServiceComponent { +public class AndroidPluginServiceComponent { - private static final Log log = LogFactory.getLog(AndroidDeviceManagementServiceComponent.class); + private static final Log log = LogFactory.getLog(AndroidPluginServiceComponent.class); protected void activate(ComponentContext ctx) { @@ -53,9 +56,17 @@ public class AndroidDeviceManagementServiceComponent { log.debug("Activating Android Mobile Device Management Service Component"); } try { - DeviceManagementService androidDeviceManagementService = new AndroidDeviceManagementService(); + BundleContext bundleContext = ctx.getBundleContext(); + + + MobileDeviceManagementUtil.initConfig(); + AbstractMobileDeviceManagementDAOFactory.init("android", MobileDeviceManagementUtil + .getIosDataSourceConfigurations().getIosDataSourceConfiguration()); + + AndroidPluginService androidPluginService = new AndroidPluginServiceImpl(); AndroidDeviceManagementDataHolder.getInstance().setAndroidDeviceManagementService( - androidDeviceManagementService); + androidPluginService); + bundleContext.registerService(AndroidPluginService.class.getName(), androidPluginService, null); if (log.isDebugEnabled()) { log.debug("Android Mobile Device Management Service Component has been successfully activated"); } diff --git a/components/mobile-plugins/android-plugin/pom.xml b/components/mobile-plugins/android-plugin/pom.xml index d6f01d289..dfa060751 100644 --- a/components/mobile-plugins/android-plugin/pom.xml +++ b/components/mobile-plugins/android-plugin/pom.xml @@ -35,7 +35,6 @@ org.wso2.carbon.device.mgt.mobile.android org.wso2.carbon.device.mgt.mobile.android.api - org.wso2.carbon.device.mgt.mobile.android.v09.api org.wso2.carbon.device.mgt.mobile.android.emulator org.wso2.carbon.device.mgt.mobile.android.ui diff --git a/components/test-coverage/pom.xml b/components/test-coverage/pom.xml index c473d2f36..a4bb7f260 100644 --- a/components/test-coverage/pom.xml +++ b/components/test-coverage/pom.xml @@ -55,14 +55,6 @@ extensions - - - ${basedir}/../${extensions}/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector - - - ${basedir}/../${extensions}/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector - - ${extensions}/cdmf-transport-adapters @@ -196,25 +188,6 @@ - - - - - - - - - - - - - - - - - - - diff --git a/features/extensions-feature/org.wso2.carbon.appmgt.mdm.osgiconnector.feature/pom.xml b/features/extensions-feature/org.wso2.carbon.appmgt.mdm.osgiconnector.feature/pom.xml deleted file mode 100644 index 5cdd430da..000000000 --- a/features/extensions-feature/org.wso2.carbon.appmgt.mdm.osgiconnector.feature/pom.xml +++ /dev/null @@ -1,94 +0,0 @@ - - - - 4.0.0 - - - org.wso2.carbon.devicemgt-plugins - extensions-feature - 5.0.0-SNAPSHOT - ../pom.xml - - - org.wso2.carbon.appmgt.mdm.osgiconnector.feature - pom - 5.0.0-SNAPSHOT - WSO2 Carbon - App management MDM OSGI Connector - http://wso2.org - This feature contains the core bundles required for APP management OSGI MDM connection - - - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.appmgt.mdm.osgiconnector - 5.0.0-SNAPSHOT - - - org.apache.ws.commons.axiom - axiom-api - - - org.apache.ws.commons.axiom - axiom-impl - - - - - com.googlecode.plist - dd-plist - - - - - - - org.wso2.maven - carbon-p2-plugin - ${carbon.p2.plugin.version} - - - 4-p2-feature-generation - package - - p2-feature-gen - - - org.wso2.carbon.appmgt.mdm.osgiconnector - ../etc/feature.properties - - - org.wso2.carbon.p2.category.type:server - - org.eclipse.equinox.p2.type.group:false - - - - - org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.appmgt.mdm.osgiconnector:${carbon.devicemgt.plugins.version} - com.googlecode.plist:dd-plist:${googlecode.plist.version} - - - - - - - - - - - diff --git a/features/extensions-feature/org.wso2.carbon.appmgt.mdm.restconnector.feature/pom.xml b/features/extensions-feature/org.wso2.carbon.appmgt.mdm.restconnector.feature/pom.xml deleted file mode 100644 index 17ab757e1..000000000 --- a/features/extensions-feature/org.wso2.carbon.appmgt.mdm.restconnector.feature/pom.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - 4.0.0 - - - org.wso2.carbon.devicemgt-plugins - extensions-feature - 5.0.0-SNAPSHOT - ../pom.xml - - - org.wso2.carbon.appmgt.mdm.restconnector.feature - pom - 5.0.0-SNAPSHOT - WSO2 Carbon - App management MDM REST Connector - http://wso2.org - This feature contains the core bundles required for APP management MDM REST connection - - - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.appmgt.mdm.restconnector - 5.0.0-SNAPSHOT - - - org.apache.ws.commons.axiom - axiom-api - - - org.apache.ws.commons.axiom - axiom-impl - - - - - com.googlecode.plist - dd-plist - - - - - - - org.wso2.maven - carbon-p2-plugin - ${carbon.p2.plugin.version} - - - 4-p2-feature-generation - package - - p2-feature-gen - - - org.wso2.carbon.appmgt.mdm.restconnector - ../etc/feature.properties - - - org.wso2.carbon.p2.category.type:server - - org.eclipse.equinox.p2.type.group:false - - - - - - org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.appmgt.mdm.restconnector:${carbon.devicemgt.plugins.version} - - com.googlecode.plist:dd-plist:${googlecode.plist.version} - - - - - - - - - - - diff --git a/features/extensions-feature/pom.xml b/features/extensions-feature/pom.xml index 4385ac248..8503854cd 100644 --- a/features/extensions-feature/pom.xml +++ b/features/extensions-feature/pom.xml @@ -34,8 +34,6 @@ http://wso2.org - org.wso2.carbon.appmgt.mdm.osgiconnector.feature - org.wso2.carbon.appmgt.mdm.restconnector.feature org.wso2.carbon.device.mgt.adapter.feature org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature org.wso2.carbon.andes.extensions.device.mgt.api.feature diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml index f2fc4b7ef..261311d17 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml @@ -141,27 +141,6 @@ - - copy-v09-jaxrs-war - package - - copy - - - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.mobile.android.v09.api - ${project.version} - war - true - ${project.build.directory}/maven-shared-archive-resources/webapps/ - - api#device-mgt#android#v0.9.war - - - - diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/conf/android-dbconfig.xml b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/conf/android-dbconfig.xml new file mode 100644 index 000000000..384f3fd16 --- /dev/null +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/conf/android-dbconfig.xml @@ -0,0 +1,25 @@ + + + + + jdbc/MobileAndroidDM_DS + + + diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/conf/mobile-config.xml b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/conf/mobile-config.xml index 39abe6e01..e22a61b63 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/conf/mobile-config.xml +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/conf/mobile-config.xml @@ -34,6 +34,7 @@ + appmanager admin diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/h2.sql b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/h2.sql index 845dbe88e..329290335 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/h2.sql +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/h2.sql @@ -31,3 +31,31 @@ CREATE TABLE IF NOT EXISTS `AD_FEATURE` ( `DESCRIPTION` VARCHAR(200) NULL, PRIMARY KEY (`ID`)); +-- ----------------------------------------------------- +-- Table `AD_ENTERPRISE_USER_DEVICE` +-- ----------------------------------------------------- + +CREATE TABLE IF NOT EXISTS `AD_ENTERPRISE_USER_DEVICE` ( + `ID` INT NOT NULL AUTO_INCREMENT, + `ENTERPRISE_ID` VARCHAR(50) NULL, + `EMM_USERNAME` VARCHAR(100) NOT NULL, + `GOOGLE_USER_ID` VARCHAR(50) NULL, + `ANDROID_PLAY_DEVICE_ID` VARCHAR(50) NULL, + `EMM_DEVICE_ID` VARCHAR(50) NULL, + `TENANT_ID` INT(11) NULL DEFAULT '0', + `LAST_UPDATED_TIMESTAMP` TIMESTAMP NOT NULL, + PRIMARY KEY (`ID`)); + +-- ----------------------------------------------------- +-- Table `AD_ENTERPRISE_MANAGED_CONFIGS` +-- ----------------------------------------------------- + +CREATE TABLE IF NOT EXISTS `AD_ENTERPRISE_MANAGED_CONFIGS` ( + `ID` INT NOT NULL AUTO_INCREMENT, + `MCM_ID` VARCHAR(50) NULL, + `PROFILE_NAME` VARCHAR(100) NULL, + `PACKAGE_NAME` VARCHAR(100) NOT NULL, + `TENANT_ID` INT(11) NULL DEFAULT '0', + `LAST_UPDATED_TIMESTAMP` TIMESTAMP NOT NULL, + PRIMARY KEY (`ID`)); + diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mssql.sql b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mssql.sql index ed7976347..adbb578a4 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mssql.sql +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mssql.sql @@ -32,3 +32,25 @@ CREATE TABLE AD_FEATURE ( DESCRIPTION VARCHAR(200) NULL, PRIMARY KEY (ID) ); + +CREATE TABLE AD_ENTERPRISE_USER_DEVICE ( + [ID] INT NOT NULL IDENTITY, + [ENTERPRISE_ID] VARCHAR(50) NULL, + [EMM_USERNAME] VARCHAR(100) NOT NULL, + [GOOGLE_USER_ID] VARCHAR(50) NULL, + [ANDROID_PLAY_DEVICE_ID] VARCHAR(50) NULL, + [EMM_DEVICE_ID] VARCHAR(50) NULL, + [TENANT_ID] INT NULL DEFAULT '0', + [LAST_UPDATED_TIMESTAMP] DATETIME2(0) NOT NULL, + PRIMARY KEY ([ID]) +); + +CREATE TABLE AD_ENTERPRISE_MANAGED_CONFIGS ( + [ID] INT NOT NULL IDENTITY, + [MCM_ID] VARCHAR(50) NULL, + [PROFILE_NAME] VARCHAR(100) NULL, + [PACKAGE_NAME] VARCHAR(100) NOT NULL, + [TENANT_ID] INT NULL DEFAULT '0', + [LAST_UPDATED_TIMESTAMP] DATETIME2(0) NOT NULL, + PRIMARY KEY ([ID]) +) ; diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mysql.sql b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mysql.sql index 655af9948..f66dd121b 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mysql.sql +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mysql.sql @@ -31,3 +31,26 @@ CREATE TABLE IF NOT EXISTS `AD_FEATURE` ( `DESCRIPTION` VARCHAR(200) NULL, PRIMARY KEY (`ID`) ) ENGINE = InnoDB; + +CREATE TABLE IF NOT EXISTS `AD_ENTERPRISE_USER_DEVICE` ( + `ID` INT NOT NULL AUTO_INCREMENT, + `ENTERPRISE_ID` VARCHAR(50) NULL, + `EMM_USERNAME` VARCHAR(100) NOT NULL, + `GOOGLE_USER_ID` VARCHAR(50) NULL, + `ANDROID_PLAY_DEVICE_ID` VARCHAR(50) NULL, + `EMM_DEVICE_ID` VARCHAR(50) NULL, + `TENANT_ID` INT(11) NULL DEFAULT '0', + `LAST_UPDATED_TIMESTAMP` TIMESTAMP NOT NULL, + PRIMARY KEY (`ID`) +) ENGINE = InnoDB; + +CREATE TABLE IF NOT EXISTS `AD_ENTERPRISE_MANAGED_CONFIGS` ( + `ID` INT NOT NULL AUTO_INCREMENT, + `MCM_ID` VARCHAR(50) NULL, + `PROFILE_NAME` VARCHAR(100) NULL, + `PACKAGE_NAME` VARCHAR(100) NOT NULL, + `TENANT_ID` INT(11) NULL DEFAULT '0', + `LAST_UPDATED_TIMESTAMP` TIMESTAMP NOT NULL, + PRIMARY KEY (`ID`) +) ENGINE = InnoDB; + diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/oracle.sql b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/oracle.sql index 6ad72c41c..246ee5df9 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/oracle.sql +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/oracle.sql @@ -50,4 +50,49 @@ FOR EACH ROW BEGIN SELECT AD_FEATURE_ID_INC_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL; END; +/ + + +CREATE TABLE AD_ENTERPRISE_USER_DEVICE ( + ID NUMBER(10) NOT NULL, + ENTERPRISE_ID VARCHAR2(50) NULL, + EMM_USERNAME VARCHAR2(100) NOT NULL, + GOOGLE_USER_ID VARCHAR2(50) NULL, + ANDROID_PLAY_DEVICE_ID VARCHAR2(50) NULL, + EMM_DEVICE_ID VARCHAR2(50) NULL, + TENANT_ID NUMBER(10) DEFAULT '0' NULL, + LAST_UPDATED_TIMESTAMP TIMESTAMP(0) NOT NULL, + PRIMARY KEY (ID) +); + +-- Generate ID using sequence and trigger +CREATE SEQUENCE AD_ENTERPRISE_USER_DEVICE_seq START WITH 1 INCREMENT BY 1; + +CREATE OR REPLACE TRIGGER AD_ENTERPRISE_USER_DEVICE_seq_tr + BEFORE INSERT ON AD_ENTERPRISE_USER_DEVICE FOR EACH ROW + WHEN (NEW.ID IS NULL) +BEGIN + SELECT AD_ENTERPRISE_USER_DEVICE_seq.NEXTVAL INTO :NEW.ID FROM DUAL; +END; +/ + +CREATE TABLE AD_ENTERPRISE_MANAGED_CONFIGS ( + ID NUMBER(10) NOT NULL, + MCM_ID VARCHAR2(50) NULL, + PROFILE_NAME VARCHAR2(100) NULL, + PACKAGE_NAME VARCHAR2(100) NOT NULL, + TENANT_ID NUMBER(10) DEFAULT '0' NULL, + LAST_UPDATED_TIMESTAMP TIMESTAMP(0) NOT NULL, + PRIMARY KEY (ID) +) ; + +-- Generate ID using sequence and trigger +CREATE SEQUENCE AD_ENTERPRISE_MANAGED_CONFIGS_seq START WITH 1 INCREMENT BY 1; + +CREATE OR REPLACE TRIGGER AD_ENTERPRISE_MANAGED_CONFIGS_seq_tr + BEFORE INSERT ON AD_ENTERPRISE_MANAGED_CONFIGS FOR EACH ROW + WHEN (NEW.ID IS NULL) +BEGIN + SELECT AD_ENTERPRISE_MANAGED_CONFIGS_seq.NEXTVAL INTO :NEW.ID FROM DUAL; +END; / \ No newline at end of file diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/postgresql.sql b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/postgresql.sql index 908d1c21f..a34075d5a 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/postgresql.sql +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/postgresql.sql @@ -30,3 +30,29 @@ CREATE TABLE IF NOT EXISTS AD_FEATURE ( HIDDEN BOOLEAN DEFAULT FALSE, DESCRIPTION VARCHAR(200) NULL ); + +CREATE SEQUENCE AD_ENTERPRISE_USER_DEVICE_seq; + +CREATE TABLE IF NOT EXISTS AD_ENTERPRISE_USER_DEVICE ( + ID INT NOT NULL DEFAULT NEXTVAL ('AD_ENTERPRISE_USER_DEVICE_seq'), + ENTERPRISE_ID VARCHAR(50) NULL, + EMM_USERNAME VARCHAR(100) NOT NULL, + GOOGLE_USER_ID VARCHAR(50) NULL, + ANDROID_PLAY_DEVICE_ID VARCHAR(50) NULL, + EMM_DEVICE_ID VARCHAR(50) NULL, + TENANT_ID INT NULL DEFAULT '0', + LAST_UPDATED_TIMESTAMP TIMESTAMP(0) NOT NULL, + PRIMARY KEY (ID) +); + +CREATE SEQUENCE AD_ENTERPRISE_MANAGED_CONFIGS_seq; + +CREATE TABLE IF NOT EXISTS AD_ENTERPRISE_MANAGED_CONFIGS ( + ID INT NOT NULL DEFAULT NEXTVAL ('AD_ENTERPRISE_MANAGED_CONFIGS_seq'), + MCM_ID VARCHAR(50) NULL, + PROFILE_NAME VARCHAR(100) NULL, + PACKAGE_NAME VARCHAR(100) NOT NULL, + TENANT_ID INT NULL DEFAULT '0', + LAST_UPDATED_TIMESTAMP TIMESTAMP(0) NOT NULL, + PRIMARY KEY (ID) +) ; diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml index 9a7b9a428..40e84c21a 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml @@ -191,6 +191,26 @@ + + Change LockTask + Change LockTask mode of KIOSK device + + Upgrade Firmware Upgrade Firmware @@ -683,4 +703,147 @@ 900 600 + + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 8 + + + + 9 + + + + 10 + + + + 11 + + + + 12 + + + + 13 + + + + 14 + + + + 15 + + + + 16 + + + + 17 + + + + 18 + + + + 19 + + + + 20 + + + + 21 + + + + 22 + + + + 23 + + + + 24 + + + + 25 + + + + 26 + + + + 27 + + + + 28 + + + + 29 + + + + 30 + + + + 31 + + + + 32 + + + + 33 + + + + 34 + + + + 35 + + diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf index e97190bd3..5edb8b23b 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf @@ -1,6 +1,5 @@ instructions.configure = \ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/webapps/api#device-mgt#android#v1.0.war,target:${installFolder}/../../deployment/server/webapps/api#device-mgt#android#v1.0.war,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/webapps/api#device-mgt#android#v0.9.war,target:${installFolder}/../../deployment/server/webapps/api#device-mgt#android#v0.9.war,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/jaggeryapps/devicemgt,target:${installFolder}/../../deployment/server/jaggeryapps/devicemgt,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/datasources/,target:${installFolder}/../../conf/datasources/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/conf/mobile-config.xml,target:${installFolder}/../../conf/mobile-config.xml,overwrite:true);\ @@ -13,6 +12,7 @@ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../featur org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/apis/admin--Android-Mutual-SSL-Configuration-Management.xml,target:${installFolder}/../../deployment/server/synapse-configs/default/api/admin--Android-Mutual-SSL-Configuration-Management.xml,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/apis/admin--Android-Mutual-SSL-Device-Management.xml,target:${installFolder}/../../deployment/server/synapse-configs/default/api/admin--Android-Mutual-SSL-Device-Management.xml,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/apis/admin--Android-Mutual-SSL-Event-Receiver.xml,target:${installFolder}/../../deployment/server/synapse-configs/default/api/admin--Android-Mutual-SSL-Event-Receiver.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/conf/android-dbconfig.xml,target:${installFolder}/../../conf/android-dbconfig.xml,overwrite:true);\ instructions.unconfigure = \ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/mdm-android-agent.war);\ diff --git a/pom.xml b/pom.xml index 792e81f3a..2a999bc86 100644 --- a/pom.xml +++ b/pom.xml @@ -94,6 +94,11 @@ org.wso2.carbon.user.api ${carbon.kernel.version} + + org.wso2.carbon + org.wso2.carbon.base + ${carbon.kernel.version} + org.wso2.carbon org.wso2.carbon.logging @@ -567,19 +572,9 @@ - org.wso2.carbon.appmgt - org.wso2.carbon.appmgt.mobile - ${carbon.appmgt.version} - - - org.apache.ws.commons.axiom - axiom-api - - - org.apache.ws.commons.axiom - axiom-impl - - + org.wso2.carbon.devicemgt + org.wso2.carbon.device.application.mgt.common + ${carbon.devicemgt.version} @@ -1242,12 +1237,9 @@ 1.1.1 - 4.0.0 + 4.1.0 [4.0.0, 5.0.0) - - 1.5.7 - 5.0.0-SNAPSHOT