Bug 976692 - Add IdP caching. r=jib

CLOSED TREE
This commit is contained in:
Martin Thomson 2014-03-14 11:25:37 -07:00
parent a89d5139a1
commit 290aaae8d9
2 changed files with 14 additions and 8 deletions

View File

@ -160,6 +160,10 @@ IdpProxy.prototype = {
this.pending = []; this.pending = [];
}, },
isSame: function(domain, protocol) {
return this.domain === domain && ((protocol || "default") === this.protocol);
},
/** /**
* Get a sandboxed iframe for hosting the idp-proxy's js. Create a message * Get a sandboxed iframe for hosting the idp-proxy's js. Create a message
* channel down to the frame. * channel down to the frame.
@ -260,7 +264,7 @@ IdpProxy.prototype = {
}, },
toString: function() { toString: function() {
return this.domain + '/' + this.protocol; return this.domain + '/.../' + this.protocol;
} }
}; };

View File

@ -38,10 +38,15 @@ function PeerConnectionIdp(window, timeout, warningFunc) {
})(); })();
PeerConnectionIdp.prototype = { PeerConnectionIdp.prototype = {
setIdentityProvider: function( setIdentityProvider: function(provider, protocol, username) {
provider, protocol, username) {
this.provider = provider; this.provider = provider;
this.username = username; this.username = username;
if (this._idpchannel) {
if (this._idpchannel.isSame(provider, protocol)) {
return;
}
this._idpchannel.close();
}
this._idpchannel = new IdpProxy(provider, protocol); this._idpchannel = new IdpProxy(provider, protocol);
}, },
@ -129,9 +134,7 @@ PeerConnectionIdp.prototype = {
callback(null); callback(null);
return; return;
} }
if (!this._idpchannel) { this.setIdentityProvider(identity.idp.domain, identity.idp.protocol);
this.setIdentityProvider(identity.idp.domain, identity.idp.protocol);
}
this._verifyIdentity(identity.assertion, fingerprint, callback); this._verifyIdentity(identity.assertion, fingerprint, callback);
}, },
@ -230,8 +233,7 @@ PeerConnectionIdp.prototype = {
* parameter. If no IdP is configured the original SDP (without a=identity * parameter. If no IdP is configured the original SDP (without a=identity
* line) is passed to the callback. * line) is passed to the callback.
*/ */
appendIdentityToSDP: function( appendIdentityToSDP: function(sdp, fingerprint, callback) {
sdp, fingerprint, callback) {
if (!this._idpchannel) { if (!this._idpchannel) {
callback(sdp); callback(sdp);
return; return;