diff --git a/components/device-mgt-mdm/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/URLPrinterStartupHandler.java b/components/device-mgt-mdm/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/URLPrinterStartupHandler.java
index ab9d41b14c..1eaad8ad4c 100644
--- a/components/device-mgt-mdm/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/URLPrinterStartupHandler.java
+++ b/components/device-mgt-mdm/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/URLPrinterStartupHandler.java
@@ -37,7 +37,7 @@ public class URLPrinterStartupHandler implements ServerStartupObserver {
@Override
public void completedServerStartup() {
- log.info("EMM Console URL : " + this.getEmmUrl());
+ log.info("Device Management Console URL : " + this.getEmmUrl());
}
private String getEmmUrl() {
@@ -58,7 +58,7 @@ public class URLPrinterStartupHandler implements ServerStartupObserver {
if (httpsProxyPort > 0) {
port = httpsProxyPort;
}
- return "https://" + hostName + ":" + port + "/mdm";
+ return "https://" + hostName + ":" + port + "/devicemgt";
}
}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.appmgt/pom.xml b/components/device-mgt-mdm/org.wso2.mdm.appmgt/pom.xml
new file mode 100644
index 0000000000..75d2f993ba
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.appmgt/pom.xml
@@ -0,0 +1,125 @@
+
+
+
+ org.wso2.carbon.devicemgt-plugins
+ device-mgt-mdm
+ 1.9.2-SNAPSHOT
+ ../pom.xml
+
+
+ 4.0.0
+ WSO2 Carbon - Mobile Device app Management Core
+ WSO2 Carbon - Device Management Core
+ http://wso2.org
+ org.wso2.mdm.appmgt
+ 1.9.2-SNAPSHOT
+ bundle
+
+
+
+
+ org.apache.felix
+ maven-scr-plugin
+
+
+ org.apache.felix
+ maven-bundle-plugin
+ 1.4.0
+ true
+
+
+ ${project.artifactId}
+ ${project.artifactId}
+ ${project.version}
+ MDM Management Core Bundle
+ org.wso2.mdm.appmgt.internal
+
+ org.osgi.framework,
+ org.osgi.service.component,
+ org.apache.commons.logging,
+ org.wso2.carbon.appmgt.mobile.*,
+ org.wso2.carbon.device.mgt.common,
+ org.wso2.carbon.device.mgt.common.operation.mgt,
+ org.wso2.carbon.device.mgt.core.operation.mgt,
+ org.wso2.mdm.mdmmgt.*,
+ org.wso2.carbon.device.mgt.common.app.mgt,
+ org.wso2.carbon.device.mgt.core.service,
+ org.wso2.carbon.device.mgt.core.app.mgt
+
+
+ !org.wso2.mdm.appmgt.internal,
+ org.wso2.mdm.appmgt.*
+
+
+
+
+
+
+
+
+
+
+ org.wso2.carbon.devicemgt-plugins
+ org.wso2.mdm.mdmmgt
+
+
+ org.eclipse.osgi
+ org.eclipse.osgi
+
+
+ org.eclipse.osgi
+ org.eclipse.osgi.services
+
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.device.mgt.common
+
+
+ org.wso2.carbon
+ org.wso2.carbon.logging
+
+
+ org.wso2.carbon
+ org.wso2.carbon.utils
+
+
+ org.wso2.carbon
+ org.wso2.carbon.core
+
+
+ org.testng
+ testng
+
+
+ org.wso2.carbon.appmgt
+ org.wso2.carbon.appmgt.mobile
+
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.device.mgt.core
+ provided
+
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.policy.mgt.core
+ provided
+
+
+
+
\ No newline at end of file
diff --git a/components/device-mgt-mdm/org.wso2.mdm.appmgt/src/main/java/org/wso2/mdm/appmgt/internal/AppMgtMDMService.java b/components/device-mgt-mdm/org.wso2.mdm.appmgt/src/main/java/org/wso2/mdm/appmgt/internal/AppMgtMDMService.java
new file mode 100644
index 0000000000..76eb72b759
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.appmgt/src/main/java/org/wso2/mdm/appmgt/internal/AppMgtMDMService.java
@@ -0,0 +1,24 @@
+package org.wso2.mdm.appmgt.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.appmgt.mobile.interfaces.MDMOperations;
+import org.wso2.mdm.appmgt.service.MDMOperationsImpl;
+
+/**
+ * @scr.component name="org.wso2.mdm.appmgt.manager" immediate="true"
+ */
+public class AppMgtMDMService {
+ private static Log log = LogFactory.getLog(AppMgtMDMService.class);
+
+ protected void activate(ComponentContext componentContext) {
+
+ BundleContext bundleContext = componentContext.getBundleContext();
+ bundleContext.registerService(MDMOperations.class.getName(),
+ new MDMOperationsImpl(), null);
+
+ }
+
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.appmgt/src/main/java/org/wso2/mdm/appmgt/service/MDMOperationsImpl.java b/components/device-mgt-mdm/org.wso2.mdm.appmgt/src/main/java/org/wso2/mdm/appmgt/service/MDMOperationsImpl.java
new file mode 100644
index 0000000000..279e9c3d45
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.appmgt/src/main/java/org/wso2/mdm/appmgt/service/MDMOperationsImpl.java
@@ -0,0 +1,185 @@
+package org.wso2.mdm.appmgt.service;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.appmgt.mobile.interfaces.MDMOperations;
+import org.wso2.carbon.appmgt.mobile.mdm.App;
+import org.wso2.carbon.appmgt.mobile.mdm.Device;
+import org.wso2.carbon.appmgt.mobile.utils.User;
+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.app.mgt.ApplicationManager;
+import org.wso2.mdm.mdmmgt.beans.MobileApp;
+import org.wso2.mdm.mdmmgt.beans.MobileAppTypes;
+import org.wso2.mdm.mdmmgt.common.MDMException;
+import org.wso2.mdm.mdmmgt.util.MDMAndroidOperationUtil;
+import org.wso2.mdm.mdmmgt.util.MDMIOSOperationUtil;
+import org.wso2.mdm.mdmmgt.util.MDMServiceAPIUtils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Properties;
+
+public class MDMOperationsImpl implements MDMOperations {
+
+ private static Log log = LogFactory.getLog(MDMOperationsImpl.class);
+
+ @Override
+ public void performAction(User currentUser, String action, App app, int tenantId, String type,
+ String[] params,
+ HashMap configProperties) {
+
+ ApplicationManager appManagerConnector;
+ org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation = null;
+
+ List userNameList;
+ List roleNameList;
+ List deviceIdentifiers = new ArrayList<>();
+ List deviceList = null;
+
+ if ("user".equals(type)) {
+ String userName = null;
+ for (String param : params) {
+ userName = param;
+
+ try {
+ deviceList = MDMServiceAPIUtils.getDeviceManagementService(tenantId).getDevicesOfUser(userName);
+ } catch (DeviceManagementException devEx) {
+ String errorMsg =
+ "Error occurred fetch device for user " + userName + devEx.getErrorMessage() + " " +
+ "at app installation";
+ log.error(errorMsg, devEx);
+ }
+
+ for (org.wso2.carbon.device.mgt.common.Device device : deviceList) {
+ DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
+ deviceIdentifier.setId(device.getDeviceIdentifier());
+ deviceIdentifier.setType(device.getType());
+
+ deviceIdentifiers.add(deviceIdentifier);
+ }
+ }
+ } else if ("role".equals(type)) {
+ String userRole;
+ for (String param : params) {
+ userRole = param;
+ try {
+ deviceList = MDMServiceAPIUtils.getDeviceManagementService(tenantId).getAllDevices();
+ } catch (DeviceManagementException devMgtEx) {
+ String errorMsg = "Error occurred fetch device for user role " + userRole + devMgtEx
+ .getErrorMessage() + " " +
+ "at app installation";
+ log.error(errorMsg, devMgtEx);
+ }
+ for (org.wso2.carbon.device.mgt.common.Device device : deviceList) {
+ DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
+ deviceIdentifier.setId(device.getDeviceIdentifier());
+ deviceIdentifier.setType(device.getType());
+ deviceIdentifiers.add(deviceIdentifier);
+ }
+ }
+ } else {
+ deviceIdentifiers = new ArrayList<>();
+ DeviceIdentifier deviceIdentifier = null;
+ for (String param : params) {
+ deviceIdentifier = new DeviceIdentifier();
+ String[] paramDevices = param.split("---");
+ deviceIdentifier.setId(paramDevices[0]);
+ deviceIdentifier.setType(paramDevices[1]);
+ deviceIdentifiers.add(deviceIdentifier);
+ }
+
+ }
+ 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 ("ios".equals(app.getPlatform())) {
+ if ("enterprise".equals(app.getType())) {
+ properties.put("isRemoveApp", true);
+ properties.put("isPreventBackup", true);
+ } else if ("public".equals(app.getType())) {
+ properties.put("iTunesId", Integer.parseInt(app.getIdentifier().toString()));
+ properties.put("isRemoveApp", true);
+ properties.put("isPreventBackup", true);
+ } else if ("webapp".equals(app.getType())) {
+ properties.put("label", app.getName());
+ properties.put("isRemoveApp", true);
+ }
+ } else if ("webapp".equals(app.getPlatform())) {
+ properties.put("label", app.getName());
+ properties.put("isRemoveApp", true);
+ }
+ mobileApp.setProperties(properties);
+
+ try {
+ if (deviceIdentifiers != null) {
+ for (DeviceIdentifier deviceIdentifier : deviceIdentifiers) {
+ if (deviceIdentifier.getType().equals(Platform.android.toString())) {
+ if ("install".equals(action)) {
+ operation = MDMAndroidOperationUtil.createInstallAppOperation(mobileApp);
+ } else {
+ operation = MDMAndroidOperationUtil.createAppUninstallOperation(mobileApp);
+ }
+ } else if (deviceIdentifier.getType().equals(Platform.ios.toString())) {
+ if ("install".equals(action)) {
+ operation = MDMIOSOperationUtil.createInstallAppOperation(mobileApp);
+ } else {
+ operation = MDMIOSOperationUtil.createAppUninstallOperation(mobileApp);
+ }
+ }
+ MDMServiceAPIUtils.getAppManagementService(tenantId).installApplicationForDevices(operation,
+ deviceIdentifiers);
+ }
+ }
+ } catch (MDMException mdmExce) {
+ log.error("Error in creating operation object using app", mdmExce);
+ } catch (ApplicationManagementException appMgtExce) {
+ log.error("Error in app installation", appMgtExce);
+ }
+ }
+
+ @Override
+
+ public List getDevices(User currentUser, int tenantId, String type, String[] params,
+ String platform,
+ String platformVersion, boolean isSampleDevicesEnabled,
+ HashMap configProperties) {
+
+ List devices = new ArrayList<>();
+ Device device = null;
+ try {
+ List deviceList =
+ MDMServiceAPIUtils.getDeviceManagementService(tenantId).getAllDevices();
+
+ for (org.wso2.carbon.device.mgt.common.Device commondevice : deviceList) {
+ device = new Device();
+ device.setId(commondevice.getDeviceIdentifier() + "---" + commondevice.getType());
+ device.setName(commondevice.getName());
+ device.setModel(commondevice.getName());
+ device.setType("mobileDevice");
+ device.setImage("/store/extensions/assets/mobileapp/resources/models/none.png");
+ device.setPlatform(commondevice.getType());
+ devices.add(device);
+
+ }
+
+ } catch (DeviceManagementException e) {
+ e.printStackTrace();
+ }
+ return devices;
+ }
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/pom.xml b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/pom.xml
new file mode 100644
index 0000000000..4153f4a43c
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/pom.xml
@@ -0,0 +1,101 @@
+
+
+
+ org.wso2.carbon.devicemgt-plugins
+ device-mgt-mdm
+ 1.9.2-SNAPSHOT
+ ../pom.xml
+
+
+ 4.0.0
+ bundle
+ org.wso2.mdm.mdmmgt
+ 1.9.2-SNAPSHOT
+
+
+
+ org.apache.cxf
+ cxf-rt-frontend-jaxws
+
+
+ org.apache.cxf
+ cxf-rt-frontend-jaxrs
+
+
+ org.apache.cxf
+ cxf-rt-transports-http
+
+
+ junit
+ junit
+ test
+
+
+ commons-httpclient.wso2
+ commons-httpclient
+ provided
+
+
+ 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.device.mgt.core
+ provided
+
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.policy.mgt.core
+ provided
+
+
+ org.wso2.carbon.identity
+ org.wso2.carbon.identity.oauth.stub
+ provided
+
+
+ com.google.code.gson
+ gson
+
+
+
+
+
+ org.apache.felix
+ maven-bundle-plugin
+ 1.4.0
+ true
+
+
+ ${project.artifactId}
+ ${project.artifactId}
+ ${project.version}
+ MDM Management Components Bundle
+
+ org.wso2.mdm.mdmmgt.*
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/ApplicationWrapper.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/ApplicationWrapper.java
new file mode 100644
index 0000000000..c9cde2fe16
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/ApplicationWrapper.java
@@ -0,0 +1,65 @@
+/*
+ *
+ * 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.mdm.mdmmgt.beans;
+
+import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
+
+import java.util.List;
+
+public class ApplicationWrapper {
+
+ private List userNameList;
+ private List roleNameList;
+ private List deviceIdentifiers;
+ private MobileApp application;
+
+ public MobileApp getApplication() {
+ return application;
+ }
+
+ public void setApplication(MobileApp application) {
+ this.application = application;
+ }
+
+ public List getUserNameList() {
+ return userNameList;
+ }
+
+ public void setUserNameList(List userNameList) {
+ this.userNameList = userNameList;
+ }
+
+ public List getRoleNameList() {
+ return roleNameList;
+ }
+
+ public void setRoleNameList(List roleNameList) {
+ this.roleNameList = roleNameList;
+ }
+
+ public List getDeviceIdentifiers() {
+ return deviceIdentifiers;
+ }
+
+ public void setDeviceIdentifiers(List deviceIdentifiers) {
+ this.deviceIdentifiers = deviceIdentifiers;
+ }
+
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/MobileApp.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/MobileApp.java
new file mode 100644
index 0000000000..f009b71469
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/MobileApp.java
@@ -0,0 +1,128 @@
+/*
+ * 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.mdm.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/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/MobileAppTypes.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/MobileAppTypes.java
new file mode 100644
index 0000000000..da72bed0fc
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/MobileAppTypes.java
@@ -0,0 +1,22 @@
+/*
+ * 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.mdm.mdmmgt.beans;
+
+public enum MobileAppTypes {
+ ENTERPRISE, WEBAPP, PUBLIC
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/PolicyWrapper.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/PolicyWrapper.java
new file mode 100644
index 0000000000..440e24ff20
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/PolicyWrapper.java
@@ -0,0 +1,127 @@
+/*
+ * 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.mdm.mdmmgt.beans;
+
+import org.wso2.carbon.device.mgt.common.Device;
+
+import java.util.List;
+
+public class PolicyWrapper {
+
+ private int id;
+ private Profile profile;
+ private String policyName;
+ private String description;
+ private String compliance;
+ private List roles;
+ private String ownershipType;
+ private List devices;
+ private List users;
+ private int tenantId;
+ private int profileId;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public Profile getProfile() {
+ return profile;
+ }
+
+ public void setProfile(Profile profile) {
+ this.profile = profile;
+ }
+
+ public String getCompliance() {
+ return compliance;
+ }
+
+ public void setCompliance(String compliance) {
+ this.compliance = compliance;
+ }
+
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public List getRoles() {
+ return roles;
+ }
+
+ public void setRoles(List roles) {
+ this.roles = roles;
+ }
+
+ public String getOwnershipType() {
+ return ownershipType;
+ }
+
+ public void setOwnershipType(String ownershipType) {
+ this.ownershipType = ownershipType;
+ }
+
+ public List getDevices() {
+ return devices;
+ }
+
+ public void setDevices(List devices) {
+ this.devices = devices;
+ }
+
+ public List getUsers() {
+ return users;
+ }
+
+ public void setUsers(List users) {
+ this.users = users;
+ }
+
+ public int getTenantId() {
+ return tenantId;
+ }
+
+ public void setTenantId(int tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public int getProfileId() {
+ return profileId;
+ }
+
+ public void setProfileId(int profileId) {
+ this.profileId = profileId;
+ }
+
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/PriorityUpdatedPolicyWrapper.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/PriorityUpdatedPolicyWrapper.java
new file mode 100644
index 0000000000..73d67c56d6
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/PriorityUpdatedPolicyWrapper.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.mdm.mdmmgt.beans;
+
+public class PriorityUpdatedPolicyWrapper {
+
+ private int id;
+ private int priority;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getPriority() {
+ return priority;
+ }
+
+ public void setPriority(int priority) {
+ this.priority = priority;
+ }
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/Profile.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/Profile.java
new file mode 100644
index 0000000000..3a665d93c5
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/Profile.java
@@ -0,0 +1,107 @@
+/*
+* 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.mdm.mdmmgt.beans;
+
+import org.wso2.carbon.device.mgt.core.dto.DeviceType;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.sql.Timestamp;
+import java.util.List;
+
+@XmlRootElement
+public class Profile {
+
+ private int profileId;
+ private String profileName;
+ private int tenantId;
+ private DeviceType deviceType;
+ private Timestamp createdDate;
+ private Timestamp updatedDate;
+ private List profileFeaturesList; // Features included in the policies.
+
+ public DeviceType getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(DeviceType deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ @XmlElement
+ public int getTenantId() {
+ return tenantId;
+ }
+
+ public void setTenantId(int tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ /* public List getFeaturesList() {
+ return featuresList;
+ }
+
+ public void setFeaturesList(List featuresList) {
+ this.featuresList = featuresList;
+ }*/
+ @XmlElement
+ public int getProfileId() {
+ return profileId;
+ }
+
+ public void setProfileId(int profileId) {
+ this.profileId = profileId;
+ }
+
+ @XmlElement
+ public String getProfileName() {
+ return profileName;
+ }
+
+ public void setProfileName(String profileName) {
+ this.profileName = profileName;
+ }
+
+ @XmlElement
+ public Timestamp getCreatedDate() {
+ return createdDate;
+ }
+
+ public void setCreatedDate(Timestamp createdDate) {
+ this.createdDate = createdDate;
+ }
+
+ @XmlElement
+ public Timestamp getUpdatedDate() {
+ return updatedDate;
+ }
+
+ public void setUpdatedDate(Timestamp updatedDate) {
+ this.updatedDate = updatedDate;
+ }
+
+ @XmlElement
+ public List getProfileFeaturesList() {
+ return profileFeaturesList;
+ }
+
+ public void setProfileFeaturesList(List profileFeaturesList) {
+ this.profileFeaturesList = profileFeaturesList;
+ }
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/ProfileFeature.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/ProfileFeature.java
new file mode 100644
index 0000000000..637d07fb0f
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/ProfileFeature.java
@@ -0,0 +1,85 @@
+/*
+* 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.mdm.mdmmgt.beans;
+
+import com.google.gson.Gson;
+
+import java.io.Serializable;
+
+public class ProfileFeature implements Serializable {
+
+ private int id;
+ private String featureCode;
+ private int profileId;
+ private int deviceTypeId;
+ private Object content;
+ private String payLoad;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getFeatureCode() {
+ return featureCode;
+ }
+
+ public void setFeatureCode(String featureCode) {
+ this.featureCode = featureCode;
+ }
+
+ public int getProfileId() {
+ return profileId;
+ }
+
+ public void setProfileId(int profileId) {
+ this.profileId = profileId;
+ }
+
+ public int getDeviceTypeId() {
+ return deviceTypeId;
+ }
+
+ public void setDeviceTypeId(int deviceTypeId) {
+ this.deviceTypeId = deviceTypeId;
+ }
+
+
+ public String getPayLoad() {
+ Gson gson = new Gson();
+ this.payLoad = gson.toJson(content);
+ return payLoad;
+ }
+
+ public void setPayLoad(String payLoad) {
+ this.payLoad = payLoad;
+ }
+
+
+ public Object getContent() {
+ return content;
+ }
+
+ public void setContent(Object content) {
+ this.content = content;
+ }
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/RoleWrapper.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/RoleWrapper.java
new file mode 100644
index 0000000000..014ecde56b
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/RoleWrapper.java
@@ -0,0 +1,59 @@
+package org.wso2.mdm.mdmmgt.beans;
+
+import org.wso2.carbon.user.mgt.common.UIPermissionNode;
+
+/*
+ * 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.
+ */
+public class RoleWrapper {
+ private String roleName;
+ private String[] permissions;
+ private String[] users;
+ private UIPermissionNode permissionList;
+
+ public String getRoleName() {
+ return roleName;
+ }
+
+ public void setRoleName(String roleName) {
+ this.roleName = roleName;
+ }
+
+ public String[] getPermissions() {
+ return permissions;
+ }
+
+ public void setPermissions(String[] permissions) {
+ this.permissions = permissions;
+ }
+
+ public String[] getUsers() {
+ return users;
+ }
+
+ public void setUsers(String[] users) {
+ this.users = users;
+ }
+
+ public UIPermissionNode getPermissionList() {
+ return permissionList;
+ }
+
+ public void setPermissionList(UIPermissionNode permissionList) {
+ this.permissionList = permissionList;
+ }
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/UserCredentialWrapper.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/UserCredentialWrapper.java
new file mode 100644
index 0000000000..87c70dd368
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/UserCredentialWrapper.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.mdm.mdmmgt.beans;
+
+public class UserCredentialWrapper {
+
+ private String username;
+ /*
+ Base64 encoded password
+ */
+ private String oldPassword;
+ private String newPassword;
+
+ public String getNewPassword() {
+ return newPassword;
+ }
+
+ public void setNewPassword(String newPassword) {
+ this.newPassword = newPassword;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getOldPassword() {
+ return oldPassword;
+ }
+
+ public void setOldPassword(String oldPassword) {
+ this.oldPassword = oldPassword;
+ }
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/UserWrapper.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/UserWrapper.java
new file mode 100644
index 0000000000..cd9705f79d
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/UserWrapper.java
@@ -0,0 +1,87 @@
+/*
+ * 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.mdm.mdmmgt.beans;
+
+public class UserWrapper {
+
+ private String username;
+ /*
+ Base64 encoded password
+ */
+ private String password;
+ private String firstname;
+ private String lastname;
+ private String emailAddress;
+ private String[] roles;
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getFirstname() {
+ return firstname;
+ }
+
+ public void setFirstname(String firstname) {
+ this.firstname = firstname;
+ }
+
+ public String getLastname() {
+ return lastname;
+ }
+
+ public void setLastname(String lastname) {
+ this.lastname = lastname;
+ }
+
+ public String getEmailAddress() {
+ return emailAddress;
+ }
+
+ public void setEmailAddress(String emailAddress) {
+ this.emailAddress = emailAddress;
+ }
+
+ /*
+ Giving a clone of the array since arrays are mutable
+ */
+ public String[] getRoles() {
+ String[] copiedRoles = roles;
+ if (roles != null) {
+ copiedRoles = roles.clone();
+ }
+ return copiedRoles;
+ }
+
+ public void setRoles(String[] roles) {
+ this.roles = roles;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/android/AppStoreApplication.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/android/AppStoreApplication.java
new file mode 100644
index 0000000000..afb46ad21f
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/android/AppStoreApplication.java
@@ -0,0 +1,52 @@
+/*
+ *
+ * Copyright (c) 2015, 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.mdm.mdmmgt.beans.android;
+
+import com.google.gson.Gson;
+import org.wso2.mdm.mdmmgt.common.MDMException;
+
+import java.io.Serializable;
+
+/**
+ * This class represents the Appstore Application information.
+ */
+public class AppStoreApplication implements Serializable {
+
+ private String type;
+ private String appIdentifier;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getAppIdentifier() {
+ return appIdentifier;
+ }
+
+ public void setAppIdentifier(String appIdentifier) {
+ this.appIdentifier = appIdentifier;
+ }
+
+ public String toJSON() throws MDMException {
+ Gson gson = new Gson();
+ return gson.toJson(this);
+ }
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/android/EnterpriseApplication.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/android/EnterpriseApplication.java
new file mode 100644
index 0000000000..5e23755c3a
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/android/EnterpriseApplication.java
@@ -0,0 +1,61 @@
+/*
+ *
+ * Copyright (c) 2015, 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.mdm.mdmmgt.beans.android;
+
+import com.google.gson.Gson;
+import org.wso2.mdm.mdmmgt.common.MDMException;
+
+import java.io.Serializable;
+
+/**
+ * This class represents the Enterprise Application information.
+ */
+public class EnterpriseApplication implements Serializable {
+
+ private String type;
+ private String url;
+ 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 getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String toJSON() throws MDMException {
+ Gson gson = new Gson();
+ return gson.toJson(this);
+ }
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/android/WebApplication.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/android/WebApplication.java
new file mode 100644
index 0000000000..58a282b5b8
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/android/WebApplication.java
@@ -0,0 +1,61 @@
+/*
+ *
+ * Copyright (c) 2015, 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.mdm.mdmmgt.beans.android;
+
+import com.google.gson.Gson;
+import org.wso2.mdm.mdmmgt.common.MDMException;
+
+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 MDMException {
+ Gson gson = new Gson();
+ return gson.toJson(this);
+ }
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/ios/AppStoreApplication.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/ios/AppStoreApplication.java
new file mode 100644
index 0000000000..e30c09b19c
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/ios/AppStoreApplication.java
@@ -0,0 +1,86 @@
+/*
+ * 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.mdm.mdmmgt.beans.ios;
+
+import com.google.gson.Gson;
+import org.wso2.mdm.mdmmgt.common.MDMException;
+
+import java.io.Serializable;
+
+public class AppStoreApplication implements Serializable {
+
+ private String identifier;
+ private int iTunesStoreID;
+ 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 int getiTunesStoreID() {
+ return iTunesStoreID;
+ }
+
+ public void setiTunesStoreID(int iTunesStoreID) {
+ this.iTunesStoreID = iTunesStoreID;
+ }
+
+ 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 MDMException {
+ Gson gson = new Gson();
+ return gson.toJson(this);
+ }
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/ios/EnterpriseApplication.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/ios/EnterpriseApplication.java
new file mode 100644
index 0000000000..dbe6d5ba77
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/ios/EnterpriseApplication.java
@@ -0,0 +1,83 @@
+/*
+ * 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.mdm.mdmmgt.beans.ios;
+
+import com.google.gson.Gson;
+import org.wso2.mdm.mdmmgt.common.MDMException;
+
+import java.io.Serializable;
+
+public class EnterpriseApplication implements Serializable {
+
+ private String identifier;
+ private String manifestURL;
+ private boolean removeAppUponMDMProfileRemoval;
+ private boolean preventBackupOfAppData;
+ private String bundleId;
+ private String UUID;
+
+ public void setUUID(String UUID) {
+ this.UUID = UUID;
+ }
+
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ public void setIdentifier(String identifier) {
+ this.identifier = identifier;
+ }
+
+ public String getManifestURL() {
+ return manifestURL;
+ }
+
+ public void setManifestURL(String manifestURL) {
+ this.manifestURL = manifestURL;
+ }
+
+ 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 MDMException {
+ Gson gson = new Gson();
+ return gson.toJson(this);
+ }
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/ios/RemoveApplication.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/ios/RemoveApplication.java
new file mode 100644
index 0000000000..3deb12c4bd
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/ios/RemoveApplication.java
@@ -0,0 +1,24 @@
+package org.wso2.mdm.mdmmgt.beans.ios;
+
+import com.google.gson.Gson;
+import org.wso2.mdm.mdmmgt.common.MDMException;
+
+import java.io.Serializable;
+
+public class RemoveApplication implements Serializable {
+
+ private String bundleId;
+
+ public String getBundleId() {
+ return bundleId;
+ }
+
+ public void setBundleId(String bundleId) {
+ this.bundleId = bundleId;
+ }
+
+ public String toJSON() throws MDMException {
+ Gson gson = new Gson();
+ return gson.toJson(this);
+ }
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/ios/WebClip.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/ios/WebClip.java
new file mode 100644
index 0000000000..1517631aab
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/beans/ios/WebClip.java
@@ -0,0 +1,59 @@
+package org.wso2.mdm.mdmmgt.beans.ios;
+
+import com.google.gson.Gson;
+import org.wso2.mdm.mdmmgt.common.MDMException;
+
+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 MDMException {
+ Gson gson = new Gson();
+ return gson.toJson(this);
+ }
+
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/common/MDMException.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/common/MDMException.java
new file mode 100644
index 0000000000..8591bfee47
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/common/MDMException.java
@@ -0,0 +1,36 @@
+package org.wso2.mdm.mdmmgt.common;
+
+
+public class MDMException extends Exception {
+
+ private static final long serialVersionUID = 5136875495185597926L;
+ private String errorMessage;
+
+
+ public MDMException(String msg, Exception e) {
+ super(msg, e);
+ setErrorMessage(msg);
+ }
+
+ public MDMException(String msg, Throwable cause) {
+ super(msg, cause);
+ setErrorMessage(msg);
+ }
+
+ public MDMException(String msg) {
+ super(msg);
+ setErrorMessage(msg);
+ }
+
+ public MDMException() {
+ super();
+ }
+
+ public MDMException(Throwable cause) {
+ super(cause);
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/util/MDMAndroidOperationUtil.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/util/MDMAndroidOperationUtil.java
new file mode 100644
index 0000000000..c486a390f8
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/util/MDMAndroidOperationUtil.java
@@ -0,0 +1,114 @@
+/*
+ * 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.mdm.mdmmgt.util;
+
+
+import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
+import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
+import org.wso2.mdm.mdmmgt.beans.MobileApp;
+import org.wso2.mdm.mdmmgt.beans.android.AppStoreApplication;
+import org.wso2.mdm.mdmmgt.beans.android.EnterpriseApplication;
+import org.wso2.mdm.mdmmgt.beans.android.WebApplication;
+import org.wso2.mdm.mdmmgt.common.MDMException;
+
+/**
+ * This class contains the all the operations related to Android.
+ */
+public class MDMAndroidOperationUtil {
+
+ /**
+ * This method is used to create Install Application operation.
+ *
+ * @param application MobileApp application
+ * @return operation
+ * @throws MDMException
+ */
+ public static Operation createInstallAppOperation(MobileApp application) throws MDMException {
+
+ 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());
+ operation.setPayLoad(enterpriseApplication.toJSON());
+ break;
+ case PUBLIC:
+ AppStoreApplication appStoreApplication = new AppStoreApplication();
+ appStoreApplication.setType(application.getType().toString());
+ appStoreApplication.setAppIdentifier(application.getIdentifier());
+ operation.setPayLoad(appStoreApplication.toJSON());
+ break;
+ case WEBAPP:
+ WebApplication webApplication = new WebApplication();
+ webApplication.setUrl(application.getLocation());
+ webApplication.setName(application.getName());
+ webApplication.setType(application.getType().toString());
+ operation.setPayLoad(webApplication.toJSON());
+ break;
+ default:
+ String errorMessage = "Invalid application type.";
+ throw new MDMException(errorMessage);
+ }
+ return operation;
+ }
+
+ /**
+ * This method is used to create Uninstall Application operation.
+ *
+ * @param application MobileApp application
+ * @return operation
+ * @throws MDMException
+ */
+ public static Operation createAppUninstallOperation(MobileApp application) throws MDMException {
+
+ 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());
+ operation.setPayLoad(enterpriseApplication.toJSON());
+ break;
+ case PUBLIC:
+ AppStoreApplication appStoreApplication = new AppStoreApplication();
+ appStoreApplication.setType(application.getType().toString());
+ appStoreApplication.setAppIdentifier(application.getIdentifier());
+ operation.setPayLoad(appStoreApplication.toJSON());
+ break;
+ case WEBAPP:
+ WebApplication webApplication = new WebApplication();
+ webApplication.setUrl(application.getLocation());
+ webApplication.setName(application.getName());
+ webApplication.setType(application.getType().toString());
+ operation.setPayLoad(webApplication.toJSON());
+ break;
+ default:
+ String errorMessage = "Invalid application type.";
+ throw new MDMException(errorMessage);
+ }
+ return operation;
+ }
+
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/util/MDMAppConstants.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/util/MDMAppConstants.java
new file mode 100644
index 0000000000..46fe591710
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/util/MDMAppConstants.java
@@ -0,0 +1,63 @@
+/*
+ *
+ * Copyright (c) 2015, 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.mdm.mdmmgt.util;
+
+/**
+ * This class holds all the constants used for IOS and Android.
+ */
+public class MDMAppConstants {
+
+ public class IOSConstants {
+
+ 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 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";
+
+ private IOSConstants() {
+ throw new AssertionError();
+ }
+ }
+
+ public class AndroidConstants {
+
+ public static final String OPCODE_INSTALL_APPLICATION = "INSTALL_APPLICATION";
+ public static final String OPCODE_UNINSTALL_APPLICATION = "UNINSTALL_APPLICATION";
+
+ private AndroidConstants() {
+ throw new AssertionError();
+ }
+ }
+
+ public class RegistryConstants {
+
+ public static final String GENERAL_CONFIG_RESOURCE_PATH = "general";
+
+ private RegistryConstants() {
+ throw new AssertionError();
+ }
+ }
+
+ public class APPManagerConstants {
+
+ private static final String APP_MANAGER_MDM_SERVICE_NAME = "org.wso2.carbon.appmgt.mobile.interfaces.MDMOperations";
+ }
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/util/MDMIOSOperationUtil.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/util/MDMIOSOperationUtil.java
new file mode 100644
index 0000000000..0f3413b44f
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/util/MDMIOSOperationUtil.java
@@ -0,0 +1,105 @@
+/*
+ *
+ * Copyright (c) 2015, 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.mdm.mdmmgt.util;
+
+import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
+import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
+import org.wso2.mdm.mdmmgt.beans.MobileApp;
+import org.wso2.mdm.mdmmgt.beans.ios.AppStoreApplication;
+import org.wso2.mdm.mdmmgt.beans.ios.EnterpriseApplication;
+import org.wso2.mdm.mdmmgt.beans.ios.RemoveApplication;
+import org.wso2.mdm.mdmmgt.beans.ios.WebClip;
+import org.wso2.mdm.mdmmgt.common.MDMException;
+
+import java.util.Properties;
+
+/**
+ * This class contains the all the operations related to IOS.
+ */
+public class MDMIOSOperationUtil {
+
+ /**
+ * This method is used to create Install Application operation.
+ *
+ * @param application MobileApp application
+ * @return operation
+ * @throws MDMException
+ */
+ public static Operation createInstallAppOperation(MobileApp application) throws MDMException {
+
+ 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) 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;
+ }
+ return operation;
+ }
+
+ public static Operation createAppUninstallOperation(MobileApp application) throws MDMException {
+
+ ProfileOperation operation = new ProfileOperation();
+ operation.setCode(MDMAppConstants.IOSConstants.OPCODE_REMOVE_APPLICATION);
+ operation.setType(Operation.Type.PROFILE);
+
+ RemoveApplication removeApplication = new RemoveApplication();
+ removeApplication.setBundleId(application.getIdentifier());
+ operation.setPayLoad(removeApplication.toJSON());
+
+ return operation;
+ }
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/util/MDMServiceAPIUtils.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/util/MDMServiceAPIUtils.java
new file mode 100644
index 0000000000..dd6082081b
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/util/MDMServiceAPIUtils.java
@@ -0,0 +1,226 @@
+/*
+ * 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.mdm.mdmmgt.util;
+
+
+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.common.DeviceIdentifier;
+import org.wso2.carbon.device.mgt.common.PaginationResult;
+import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfigurationManagementService;
+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.service.DeviceManagementProviderService;
+import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
+import org.wso2.carbon.user.api.AuthorizationManager;
+import org.wso2.carbon.user.api.UserRealm;
+import org.wso2.carbon.user.api.UserStoreException;
+import org.wso2.carbon.user.api.UserStoreManager;
+import org.wso2.carbon.user.core.service.RealmService;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
+import org.wso2.mdm.mdmmgt.common.MDMException;
+
+import java.util.List;
+
+/**
+ * MDMServiceAPIUtils class provides utility function.
+ */
+public class MDMServiceAPIUtils {
+
+ private static Log log = LogFactory.getLog(MDMServiceAPIUtils.class);
+
+ 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;
+ }
+
+ public static int getTenantId(String tenantDomain) throws MDMException {
+ PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ RealmService realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
+ try {
+ return realmService.getTenantManager().getTenantId(tenantDomain);
+ } catch (UserStoreException e) {
+ throw new MDMException(
+ "Error obtaining tenant id from tenant domain " + tenantDomain);
+ }
+ }
+
+ public static UserStoreManager getUserStoreManager(int tenantId) throws MDMException {
+ RealmService realmService;
+ UserStoreManager userStoreManager;
+ try {
+ PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ ctx.setTenantId(tenantId, true);
+ realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
+ if (realmService == null) {
+ String msg = "Realm service has not initialized.";
+ log.error(msg);
+ throw new IllegalStateException(msg);
+ }
+ userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager();
+ } catch (UserStoreException e) {
+ String msg = "Error occurred while retrieving current user store manager";
+ log.error(msg, e);
+ throw new MDMException(msg, e);
+ }
+ return userStoreManager;
+ }
+
+ /**
+ * Getting the current tenant's user realm
+ *
+ * @return
+ * @throws org.wso2.mdm.mdmmgt.common.MDMException
+ */
+ public static UserRealm getUserRealm(int tenantId) throws MDMException {
+ RealmService realmService;
+ UserRealm realm;
+ try {
+ PrivilegedCarbonContext.startTenantFlow();
+ PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ ctx.setTenantId(tenantId, true);
+ ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
+ ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
+ realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
+
+ if (realmService == null) {
+ String msg = "Realm service not initialized";
+ log.error(msg);
+ throw new MDMException(msg);
+ }
+ realm = realmService.getTenantUserRealm(tenantId);
+ } catch (UserStoreException e) {
+ String msg = "Error occurred while retrieving current user realm";
+ log.error(msg, e);
+ throw new MDMException(msg, e);
+ } finally {
+ PrivilegedCarbonContext.endTenantFlow();
+ }
+ return realm;
+ }
+
+ public static AuthorizationManager getAuthorizationManager(int tenantId) throws MDMException {
+ RealmService realmService;
+ AuthorizationManager authorizationManager;
+ try {
+ PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ ctx.setTenantId(tenantId, true);
+ realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
+ if (realmService == null) {
+ String msg = "Realm service has not initialized.";
+ log.error(msg);
+ throw new IllegalStateException(msg);
+ }
+ authorizationManager = realmService.getTenantUserRealm(tenantId).getAuthorizationManager();
+ } catch (UserStoreException e) {
+ String msg = "Error occurred while retrieving current Authorization manager.";
+ log.error(msg, e);
+ throw new MDMException(msg, e);
+ }
+ return authorizationManager;
+ }
+
+ /**
+ * This method is used to get the current tenant id.
+ *
+ * @return returns the tenant id.
+ */
+ public static int getTenantId() {
+ return CarbonContext.getThreadLocalCarbonContext().getTenantId();
+ }
+
+ public static DeviceIdentifier instantiateDeviceIdentifier(String deviceType, String deviceId) {
+ DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
+ deviceIdentifier.setType(deviceType);
+ deviceIdentifier.setId(deviceId);
+ return deviceIdentifier;
+ }
+
+ 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;
+ }
+
+ public static PolicyManagerService getPolicyManagementService(int tenantId) {
+ PolicyManagerService policyManagementService;
+ PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ ctx.setTenantId(tenantId, true);
+ policyManagementService =
+ (PolicyManagerService) ctx.getOSGiService(PolicyManagerService.class, null);
+ if (policyManagementService == null) {
+ String msg = "Policy Management service not initialized.";
+ log.error(msg);
+ throw new IllegalStateException(msg);
+ }
+ return policyManagementService;
+ }
+
+ public static TenantConfigurationManagementService getTenantConfigurationManagementService() {
+ PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ TenantConfigurationManagementService tenantConfigurationManagementService =
+ (TenantConfigurationManagementService) ctx.getOSGiService(TenantConfigurationManagementService.class, null);
+ if (tenantConfigurationManagementService == null) {
+ String msg = "Tenant configuration Management service not initialized.";
+ log.error(msg);
+ throw new IllegalStateException(msg);
+ }
+ return tenantConfigurationManagementService;
+ }
+
+ 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 PaginationResult getPagingResponse(int recordsTotal, int recordsFiltered,
+ int draw, List> data) {
+ PaginationResult pagingResponse = new PaginationResult();
+ pagingResponse.setRecordsTotal(recordsTotal);
+ pagingResponse.setRecordsFiltered(recordsFiltered);
+ pagingResponse.setDraw(draw);
+ pagingResponse.setData(data);
+ return pagingResponse;
+ }
+}
diff --git a/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/util/ResponsePayload.java b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/util/ResponsePayload.java
new file mode 100644
index 0000000000..563f454453
--- /dev/null
+++ b/components/device-mgt-mdm/org.wso2.mdm.mdmmgt/src/main/java/org/wso2/mdm/mdmmgt/util/ResponsePayload.java
@@ -0,0 +1,106 @@
+/*
+ * 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 main.java.org.wso2.mdm.mdmmgt.util;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class ResponsePayload {
+
+ private int statusCode;
+ private String messageFromServer;
+ private Object responseContent;
+
+ public static ResponsePayloadBuilder statusCode(int statusCode) {
+ ResponsePayload message = new ResponsePayload();
+ return message.getBuilder().statusCode(statusCode);
+ }
+
+ public static ResponsePayloadBuilder messageFromServer(String messageFromServer) {
+ ResponsePayload message = new ResponsePayload();
+ return message.getBuilder().messageFromServer(messageFromServer);
+ }
+
+ public static ResponsePayloadBuilder responseContent(String responseContent) {
+ ResponsePayload message = new ResponsePayload();
+ return message.getBuilder().responseContent(responseContent);
+ }
+
+ @XmlElement
+ public int getStatusCode() {
+ return statusCode;
+ }
+
+ public void setStatusCode(int statusCode) {
+ this.statusCode = statusCode;
+ }
+
+ @XmlElement
+ public String getMessageFromServer() {
+ return messageFromServer;
+ }
+
+ public void setMessageFromServer(String messageFromServer) {
+ this.messageFromServer = messageFromServer;
+ }
+
+ @XmlElement
+ public Object getResponseContent() {
+ return responseContent;
+ }
+
+ public void setResponseContent(Object responseContent) {
+ this.responseContent = responseContent;
+ }
+
+ private ResponsePayloadBuilder getBuilder() {
+ return new ResponsePayloadBuilder();
+ }
+
+ public class ResponsePayloadBuilder {
+
+ private int statusCode;
+ private String messageFromServer;
+ private Object responseContent;
+
+ public ResponsePayloadBuilder statusCode(int statusCode) {
+ this.statusCode = statusCode;
+ return this;
+ }
+
+ public ResponsePayloadBuilder messageFromServer(String messageFromServer) {
+ this.messageFromServer = messageFromServer;
+ return this;
+ }
+
+ public ResponsePayloadBuilder responseContent(String responseContent) {
+ this.responseContent = responseContent;
+ return this;
+ }
+
+ public ResponsePayload build() {
+ ResponsePayload payload = new ResponsePayload();
+ payload.setStatusCode(statusCode);
+ payload.setMessageFromServer(messageFromServer);
+ payload.setResponseContent(responseContent);
+ return payload;
+ }
+ }
+
+}
diff --git a/components/device-mgt-mdm/pom.xml b/components/device-mgt-mdm/pom.xml
index 1ef3e71390..8ab7a9e1cb 100644
--- a/components/device-mgt-mdm/pom.xml
+++ b/components/device-mgt-mdm/pom.xml
@@ -17,8 +17,8 @@
~ under the License.
-->
-
@@ -39,6 +39,8 @@
org.wso2.carbon.device.mgt.mobile
org.wso2.carbon.device.mgt.mobile.api
org.wso2.carbon.device.mgt.mobile.url.printer
+ org.wso2.mdm.appmgt
+ org.wso2.mdm.mdmmgt
diff --git a/features/device-mgt-mdm-feature/org.wso2.mdm.mdmmgt.server.feature/pom.xml b/features/device-mgt-mdm-feature/org.wso2.mdm.mdmmgt.server.feature/pom.xml
new file mode 100644
index 0000000000..05269b4767
--- /dev/null
+++ b/features/device-mgt-mdm-feature/org.wso2.mdm.mdmmgt.server.feature/pom.xml
@@ -0,0 +1,107 @@
+
+
+
+ org.wso2.carbon.devicemgt-plugins
+ device-mgt-mdm-feature
+ 1.9.2-SNAPSHOT
+ ../pom.xml
+
+ 4.0.0
+
+ org.wso2.mdm.mdmmgt.server.feature
+ 1.9.2-SNAPSHOT
+
+
+
+
+ maven-resources-plugin
+ 2.6
+
+
+ copy-resources
+ generate-resources
+
+ copy-resources
+
+
+ src/main/resources
+
+
+ resources
+
+ build.properties
+ p2.inf
+
+
+
+
+
+
+
+
+ org.wso2.maven
+ carbon-p2-plugin
+ ${carbon.p2.plugin.version}
+
+
+ p2-feature-generation
+ package
+
+ p2-feature-gen
+
+
+ org.wso2.mdm.mdmmgt.server
+ ../../../features/etc/feature.properties
+
+
+
+ org.wso2.carbon.p2.category.type:server
+
+ org.eclipse.equinox.p2.type.group:false
+
+
+
+
+
+ org.wso2.carbon.devicemgt-plugins:org.wso2.mdm.mdmmgt:${project.version}
+
+
+ org.wso2.carbon.devicemgt-plugins:org.wso2.mdm.appmgt:${project.version}
+
+
+
+
+ org.wso2.carbon.core.server:${carbon.kernel.version}
+
+
+ org.wso2.carbon.apimgt.core:${carbon.api.mgt.version}
+
+
+ org.wso2.carbon.device.mgt.extensions:${carbon.device.mgt.version}
+
+
+
+ com.google.code.gson:gson:${google.gson.version}
+
+
+ org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.common:compatible:${carbon.device.mgt.version}
+
+
+ org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.core:compatible:${carbon.device.mgt.version}
+
+
+ org.wso2.carbon.devicemgt:org.wso2.carbon.policy.mgt.core:compatible:${carbon.device.mgt.version}
+
+
+ org.wso2.carbon.appmgt:org.wso2.carbon.appmgt.mobile:compatible:${appmgt.feature.version}
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/features/device-mgt-mdm-feature/org.wso2.mdm.mdmmgt.server.feature/src/main/resources/build.properties b/features/device-mgt-mdm-feature/org.wso2.mdm.mdmmgt.server.feature/src/main/resources/build.properties
new file mode 100644
index 0000000000..9c86577d76
--- /dev/null
+++ b/features/device-mgt-mdm-feature/org.wso2.mdm.mdmmgt.server.feature/src/main/resources/build.properties
@@ -0,0 +1 @@
+custom = true
diff --git a/features/device-mgt-mdm-feature/org.wso2.mdm.mdmmgt.server.feature/src/main/resources/p2.inf b/features/device-mgt-mdm-feature/org.wso2.mdm.mdmmgt.server.feature/src/main/resources/p2.inf
new file mode 100644
index 0000000000..a828a69832
--- /dev/null
+++ b/features/device-mgt-mdm-feature/org.wso2.mdm.mdmmgt.server.feature/src/main/resources/p2.inf
@@ -0,0 +1 @@
+instructions.configure = \
diff --git a/features/device-mgt-mdm-feature/pom.xml b/features/device-mgt-mdm-feature/pom.xml
index 7c966344de..cd4d0102e7 100644
--- a/features/device-mgt-mdm-feature/pom.xml
+++ b/features/device-mgt-mdm-feature/pom.xml
@@ -17,7 +17,8 @@
~ under the License.
-->
-
@@ -36,6 +37,7 @@
org.wso2.carbon.device.mgt.mobile.feature
+ org.wso2.mdm.mdmmgt.server.feature
diff --git a/pom.xml b/pom.xml
index 763871c499..7160bbba66 100644
--- a/pom.xml
+++ b/pom.xml
@@ -18,7 +18,8 @@
-->
-
4.0.0
@@ -442,6 +443,11 @@
org.wso2.carbon.device.mgt.mobile.url.printer
${carbon.mobile.device.mgt.version}
+
+ org.wso2.carbon.devicemgt-plugins
+ org.wso2.mdm.mdmmgt
+ ${carbon.mobile.device.mgt.version}
+
@@ -902,57 +908,57 @@
org.wso2.carbon.appmgt
org.wso2.carbon.appmgt.core.feature
- ${appmgt..feature.version}
+ ${appmgt.feature.version}
org.wso2.carbon.appmgt
org.wso2.carbon.appmgt.feature
- ${appmgt..feature.version}
+ ${appmgt.feature.version}
-
+
org.wso2.carbon.appmgt
org.wso2.carbon.appmgt.mdm.wso2emm.feature
- ${appmgt..feature.version}
+ ${appmgt.feature.version}
org.wso2.carbon.appmgt
org.wso2.carbon.appmgt.mdm.wso2mdm.feature
- ${appmgt..feature.version}
+ ${appmgt.feature.version}
org.wso2.carbon.appmgt
- org.wso2.carbon.appmgt.mobile.feature
- ${appmgt..feature.version}
+ org.wso2.carbon.appmgt.mobile
+ ${appmgt.feature.version}
org.wso2.carbon.appmgt
org.wso2.carbon.appmgt.publisher.feature
- ${appmgt..feature.version}
+ ${appmgt.feature.version}
org.wso2.carbon.appmgt
org.wso2.carbon.appmgt.services.api.feature
- ${appmgt..feature.version}
+ ${appmgt.feature.version}
-
+
org.wso2.carbon.appmgt
org.wso2.carbon.appmgt.store.feature
- ${appmgt..feature.version}
+ ${appmgt.feature.version}
@@ -1100,6 +1106,10 @@
4.3.0
+
+ 1.1.1
+ 1.1.1
+
4.6.0