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 3ffc53b9e5..0000000000 --- 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 - 4.2.7-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 7300738bff..0000000000 --- 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,458 +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.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.exceptions.DeviceManagementException; -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.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 085f3a6501..0000000000 --- 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 2933669a45..0000000000 --- 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 9b1b306c03..0000000000 --- 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 d638d7b111..0000000000 --- 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 6f78eb2443..0000000000 --- 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 f8990e5856..0000000000 --- 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 08a35e08e7..0000000000 --- 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 b8e6a4e09f..0000000000 --- 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 3a09b73252..0000000000 --- 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 12a8db23ab..0000000000 --- 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 d5ae921705..0000000000 --- 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 000374c433..0000000000 --- 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 84818e4a08..0000000000 --- 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 7c1288b1ac..0000000000 --- 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 6adb9fe09d..0000000000 --- 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 5903b64843..0000000000 --- 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 9bf9822eba..0000000000 --- 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 6d622157fa..0000000000 --- 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 - 4.2.7-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 1f5399bcac..0000000000 --- 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 1721fc1a78..0000000000 --- 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 1ff87e7e67..0000000000 --- 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 f315ae116a..0000000000 --- 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 b373a1c631..0000000000 --- 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 0c34147e26..0000000000 --- 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 65f5db187c..0000000000 --- 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 15179e1a95..0000000000 --- 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 e48e8e5c1b..0000000000 --- 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 4e0d497d12..0000000000 --- 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 96af8865ab..0000000000 --- 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 6470910c2c..0000000000 --- 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 0bed67b3ac..0000000000 --- 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 66cd083049..0000000000 --- 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 18a7b853f8..0000000000 --- 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 f3127ab255..0000000000 --- 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 81e44bb2cf..0000000000 --- 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 707ef50fa6..0000000000 --- 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 15a53b7ff0..0000000000 --- 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 2c1e6b2f12..0000000000 --- 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 3851bf2ca6..0000000000 --- a/components/extensions/appm-connector/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - org.wso2.carbon.devicemgt-plugins - extensions - 4.2.7-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/pom.xml b/components/extensions/pom.xml index 1c3f6fc1f1..d90303e144 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/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml index 17088e6c4e..7f434c94b1 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml @@ -359,5 +359,10 @@ org.wso2.carbon.apimgt.application.extension provided + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.application.mgt.common + provided + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.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.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java index 40cf3c373e..d720aca405 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.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.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java @@ -57,6 +57,7 @@ import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; @@ -236,6 +237,14 @@ public class AndroidDeviceUtils { } catch (DeviceDetailsMgtException e) { throw new OperationManagementException("Error occurred while updating the device location.", e); } + } else if (AndroidConstants.OperationCodes.INSTALL_APPLICATION.equals(operation.getCode())) { + try { + updateAppSubStatus(operation.getId(), operation.getStatus().toString()); + } catch (org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException e) { + String msg = "Error occurred while updating the app subscription for device."; + log.error(msg); + throw new OperationManagementException(msg, e); + } } AndroidAPIUtils.getDeviceManagementService().updateOperation(deviceIdentifier, operation); } @@ -294,6 +303,15 @@ public class AndroidDeviceUtils { informationManager.addDeviceLocation(deviceLocation); } + private static void updateAppSubStatus(int operationId, String status) + throws org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + ApplicationManager applicationManager = + (ApplicationManager) ctx.getOSGiService(ApplicationManager.class, null); + + applicationManager.updateSubsStatus(operationId, status); + } + private static void updateDeviceInfo(DeviceIdentifier deviceId, DeviceInfo deviceInfo) throws DeviceDetailsMgtException { DeviceInformationManager informationManager = AndroidAPIUtils.getDeviceInformationManagerService(); diff --git a/components/test-coverage/pom.xml b/components/test-coverage/pom.xml index f1e07e8df7..614f5c0bb6 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 @@ -199,25 +191,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 240b4e812e..0000000000 --- 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 - 4.2.7-SNAPSHOT - ../pom.xml - - - org.wso2.carbon.appmgt.mdm.osgiconnector.feature - pom - 4.2.7-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 - 4.2.7-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 049bb4da60..0000000000 --- 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 - 4.2.7-SNAPSHOT - ../pom.xml - - - org.wso2.carbon.appmgt.mdm.restconnector.feature - pom - 4.2.7-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 - 4.2.7-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 9f74d5df81..e10a45b95e 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/pom.xml b/pom.xml index 7c3ef65a59..07a78b966b 100644 --- a/pom.xml +++ b/pom.xml @@ -567,19 +567,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} @@ -1245,10 +1235,6 @@ 3.2.7-SNAPSHOT [3.1.0, 4.0.0) - - - 1.5.5 - 4.2.7-SNAPSHOT