From 223a973cda441fe23b9e3b51f47658b65e594abe Mon Sep 17 00:00:00 2001 From: Hasunie Date: Fri, 6 Jan 2017 14:12:14 +0530 Subject: [PATCH 1/7] adding Windows 10 location support --- .../windows/api/common/PluginConstants.java | 7 ++ .../api/common/util/WindowsAPIUtils.java | 13 ++++ .../api/operations/util/OperationCode.java | 9 ++- .../api/operations/util/OperationHandler.java | 76 +++++++++++++++++-- .../api/operations/util/OperationReply.java | 22 +++++- .../device-view.js | 67 ---------------- .../enrollments/windows/agent-controller.jag | 2 +- .../enrollments/windows/agent-enroll.jag | 2 +- .../main/resources/devicetypes/windows.xml | 50 +++++++++--- 9 files changed, 155 insertions(+), 93 deletions(-) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/PluginConstants.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/PluginConstants.java index 92573902d..b44bee037 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/PluginConstants.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/PluginConstants.java @@ -218,6 +218,8 @@ public final class PluginConstants { public static final String BATTERY_CHARGE_REMAINING = "BATTERY_CHARGE_REMAINING"; public static final String BATTERY_ESTIMATED_RUNTIME = "BATTERY_ESTIMATED_RUNTIME"; public static final String MOBILE_ID = "MOBILE_ID"; + public static final String LONGITUDE = "LONGITUDE"; + public static final String LATITUDE = "LATITUDE"; } @@ -267,6 +269,11 @@ public final class PluginConstants { public static final String DEVICE_PASSWORD_STATUS = "DEVICE_PASSWORD_STATUS"; public static final String DEVICE_PASSCODE_DELETE = "DEVICE_PASSCODE_DELETE"; public static final String DEVICE_INFO = "DEVICE_INFO"; + public static final String POLICY_REVOKE = "POLICY_REVOKE"; + public static final String DEVICE_LOCATION = "DEVICE_LOCATION"; + public static final String LONGITUDE = "LONGITUDE"; + public static final String LATITUDE = "LATITUDE"; + public static final String DEVICE_REBOOT = "DEVICE_REBOOT"; } /** diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/util/WindowsAPIUtils.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/util/WindowsAPIUtils.java index 274c7ffae..dd5b435ba 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/util/WindowsAPIUtils.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/util/WindowsAPIUtils.java @@ -29,6 +29,7 @@ import org.wso2.carbon.device.mgt.common.InvalidDeviceException; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo; +import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; @@ -239,4 +240,16 @@ public class WindowsAPIUtils { (DeviceInformationManager) ctx.getOSGiService(DeviceInformationManager.class, null); informationManager.addDeviceInfo(deviceId, deviceInfo); } + + /** + * This method is used to update device location. + * @param deviceLocation Device coordination related information. + * @throws DeviceDetailsMgtException Error occurs while updating Device location. + */ + public static void updateDeviceLocation(DeviceLocation deviceLocation) throws DeviceDetailsMgtException { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + DeviceInformationManager informationManager = + (DeviceInformationManager) ctx.getOSGiService(DeviceInformationManager.class, null); + informationManager.addDeviceLocation(deviceLocation); + } } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationCode.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationCode.java index 8ba4b4416..60547fa5e 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationCode.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationCode.java @@ -43,8 +43,6 @@ public class OperationCode { ENCRYPT_STORAGE_STATUS("./Vendor/MSFT/PolicyManager/Device/Security/RequireDeviceEncryption"), DEVICE_PASSWORD_STATUS("./Vendor/MSFT/PolicyManager/Device/DeviceLock/DevicePasswordEnabled"), DEVICE_PASSCODE_DELETE("./Vendor/MSFT/PolicyManager/My/DeviceLock"), - LONGITUDE("./Vendor/MSFT/RemoteFind/Location/Longitude"), - LATITUDE("./Vendor/MSFT/RemoteFind/Location/Latitude"), // Windows10 operation codes TOTAL_RAM("./DevDetail/Ext/Microsoft/TotalRAM"), @@ -56,6 +54,8 @@ public class OperationCode { BATTERY_STATUS("./Vendor/MSFT/DeviceStatus/Battery/Status"), BATTERY_CHARGE_REMAINING("./Vendor/MSFT/DeviceStatus/Battery/EstimatedChargeRemaining"), BATTERY_ESTIMATED_RUNTIME("./Vendor/MSFT/DeviceStatus/Battery/EstimatedRuntime"), + LONGITUDE("./Vendor/MSFT/RemoteFind/Location/Longitude"), + LATITUDE("./Vendor/MSFT/RemoteFind/Location/Latitude"), TEST("./Vendor/MSFT/DiagnosticLog/EtwLog/Collectors"); private final String code; @@ -91,7 +91,10 @@ public class OperationCode { BATTERY_STATUS("./Vendor/MSFT/DeviceStatus/Battery/Status"), BATTERY_CHARGE_REMAINING("./Vendor/MSFT/DeviceStatus/Battery/EstimatedChargeRemaining"), BATTERY_ESTIMATED_RUNTIME("./Vendor/MSFT/DeviceStatus/Battery/EstimatedRuntime"), - TEST("./Vendor/MSFT/DiagnosticLog/EtwLog/Collectors"); + LONGITUDE("./Vendor/MSFT/RemoteFind/Location/Longitude"), + LATITUDE("./Vendor/MSFT/RemoteFind/Location/Latitude"), + TEST("./Vendor/MSFT/DiagnosticLog/EtwLog/Collectors"), + DEVICE_REBOOT("./Vendor/MSFT/Reboot/RebootNow"); private final String code; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationHandler.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationHandler.java index 8b0db0222..fe07b720b 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationHandler.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationHandler.java @@ -25,11 +25,13 @@ import org.json.JSONObject; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo; +import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; import org.wso2.carbon.device.mgt.common.notification.mgt.Notification; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; +import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants; import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.WindowsAPIUtils; import org.wso2.carbon.device.mgt.mobile.windows.api.services.syncml.beans.Profile; @@ -239,6 +241,33 @@ public class OperationHandler { } } + public void updateDeviceLocationStatus(SyncmlDocument syncmlDocument) throws OperationManagementException { + List pendingDataOperations; + List statuses = syncmlDocument.getBody().getStatus(); + DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject( + syncmlDocument.getHeader().getSource().getLocURI()); + try { + pendingDataOperations = WindowsAPIUtils.getPendingOperations(deviceIdentifier); + } catch (DeviceManagementException e) { + throw new OperationManagementException("Error occurred in getting pending operation."); + } + for (Operation operation : pendingDataOperations) { + if (PluginConstants.OperationCodes.DEVICE_LOCATION.equals(operation.getCode())) { + for (StatusTag statusTag : statuses) { + if (Constants.GET.equals(statusTag.getCommand()) && statusTag.getTargetReference() != null + && OperationCode.Command.LATITUDE.getCode().equals(statusTag.getTargetReference())) { + if (Constants.SyncMLResponseCodes.ACCEPTED.equals(statusTag.getData())) { + operation.setStatus(Operation.Status.COMPLETED); + } else { + operation.setStatus(Operation.Status.ERROR); + } + } + } + updateStatus(syncmlDocument.getHeader().getSource().getLocURI(), + pendingDataOperations); + } + } + } /** * Get pending operations. @@ -253,12 +282,18 @@ public class OperationHandler { SyncmlBody syncmlBody = syncmlDocument.getBody(); List pendingOperations; DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(syncmlHeader.getSource().getLocURI()); - int sessionId = syncmlHeader.getSessionId(); - int msgId = syncmlHeader.getMsgID(); - if (!(PluginConstants.SyncML.SYNCML_FIRST_MESSAGE_ID == msgId && - PluginConstants.SyncML.SYNCML_FIRST_SESSION_ID == sessionId)) { - if ((syncmlBody.getResults() != null)) { - updateDeviceInfo(syncmlDocument); + List statuses = syncmlBody.getStatus(); + for (StatusTag status : statuses ) { + if (OperationCode.Command.LATITUDE.getCode().equals(status.getTargetReference()) && + Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData())) { + updateLocation(syncmlDocument); + } + + if (OperationCode.Command.TOTAL_RAM.getCode().equals(status.getTargetReference()) && + Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData())) { + if ((syncmlBody.getResults() != null)) { + updateDeviceInfo(syncmlDocument); + } } } UpdateUriOperations(syncmlDocument); @@ -568,4 +603,33 @@ public class OperationHandler { throw new WindowsOperationException("Error occurred while updating Device info operation status."); } } + + private void updateLocation(SyncmlDocument syncmlDocument) throws WindowsOperationException { + List deviceInformations = syncmlDocument.getBody().getResults().getItem(); + DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject( + syncmlDocument.getHeader().getSource().getLocURI()); + + DeviceLocation deviceLocation = new DeviceLocation(); + deviceLocation.setDeviceIdentifier(deviceIdentifier); + for (ItemTag item : deviceInformations) { + String source = item.getSource().getLocURI(); + if (OperationCode.Info.LONGITUDE.getCode().equals(source)) { + String longitude = item.getData(); + deviceLocation.setLongitude(Double.parseDouble(longitude)); + } + if (OperationCode.Info.LATITUDE.getCode().equals(source)) { + Double latitude = Double.parseDouble(item.getData()); + deviceLocation.setLatitude(latitude); + } + } + try { + WindowsAPIUtils.updateDeviceLocation(deviceLocation); + updateDeviceLocationStatus(syncmlDocument); + } catch (DeviceDetailsMgtException e) { + throw new WindowsOperationException("Error occurred while updating Device Location."); + } catch (OperationManagementException e) { + throw new WindowsOperationException("Error occurred while updating Device Location operation status."); + } + + } } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationReply.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationReply.java index 658e7dc13..c4f28cb40 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationReply.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationReply.java @@ -240,7 +240,6 @@ public class OperationReply { List replaceItems = new ArrayList<>(); SequenceTag monitorSequence = new SequenceTag(); List deviceInfoOperations; - if (operations != null) { for (Operation operation : operations) { Operation.Type type = operation.getType(); @@ -293,6 +292,23 @@ public class OperationReply { SequenceTag sequence = buildSequence(operation, sequenceElement); syncmlBody.setSequence(sequence); } + if (PluginConstants.OperationCodes.DEVICE_LOCATION.equals(operation.getCode())) { + Operation longitudeOperation = new Operation(); + Operation latitudeOperation = new Operation(); + longitudeOperation.setCode(PluginConstants.OperationCodes.LONGITUDE); + latitudeOperation.setCode(PluginConstants.OperationCodes.LATITUDE); + List deviceLocationOperations = new ArrayList<>(); + deviceLocationOperations.add(latitudeOperation); + deviceLocationOperations.add(longitudeOperation); + for (Operation infoOperation : deviceLocationOperations) { + ItemTag deviceInfo = appendGetInfo(infoOperation); + getElements.add(deviceInfo); + } + } + if (PluginConstants.OperationCodes.DEVICE_REBOOT.equals(operation.getCode())) { + execElement = executeCommand(operation); + executeElements.add(execElement); + } if ((PluginConstants.OperationCodes.MONITOR.equals(operation.getCode()))) { GetTag monitorGetElement = new GetTag(); List monitorItems; @@ -561,8 +577,7 @@ public class OperationReply { return execElement; } - public SequenceTag buildSequence(Operation operation, SequenceTag sequenceElement) throws - JSONException, + public SequenceTag buildSequence(Operation operation, SequenceTag sequenceElement) throws JSONException, SyncmlOperationException { sequenceElement.setCommandId(operation.getId()); @@ -580,7 +595,6 @@ public class OperationReply { sequenceElement.setExec(execElement); sequenceElement.setGet(getElements); return sequenceElement; - } else if ((PluginConstants.OperationCodes.POLICY_BUNDLE.equals(operation.getCode()))) { List policyOperations; try { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.device-view/device-view.js b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.device-view/device-view.js index d1de7c960..c5e0619f7 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.device-view/device-view.js +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.device-view/device-view.js @@ -62,73 +62,6 @@ function onRequest(context) { viewModel["ownership"] = filteredDeviceData["enrolmentInfo"]["ownership"]; } } - if (filteredDeviceData["initialDeviceInfo"]) { - viewModel["deviceInfoAvailable"] = true; - if (filteredDeviceData["initialDeviceInfo"]["IMEI"]) { - viewModel["imei"] = filteredDeviceData["initialDeviceInfo"]["IMEI"]; - } - if (!filteredDeviceData["latestDeviceInfo"]) { - if (filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"]) { - if (filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"] != "0") { - viewModel["osBuildDate"] = new Date(filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"] * 1000); - } - } - if (filteredDeviceData["initialDeviceInfo"]["LATITUDE"] && filteredDeviceData["initialDeviceInfo"]["LONGITUDE"]) { - viewModel["location"] = {}; - viewModel["location"]["latitude"] = filteredDeviceData["initialDeviceInfo"]["LATITUDE"]; - viewModel["location"]["longitude"] = filteredDeviceData["initialDeviceInfo"]["LONGITUDE"]; - } - if (filteredDeviceData["initialDeviceInfo"]["VENDOR"] && filteredDeviceData["initialDeviceInfo"]["DEVICE_MODEL"]) { - viewModel["vendor"] = filteredDeviceData["initialDeviceInfo"]["VENDOR"]; - viewModel["model"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_MODEL"]; - } - if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]) { - if (deviceType == "android") { - viewModel["BatteryLevel"] = {}; - viewModel["BatteryLevel"]["value"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["BATTERY_LEVEL"]; - - viewModel["internalMemory"] = {}; - viewModel["internalMemory"]["total"] = Math. - round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] * 100) / 100; - if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] != 0) { - viewModel["internalMemory"]["usage"] = Math. - round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] - - filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_AVAILABLE_MEMORY"]) - / filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] * 10000) / 100; - } else { - viewModel["internalMemory"]["usage"] = 0; - } - - viewModel["externalMemory"] = {}; - viewModel["externalMemory"]["total"] = Math. - round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] * 100) / 100; - if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] != 0) { - viewModel["externalMemory"]["usage"] = Math. - round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] - - filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_AVAILABLE_MEMORY"]) - / filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] * 10000) / 100; - } else { - viewModel["externalMemory"]["usage"] = 0; - } - } else if (deviceType == "ios") { - viewModel["BatteryLevel"] = {}; - viewModel["BatteryLevel"]["value"] = Math. round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["BatteryLevel"] * 10000) / 100; - - viewModel["internalMemory"] = {}; - viewModel["internalMemory"]["total"] = Math. - round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] * 100) / 100; - if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] != 0) { - viewModel["internalMemory"]["usage"] = Math. - round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] - - filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["AvailableDeviceCapacity"]) - / filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] * 10000) / 100; - } else { - viewModel["internalMemory"]["usage"] = 0; - } - } - } - } - } if (filteredDeviceData["latestDeviceInfo"]) { viewModel["deviceInfoAvailable"] = true; if (filteredDeviceData["latestDeviceInfo"]["osBuildDate"]) { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/enrollments/windows/agent-controller.jag b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/enrollments/windows/agent-controller.jag index c5740cd40..1cf29bb0e 100755 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/enrollments/windows/agent-controller.jag +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/enrollments/windows/agent-controller.jag @@ -32,7 +32,7 @@ parser.getResult(); var os = parser.getOS(); var platform = os.name; -if (platform != "Windows Phone") { +if (platform != "Windows Phone" && platform != "Windows") { response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); } else if (session.get("lastAccessedPage") != "login-agent") { response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/enrollments/windows/agent-enroll.jag b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/enrollments/windows/agent-enroll.jag index 66a4eed09..92687fcff 100755 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/enrollments/windows/agent-enroll.jag +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/enrollments/windows/agent-enroll.jag @@ -27,7 +27,7 @@ parser.getResult(); var os = parser.getOS(); var platform = os.name; -if (platform != "Windows Phone") { +if (platform != "Windows Phone" && platform != "Windows") { response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); } else if (session.get("lastAccessedPage") != "license-agent") { response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/devicetypes/windows.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/devicetypes/windows.xml index 1313b6867..2872f0e7a 100644 --- a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/devicetypes/windows.xml +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/devicetypes/windows.xml @@ -24,11 +24,27 @@ en_US 1.0.0 - This End User License Agreement ("Agreement") is a legal agreement between you ("You") and WSO2, Inc., regarding the enrollment of Your personal mobile device ("Device") in SoR's mobile device management program, and the loading to and removal from Your Device and Your use of certain applications and any associated software and user documentation, whether provided in "online" or electronic format, used in connection with the operation of or provision of services to WSO2, Inc., BY SELECTING "I ACCEPT" DURING INSTALLATION, YOU ARE ENROLLING YOUR DEVICE, AND THEREBY AUTHORIZING SOR OR ITS AGENTS TO INSTALL, UPDATE AND REMOVE THE APPS FROM YOUR DEVICE AS DESCRIBED IN THIS AGREEMENT. YOU ARE ALSO EXPLICITLY ACKNOWLEDGING AND AGREEING THAT (1) THIS IS A BINDING CONTRACT AND (2) YOU HAVE READ AND AGREE TO THE TERMS OF THIS AGREEMENT. + This End User License Agreement ("Agreement") is a legal agreement between you ("You") and WSO2, Inc., + regarding the enrollment of Your personal mobile device ("Device") in SoR's mobile device management + program, and the loading to and removal from Your Device and Your use of certain applications and any + associated software and user documentation, whether provided in "online" or electronic format, used in + connection with the operation of or provision of services to WSO2, Inc., + BY SELECTING "I ACCEPT" DURING INSTALLATION, YOU ARE ENROLLING YOUR DEVICE, + AND THEREBY AUTHORIZING SOR OR ITS AGENTS TO INSTALL, UPDATE AND REMOVE THE APPS FROM YOUR DEVICE AS + DESCRIBED IN THIS AGREEMENT. YOU ARE ALSO EXPLICITLY ACKNOWLEDGING AND AGREEING THAT (1) + THIS IS A BINDING CONTRACT AND (2) YOU HAVE READ AND AGREE TO THE TERMS OF THIS AGREEMENT. IF YOU DO NOT ACCEPT THESE TERMS, DO NOT ENROLL YOUR DEVICE AND DO NOT PROCEED ANY FURTHER. - You agree that: (1) You understand and agree to be bound by the terms and conditions contained in this Agreement, and (2) You are at least 21 years old and have the legal capacity to enter into this Agreement as defined by the laws of Your jurisdiction. SoR shall have the right, without prior notice, to terminate or suspend (i) this Agreement, (ii) the enrollment of Your Device, or (iii) the functioning of the Apps in the event of a violation of this Agreement or the cessation of Your relationship with SoR (including termination of Your employment if You are an employee or expiration or termination of Your applicable franchise or supply agreement if You are a franchisee of or supplier to the WSO2 WSO2, Inc., system). SoR expressly reserves all rights not expressly granted herein. + You agree that: (1) You understand and agree to be bound by the terms and conditions + contained in this Agreement, and (2) You are at least 21 years old and have the legal capacity to enter + into this Agreement as defined by the laws of Your jurisdiction. SoR shall have the right, + without prior notice, to terminate or suspend (i) this Agreement, (ii) the enrollment of + Your Device, or (iii) the functioning of the Apps in the event of a violation of this Agreement or + the cessation of Your relationship with SoR (including termination of Your employment + if You are an employee or expiration or termination of Your applicable franchise or supply agreement + if You are a franchisee of or supplier to the WSO2 WSO2, Inc., system). SoR expressly + reserves all rights not expressly granted herein. @@ -64,32 +80,44 @@ Disenroll - Lock the device - + Dis-enrol the device + Wipe Data - Lock the device - + Wipe the device + Ring - Lock the device - + Ring the device + Device Lock Lock the device - + Device Lock Reset - Lock the device - + Lock Reset the device + + + + + Location + Request coordinates of device location + From 0a5cafd6ef5605a92b0e244855bd035b3e3fdb30 Mon Sep 17 00:00:00 2001 From: Hasunie Date: Fri, 6 Jan 2017 14:14:25 +0530 Subject: [PATCH 2/7] fixing windows device view --- .../cdmf.unit.device.type.windows.device-view/device-view.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.device-view/device-view.hbs b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.device-view/device-view.hbs index 6030939ef..cb00b423a 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.device-view/device-view.hbs +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.device-view/device-view.hbs @@ -1,6 +1,6 @@ {{unit "cdmf.unit.device.type.windows.leaflet"}} {{unit "cdmf.unit.lib.qrcode"}} -{{unit "cdmf.unit.device.type.windows.qr-modal"}} +{{unit "cdmf.unit.device.type.qr-modal"}} {{#if deviceFound}} {{#if isAuthorized}} From d7b94a7f0797cbd93c6de8311d92084e50bc82fa Mon Sep 17 00:00:00 2001 From: Hasunie Date: Fri, 6 Jan 2017 14:18:20 +0530 Subject: [PATCH 3/7] adding location,reboot operation icons --- .../public/js/operation-mod.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-mod/public/js/operation-mod.js b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-mod/public/js/operation-mod.js index 3d35bd67d..b064ef186 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-mod/public/js/operation-mod.js +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-mod/public/js/operation-mod.js @@ -143,9 +143,10 @@ var windowsOperationModule = function () { "DISENROLL": "disenroll", "DEVICE_RING": "ring-device", "LOCK_RESET": "lock-reset", - "WIPE_DATA": "wipe-data" + "WIPE_DATA": "wipe-data", + "DEVICE_LOCATION": "location", + "DEVICE_REBOOT": "reboot" }; - //return "/mdm-windows-agent/services/windows/operation/" + featureMap[operationCode]; return "/api/device-mgt/windows/v1.0/operation/admin/devices/" + featureMap[operationCode]; }; @@ -160,7 +161,9 @@ var windowsOperationModule = function () { "DEVICE_RING": "fw-dial-up", "DISENROLL": "fw-export", "LOCK_RESET": "fw-key", - "WIPE_DATA": "fw-delete" + "WIPE_DATA": "fw-delete", + "DEVICE_LOCATION": "location", + "DEVICE_REBOOT": "fw-refresh" }; return featureMap[operationCode]; }; From 32d603c8f6e2de6bb57b6285e65aaed00e766a98 Mon Sep 17 00:00:00 2001 From: Hasunie Date: Fri, 6 Jan 2017 14:56:57 +0530 Subject: [PATCH 4/7] updating API context and publish names --- .../api/services/ConfigurationMgtService.java | 4 +- .../DeviceManagementAdminService.java | 649 +++++++++++------- .../api/services/DeviceManagementService.java | 12 +- .../api/services/authbst/BSTProvider.java | 6 +- .../services/discovery/DiscoveryService.java | 56 +- .../discovery/impl/DiscoveryServiceImpl.java | 15 - .../enrollment/EnrollmentService.java | 75 ++ .../enrollment/beans/ContextItem.java | 5 +- .../DeviceManagementAdminServiceImpl.java | 68 ++ .../api/services/syncml/SyncmlService.java | 8 +- .../syncml/impl/SyncmlServiceImpl.java | 1 - .../wstep/CertificateEnrollmentService.java | 4 +- .../CertificateEnrollmentPolicyService.java | 6 +- 13 files changed, 558 insertions(+), 351 deletions(-) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java index 1796a637c..4d57e80a3 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java @@ -59,11 +59,11 @@ import javax.ws.rs.core.Response; } ), tags = { - @Tag(name = "devicemgt_windows", description = "") + @Tag(name = "windows", description = "") } ) @Api(value = "Windows Configuration Management", - description = "This carries all the resources related to Windows configurations management functionalities") + description = "This carries all the resources related to Windows configurations management functionality") @WebService @Path("/configuration") @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java index 0b1b0995c..0652953f4 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java @@ -52,7 +52,7 @@ import java.util.List; } ), tags = { - @Tag(name = "devicemgt_windows", description = "") + @Tag(name = "windows", description = "") } ) @Api(value = "Windows Device Management Administrative Service", @@ -63,277 +63,407 @@ import java.util.List; @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public interface DeviceManagementAdminService { - @POST - @Path("/lock-devices") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Adding a Device Lock on Windows devices.", - notes = "Using this API you have the option of Device Windows device.", - response = Activity.class, - tags = "Windows Device Management Administrative Service", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/windows/lock", - description = "Lock Device")} - ) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the device lock operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified. \n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while locking the device.") - }) - Response lock(@HeaderParam("Accept") String headerParam, @ApiParam( - name = "deviceIDs", - value = "Provide the ID of the AWindows device. Multiple device IDs can be added by " + - "using comma separated values. ", - required = true) List deviceIds) throws WindowsDeviceEnrolmentException; + @POST + @Path("/lock-devices") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Adding a Device Lock on Windows devices.", + notes = "Using this API you have the option of Device Windows device.", + response = Activity.class, + tags = "Windows Device Management Administrative Service", + authorizations = { + @Authorization( + value = "permission", + scopes = {@AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/windows/lock", + description = "Lock Device")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Successfully scheduled the device lock operation.", + response = Activity.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified. \n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while locking the device.") + }) + Response lock(@HeaderParam("Accept") String headerParam, @ApiParam( + name = "deviceIDs", + value = "Provide the ID of the AWindows device. Multiple device IDs can be added by " + + "using comma separated values. ", + required = true) List deviceIds) throws WindowsDeviceEnrolmentException; - @POST - @Path("/disenroll-devices") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Dis-enrol the windows Devices", - notes = "Dis-enroll on Android devices", - response = Activity.class, - tags = "Windows Device Management Administrative Service.", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope( - scope = "/device-mgt/devices/disenroll/windows", - description = "Dis-enroll the windows devices ")} - ) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the Dis-enroll operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified the last time.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding a Dis-enroll operation.") - }) - Response disenroll(@HeaderParam("Accept") String headerParam, @ApiParam( - name = "deviceIDs", - value = "Provide the ID of the A Windows device. Multiple device IDs can be added by " + - "using comma separated values. ", - required = true) List deviceIds) throws WindowsDeviceEnrolmentException; + @POST + @Path("/disenroll-devices") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Dis-enrol the windows Devices", + notes = "Dis-enroll on Android devices", + response = Activity.class, + tags = "Windows Device Management Administrative Service.", + authorizations = { + @Authorization( + value = "permission", + scopes = {@AuthorizationScope( + scope = "/device-mgt/devices/disenroll/windows", + description = "Dis-enroll the windows devices ")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Successfully scheduled the Dis-enroll operation.", + response = Activity.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified the last time.\n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while adding a Dis-enroll operation.") + }) + Response disenroll(@HeaderParam("Accept") String headerParam, @ApiParam( + name = "deviceIDs", + value = "Provide the ID of the A Windows device. Multiple device IDs can be added by " + + "using comma separated values. ", + required = true) List deviceIds) throws WindowsDeviceEnrolmentException; - @POST - @Path("/wipe-devices") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Factory Resetting an Windows Device", - notes = "Factory rest or erase all the data stored on the Windows devices" + - "to restore them back to the original system.", - response = Activity.class, - tags = "Windows Device Management Administrative Service", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/windows/wipe", - description = "DeviceWipe")} - ) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the Data wipe operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified." + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding the Data wipe operation.")}) - Response wipe(@HeaderParam("Accept") String headerParam, @ApiParam( - name = "deviceIDs", - value = "Provide the ID of the A Windows device. Multiple device IDs can be added by " + - "using comma separated values. ", - required = true) List deviceIds) throws WindowsDeviceEnrolmentException; + @POST + @Path("/wipe-devices") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + produces = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Factory Resetting an Windows Device", + notes = "Factory rest or erase all the data stored on the Windows devices" + + "to restore them back to the original system.", + response = Activity.class, + tags = "Windows Device Management Administrative Service", + authorizations = { + @Authorization( + value = "permission", + scopes = {@AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/windows/wipe", + description = "DeviceWipe")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Successfully scheduled the Data wipe operation.", + response = Activity.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified." + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while adding the Data wipe operation.")}) + Response wipe(@HeaderParam("Accept") String headerParam, @ApiParam( + name = "deviceIDs", + value = "Provide the ID of the A Windows device. Multiple device IDs can be added by " + + "using comma separated values. ", + required = true) List deviceIds) throws WindowsDeviceEnrolmentException; - @POST - @Path("/ring-devices") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Ringing Windows Devices", - notes = "Ring Windows devices.", - response = Activity.class, - tags = "Windows Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/windows/ring", - description = "Ring Device") } - ) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the device ring operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding a new device ring operation.") - }) - Response ring(@HeaderParam("Accept") String headerParam, @ApiParam( - name = "deviceIDs", - value = "Provide the ID of the A Windows device. Multiple device IDs can be added by " + - "using comma separated values. ", - required = true) List deviceIds) throws WindowsDeviceEnrolmentException; + @POST + @Path("/ring-devices") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Ringing Windows Devices", + notes = "Ring Windows devices.", + response = Activity.class, + tags = "Windows Device Management Administrative Service", + authorizations = { + @Authorization( + value = "permission", + scopes = {@AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/windows/ring", + description = "Ring Device")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Successfully scheduled the device ring operation.", + response = Activity.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified.\n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while adding a new device ring operation.") + }) + Response ring(@HeaderParam("Accept") String headerParam, @ApiParam( + name = "deviceIDs", + value = "Provide the ID of the A Windows device. Multiple device IDs can be added by " + + "using comma separated values. ", + required = true) List deviceIds) throws WindowsDeviceEnrolmentException; + + @POST + @Path("/lock-reset-devices") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Lock reset on Windows devices", + notes = "Lock reset on Windows devices.Its use to reset the device pass code", + response = Activity.class, + tags = "Windows Device Management Administrative Service", + authorizations = { + @Authorization( + value = "permission", + scopes = {@AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/windows/lock-reset", + description = "Lock reset")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Successfully scheduled the lock-reset operation.", + response = Activity.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified.\n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while adding adding a lock-reset operation.") + }) + Response lockReset(@HeaderParam("Accept") String acceptHeader, @ApiParam( + name = "deviceIDs", + value = "Provide the ID of the A Windows device. Multiple device IDs can be added by " + + "using comma separated values. ", + required = true) List deviceIds) throws WindowsDeviceEnrolmentException; + + @POST + @Path("/location") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Requesting Location Coordinates", + responseContainer = "List", + notes = "Request location coordinates of Windows devices. \n" + + "Example: In situations where you have lost your device and need to find out where it is, " + + "you can use this REST API to get the location of the device.", + response = Activity.class, + tags = "Windows Device Management Administrative Service", + authorizations = { + @Authorization( + value = "permission", + scopes = {@AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/windows/location", + description = "Get Device Location")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Get-location operation has successfully been scheduled", + response = Activity.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the " + + "scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified.\n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the" + + " location header.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while adding a new get-location operation.")}) + Response getDeviceLocation( + @ApiParam( + name = "deviceIDs", + value = "Provide the ID of the Windows device. Multiple device IDs can be added by " + + "using comma separated values. ", + required = true) + List deviceIDs); @POST - @Path("/lock-reset-devices") + @Path("/reboot") @ApiOperation( consumes = MediaType.APPLICATION_JSON, httpMethod = "POST", - value = "Lock reset on Windows devices", - notes = "Lock reset on Windows devices.Its use to reset the device pass code", + value = "Rebooting Windows Devices", + notes = "Reboot or restart your Windows devices.", response = Activity.class, tags = "Windows Device Management Administrative Service", authorizations = { @Authorization( value="permission", scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/windows/lock-reset", - description = "Lock reset") } + scope = "/device-mgt/devices/owning-device/operations/windows/reboot", + description = "Reboot Device") } ) } ) @ApiResponses(value = { @ApiResponse( code = 201, - message = "Created. \n Successfully scheduled the lock-reset operation.", + message = "Created. \n Successfully scheduled the device reboot operation.", response = Activity.class, responseHeaders = { @ResponseHeader( @@ -362,15 +492,16 @@ public interface DeviceManagementAdminService { message = "Bad Request. \n Invalid request or validation error."), @ApiResponse( code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), + message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), @ApiResponse( code = 500, message = "Internal Server Error. \n " + - "Server error occurred while adding adding a lock-reset operation.") + "Server error occurred while adding the new device reboot operation.") }) - Response lockReset(@HeaderParam("Accept") String acceptHeader, @ApiParam( - name = "deviceIDs", - value = "Provide the ID of the A Windows device. Multiple device IDs can be added by " + - "using comma separated values. ", - required = true) List deviceIds) throws WindowsDeviceEnrolmentException; + Response rebootDevice( + @ApiParam( + name = "deviceIDs", + value = "Provide the ID of the Android device. Multiple device IDs can be added using comma separated values. ", + required = true) + List deviceIDs); } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java index 2b3dd6ae6..7a08827df 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java @@ -36,7 +36,7 @@ import javax.ws.rs.core.Response; /** - * Interface for Syncml message flow. + * Interface for Windows 10 Device management phase. */ @SwaggerDefinition( info = @Info( @@ -44,18 +44,18 @@ import javax.ws.rs.core.Response; title = "", extensions = { @Extension(properties = { - @ExtensionProperty(name = "name", value = "Syncml Endpoint"), + @ExtensionProperty(name = "name", value = "Windows 10 Device management"), @ExtensionProperty(name = "context", - value = "/api/device-mgt/windows/v1.0/syncmlmgt"), + value = "/api/device-mgt/windows/v1.0/management"), }) } ), tags = { - @Tag(name = "devicemgt_windows", description = "") + @Tag(name = "windows", description = "") } ) -@Api(value = "Windows syncml service to initialize management session", - description = "This carries all the resources related to Windows syncml message flow.") +@Api(value = "Windows 10 Device management", + description = "This carries all the resources related to Windows 10 management session message flow.") @Path("/devicemgt") public interface DeviceManagementService { @Path("/pending-operations") diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/authbst/BSTProvider.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/authbst/BSTProvider.java index 1cea655c4..fd2478668 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/authbst/BSTProvider.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/authbst/BSTProvider.java @@ -41,17 +41,17 @@ import javax.ws.rs.core.Response; title = "", extensions = { @Extension(properties = { - @ExtensionProperty(name = "name", value = "Windows Binary security token provider"), + @ExtensionProperty(name = "name", value = "Windows Binary Security Token Service"), @ExtensionProperty(name = "context", value = "/api/device-mgt/windows/v1.0/federated"), }) } ), tags = { - @Tag(name = "devicemgt_windows", description = "") + @Tag(name = "windows", description = "") } ) -@Api(value = "Windows BST Management", +@Api(value = "Windows Binary Security Token Service", description = "This carries all the resources related to Windows Binary security token management.") @WebService @Path("/bst") diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/DiscoveryService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/DiscoveryService.java index 460f11f40..db9a8125d 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/DiscoveryService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/DiscoveryService.java @@ -48,17 +48,17 @@ import javax.xml.ws.soap.SOAPBinding; title = "", extensions = { @Extension(properties = { - @ExtensionProperty(name = "name", value = "Windows Discovery service provider"), + @ExtensionProperty(name = "name", value = "Windows Discovery Service"), @ExtensionProperty(name = "context", value = "/api/device-mgt/windows/v1.0/discovery/post"), }) } ), tags = { - @Tag(name = "devicemgt_windows", description = "") + @Tag(name = "windows", description = "") } ) -@Api(value = "Windows Discovery service", +@Api(value = "Windows Discovery Service", description = "This carries all the resources related to Windows Discovery service.") @WebService(targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE, name = "IDiscoveryService") @@ -133,54 +133,4 @@ public interface DiscoveryService { javax.xml.ws.Holder response ) throws WindowsDeviceEnrolmentException; - - @ApiOperation( - httpMethod = "GET", - value = "Device ping the server to check whether it is running or not.", - notes = ".", - tags = "Windows Discovery service.", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope(scope = "/device-mgt/devices/enroll/windows", - description = "Ping the Discovery service")} - ) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Server is already running."), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified " + - "in the location header.", - responseHeaders = { - @ResponseHeader(name = "Content-Location", - description = "Source URL of the document.") - }), - @ApiResponse( - code = 304, - message = "Not Modified. \n " + - "Empty body because the client already has the latest version of " + - "the requested resource."), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error. You must provide" + - " the device identifier. Additionally, the device identifier can be combined" + - " with either the device type" + - " OR the from and to date."), - @ApiResponse( - code = 404, - message = "Not Found. \n The specified resource does not exist."), - @ApiResponse( - code = 500, - message = "Error occurred while pinging the server.") - }) - @GET - @WebMethod - @WebResult() - Response discoverGet(); - } \ No newline at end of file diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/impl/DiscoveryServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/impl/DiscoveryServiceImpl.java index 6b7d57fac..08e69af07 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/impl/DiscoveryServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/impl/DiscoveryServiceImpl.java @@ -101,21 +101,6 @@ public class DiscoveryServiceImpl implements DiscoveryService { } } - /** - * This is the first method called through device. The device checks the availability of the - * Service end point by calling this method. - * - * @return - HTTP 200OK message - */ - @Override - public Response discoverGet() { - - if (log.isDebugEnabled()) { - log.debug("Discovery service end point was triggered via GET method."); - } - return Response.ok().build(); - } - /** * Get authentication policy from the tenant configuration, otherwise set default value as Federated. * diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/EnrollmentService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/EnrollmentService.java index 74390a031..42af80541 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/EnrollmentService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/EnrollmentService.java @@ -18,6 +18,7 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services.enrollment; +import io.swagger.annotations.*; import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WAPProvisioningException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; @@ -27,12 +28,32 @@ import org.wso2.carbon.device.mgt.mobile.windows.api.services.enrollment.beans.R import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; +import javax.ws.rs.POST; import javax.xml.ws.BindingType; import javax.xml.ws.RequestWrapper; import javax.xml.ws.ResponseWrapper; import javax.xml.ws.soap.SOAPBinding; import java.io.UnsupportedEncodingException; +@SwaggerDefinition( + info = @Info( + version = "1.0.0", + title = "", + extensions = { + @io.swagger.annotations.Extension(properties = { + @ExtensionProperty(name = "name", value = "Windows 10 Enrollment Service"), + @ExtensionProperty(name = "context", + value = "/api/device-mgt/windows/v1.0/deviceenrolment/enrollment"), + }) + } + ), + tags = { + @Tag(name = "windows", description = "") + } +) +@Api(value = "Windows 10 Enrollment Service", + description = "This carries all the resources related to Windows enrollment.") + @WebService(targetNamespace = PluginConstants.DEVICE_ENROLLMENT_SERVICE_TARGET_NAMESPACE, name = "enrollment") @BindingType(value = SOAPBinding.SOAP12HTTP_BINDING) public interface EnrollmentService { @@ -42,6 +63,60 @@ public interface EnrollmentService { @WebMethod(operationName = "RequestSecurityToken") @ResponseWrapper(localName = "RequestSecurityTokenResponseCollection", targetNamespace = PluginConstants.WS_TRUST_TARGET_NAMESPACE) + @POST + @ApiOperation( + httpMethod = "POST", + value = "Signing the certificate signing request(CSR) and provide request security token response.", + notes = "Using this API to fetching more information to enroll the Device and " + + "getting pending operations.", + tags = "Windows 10 Device Enrollment Service.", + authorizations = { + @Authorization( + value = "permission", + scopes = {@AuthorizationScope( + scope = "/device-mgt/devices/enroll/windows", + description = "Signing the certificate signing request(CSR) " + + "and provide request security token response")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 200, + message = "Ok.Successfully signed the CSR.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified. \n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while Signing the CSR.") + }) void requestSecurityToken( @WebParam(name = "TokenType", targetNamespace = PluginConstants.WS_TRUST_TARGET_NAMESPACE) String tokenType, diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/beans/ContextItem.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/beans/ContextItem.java index bbbdbd09c..dbc690aa4 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/beans/ContextItem.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/beans/ContextItem.java @@ -25,9 +25,8 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "ContextItem", namespace = PluginConstants.SOAP_AUTHORIZATION_TARGET_NAMESPACE, - propOrder = {"Name" , "Value"}) +@XmlAccessorType(XmlAccessType.PROPERTY) +@XmlType(name = "ContextItem", namespace = PluginConstants.SOAP_AUTHORIZATION_TARGET_NAMESPACE) public class ContextItem { @XmlElement(required = true, namespace = PluginConstants.SOAP_AUTHORIZATION_TARGET_NAMESPACE) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/impl/DeviceManagementAdminServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/impl/DeviceManagementAdminServiceImpl.java index 1bcd6da0a..56e933496 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/impl/DeviceManagementAdminServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/impl/DeviceManagementAdminServiceImpl.java @@ -19,6 +19,7 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services.impl; import com.ibm.wsdl.OperationImpl; +import io.swagger.annotations.ApiParam; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceManagementException; @@ -29,6 +30,7 @@ import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants; import org.wso2.carbon.device.mgt.mobile.windows.api.common.beans.ErrorResponse; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.BadRequestException; +import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.UnexpectedServerErrorException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsOperationsException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.Message; @@ -268,4 +270,70 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); } } + + @POST + @Path("/location") + public Response getDeviceLocation(@ApiParam( + name = "deviceIDs", + value = "Provide the ID of the Windows device. Multiple device IDs can be added by " + + "using comma separated values. ", + required = true) List deviceIDs) { + if (log.isDebugEnabled()) { + log.debug("Invoking Windows device location operation."); + } + try { + CommandOperation operation = new CommandOperation(); + operation.setCode(PluginConstants.OperationCodes.DEVICE_LOCATION); + operation.setType(Operation.Type.COMMAND); + return WindowsAPIUtils.getOperationResponse(deviceIDs, operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException( + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + throw new UnexpectedServerErrorException( + new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); + } catch (DeviceManagementException e) { + String errorMessage = "Issue in retrieving device management service instance"; + log.error(errorMessage, e); + throw new UnexpectedServerErrorException( + new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); + } + } + + @POST + @Path("/reboot") + public Response rebootDevice(@ApiParam( + name = "deviceIDs", + value = "Provide the ID of the Windows device. Multiple device IDs can be " + + "added using comma separated values.", + required = true) List deviceIDs) { + if (log.isDebugEnabled()) { + log.debug("Invoking Windows reboot-device device operation"); + } + try { + CommandOperation operation = new CommandOperation(); + operation.setCode(PluginConstants.OperationCodes.DEVICE_REBOOT); + operation.setType(Operation.Type.COMMAND); + return WindowsAPIUtils.getOperationResponse(deviceIDs, operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException( + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + throw new UnexpectedServerErrorException( + new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); + } catch (DeviceManagementException e) { + String errorMessage = "Issue in retrieving device management service instance"; + log.error(errorMessage, e); + throw new UnexpectedServerErrorException( + new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); + } + } } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/SyncmlService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/SyncmlService.java index 37194987b..7ba8c570b 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/SyncmlService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/SyncmlService.java @@ -35,7 +35,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; /** - * Interface for Syncml message flow. + * Interface for Windows 8.1 enrollment flow. */ @SwaggerDefinition( info = @Info( @@ -43,17 +43,17 @@ import javax.ws.rs.core.Response; title = "", extensions = { @Extension(properties = { - @ExtensionProperty(name = "name", value = "Syncml Endpoint"), + @ExtensionProperty(name = "name", value = "Windows 8.1 Device Management Service"), @ExtensionProperty(name = "context", value = "/api/device-mgt/windows/v1.0/syncml"), }) } ), tags = { - @Tag(name = "devicemgt_windows", description = "") + @Tag(name = "windows", description = "") } ) -@Api(value = "Windows syncml service", +@Api(value = "Windows 8.1 Device Management Service", description = "This carries all the resources related to Windows syncml message flow.") @Path("/devicemanagement") public interface SyncmlService { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/impl/SyncmlServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/impl/SyncmlServiceImpl.java index 3dfcb4461..4cc2f0ac8 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/impl/SyncmlServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/impl/SyncmlServiceImpl.java @@ -235,7 +235,6 @@ public class SyncmlServiceImpl implements SyncmlService { String devLang; String vendor; String macAddress; - String resolution; String modVersion; boolean status = false; String user; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/wstep/CertificateEnrollmentService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/wstep/CertificateEnrollmentService.java index 2bdf78128..eb6f7001a 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/wstep/CertificateEnrollmentService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/wstep/CertificateEnrollmentService.java @@ -47,14 +47,14 @@ import java.io.UnsupportedEncodingException; title = "", extensions = { @Extension(properties = { - @ExtensionProperty(name = "name", value = "Windows enrollment service provider"), + @ExtensionProperty(name = "name", value = "Windows 8.1 Enrollment Service"), @ExtensionProperty(name = "context", value = "/api/device-mgt/windows/v1.0/deviceenrolment/wstep"), }) } ), tags = { - @Tag(name = "devicemgt_windows", description = "") + @Tag(name = "windows", description = "") } ) @Api(value = "Windows Enrollment service Management", diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/xcep/CertificateEnrollmentPolicyService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/xcep/CertificateEnrollmentPolicyService.java index 70d6cbb21..0934824c9 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/xcep/CertificateEnrollmentPolicyService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/xcep/CertificateEnrollmentPolicyService.java @@ -47,17 +47,17 @@ import javax.xml.ws.soap.SOAPBinding; title = "", extensions = { @io.swagger.annotations.Extension(properties = { - @ExtensionProperty(name = "name", value = "Windows Enrollment policy service"), + @ExtensionProperty(name = "name", value = "Windows Enrollment policy Service"), @ExtensionProperty(name = "context", value = "/api/device-mgt/windows/v1.0/certificatepolicy/xcep"), }) } ), tags = { - @Tag(name = "devicemgt_windows", description = "") + @Tag(name = "windows", description = "") } ) -@Api(value = "Windows enrollment policy Management", +@Api(value = "Windows Enrollment policy Service", description = "This carries all the resources related to Windows enrollment policy.") @WebService(targetNamespace = PluginConstants.CERTIFICATE_ENROLLMENT_POLICY_SERVICE_TARGET_NAMESPACE, name = "IPolicy") From e186ef6bb33d0a9ca9826b761cf8a020728de5f9 Mon Sep 17 00:00:00 2001 From: Hasunie Date: Fri, 6 Jan 2017 18:29:32 +0530 Subject: [PATCH 5/7] fixing jira issue IOTS-368 --- .../invoke-agent.hbs | 2 +- .../access-control.js | 19 ++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/pages/mdm.page.enrollments.windows.invoke-agent/invoke-agent.hbs b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/pages/mdm.page.enrollments.windows.invoke-agent/invoke-agent.hbs index a3af675ca..7a958ed83 100755 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/pages/mdm.page.enrollments.windows.invoke-agent/invoke-agent.hbs +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/pages/mdm.page.enrollments.windows.invoke-agent/invoke-agent.hbs @@ -18,7 +18,7 @@ under the License. --}} {{#zone "accessControl"}} {{ unit "mdm.unit.enrollments.access-control" - allowedPlatform = "Windows Phone" + allowedPlatform = ["Windows Phone", "Windows"] currentPage = "invoke-agent" nextPage = "login-agent" }} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/units/mdm.unit.enrollments.access-control/access-control.js b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/units/mdm.unit.enrollments.access-control/access-control.js index 58d161f3e..a6927b298 100755 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/units/mdm.unit.enrollments.access-control/access-control.js +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/units/mdm.unit.enrollments.access-control/access-control.js @@ -29,11 +29,7 @@ function onRequest(context) { parser.getResult(); var userAgentPlatform = parser.getOS()["name"]; - if (userAgentPlatform != context.unit.params["allowedPlatform"]) { - // if userAgentPlatform is not allowed - log.error("platform not allowed"); - response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request"); - } else { + if (context.unit.params["allowedPlatform"].indexOf(userAgentPlatform) !== -1) { var lastPage = context.unit.params["lastPage"]; var nextPage = context.unit.params["nextPage"]; var currentPage = context.unit.params["currentPage"]; @@ -44,9 +40,7 @@ function onRequest(context) { if (!session.get("lastAccessedPage")) { // meaning a middle page is accessed at first response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request"); - } else if (!(session.get("lastAccessedPage") == currentPage) && - !(session.get("lastAccessedPage") == lastPage) && - !(session.get("lastAccessedPage") == nextPage)) { + } else if (!(session.get("lastAccessedPage") == currentPage) && !(session.get("lastAccessedPage") == lastPage) && !(session.get("lastAccessedPage") == nextPage)) { response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request"); } else if (currentPage) { // if currentPage is set, update lastAccessedPage as currentPage @@ -57,8 +51,7 @@ function onRequest(context) { if (!session.get("lastAccessedPage")) { // this means the last page is accessed at first response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request"); - } else if (!(session.get("lastAccessedPage") == currentPage) && - !(session.get("lastAccessedPage") == lastPage)) { + } else if (!(session.get("lastAccessedPage") == currentPage) && !(session.get("lastAccessedPage") == lastPage)) { response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request"); } else if (currentPage) { // if currentPage is set, update lastAccessedPage as currentPage @@ -69,11 +62,15 @@ function onRequest(context) { // if currentPage is set, update lastAccessedPage as currentPage session.put("lastAccessedPage", currentPage); } + } else { + // if userAgentPlatform is not allowed + log.error("platform not allowed"); + response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request"); } if (log.isDebugEnabled()) { log.debug("last-accessed-page = " + session.get("lastAccessedPage") + - " : " + "session-id = " + session.getId()); + " : " + "session-id = " + session.getId()); } return context; } \ No newline at end of file From 440473bc13d7868147c1cfcc23495b939d1093c9 Mon Sep 17 00:00:00 2001 From: Hasunie Date: Fri, 6 Jan 2017 18:49:52 +0530 Subject: [PATCH 6/7] adding context path to web xml nonsecuredEndpoints --- .../src/main/webapp/WEB-INF/web.xml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/WEB-INF/web.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/WEB-INF/web.xml index 50033c2e5..8dbd5e352 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/WEB-INF/web.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/webapp/WEB-INF/web.xml @@ -62,8 +62,11 @@ nonSecuredEndPoints - /discovery/get,/discovery/post,/certificatepolicy/xcep, - ,/deviceenrolment/wstep,/syncml/devicemanagement/request,/deviceenrolment/enrollment,/management/devicemgt/pending-operations + /api/device-mgt/windows/v1.0/discovery/get,/api/device-mgt/windows/v1.0/discovery/post, + /api/device-mgt/windows/v1.0/certificatepolicy/xcep,/api/device-mgt/windows/v1.0/deviceenrolment/wstep, + /api/device-mgt/windows/v1.0/syncml/devicemanagement/request, + /api/device-mgt/windows/v1.0/deviceenrolment/enrollment, + /api/device-mgt/windows/v1.0/management/devicemgt/pending-operations \ No newline at end of file From 4c4d6b9d67e3f01f3d647ee75f8f9cb88ec75ff5 Mon Sep 17 00:00:00 2001 From: Hasunie Date: Fri, 6 Jan 2017 18:53:48 +0530 Subject: [PATCH 7/7] adding location operation to task --- .../src/main/resources/devicetypes/windows.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/devicetypes/windows.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/devicetypes/windows.xml index 69f31f679..517a9fe0b 100644 --- a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/devicetypes/windows.xml +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/devicetypes/windows.xml @@ -145,6 +145,10 @@ DEVICE_INFO 1 + + DEVICE_LOCATION + 1 +