Removed iOS stuff from windows-web-agent

revert-dabc3590
Rasika Perera 8 years ago
parent 8b1a27a181
commit c04851d448

@ -1,66 +0,0 @@
<%
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var log = new Log("/modules/enrollments/ios/agent-check.jag");
var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
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 userAgent = request.getHeader("User-Agent");
parser.setUA(userAgent);
parser.getResult();
var os = parser.getOS();
var platform = os.name;
if (platform != "iOS") {
response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request");
} else if (session.get("lastAccessedPage") != "license-agent") {
response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request");
} else {
var enrolledUser = session.get("enrolledUser");
if (!enrolledUser) {
response["status"] = 200;
response["content"] = {"deviceID" : null};
} else {
var deviceCheckURL = mdmProps["iOSAPIRoot"] + "devices/udid";
var challengeToken = session.get("iOSChallengeToken");
var payload = {"challengeToken" : challengeToken};
serviceInvokers.XMLHttp.post(
deviceCheckURL,
stringify(payload),
function (restAPIResponse) {
var status = restAPIResponse["status"];
if (status == 200) {
var responseContent = parse(restAPIResponse.responseText);
response["status"] = 200;
response["content"] = responseContent;
} else {
response["status"] = 200;
response["content"] = {"deviceID" : null};
}
}
);
}
}
%>

@ -1,80 +0,0 @@
<%
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var log = new Log("/modules/enrollments/ios/agent-controller.jag");
var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
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 constants = require("/app/modules/constants.js");
var parser = new UAParser();
var userAgent = request.getHeader("User-Agent");
parser.setUA(userAgent);
parser.getResult();
var os = parser.getOS();
var platform = os.name;
if (platform != "iOS") {
response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request");
} else if (session.get("lastAccessedPage") != "login-agent") {
response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request");
} else {
var username = request.getParameter("username");
var password = request.getParameter("password");
var ownership = request.getParameter("ownership");
var domain = request.getParameter("domain");
if (!username || !password || !ownership) {
response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request");
} else {
var fullyQualifiedUsername = username;
if(domain != null && domain != ''){
fullyQualifiedUsername = username + "@" + domain;
}
tokenUtil.setupTokenPairByPasswordGrantType(fullyQualifiedUsername, password);
var authUrl = mdmProps["iOSConfigRoot"] + "authenticate";
var payload = {
"username": username, "password": password, "ownership": ownership,
"tenantDomain": domain
};
serviceInvokers.XMLHttp.post(
authUrl,
stringify(payload),
function (restAPIResponse) {
var status = restAPIResponse["status"];
if (status == 200) {
var responseContent = parse(restAPIResponse.responseText);
session.put("authenticatedUser", username);
session.put("authenticatedUserPassword", password);
session.put("authenticatedUserDeviceOwnership", ownership);
session.put("authenticatedUserDomain", domain);
session.put("iOSChallengeToken", responseContent["challengeToken"]);
response.sendRedirect(mdmProps["appContext"] + "enrollments/ios/license-agent");
} else if (status == 403) {
response.sendRedirect(mdmProps["appContext"] + "enrollments/ios/login-agent?error=auth-failed");
} else {
// one visible possibility would be server sending 500
response.sendRedirect(mdmProps["appContext"] + "enrollments/ios/login-agent?error=unexpected");
}
}
);
}
}
%>

