fixing windows enrollment flow

revert-dabc3590
Hasunie 8 years ago
parent 0fd317d027
commit 35ba0b2a9b

@ -28,17 +28,17 @@
<baseDirectory>${basedir}/src</baseDirectory> <baseDirectory>${basedir}/src</baseDirectory>
<fileSets> <fileSets>
<fileSet> <fileSet>
<directory>${basedir}/src/main/resources/jaggeryapps/devicemgt</directory> <directory>${basedir}/src/main/resources/jaggeryapps/windows-web-agent</directory>
<outputDirectory>/devicemgt</outputDirectory> <outputDirectory>/windows-web-agent</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes> <useDefaultExcludes>true</useDefaultExcludes>
</fileSet> </fileSet>
<fileSet> <fileSet>
<directory>${basedir}/src/main/resources/jaggeryapps/uuf-template-app</directory> <directory>${basedir}/src/main/resources/jaggeryapps/devicemgt</directory>
<outputDirectory>/windows-web-agent</outputDirectory> <outputDirectory>/devicemgt</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes> <useDefaultExcludes>true</useDefaultExcludes>
</fileSet> </fileSet>
<fileSet> <fileSet>
<directory>${basedir}/src/main/resources/jaggeryapps/windows-web-agent</directory> <directory>${basedir}/src/main/resources/jaggeryapps/uuf-template-app</directory>
<outputDirectory>/windows-web-agent</outputDirectory> <outputDirectory>/windows-web-agent</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes> <useDefaultExcludes>true</useDefaultExcludes>
</fileSet> </fileSet>

@ -312,7 +312,7 @@ deviceModule = function () {
var url; var url;
var license; var license;
if (deviceType == "windows") { 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") { } else if (deviceType == "ios") {
url = devicemgtProps["httpsURL"] + "/ios-enrollment/license/"; url = devicemgtProps["httpsURL"] + "/ios-enrollment/license/";
} }

@ -57,24 +57,24 @@ if (platform != "Windows Phone") {
} }
}; };
serviceInvokers.XMLHttp.post( serviceInvokers.XMLHttp.post(
authUrl, authUrl,
stringify(payload), stringify(payload),
function (restAPIResponse) { function (restAPIResponse) {
var status = restAPIResponse["status"]; var status = restAPIResponse["status"];
if (status == 200) { if (status == 200) {
session.put("authenticatedUser", username); session.put("authenticatedUser", username);
session.put("windowsBinaryToken", parse(xmlHttpRequest["responseText"]).UserToken); session.put("windowsBinaryToken", parse(restAPIResponse["responseText"]).UserToken);
response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/license-agent"); response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/license-agent");
} else if (status == 403) { } else if (status == 403) {
response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/login-agent?error=auth-failed"); response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/login-agent?error=auth-failed");
} else if (status == 409) { } else if (status == 409) {
response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/login-agent?" + response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/login-agent?" +
"error=auth-failed&message=Provided Workplace email does not match with username. Please check."); "error=auth-failed&message=Provided Workplace email does not match with username. Please check.");
} else { } else {
// one visible possibility would be server sending 500 // one visible possibility would be server sending 500
response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/login-agent?error=unexpected"); response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/login-agent?error=unexpected");
}
} }
}
); );
} }
} }

