1 console.log('Loading navigator.gss.js - #7');
3 /* This file gets injected into the web page verbatim */
7 var GSSEap = (function ()
9 function GSSEap(config)
12 this.version = "0.0.1";
13 this.implemented_methods = ["gss_import_name"];
17 this.appTag = config.appTag || "";
18 this.default_error = config.error ||
19 function (major, minor, error, appTag) {
22 window.addEventListener(
24 this.dispatch_responses.bind(this)
27 GSSEap.prototype.dispatch_responses = function (event)
35 /* This message is destined for us only if all the following apply:
36 * - The data.method_name is one of the methods implemented by this
38 * - data.return_values exists
39 * - data.cookies exists
40 * - One of my callbacks matches the nonce in
41 * data.cookies.navigator_gss_tag
42 * - One of my methods matches the nonce in
43 * data.cookies.navigator_gss_tag and that method matches
46 method = event.data.method;
48 ( -1 == this.implemented_methods.indexOf(method) ) ||
49 ("undefined" == typeof (event.data.return_values)) ||
50 ("undefined" == typeof (event.data.cookies)))
55 nonce = event.data.cookies.navigator_gss_tag;
56 event.data.cookies.navigator_gss_tag = undefined;
57 callback = this.callbacks[nonce];
58 if ("undefined" == typeof (callback) ||
59 this.methods[nonce] != method) {
63 // We now know that this message is for us!
64 this.callbacks[nonce] = undefined;
65 app_tag = event.data.cookies.app_tag;
66 error = this.errors[nonce] || this.default_error;
68 if (this.gss_error(event.data.return_values.major_status))
70 var errMsg = "Error during " + method + ": " +
71 "Major status message: " +
72 event.data.return_values.errors.major_status_message +
73 "; Minor status message: " +
74 event.data.return_values.errors.minor_status_message;
76 event.data.return_values.major_status,
77 event.data.return_values.minor_status,
81 callback(event.data.return_values, app_tag);
85 GSSEap.prototype.import_name = function (params)
89 var name = params.name;
90 var name_type = params.name_type || "{1 2 840 113554 1 2 1 4 }";
91 var callback = params.success;
92 var error = params.error || this.default_error;
93 var app_tag = params.app_tag || this.appTag;
96 // Call an error if we don't have the required parameters.
99 if ( "undefined" == typeof(name) ||
100 "undefined" == typeof(callback) )
103 "import_name called missing either name or success callback"
108 nonce = navigator.generateNonce();
109 this.callbacks[nonce] = callback;
110 this.methods[nonce] = "gss_import_name";
111 this.errors[nonce] = error;
113 "method":"gss_import_name",
117 "input_name_type": name_type
121 "navigator_gss_tag": nonce,
128 GSSEap.prototype.gss_error = function (major)
134 callingMask = 255 << 24;
135 routineMask = 255 << 16;
136 mask = callingMask | routineMask;
138 return (0 != (major & mask));
143 navigator.gss_eap = GSSEap;