Newer
Older
Alexander König
committed
'use strict';
(function(window){
function AAI() {
var host = 'https://' + window.location.hostname,
ourEntityID = host.match("clarin-dev.eurac.edu") ? "https://clarin-dev.eurac.edu" : host;
Alexander König
committed
this.defaults = {
//host : 'https://ufal-point.mff.cuni.cz',
host : host, //better default (useful when testing on ufal-point-dev)
// do not add protocol because an error will appear in the DJ dialog
// if you see the error, your SP is not listed among djc trusted (edugain is enough to be trusted)
responseUrl: window.location.protocol + '//clarin-dev.eurac.edu/aai/discojuiceDiscoveryResponse.html',
Alexander König
committed
ourEntityID: ourEntityID + '/Shibboleth.sso/Metadata',
serviceName: '',
metadataFeed: host + '/xmlui/discojuice/feeds',
selector: 'a.signon', // selector for login button
autoInitialize: true, // auto attach DiscoJuice to DOM
textHelpMore: "First check you are searching under the right country.\nIf your provider is not listed, please read <a href='https://clarin-dev.eurac.edu/how-do-i-sign-up' style='text-decoration: underline; font-weight: bold;'>these instructions</a> to obtain an account."
Alexander König
committed
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
};
this.setup = function(options) {
var opts = jQuery.extend({}, this.defaults, options),
defaultCallback = function(e) {
window.location = opts.host + '/Shibboleth.sso/Login?SAMLDS=1&target=' + opts.target + '&entityID=' + window.encodeURIComponent(e.entityID);
};
//console.log(opts);
if(!opts.target){
throw 'You need to set the \'target\' parameter.';
}
// call disco juice setup
if (!opts.autoInitialize || $(opts.selector).length > 0) {
if(! window.DiscoJuice ){
throw 'Failed to find DiscoJuice. Did you include all that is necessary?';
}
var djc = DiscoJuice.Hosted.getConfig(
opts.serviceName,
opts.ourEntityID,
opts.responseUrl,
[ ],
opts.host + '/Shibboleth.sso/Login?SAMLDS=1&target='+opts.target+'&entityID=');
djc.metadata = [opts.metadataFeed];
djc.subtitle = "Login via Your home institution (e.g. university)";
djc.textHelp = opts.textHelp;
djc.textHelpMore = opts.textHelpMore;
djc.inlinemetadata = typeof opts.inlinemetadata === 'object' ? opts.inlinemetadata : [];
djc.inlinemetadata.push({
'country': '_all_',
'entityID': 'https://idm.clarin.eu',
'geo': {'lat': '51.833298', 'lon': '5.866699'},
'title': 'Clarin.eu website account',
'weight': -801
});
djc.inlinemetadata.push({
'country': 'IT',
'entityID': 'https://idp.eurac.edu/idp/shibboleth',
'geo': {'lat': '46.494281', 'lon': '11.346842'},
'title': 'Eurac Research',
'weight': -1000
});
if(opts.localauth) {
djc.inlinemetadata.push(
{
'entityID': 'local://',
'auth': 'local',
'title': 'Local authentication',
'country': '_all_',
'geo': null,
'weight': 1000
});
djc.callback = function(e){
var auth = e.auth || null;
switch(auth) {
case 'local':
DiscoJuice.UI.setScreen(opts.localauth);
jQuery('input#login').focus();
break;
//case 'saml':
default:
defaultCallback(e);
break;
}
};
}
if (opts.callback && typeof opts.callback === 'function') {
djc.callback = function(e) {
opts.callback(e, opts, defaultCallback);
};
}
if (opts.autoInitialize) {
jQuery(opts.selector).DiscoJuice( djc );
}
return djc;
} //if jQuery(selector)
};
}
if (!window.aai) {
window.aai = new AAI();
}
})(window);