@ -36,10 +36,10 @@ if (platform != "Windows Phone") {
if (!authenticatedUser) { if (!authenticatedUser) {
response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request");
} else { } else {
var enrollmentUtils = require("/modules/enrollments/util/utils.js")["methods"]; var enrollmentUtils = require("/app/modules/enrollments/util/utils.js")["methods"];
var Handlebars = require("/lib/handlebars-v2.0.0.js")["Handlebars"]; var Handlebars = require("/lib/modules/handlebars/handlebars-v2.0.0.js")["Handlebars"];
var template = Handlebars.compile(enrollmentUtils. 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 windowsWorkplaceAppID = session.get("windowsWorkplaceAppID");
var windowsBinaryToken = session.get("windowsBinaryToken"); var windowsBinaryToken = session.get("windowsBinaryToken");

@ -133,35 +133,44 @@ var handlers = function () {
privateMethods["setUpEncodedTenantBasedClientAppCredentials"] = function (username) { privateMethods["setUpEncodedTenantBasedClientAppCredentials"] = function (username) {
if (!username) { if (!username) {
throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant based " + 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 " + "client credentials to session context. No username of logged in user is found as " +
"input - setUpEncodedTenantBasedClientAppCredentials(x)"); "input - setUpEncodedTenantBasedClientAppCredentials(x)");
} else { } else {
var dynamicClientAppCredentials = tokenUtil.getDynamicClientAppCredentials(); var dynamicClientAppCredentials = tokenUtil.getDynamicClientAppCredentials();
if (!dynamicClientAppCredentials) { if (!dynamicClientAppCredentials) {
throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant based " + 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 " + "client credentials to session context as the server is unable to obtain " +
"dynamic client credentials - setUpEncodedTenantBasedClientAppCredentials(x)"); "dynamic client credentials - setUpEncodedTenantBasedClientAppCredentials(x)");
} else { } else {
var jwtToken = tokenUtil.getAccessTokenByJWTGrantType(dynamicClientAppCredentials); if (devicemgtProps["apimgt-gateway"]) {
if (!jwtToken) { var jwtToken = tokenUtil.getAccessTokenByJWTGrantType(dynamicClientAppCredentials);
throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant based " + 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 " + "client credentials to session context as the server is unable to obtain " +
"a jwt token - setUpEncodedTenantBasedClientAppCredentials(x)"); "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)");
} else { } else {
var encodedTenantBasedClientAppCredentials = var tenantBasedClientAppCredentials = tokenUtil.
tokenUtil.encode(tenantBasedClientAppCredentials["clientId"] + ":" + 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"]); tenantBasedClientAppCredentials["clientSecret"]);
// setting up encoded tenant based client credentials to session context. // setting up encoded tenant based client credentials to session context.
session.put(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"], session.put(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"],
encodedTenantBasedClientAppCredentials); 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);
} }
} }
} }

@ -65,33 +65,33 @@
} }
], ],
"securityConstraints": [ "securityConstraints": [
{ {
"securityConstraint": { "securityConstraint": {
"webResourceCollection": { "webResourceCollection": {
"name": "WINDOWS-WEB-AGENT", "name": "WINDOWS-WEB-AGENT",
"urlPatterns": [ "urlPatterns": [
"/*" "/*"
] ]
}, },
"userDataConstraint": { "userDataConstraint": {
"transportGuarantee": "CONFIDENTIAL" "transportGuarantee": "CONFIDENTIAL"
} }
} }
}, },
{ {
"securityConstraint": { "securityConstraint": {
"webResourceCollection": { "webResourceCollection": {
"name": "WINDOWS-WEB-AGENT-http", "name": "WINDOWS-WEB-AGENT-http",
"urlPatterns": [ "urlPatterns": [
"/public/*", "/public/*",
"/enrollments/windows/*", "/enrollments/windows/*",
"/enrollment/windows/*" "/enrollment/windows/*"
] ]
}, },
"userDataConstraint": { "userDataConstraint": {
"transportGuarantee": "NONE" "transportGuarantee": "NONE"
} }
}
} }
}
] ]
} }

@ -30,7 +30,7 @@
</jndiConfig> </jndiConfig>
<definition type="RDBMS"> <definition type="RDBMS">
<configuration> <configuration>
<url>jdbc:h2:repository/database/WindowsDM_DB;DB_CLOSE_ON_EXIT=FALSE <url>jdbc:h2:repository/database/WSO2MobileWindows_DB;DB_CLOSE_ON_EXIT=FALSE
</url> </url>
<username>wso2carbon</username> <username>wso2carbon</username>
<password>wso2carbon</password> <password>wso2carbon</password>

