Author: ssievers
Date: Wed May  2 16:28:05 2012
New Revision: 1333101

URL: http://svn.apache.org/viewvc?rev=1333101&view=rev
Log:
SHINDIG-1764 | Missed request in SHINDIG-1756 | Patch from Brian Lillie.  
Thanks!

Modified:
    
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthRequest.java
    
shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth/testing/FakeOAuthServiceProvider.java

Modified: 
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthRequest.java
URL: 
http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthRequest.java?rev=1333101&r1=1333100&r2=1333101&view=diff
==============================================================================
--- 
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthRequest.java
 (original)
+++ 
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthRequest.java
 Wed May  2 16:28:05 2012
@@ -740,6 +740,7 @@ public class OAuthRequest {
     Uri accessTokenUri = 
Uri.parse(accessor.consumer.serviceProvider.accessTokenURL);
     HttpRequest request = new HttpRequest(accessTokenUri);
     request.setMethod(accessorInfo.getHttpMethod().toString());
+    request.setSecurityToken( new AnonymousSecurityToken( "", 0L, 
this.realRequest.getSecurityToken().getAppUrl(), 0L));
     if (accessorInfo.getHttpMethod() == HttpMethod.POST) {
       request.setHeader("Content-Type", OAuth.FORM_ENCODED);
     }

Modified: 
shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth/testing/FakeOAuthServiceProvider.java
URL: 
http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth/testing/FakeOAuthServiceProvider.java?rev=1333101&r1=1333100&r2=1333101&view=diff
==============================================================================
--- 
shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth/testing/FakeOAuthServiceProvider.java
 (original)
+++ 
shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth/testing/FakeOAuthServiceProvider.java
 Wed May  2 16:28:05 2012
@@ -282,20 +282,11 @@ public class FakeOAuthServiceProvider im
     String url = request.getUri().toString();
     try {
       if (url.startsWith(REQUEST_TOKEN_URL)) {
-        if (request.getSecurityToken() == null) {
-          throw new RuntimeException("Security token should not be null" );
-        }
-        if (!request.getSecurityToken().isAnonymous()) {
-          throw new RuntimeException("Expected an anonymous security token" );
-        }
-        if (expectedRequestSecurityToken != null) {
-          if (!expectedRequestSecurityToken.getAppUrl().equals( 
request.getSecurityToken().getAppUrl() )) {
-            throw new RuntimeException("Security token AppUrl mismatch" );
-          }
-        }
+        checkSecurityToken(request);
         ++requestTokenCount;
         return handleRequestTokenUrl(request);
       } else if (url.startsWith(ACCESS_TOKEN_URL)) {
+        checkSecurityToken(request);
         ++accessTokenCount;
         return handleAccessTokenUrl(request);
       } else if (url.startsWith(RESOURCE_URL)){
@@ -314,6 +305,20 @@ public class FakeOAuthServiceProvider im
     throw new RuntimeException("Unexpected request for " + url);
   }
 
+  private void checkSecurityToken(HttpRequest request) {
+    if (request.getSecurityToken() == null) {
+      throw new RuntimeException("Security token should not be null" );
+    }
+    if (!request.getSecurityToken().isAnonymous()) {
+      throw new RuntimeException("Expected an anonymous security token" );
+    }
+    if (expectedRequestSecurityToken != null) {
+      if (!expectedRequestSecurityToken.getAppUrl().equals( 
request.getSecurityToken().getAppUrl() )) {
+        throw new RuntimeException("Security token AppUrl mismatch" );
+      }
+    }
+  }
+
   private HttpResponse handleRequestTokenUrl(HttpRequest request)
       throws Exception {
     MessageInfo info = parseMessage(request);


Reply via email to