From 35ba0b2a9bf6783d545d01e3dfb30cd49b50c6a8 Mon Sep 17 00:00:00 2001 From: Hasunie Date: Thu, 1 Dec 2016 09:40:29 +0530 Subject: [PATCH] fixing windows enrollment flow --- .../src/assembly/src.xml | 10 +- .../modules/business-controllers/device.js | 2 +- .../enrollments/windows/agent-controller.jag | 34 ++--- .../enrollments/windows/agent-enroll.jag | 6 +- .../app/modules/oauth/token-handlers.js | 49 ++++--- .../windows-web-agent/jaggery.conf | 54 +++---- .../datasources/windows-datasources.xml | 2 +- .../main/resources/devicetypes/windows.xml | 136 +++++++++++------- .../src/main/resources/p2.inf | 5 + 9 files changed, 176 insertions(+), 122 deletions(-) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/assembly/src.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/assembly/src.xml index 3815c75d72..5996c04577 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/assembly/src.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/assembly/src.xml @@ -28,17 +28,17 @@ ${basedir}/src - ${basedir}/src/main/resources/jaggeryapps/devicemgt - /devicemgt + ${basedir}/src/main/resources/jaggeryapps/windows-web-agent + /windows-web-agent true - ${basedir}/src/main/resources/jaggeryapps/uuf-template-app - /windows-web-agent + ${basedir}/src/main/resources/jaggeryapps/devicemgt + /devicemgt true - ${basedir}/src/main/resources/jaggeryapps/windows-web-agent + ${basedir}/src/main/resources/jaggeryapps/uuf-template-app /windows-web-agent true 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/business-controllers/device.js b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/business-controllers/device.js index dbc76aabca..3dce168f4b 100755 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/business-controllers/device.js +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/business-controllers/device.js @@ -312,7 +312,7 @@ deviceModule = function () { var url; var license; if (deviceType == "windows") { - url = devicemgtProps["httpURL"] + "/mdm-windows-agent/services/device/license"; + url = devicemgtProps["httpURL"] + "/api/device-mgt/windows/v1.0/services/configuration/license"; } else if (deviceType == "ios") { url = devicemgtProps["httpsURL"] + "/ios-enrollment/license/"; } 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 f76bcf9252..c5740cd403 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 @@ -57,24 +57,24 @@ if (platform != "Windows Phone") { } }; serviceInvokers.XMLHttp.post( - authUrl, - stringify(payload), - function (restAPIResponse) { - var status = restAPIResponse["status"]; - if (status == 200) { - session.put("authenticatedUser", username); - session.put("windowsBinaryToken", parse(xmlHttpRequest["responseText"]).UserToken); - response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/license-agent"); - } else if (status == 403) { - response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/login-agent?error=auth-failed"); - } else if (status == 409) { - response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/login-agent?" + - "error=auth-failed&message=Provided Workplace email does not match with username. Please check."); - } else { - // one visible possibility would be server sending 500 - response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/login-agent?error=unexpected"); + authUrl, + stringify(payload), + function (restAPIResponse) { + var status = restAPIResponse["status"]; + if (status == 200) { + session.put("authenticatedUser", username); + session.put("windowsBinaryToken", parse(restAPIResponse["responseText"]).UserToken); + response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/license-agent"); + } else if (status == 403) { + response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/login-agent?error=auth-failed"); + } else if (status == 409) { + response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/login-agent?" + + "error=auth-failed&message=Provided Workplace email does not match with username. Please check."); + } else { + // one visible possibility would be server sending 500 + response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/login-agent?error=unexpected"); + } } - } ); } } 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 1ad6930016..66a4eed09b 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 @@ -36,10 +36,10 @@ if (platform != "Windows Phone") { if (!authenticatedUser) { response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); } else { - var enrollmentUtils = require("/modules/enrollments/util/utils.js")["methods"]; - var Handlebars = require("/lib/handlebars-v2.0.0.js")["Handlebars"]; + var enrollmentUtils = require("/app/modules/enrollments/util/utils.js")["methods"]; + var Handlebars = require("/lib/modules/handlebars/handlebars-v2.0.0.js")["Handlebars"]; var template = Handlebars.compile(enrollmentUtils. - getResource("/modules/enrollments/windows/config/workplace-switch-request-template.hbs")); + getResource("/app/modules/enrollments/windows/config/workplace-switch-request-template.hbs")); var windowsWorkplaceAppID = session.get("windowsWorkplaceAppID"); var windowsBinaryToken = session.get("windowsBinaryToken"); 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/oauth/token-handlers.js b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/oauth/token-handlers.js index d163046067..bff0f143fa 100755 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/oauth/token-handlers.js +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/oauth/token-handlers.js @@ -133,35 +133,44 @@ var handlers = function () { privateMethods["setUpEncodedTenantBasedClientAppCredentials"] = function (username) { if (!username) { throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant based " + - "client credentials to session context. No username of logged in user is found as " + - "input - setUpEncodedTenantBasedClientAppCredentials(x)"); + "client credentials to session context. No username of logged in user is found as " + + "input - setUpEncodedTenantBasedClientAppCredentials(x)"); } else { var dynamicClientAppCredentials = tokenUtil.getDynamicClientAppCredentials(); if (!dynamicClientAppCredentials) { throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant based " + - "client credentials to session context as the server is unable to obtain " + - "dynamic client credentials - setUpEncodedTenantBasedClientAppCredentials(x)"); + "client credentials to session context as the server is unable to obtain " + + "dynamic client credentials - setUpEncodedTenantBasedClientAppCredentials(x)"); } else { - var jwtToken = tokenUtil.getAccessTokenByJWTGrantType(dynamicClientAppCredentials); - if (!jwtToken) { - throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant based " + + if (devicemgtProps["apimgt-gateway"]) { + var jwtToken = tokenUtil.getAccessTokenByJWTGrantType(dynamicClientAppCredentials); + if (!jwtToken) { + throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant based " + "client credentials to session context as the server is unable to obtain " + - "a jwt token - setUpEncodedTenantBasedClientAppCredentials(x)"); - } else { - var tenantBasedClientAppCredentials = tokenUtil. - getTenantBasedClientAppCredentials(username, jwtToken); - if (!tenantBasedClientAppCredentials) { - throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant " + - "based client credentials to session context as the server is unable " + - "to obtain such credentials - setUpEncodedTenantBasedClientAppCredentials(x)"); + "a jwt token - setUpEncodedTenantBasedClientAppCredentials(x)"); } else { - var encodedTenantBasedClientAppCredentials = - tokenUtil.encode(tenantBasedClientAppCredentials["clientId"] + ":" + + var tenantBasedClientAppCredentials = tokenUtil. + getTenantBasedClientAppCredentials(username, jwtToken); + if (!tenantBasedClientAppCredentials) { + throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant " + + "based client credentials to session context as the server is unable " + + "to obtain such credentials - setUpEncodedTenantBasedClientAppCredentials(x)"); + } else { + var encodedTenantBasedClientAppCredentials = + tokenUtil.encode(tenantBasedClientAppCredentials["clientId"] + ":" + tenantBasedClientAppCredentials["clientSecret"]); - // setting up encoded tenant based client credentials to session context. - session.put(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"], - encodedTenantBasedClientAppCredentials); + // setting up encoded tenant based client credentials to session context. + session.put(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"], + encodedTenantBasedClientAppCredentials); + } } + } else { + var encodedTenantBasedClientAppCredentials = + tokenUtil.encode(dynamicClientAppCredentials["clientId"] + ":" + + dynamicClientAppCredentials["clientSecret"]); + // setting up encoded tenant based client credentials to session context. + session.put(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"], + encodedTenantBasedClientAppCredentials); } } } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/jaggery.conf b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/jaggery.conf index a9c7a0ec9d..59caaa1ed4 100755 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/jaggery.conf +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/jaggery.conf @@ -65,33 +65,33 @@ } ], "securityConstraints": [ - { - "securityConstraint": { - "webResourceCollection": { - "name": "WINDOWS-WEB-AGENT", - "urlPatterns": [ - "/*" - ] - }, - "userDataConstraint": { - "transportGuarantee": "CONFIDENTIAL" - } - } - }, - { - "securityConstraint": { - "webResourceCollection": { - "name": "WINDOWS-WEB-AGENT-http", - "urlPatterns": [ - "/public/*", - "/enrollments/windows/*", - "/enrollment/windows/*" - ] - }, - "userDataConstraint": { - "transportGuarantee": "NONE" - } - } + { + "securityConstraint": { + "webResourceCollection": { + "name": "WINDOWS-WEB-AGENT", + "urlPatterns": [ + "/*" + ] + }, + "userDataConstraint": { + "transportGuarantee": "CONFIDENTIAL" + } + } + }, + { + "securityConstraint": { + "webResourceCollection": { + "name": "WINDOWS-WEB-AGENT-http", + "urlPatterns": [ + "/public/*", + "/enrollments/windows/*", + "/enrollment/windows/*" + ] + }, + "userDataConstraint": { + "transportGuarantee": "NONE" + } } + } ] } diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/datasources/windows-datasources.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/datasources/windows-datasources.xml index 89e2c13ccc..d85eaafc06 100644 --- a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/datasources/windows-datasources.xml +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/datasources/windows-datasources.xml @@ -30,7 +30,7 @@ - jdbc:h2:repository/database/WindowsDM_DB;DB_CLOSE_ON_EXIT=FALSE + jdbc:h2:repository/database/WSO2MobileWindows_DB;DB_CLOSE_ON_EXIT=FALSE wso2carbon wso2carbon 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 d62ad7d90a..e2f3bd3e72 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 @@ -19,56 +19,96 @@ --> - - en_US - 1.0.0 - This is license text - + - - false - + + en_US + 1.0.0 + This is license text + - - - jdbc/MobileWindowsDM_DS - - - - DEVICE_ID - - DEVICE_ID - CHANNEL_URI - DEVICE_INFO - IMEI - IMSI - OS_VERSION - DEVICE_MODEL - VENDOR - LATITUDE - LONGITUDE - SERIAL - MAC_ADDRESS - DEVICE_NAME - OS_BUILD_DATE - -
-
-
+ + false + - - - abc - this is a feature - - - deviceId - - - test - - - - + + + jdbc/MobileWindowsDM_DS + + + + DEVICE_ID + + CHANNEL_URI + DEVICE_INFO + IMEI + IMSI + OS_VERSION + DEVICE_MODEL + VENDOR + LATITUDE + LONGITUDE + SERIAL + MAC_ADDRESS + DEVICE_NAME + +
+
+
+ + + + Device Lock + Lock the device + + + + + Device Lock + Lock the device + + + + + Device Lock + Lock the device + + + + + Device Lock + Lock the device + + + + + Device Lock + Lock the device + + + + + Password Policy + Set passcode policy + + + + + Camera Enable/Disable + Enable/Disable camera + + + + + Encrypt Storage + Encrypt the device storage + + + + + + + false +
diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/p2.inf b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/p2.inf index 130f763b05..915cd258eb 100644 --- a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/p2.inf +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/p2.inf @@ -18,7 +18,12 @@ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../dep org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-edit);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-view);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-wizard);\ +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.qr-modal);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.type-view);\ +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.leaflet);\ +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-bar);\ +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-mod);\ +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.date-range-picker);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../dbscripts/cdm/plugins/windows);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../database/WSO2MobileWindows_DB.h2.db);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../.