@ -19,56 +19,96 @@
--> -->
<DeviceTypeConfiguration name="windows"> <DeviceTypeConfiguration name="windows">
<License> <DeviceDetails table-id="WIN_DEVICE"/>
<Language>en_US</Language>
<Version>1.0.0</Version>
<Text>This is license text</Text>
</License>
<ProvisioningConfig> <License>
<SharedWithAllTenants>false</SharedWithAllTenants> <Language>en_US</Language>
</ProvisioningConfig> <Version>1.0.0</Version>
<Text>This is license text</Text>
</License>
<DataSource> <ProvisioningConfig>
<jndiConfig> <SharedWithAllTenants>false</SharedWithAllTenants>
<name>jdbc/MobileWindowsDM_DS</name> </ProvisioningConfig>
</jndiConfig>
<tableConfig>
<Table name="WIN_DEVICE">
<PrimaryKey>DEVICE_ID</PrimaryKey>
<Attributes>
<Attribute>DEVICE_ID</Attribute>
<Attribute>CHANNEL_URI</Attribute>
<Attribute>DEVICE_INFO</Attribute>
<Attribute>IMEI</Attribute>
<Attribute>IMSI</Attribute>
<Attribute>OS_VERSION</Attribute>
<Attribute>DEVICE_MODEL</Attribute>
<Attribute>VENDOR</Attribute>
<Attribute>LATITUDE</Attribute>
<Attribute>LONGITUDE</Attribute>
<Attribute>SERIAL</Attribute>
<Attribute>MAC_ADDRESS</Attribute>
<Attribute>DEVICE_NAME</Attribute>
<Attribute>OS_BUILD_DATE</Attribute>
</Attributes>
</Table>
</tableConfig>
</DataSource>
<Features> <DataSource>
<Feature code="abc"> <jndiConfig>
<Name>abc</Name> <name>jdbc/MobileWindowsDM_DS</name>
<Description>this is a feature</Description> </jndiConfig>
<Operation context="/bulb/{state}" method="PUT"> <tableConfig>
<QueryParameters> <Table name="WIN_DEVICE">
<Parameter>deviceId</Parameter> <PrimaryKey>DEVICE_ID</PrimaryKey>
</QueryParameters> <Attributes>
<FormParameters> <Attribute>CHANNEL_URI</Attribute>
<Parameter>test</Parameter> <Attribute>DEVICE_INFO</Attribute>
</FormParameters> <Attribute>IMEI</Attribute>
</Operation> <Attribute>IMSI</Attribute>
</Feature> <Attribute>OS_VERSION</Attribute>
</Features> <Attribute>DEVICE_MODEL</Attribute>
<Attribute>VENDOR</Attribute>
<Attribute>LATITUDE</Attribute>
<Attribute>LONGITUDE</Attribute>
<Attribute>SERIAL</Attribute>
<Attribute>MAC_ADDRESS</Attribute>
<Attribute>DEVICE_NAME</Attribute>
</Attributes>
</Table>
</tableConfig>
</DataSource>
<Features>
<Feature code="DEVICE_LOCK">
<Name>Device Lock</Name>
<Description>Lock the device</Description>
<Operation context="windows/lock-devices" method="POST">
</Operation>
</Feature>
<Feature code="DISENROLL">
<Name>Device Lock</Name>
<Description>Lock the device</Description>
<Operation context="windows/disenroll-devices" method="POST">
</Operation>
</Feature>
<Feature code="WIPE_DATA">
<Name>Device Lock</Name>
<Description>Lock the device</Description>
<Operation context="windows/wipe-devices" method="POST">
</Operation>
</Feature>
<Feature code="DEVICE_RING">
<Name>Device Lock</Name>
<Description>Lock the device</Description>
<Operation context="windows/ring-devices" method="POST">
</Operation>
</Feature>
<Feature code="LOCK_RESET">
<Name>Device Lock</Name>
<Description>Lock the device</Description>
<Operation context="windows/lock-reset-devices" method="POST">
</Operation>
</Feature>
<Feature code="PASSCODE_POLICY">
<Name>Password Policy</Name>
<Description>Set passcode policy</Description>
<Operation context="" method="POST">
</Operation>
</Feature>
<Feature code="CAMERA">
<Name>Camera Enable/Disable</Name>
<Description>Enable/Disable camera</Description>
<Operation context="" method="POST">
</Operation>
</Feature>
<Feature code="ENCRYPT_STORAGE">
<Name>Encrypt Storage</Name>
<Description>Encrypt the device storage</Description>
<Operation context="" method="POST">
</Operation>
</Feature>
</Features>
<DeviceAuthorizationConfig>
<authorizationRequired>false</authorizationRequired>
</DeviceAuthorizationConfig>
</DeviceTypeConfiguration> </DeviceTypeConfiguration>

@ -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-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-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.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.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}/../../../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}/../../database/WSO2MobileWindows_DB.h2.db);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../. org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../.

Loading…
Cancel
Save