Author: beaton
Date: Tue Jun 16 21:08:36 2009
New Revision: 785403

URL: http://svn.apache.org/viewvc?rev=785403&view=rev
Log:
Don't depend on gadgets.oauth.Popup for OAuth 1.0a support.

Modified:
    incubator/shindig/trunk/features/src/main/javascript/features/core.io/io.js
    
incubator/shindig/trunk/features/src/main/javascript/features/oauthpopup/oauthpopup.js
    
incubator/shindig/trunk/features/src/test/javascript/features/core.io/iotest.js
    
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/OAuthCallbackServlet.java

Modified: 
incubator/shindig/trunk/features/src/main/javascript/features/core.io/io.js
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/features/src/main/javascript/features/core.io/io.js?rev=785403&r1=785402&r2=785403&view=diff
==============================================================================
--- incubator/shindig/trunk/features/src/main/javascript/features/core.io/io.js 
(original)
+++ incubator/shindig/trunk/features/src/main/javascript/features/core.io/io.js 
Tue Jun 16 21:08:36 2009
@@ -364,12 +364,9 @@
 
       // OAuth goodies
       if (auth === "oauth" || auth === "signed") {
-        if (gadgets.oauth && gadgets.oauth.Popup && 
gadgets.oauth.Popup.getReceivedCallbackUrl) {
-          var callbackResponse = gadgets.oauth.Popup.getReceivedCallbackUrl();
-          if (callbackResponse) {
-            paramData.OAUTH_RECEIVED_CALLBACK = callbackResponse;
-            gadgets.oauth.Popup.setReceivedCallbackUrl(null);
-          }
+        if (gadgets.io.oauthReceivedCallbackUrl_) {
+          paramData.OAUTH_RECEIVED_CALLBACK = 
gadgets.io.oauthReceivedCallbackUrl_;
+          gadgets.io.oauthReceivedCallbackUrl_ = null;
         }
         paramData.oauthState = oauthState || "";
         // Just copy the OAuth parameters into the req to the server

Modified: 
incubator/shindig/trunk/features/src/main/javascript/features/oauthpopup/oauthpopup.js
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/features/src/main/javascript/features/oauthpopup/oauthpopup.js?rev=785403&r1=785402&r2=785403&view=diff
==============================================================================
--- 
incubator/shindig/trunk/features/src/main/javascript/features/oauthpopup/oauthpopup.js
 (original)
+++ 
incubator/shindig/trunk/features/src/main/javascript/features/oauthpopup/oauthpopup.js
 Tue Jun 16 21:08:36 2009
@@ -200,11 +200,3 @@
     self.handleApproval_();
   };
 };
-
-gadgets.oauth.Popup.setReceivedCallbackUrl = function(url) {
-  gadgets.oauth.Popup.receivedCallbackUrl_ = url;
-};
-
-gadgets.oauth.Popup.getReceivedCallbackUrl = function() {
-  return gadgets.oauth.Popup.receivedCallbackUrl_;
-};

Modified: 
incubator/shindig/trunk/features/src/test/javascript/features/core.io/iotest.js
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/features/src/test/javascript/features/core.io/iotest.js?rev=785403&r1=785402&r2=785403&view=diff
==============================================================================
--- 
incubator/shindig/trunk/features/src/test/javascript/features/core.io/iotest.js 
(original)
+++ 
incubator/shindig/trunk/features/src/test/javascript/features/core.io/iotest.js 
Tue Jun 16 21:08:36 2009
@@ -529,6 +529,7 @@
   this.assertEquals("http://sp.example.com/authz?oauth_token=foo";,
       resp.oauthApprovalUrl);
 
+  gadgets.io.oauthReceivedCallbackUrl_ = "http://shindig?oauth_verifier=12345";;
   var req = new fakeXhr.Expectation("POST", "http://example.com/json";);
   this.setStandardArgs(req, true);
   req.setBodyArg("url", "http://target.example.com/somepage";);
@@ -536,6 +537,8 @@
   req.setBodyArg("st", "authtoken");
   req.setBodyArg("oauthState", "newState");
   req.setBodyArg("refresh", null);
+  req.setBodyArg("OAUTH_RECEIVED_CALLBACK",
+      "http://shindig?oauth_verifier=12345";);
   req.setHeader("Content-Type", "application/x-www-form-urlencoded");
 
   var resp = this.makeFakeResponse(
@@ -553,6 +556,7 @@
       },
       params);
   this.assertEquals("personal data", resp.text);
+  this.assertEquals(null, gadgets.io.oauthReceivedCallbackUrl_);
 };
 
 IoTest.prototype.testSignedEquivalentToOAuth = function() {

Modified: 
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/OAuthCallbackServlet.java
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/OAuthCallbackServlet.java?rev=785403&r1=785402&r2=785403&view=diff
==============================================================================
--- 
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/OAuthCallbackServlet.java
 (original)
+++ 
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/OAuthCallbackServlet.java
 Tue Jun 16 21:08:36 2009
@@ -56,8 +56,7 @@
   
   private static final int ONE_HOUR_IN_SECONDS = 3600;
   
-  // This bit of magic will check to see whether the gadget is using the 
oauthpopup library,
-  // and if it does passes the entire callback URL into the library for later 
use.
+  // This bit of magic passes the entire callback URL into the opening gadget 
for later use.
   // gadgets.io.makeRequest (or osapi.oauth) will then pick up the callback 
URL to complete the
   // oauth dance.
   private static final String RESP_BODY =
@@ -70,10 +69,7 @@
     "<body>\n" +
     "<script type='text/javascript'>\n" +
     "try {\n" +
-    "  if (window.opener && window.opener.gadgets && 
window.opener.gadgets.oauth\n" +
-    "      && window.opener.gadgets.oauth.Popup) {\n" +
-    "    
window.opener.gadgets.oauth.Popup.setReceivedCallbackUrl(document.location.href);\n"
 +
-    "  }\n" +
+    "  window.opener.gadgets.io.oauthReceivedCallbackUrl_ = 
document.location.href;\n" +
     "} catch (e) {\n" +
     "}\n" +
     "window.close();\n" +


Reply via email to