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 = [];
},
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
* channel down to the frame.
@ -260,7 +264,7 @@ IdpProxy.prototype = {
},
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 = {
setIdentityProvider: function(
provider, protocol, username) {
setIdentityProvider: function(provider, protocol, username) {
this.provider = provider;
this.username = username;
if (this._idpchannel) {
if (this._idpchannel.isSame(provider, protocol)) {
return;
}
this._idpchannel.close();
}
this._idpchannel = new IdpProxy(provider, protocol);
},
@ -129,9 +134,7 @@ PeerConnectionIdp.prototype = {
callback(null);
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);
},
@ -230,8 +233,7 @@ PeerConnectionIdp.prototype = {
* parameter. If no IdP is configured the original SDP (without a=identity
* line) is passed to the callback.
*/
appendIdentityToSDP: function(
sdp, fingerprint, callback) {
appendIdentityToSDP: function(sdp, fingerprint, callback) {
if (!this._idpchannel) {
callback(sdp);
return;