@ -1,85 +0,0 @@
<%
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var log = new Log("/app/modules/enrollments/ios/agent-enroll.jag");
var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
var UAParser = require("/app/modules/ua-parser.min.js")["UAParser"];
var parser = new UAParser();
var userAgent = request.getHeader("User-Agent");
parser.setUA(userAgent);
parser.getResult();
var os = parser.getOS();
var platform = os.name;
if (platform != "iOS") {
response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request");
} else if (session.get("lastAccessedPage") != "license-agent") {
response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request");
} else {
var authenticatedUser = session.get("authenticatedUser");
if (!authenticatedUser) {
response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request");
} else {
var HttpClient = Packages.org.apache.commons.httpclient.HttpClient;
var PostMethod = Packages.org.apache.commons.httpclient.methods.PostMethod;
var Header = Packages.org.apache.commons.httpclient.Header;
var StringRequestEntity = Packages.org.apache.commons.httpclient.methods.StringRequestEntity;
var ByteArrayInputStream = Packages.java.io.ByteArrayInputStream;
var client = new HttpClient();
var enrollUrl = mdmProps["iOSConfigRoot"] + "enroll";
var method = new PostMethod(enrollUrl);
var header = new Header();
header.setName("Content-Type");
header.setValue("application/json");
method.addRequestHeader(header);
var username = authenticatedUser;
var password = session.get("authenticatedUserPassword");
var tenantDomain = session.get("authenticatedUserDomain");
var challengeToken = session.get("iOSChallengeToken");
var inputs = {"username": username, "password": password, "challengeToken": challengeToken, "tenantDomain": tenantDomain};
var stringRequestEntity = new StringRequestEntity(stringify(inputs));
method.setRequestEntity(stringRequestEntity);
try {
client.executeMethod(method);
var status = method.getStatusCode();
if (status == 200) {
session.put("enrolledUser", authenticatedUser);
var stream = method.getResponseBody();
var byteArrayInputStream = new ByteArrayInputStream(stream);
response.contentType = "application/x-apple-aspen-config";
print(new Stream(byteArrayInputStream));
} else {
// two visible possibilities would be server sending 401 and 500
response.sendRedirect(mdmProps["appContext"] + "enrollments/ios/login-agent?error=unexpected");
}
} catch (e) {
log.error("Error occurred in enrolling ios device", e);
response.sendRedirect(mdmProps["appContext"] + "enrollments/ios/login-agent?error=unexpected");
} finally {
method.releaseConnection();
}
}
}
%>

@ -1,47 +0,0 @@
<%
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var log = new Log("/app/modules/enrollments/ios/agent.jag");
var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
var userAgent = request.getHeader("User-Agent");
var userAgentIsiPhone = (userAgent.indexOf("iPhone") > -1);
var userAgentIsiPad = (userAgent.indexOf("iPad") > -1);
var userAgentIsiPodTouch = (userAgent.indexOf("iPod Touch") > -1);
if (!userAgentIsiPhone && !userAgentIsiPad && !userAgentIsiPodTouch) {
response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request");
} else {
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("/app/modules/enrollments/ios/config/ios-manifest-template.hbs"));
var iOSManifest = template({
"url" : mdmProps["device"]["ios"]["location"],
"bundleID" : mdmProps["device"]["ios"]["bundleID"],
"bundleVersion" : mdmProps["device"]["ios"]["version"],
"appName" : mdmProps["device"]["ios"]["appName"]
});
response.contentType = "application/xml";
response.content = iOSManifest;
}
%>

@ -1,26 +0,0 @@
<%
var HttpClient = Packages.org.apache.commons.httpclient.HttpClient;
var GetMethod = Packages.org.apache.commons.httpclient.methods.GetMethod;
var StringRequestEntity = Packages.org.apache.commons.httpclient.methods.StringRequestEntity;
var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
var caURL = mdmProps["iOSConfigRoot"] + 'ca';
var client = new HttpClient();
var method = new GetMethod(caURL);
try {
client.executeMethod(method);
var status = method.getStatusCode();
if (status == 200) {
var stream = method.getResponseBody();
response.contentType = "application/x-x509-ca-cert";
var byteArrayInputStream = new Packages.java.io.ByteArrayInputStream(stream);
print(new Stream(byteArrayInputStream));
} else {
response.sendRedirect("/errorpage");
}
} catch (e) {
log.error("Error occurred when downloading CA " + e);
}
%>

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
<key>kind</key>
<string>software-package</string>
<key>url</key>
<string>{{url}}</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>{{bundleID}}</string>
<key>bundle-version</key>
<string>{{bundleVersion}}</string>
<key>kind</key>
<string>software</string>
<key>title</key>
<string>{{appName}}</string>
</dict>
</dict>
</array>
</dict>
</plist>

@ -15,26 +15,6 @@
"url": "/enrollment/windows/enroll",
"path": "/app/modules/enrollments/windows/agent-enroll.jag"
},
{
"url": "/enrollment/ios/download-certificate",
"path": "/app/modules/enrollments/ios/certificate.jag"
},
{
"url": "/enrollment/ios/download-agent",
"path": "/app/modules/enrollments/ios/agent.jag"
},
{
"url": "/enrollment/ios/login",
"path": "/app/modules/enrollments/ios/agent-controller.jag"
},
{
"url": "/enrollment/ios/enroll",
"path": "/app/modules/enrollments/ios/agent-enroll.jag"
},
{
"url": "/enrollment/ios/check",
"path": "/app/modules/enrollments/ios/agent-check.jag"
},
{
"url": "/api/invoker/*",
"path": "/api/invoker-api.jag"

Loading…
Cancel
Save