Fixing iOS enrollement check polling url

merge-requests/1/head
Rasika Perera 8 years ago
parent 6cf9dc1c67
commit 71d7baf04f

@ -5,7 +5,7 @@
"httpURL" : "%http.ip%", "httpURL" : "%http.ip%",
"enrollmentDir": "/emm-web-agent/enrollment", "enrollmentDir": "/emm-web-agent/enrollment",
"iOSConfigRoot" : "%https.ip%/ios-enrollment/", "iOSConfigRoot" : "%https.ip%/ios-enrollment/",
"iOSAPIRoot" : "%https.ip%/ios/", "iOSAPIRoot" : "%https.ip%/api/device-mgt/ios/v1.0/",
"dynamicClientRegistrationEndPoint" : "%https.ip%/dynamic-client-web/register/", "dynamicClientRegistrationEndPoint" : "%https.ip%/dynamic-client-web/register/",
"adminService":"%https.ip%", "adminService":"%https.ip%",
"idPServer":"%https.ip%", "idPServer":"%https.ip%",

@ -22,6 +22,9 @@ var log = new Log("/modules/enrollments/ios/agent-check.jag");
var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
var UAParser = require("/app/modules/ua-parser.min.js")["UAParser"]; var UAParser = require("/app/modules/ua-parser.min.js")["UAParser"];
var tokenUtil = require("/app/modules/oauth/token-handlers.js")["handlers"];
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
var parser = new UAParser(); var parser = new UAParser();
var userAgent = request.getHeader("User-Agent"); var userAgent = request.getHeader("User-Agent");
parser.setUA(userAgent); parser.setUA(userAgent);
@ -39,25 +42,25 @@ if (platform != "iOS") {
response["status"] = 200; response["status"] = 200;
response["content"] = {"deviceID" : null}; response["content"] = {"deviceID" : null};
} else { } else {
var deviceCheckURL = mdmProps["iOSAPIRoot"] + "device/deviceid"; var deviceCheckURL = mdmProps["iOSAPIRoot"] + "devices/udid";
var xhr = new XMLHttpRequest();
xhr.open("POST", deviceCheckURL);
var challengeToken = session.get("iOSChallengeToken"); var challengeToken = session.get("iOSChallengeToken");
var inputs = {"challengeToken" : challengeToken}; var payload = {"challengeToken" : challengeToken};
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Accept", "application/json");
xhr.send(stringify(inputs));
if (xhr.status == 200) { serviceInvokers.XMLHttp.post(
var responseObject = parse(xhr["responseText"]); deviceCheckURL,
response["status"] = 200; stringify(payload),
response["content"] = responseObject; function (restAPIResponse) {
} else { var status = restAPIResponse["status"];
// server only returns 400 in case of bad request if (status == 200) {
response["status"] = 200; var responseContent = parse(restAPIResponse.responseText);
response["content"] = {"deviceID" : null}; response["status"] = 200;
} response["content"] = responseContent;
} else {
response["status"] = 200;
response["content"] = {"deviceID" : null};
}
}
);
} }
} }
%> %>
Loading…
Cancel
Save