-
Notifications
You must be signed in to change notification settings - Fork 3
/
discojuiceDiscoveryResponse.html
76 lines (60 loc) · 2.11 KB
/
discojuiceDiscoveryResponse.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<title>IdP Discovery Response Receiver</title>
<script type="text/javascript">
function parseURL(url) {
var a = document.createElement('a');
a.href = url;
return a.hostname;
}
function receive() {
var urlParams = {},
cid = null,
idpentityid,
subid,
rsearch
;
(function () {
var e,
a = /\+/g, // Regex for replacing addition symbol with a space
r = /([^&;=]+)=?([^&;]*)/g,
d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
q = window.location.search.substring(1);
while (e = r.exec(q))
urlParams[d(e[1])] = d(e[2]);
})();
if (urlParams.cid) cid = urlParams.cid;
var sender = parseURL(document.referrer);
// Received a specific entity ID from the storage.
if (urlParams.entityID) {
window.parent.DiscoJuice.Utils.log("Entity id parameter was " + urlParams.entityID);
rsearch = urlParams.entityID.match(/^(.*)#(.*)$/);
if (rsearch) {
idpentityid = rsearch[1];
subid = rsearch[2];
} else {
idpentityid = urlParams.entityID;
subid = null;
}
window.parent.DiscoJuice.Utils.log('ResponseLocation: Response from discovery service [' + sender + ']: ' + idpentityid + ' subID: ' + subid);
window.parent.DiscoJuice.Control.discoResponse(sender, idpentityid, subid, cid);
// Received a textual error from the storage, to show in the debug log.
} else if (urlParams['error']) {
window.parent.DiscoJuice.Control.discoResponseError(cid,
"Error from IdP Discovery Service [" + sender + "]: " + urlParams.error);
// Did not receive a response parameter. This probably means that the Disco storage did not have a stored preference
// for the user. Consequently: no error.
} else {
window.parent.DiscoJuice.Utils.log('No valid response parameters. cid[' + cid + ']');
window.parent.DiscoJuice.Control.discoResponseError(cid);
}
}
</script>
</head>
<body onload="receive();">
</body>
</html>