author | Jan-Ivar Bruaroey <jib@mozilla.com> |
Mon, 08 Dec 2014 09:53:47 -0600 | |
changeset 219121 | fb73f5e56e47c3f40db7ad7870d7831520548627 |
parent 219120 | e210b532f9dcf960b40b652695d91ab1a2483cfa |
child 219122 | e5bf096003d52758f72ee79dff6f63faec4fb232 |
push id | 27956 |
push user | kwierso@gmail.com |
push date | Fri, 12 Dec 2014 00:47:19 +0000 |
treeherder | mozilla-central@32a2c5bd2f68 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mt |
bugs | 1091898 |
milestone | 37.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
dom/media/PeerConnection.js | file | annotate | diff | comparison | revisions | |
dom/media/PeerConnectionIdp.jsm | file | annotate | diff | comparison | revisions |
--- a/dom/media/PeerConnection.js +++ b/dom/media/PeerConnection.js @@ -702,19 +702,22 @@ RTCPeerConnection.prototype = { break; case "pranswer": throw new this._win.DOMError("NotSupportedError", "pranswer not yet implemented"); default: throw new this._win.DOMError("InvalidParameterError", "Invalid type " + desc.type + " provided to setRemoteDescription"); } + // Have to get caller's origin outside of Promise constructor and pass it in + let origin = Cu.getWebIDLCallerPrincipal().origin; + this._queueOrRun({ func: this._setRemoteDescription, - args: [type, desc.sdp, onSuccess, onError], + args: [type, desc.sdp, origin, onSuccess, onError], wait: true }); }, /** * Takes a result from the IdP and checks it against expectations. * If OK, generates events. * Returns true if it is either present and valid, or if there is no @@ -731,17 +734,17 @@ RTCPeerConnection.prototype = { this._impl.peerIdentity = message.identity; this._peerIdentity = new this._win.RTCIdentityAssertion( this._remoteIdp.provider, message.identity); this.dispatchEvent(new this._win.Event("peeridentity")); } return good; }, - _setRemoteDescription: function(type, sdp, onSuccess, onError) { + _setRemoteDescription: function(type, sdp, origin, onSuccess, onError) { let idpComplete = false; let setRemoteComplete = false; let idpError = null; let isDone = false; // we can run the IdP validation in parallel with setRemoteDescription this // complicates much more than would be ideal, but it ensures that the IdP // doesn't hold things up too much when it's not on the critical path @@ -780,17 +783,17 @@ RTCPeerConnection.prototype = { } else { idpComplete = true; allDone(); } }; } try { - this._remoteIdp.verifyIdentityFromSDP(sdp, idpDone); + this._remoteIdp.verifyIdentityFromSDP(sdp, origin, idpDone); } catch (e) { // if processing the SDP for identity doesn't work this.logWarning(e.message, e.fileName, e.lineNumber); idpDone(null); } this._onSetRemoteDescriptionSuccess = setRemoteDone; this._onSetRemoteDescriptionFailure = onError; @@ -1137,17 +1140,18 @@ PeerConnectionObserver.prototype = { dispatchEvent: function(event) { this._dompc.dispatchEvent(event); }, onCreateOfferSuccess: function(sdp) { let pc = this._dompc; let fp = pc._impl.fingerprint; - pc._localIdp.appendIdentityToSDP(sdp, fp, function(sdp, assertion) { + let origin = Cu.getWebIDLCallerPrincipal().origin; + pc._localIdp.appendIdentityToSDP(sdp, fp, origin, function(sdp, assertion) { if (assertion) { pc._gotIdentityAssertion(assertion); } pc.callCB(pc._onCreateOfferSuccess, new pc._win.mozRTCSessionDescription({ type: "offer", sdp: sdp })); pc._executeNext(); }.bind(this)); @@ -1156,17 +1160,18 @@ PeerConnectionObserver.prototype = { onCreateOfferError: function(code, message) { this._dompc.callCB(this._dompc._onCreateOfferFailure, this.newError(code, message)); this._dompc._executeNext(); }, onCreateAnswerSuccess: function(sdp) { let pc = this._dompc; let fp = pc._impl.fingerprint; - pc._localIdp.appendIdentityToSDP(sdp, fp, function(sdp, assertion) { + let origin = Cu.getWebIDLCallerPrincipal().origin; + pc._localIdp.appendIdentityToSDP(sdp, fp, origin, function(sdp, assertion) { if (assertion) { pc._gotIdentityAssertion(assertion); } pc.callCB(pc._onCreateAnswerSuccess, new pc._win.mozRTCSessionDescription({ type: "answer", sdp: sdp })); pc._executeNext(); }.bind(this));
--- a/dom/media/PeerConnectionIdp.jsm +++ b/dom/media/PeerConnectionIdp.jsm @@ -119,28 +119,28 @@ PeerConnectionIdp.prototype = { }, /** * Queues a task to verify the a=identity line the given SDP contains, if any. * If the verification succeeds callback is called with the message from the * IdP proxy as parameter, else (verification failed OR no a=identity line in * SDP at all) null is passed to callback. */ - verifyIdentityFromSDP: function(sdp, callback) { + verifyIdentityFromSDP: function(sdp, origin, callback) { let identity = this._getIdentityFromSdp(sdp); let fingerprints = this._getFingerprintsFromSdp(sdp); // it's safe to use the fingerprint we got from the SDP here, // only because we ensure that there is only one if (!identity || fingerprints.length <= 0) { callback(null); return; } this.setIdentityProvider(identity.idp.domain, identity.idp.protocol); - this._verifyIdentity(identity.assertion, fingerprints, callback); + this._verifyIdentity(identity.assertion, fingerprints, origin, callback); }, /** * Checks that the name in the identity provided by the IdP is OK. * * @param name (string) the name to validate * @returns (string) an error message, iff the name isn't good */ @@ -207,50 +207,51 @@ PeerConnectionIdp.prototype = { warn("invalid JSON in content"); } return false; }, /** * Asks the IdP proxy to verify an identity. */ - _verifyIdentity: function(assertion, fingerprints, callback) { + _verifyIdentity: function(assertion, fingerprints, origin, callback) { function onVerification(message) { if (message && this._checkVerifyResponse(message, fingerprints)) { callback(message); } else { this._warning("RTC identity: assertion validation failure", null, 0); callback(null); } } let request = { type: "VERIFY", - message: assertion + message: assertion, + origin: origin }; this._sendToIdp(request, "validation", onVerification.bind(this)); }, /** * Asks the IdP proxy for an identity assertion and, on success, enriches the * given SDP with an a=identity line and calls callback with the new SDP as * 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, origin, callback) { let onAssertion = function() { callback(this.wrapSdp(sdp), this.assertion); }.bind(this); if (!this._idpchannel || this.assertion) { onAssertion(); return; } - this._getIdentityAssertion(fingerprint, onAssertion); + this._getIdentityAssertion(fingerprint, origin, onAssertion); }, /** * Inserts an identity assertion into the given SDP. */ wrapSdp: function(sdp) { if (!this.assertion) { return sdp; @@ -265,31 +266,33 @@ PeerConnectionIdp.prototype = { getIdentityAssertion: function(fingerprint, callback) { if (!this._idpchannel) { this.reportError("assertion", "IdP not set"); callback(null); return; } - this._getIdentityAssertion(fingerprint, callback); + let origin = Cu.getWebIDLCallerPrincipal().origin; + this._getIdentityAssertion(fingerprint, origin, callback); }, - _getIdentityAssertion: function(fingerprint, callback) { + _getIdentityAssertion: function(fingerprint, origin, callback) { let [algorithm, digest] = fingerprint.split(" ", 2); let message = { fingerprint: [{ algorithm: algorithm, digest: digest }] }; let request = { type: "SIGN", message: JSON.stringify(message), - username: this.username + username: this.username, + origin: origin }; // catch the assertion, clean it up, warn if absent function trapAssertion(assertion) { if (!assertion) { this._warning("RTC identity: assertion generation failure", null, 0); this.assertion = null; } else { @@ -303,17 +306,16 @@ PeerConnectionIdp.prototype = { /** * Packages a message and sends it to the IdP. * @param request (dictionary) the message to send * @param type (DOMString) the type of message (assertion/validation) * @param callback (function) the function to call with the results */ _sendToIdp: function(request, type, callback) { - request.origin = Cu.getWebIDLCallerPrincipal().origin; this._idpchannel.send(request, this._wrapCallback(type, callback)); }, _reportIdpError: function(type, message) { let args = {}; let msg = ""; if (message.type === "ERROR") { msg = message.error;