Author: etnu
Date: Mon Feb 25 19:19:50 2008
New Revision: 631075
URL: http://svn.apache.org/viewvc?rev=631075&view=rev
Log:
Committing SHINDIG-93.
Fixing pom.xml to produce compressed javascript in the right location again.
Modified:
incubator/shindig/trunk/features/rpc/rpc.js
incubator/shindig/trunk/java/gadgets/pom.xml
incubator/shindig/trunk/javascript/container/gadgets.js
Modified: incubator/shindig/trunk/features/rpc/rpc.js
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/features/rpc/rpc.js?rev=631075&r1=631074&r2=631075&view=diff
==============================================================================
--- incubator/shindig/trunk/features/rpc/rpc.js (original)
+++ incubator/shindig/trunk/features/rpc/rpc.js Mon Feb 25 19:19:50 2008
@@ -33,9 +33,13 @@
var iframePool = [];
var relayUrl = {};
var useLegacyProtocol = {};
+ var authToken = {};
var callId = 0;
var callbacks = {};
- var parentUrl = gadgets.util.getUrlParameters().parent || '';
+
+ var params = gadgets.util.getUrlParameters();
+ var parentUrl = params.parent || '';
+ authToken['..'] = params.rpctoken || params.ifpctok || params.st;
// Pick the most efficient RPC relay mechanism
var relayChannel = typeof document.postMessage === 'function' ? 'dpm' :
@@ -85,6 +89,13 @@
function process(rpc) {
if (rpc && typeof rpc.s === 'string' && typeof rpc.f === 'string' &&
rpc.a instanceof Array) {
+ // Validate auth token.
+ if (authToken[rpc.f]) {
+ // We allow type coercion here because all the url params are strings.
+ if (authToken[rpc.f] != rpc.t) {
+ throw new Error("Invalid auth token.");
+ }
+ }
var result = (services[rpc.s] || services['']).apply(rpc, rpc.a);
if (rpc.c) {
gadgets.rpc.call(rpc.f, '__cb', null, rpc.c, result);
@@ -229,7 +240,8 @@
s: serviceName,
f: from,
c: callback ? callId : 0,
- a: Array.prototype.slice.call(arguments, 3)
+ a: Array.prototype.slice.call(arguments, 3),
+ t: authToken[targetId]
});
switch (relayChannel) {
@@ -277,11 +289,26 @@
* Sets the relay URL of a target frame.
* @param {String} targetId Name of the target frame.
* @param {String} relayUrl Full relay URL of the target frame.
+ * @param {Boolean} opt_useLegacy True if this relay needs the legacy IFPC
+ * wire format.
*
* @member gadgets.rpc
*/
- setRelayUrl: function(targetId, relayUrl) {
+ setRelayUrl: function(targetId, relayUrl, opt_useLegacy) {
relayUrl[targetId] = relayUrl;
+ useLegacyProtocol[targetId] = !!opt_useLegacy;
+ },
+
+ /**
+ * Sets the auth token of a target frame.
+ * @param {String} targetId Name of the target frame.
+ * @param {String} token The authentication token to use for all
+ * calls to or from this target id.
+ *
+ * @member gadgets.rpc
+ */
+ setAuthToken: function(targetId, token) {
+ authToken[targetId] = token;
},
/**
Modified: incubator/shindig/trunk/java/gadgets/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/pom.xml?rev=631075&r1=631074&r2=631075&view=diff
==============================================================================
--- incubator/shindig/trunk/java/gadgets/pom.xml (original)
+++ incubator/shindig/trunk/java/gadgets/pom.xml Mon Feb 25 19:19:50 2008
@@ -123,7 +123,7 @@
<!-- <artifactId>maven-javascript-plugin</artifactId> -->
<groupId>net.sf.alchim</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
- <version>0.6</version>
+ <version>0.6.2</version>
<executions>
<execution>
<goals>
Modified: incubator/shindig/trunk/javascript/container/gadgets.js
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/container/gadgets.js?rev=631075&r1=631074&r2=631075&view=diff
==============================================================================
--- incubator/shindig/trunk/javascript/container/gadgets.js (original)
+++ incubator/shindig/trunk/javascript/container/gadgets.js Mon Feb 25 19:19:50
2008
@@ -452,6 +452,8 @@
'gadgets-gadget-user-prefs-dialog-action-bar';
gadgets.IfrGadget.prototype.cssClassTitleButton =
'gadgets-gadget-title-button';
gadgets.IfrGadget.prototype.cssClassGadgetContent = 'gadgets-gadget-content';
+gadgets.IfrGadget.prototype.rpcToken = (0xFFFFFFFF * Math.random()) | 0;
+gadgets.IfrGadget.prototype.rpcRelay = 'files/rpc_relay.html';
gadgets.IfrGadget.prototype.getTitleBarContent = function(continuation) {
continuation('<div class="' + this.cssClassTitleBar + '"><span id="' +
@@ -480,6 +482,8 @@
gadgets.IfrGadget.prototype.getMainContent = function(continuation) {
var iframeId = this.getIframeId();
+ gadgets.rpc.setRelayUrl(iframeId, this.serverBase_ + this.rpcRelay);
+ gadgets.rpc.setAuthToken(iframeId, this.rpcToken);
continuation('<div class="' + this.cssClassGadgetContent + '"><iframe id="' +
iframeId + '" name="' + iframeId + '" class="' + this.cssClassGadget +
'" src="' + this.getIframeUrl() +
@@ -497,7 +501,7 @@
gadgets.IfrGadget.prototype.getIframeUrl = function() {
return this.serverBase_ + 'ifr?url=' +
encodeURIComponent(this.specUrl) + '&synd=' + this.SYND + '&mid=' +
- this.id + this.getUserPrefsParams();
+ this.id + "&rpctoken=" + this.rpcToken + this.getUserPrefsParams();
};
gadgets.IfrGadget.prototype.getUserPrefsParams = function() {