Commit 2c8209ca authored by Jonathon Duerig's avatar Jonathon Duerig
Browse files

Update geni-auth library to be compatible with new version of xml-signer

parent b62b48d5
var genilib = {};
genilib.trustedHost = '*';
genilib.trustedHost = 'https://www.emulab.net';
genilib.trustedPath = '/protogeni/speaks-for/index.html';
genilib.authorize = function(id, cert, callback)
{
var wrapper = {};
wrapper.other = window.open('index.html?id=' + encodeURIComponent(id), 'GENI Tool Authorization',
wrapper.other = window.open(genilib.trustedHost + genilib.trustedPath +
'?id=' +
encodeURIComponent(id),
'GENI Tool Authorization',
'height=400,width=800');
wrapper.listener = function (event) {
......@@ -16,8 +20,10 @@ genilib.authorize = function(id, cert, callback)
event.data.ready)
{
data = {
certificate: cert
certificate: cert,
tool: true
};
console.log('Sending cert to ' + genilib.trustedHost);
wrapper.other.postMessage(data, genilib.trustedHost);
}
else if (event.source === wrapper.other &&
......@@ -25,12 +31,13 @@ genilib.authorize = function(id, cert, callback)
event.data.id && event.data.id === id && event.data.credential)
{
window.removeEventListener('message', wrapper.listener, false);
wrapper.other.removeEventListener('close', wrapper.close, false);
// wrapper.other.removeEventListener('close', wrapper.close, false);
data = {
id: event.data.id,
ack: true
};
console.log('Sending ack to ' + genilib.trustedHost);
wrapper.other.postMessage(data, genilib.trustedHost);
callback(event.data.credential);
......@@ -39,15 +46,19 @@ genilib.authorize = function(id, cert, callback)
wrapper.close = function (event) {
window.removeEventListener('message', wrapper.message, false);
wrapper.other.removeEventListener('close', wrapper.close, false);
// wrapper.other.removeEventListener('close', wrapper.close, false);
};
window.addEventListener('message', wrapper.listener, false);
wrapper.other.addEventListener('close', wrapper.close, false);
// wrapper.other.addEventListener('close', wrapper.close, false);
};
genilib.sendCertificate = function (cert)
{
window.opener.postMessage({certificate: cert}, genilib.trustedHost);
var options = {
certificate: cert,
authority: true
};
window.opener.postMessage(options, '*'/*genilib.trustedHost*/);
window.close();
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment