oltu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lmo...@apache.org
Subject svn commit: r1243677 - in /incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src: main/java/org/apache/amber/oauth2/rs/extractor/ main/java/org/apache/amber/oauth2/rs/validator/ test/java/org/apache/amber/oauth2/rs/ test/java/org/apache/amber/oauth...
Date Mon, 13 Feb 2012 20:24:16 GMT
Author: lmoren
Date: Mon Feb 13 20:24:15 2012
New Revision: 1243677

URL: http://svn.apache.org/viewvc?rev=1243677&view=rev
Log:
AMBER-28 OAuthAccessResourceRequest and extractors using old version of spec to find access
token

Modified:
    incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/main/java/org/apache/amber/oauth2/rs/extractor/BodyTokenExtractor.java
    incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/main/java/org/apache/amber/oauth2/rs/extractor/QueryTokenExtractor.java
    incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/main/java/org/apache/amber/oauth2/rs/validator/BodyOAuthValidator.java
    incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/main/java/org/apache/amber/oauth2/rs/validator/QueryOAuthValidator.java
    incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/OAuthAccessResourceRequestTest.java
    incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/extractor/BodyTokenExtractorTest.java
    incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/extractor/QueryTokenExtractorTest.java
    incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/validator/BodyOAuthValidatorTest.java
    incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/validator/QueryOAuthValidatorTest.java

Modified: incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/main/java/org/apache/amber/oauth2/rs/extractor/BodyTokenExtractor.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/main/java/org/apache/amber/oauth2/rs/extractor/BodyTokenExtractor.java?rev=1243677&r1=1243676&r2=1243677&view=diff
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/main/java/org/apache/amber/oauth2/rs/extractor/BodyTokenExtractor.java
(original)
+++ incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/main/java/org/apache/amber/oauth2/rs/extractor/BodyTokenExtractor.java
Mon Feb 13 20:24:15 2012
@@ -35,7 +35,11 @@ public class BodyTokenExtractor implemen
 
     @Override
     public String getAccessToken(HttpServletRequest request) {
-        return request.getParameter(OAuth.OAUTH_TOKEN);
+        String token = request.getParameter(OAuth.OAUTH_BEARER_TOKEN);
+        if (token == null) {
+            token = request.getParameter(OAuth.OAUTH_TOKEN);
+        }
+        return token;
     }
 
     @Override

Modified: incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/main/java/org/apache/amber/oauth2/rs/extractor/QueryTokenExtractor.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/main/java/org/apache/amber/oauth2/rs/extractor/QueryTokenExtractor.java?rev=1243677&r1=1243676&r2=1243677&view=diff
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/main/java/org/apache/amber/oauth2/rs/extractor/QueryTokenExtractor.java
(original)
+++ incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/main/java/org/apache/amber/oauth2/rs/extractor/QueryTokenExtractor.java
Mon Feb 13 20:24:15 2012
@@ -34,9 +34,9 @@ public class QueryTokenExtractor impleme
 
     @Override
     public String getAccessToken(HttpServletRequest request) {
-        String token = request.getParameter(OAuth.OAUTH_TOKEN);
+        String token = request.getParameter(OAuth.OAUTH_BEARER_TOKEN);
         if (token == null) {
-            token = request.getParameter(OAuth.OAUTH_BEARER_TOKEN);
+            token = request.getParameter(OAuth.OAUTH_TOKEN);
         }
         return token;
     }

Modified: incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/main/java/org/apache/amber/oauth2/rs/validator/BodyOAuthValidator.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/main/java/org/apache/amber/oauth2/rs/validator/BodyOAuthValidator.java?rev=1243677&r1=1243676&r2=1243677&view=diff
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/main/java/org/apache/amber/oauth2/rs/validator/BodyOAuthValidator.java
(original)
+++ incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/main/java/org/apache/amber/oauth2/rs/validator/BodyOAuthValidator.java
Mon Feb 13 20:24:15 2012
@@ -23,11 +23,11 @@ package org.apache.amber.oauth2.rs.valid
 
 import javax.servlet.http.HttpServletRequest;
 
+import org.apache.amber.oauth2.common.OAuth;
 import org.apache.amber.oauth2.common.error.OAuthError;
 import org.apache.amber.oauth2.common.exception.OAuthProblemException;
 import org.apache.amber.oauth2.common.utils.OAuthUtils;
 import org.apache.amber.oauth2.common.validators.AbstractValidator;
-import org.apache.amber.oauth2.common.OAuth;
 
 
 /**
@@ -68,9 +68,12 @@ public class BodyOAuthValidator extends 
         }
 
 
-        String[] tokens = request.getParameterValues(OAuth.OAUTH_TOKEN);
+        String[] tokens = request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN);
         if (OAuthUtils.hasEmptyValues(tokens)) {
-            throw OAuthProblemException.error(null, "Missing OAuth token.");
+            tokens = request.getParameterValues(OAuth.OAUTH_TOKEN);
+            if (OAuthUtils.hasEmptyValues(tokens)) {
+                throw OAuthProblemException.error(null, "Missing OAuth token.");
+            }
         }
 
         if (tokens.length > 1) {

Modified: incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/main/java/org/apache/amber/oauth2/rs/validator/QueryOAuthValidator.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/main/java/org/apache/amber/oauth2/rs/validator/QueryOAuthValidator.java?rev=1243677&r1=1243676&r2=1243677&view=diff
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/main/java/org/apache/amber/oauth2/rs/validator/QueryOAuthValidator.java
(original)
+++ incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/main/java/org/apache/amber/oauth2/rs/validator/QueryOAuthValidator.java
Mon Feb 13 20:24:15 2012
@@ -24,8 +24,8 @@ package org.apache.amber.oauth2.rs.valid
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.amber.oauth2.common.OAuth;
-import org.apache.amber.oauth2.common.exception.OAuthProblemException;
 import org.apache.amber.oauth2.common.error.OAuthError;
+import org.apache.amber.oauth2.common.exception.OAuthProblemException;
 import org.apache.amber.oauth2.common.utils.OAuthUtils;
 import org.apache.amber.oauth2.common.validators.AbstractValidator;
 
@@ -49,10 +49,14 @@ public class QueryOAuthValidator extends
     public void validateRequiredParameters(HttpServletRequest request) throws OAuthProblemException
{
 
 
-        String[] tokens = request.getParameterValues(OAuth.OAUTH_TOKEN);
+        String[] tokens = request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN);
         if (OAuthUtils.hasEmptyValues(tokens)) {
-            throw OAuthProblemException.error("", "Missing OAuth token.");
+            tokens = request.getParameterValues(OAuth.OAUTH_TOKEN);
+            if (OAuthUtils.hasEmptyValues(tokens)) {
+                throw OAuthProblemException.error(null, "Missing OAuth token.");
+            }
         }
+        
         if (tokens != null && tokens.length > 1) {
             throw OAuthProblemException
                 .error(OAuthError.TokenResponse.INVALID_REQUEST, "Multiple tokens attached.");

Modified: incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/OAuthAccessResourceRequestTest.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/OAuthAccessResourceRequestTest.java?rev=1243677&r1=1243676&r2=1243677&view=diff
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/OAuthAccessResourceRequestTest.java
(original)
+++ incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/OAuthAccessResourceRequestTest.java
Mon Feb 13 20:24:15 2012
@@ -21,22 +21,18 @@
 
 package org.apache.amber.oauth2.rs;
 
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.fail;
+
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.amber.oauth2.common.OAuth;
+import org.apache.amber.oauth2.common.error.OAuthError;
 import org.apache.amber.oauth2.common.exception.OAuthProblemException;
 import org.apache.amber.oauth2.common.message.types.ParameterStyle;
 import org.apache.amber.oauth2.rs.request.OAuthAccessResourceRequest;
 import org.junit.Assert;
 import org.junit.Test;
-import org.apache.amber.oauth2.common.error.OAuthError;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.fail;
 
 
 /**
@@ -152,7 +148,7 @@ public class OAuthAccessResourceRequestT
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.GET);
         expect(request.getContentType()).andStubReturn(OAuth.ContentType.URL_ENCODED);
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN)).andStubReturn(new String[]
{"sometoken"});
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(new String[]
{"sometoken"});
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
         replay(request);
 
@@ -173,7 +169,7 @@ public class OAuthAccessResourceRequestT
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.POST);
         expect(request.getContentType()).andStubReturn(OAuth.ContentType.JSON);
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN)).andStubReturn(new String[]
{"sometoken"});
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(new String[]
{"sometoken"});
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
         replay(request);
         try {
@@ -193,7 +189,7 @@ public class OAuthAccessResourceRequestT
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.POST);
         expect(request.getContentType()).andStubReturn(OAuth.ContentType.URL_ENCODED);
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN)).andStubReturn(new String[]
{"sometoken"});
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(new String[]
{"sometoken"});
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn("HMAC-SHA1");
         replay(request);
         try {
@@ -215,7 +211,7 @@ public class OAuthAccessResourceRequestT
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.POST);
         expect(request.getContentType()).andStubReturn(OAuth.ContentType.URL_ENCODED);
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN)).andStubReturn(new String[]
{"sometoken"});
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(new String[]
{"sometoken"});
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
         expect(request.getHeader(OAuth.HeaderType.AUTHORIZATION))
             .andStubReturn("OAuth sadfasfd,oauth_signature_method=\"HMAC-SHA1\"");
@@ -238,6 +234,7 @@ public class OAuthAccessResourceRequestT
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.POST);
         expect(request.getContentType()).andStubReturn(OAuth.ContentType.URL_ENCODED);
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(null);
         expect(request.getParameterValues(OAuth.OAUTH_TOKEN)).andStubReturn(null);
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
         replay(request);
@@ -257,7 +254,7 @@ public class OAuthAccessResourceRequestT
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.POST);
         expect(request.getContentType()).andStubReturn(OAuth.ContentType.URL_ENCODED);
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN))
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN))
             .andStubReturn(new String[] {"sometoken", "othertoken"});
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
         replay(request);
@@ -279,7 +276,7 @@ public class OAuthAccessResourceRequestT
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.POST);
         expect(request.getContentType()).andStubReturn(OAuth.ContentType.URL_ENCODED);
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN)).andStubReturn(new String[]
{"sometoken"});
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(new String[]
{"sometoken"});
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
         replay(request);
 
@@ -297,6 +294,7 @@ public class OAuthAccessResourceRequestT
 
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.GET);
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(null);
         expect(request.getParameterValues(OAuth.OAUTH_TOKEN)).andStubReturn(null);
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
         replay(request);
@@ -316,7 +314,7 @@ public class OAuthAccessResourceRequestT
 
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.GET);
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN)).andStubReturn(new String[]
{"sometoken"});
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(new String[]
{"sometoken"});
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn("HMAC-SHA1");
         replay(request);
 
@@ -336,7 +334,7 @@ public class OAuthAccessResourceRequestT
 
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.GET);
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN))
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN))
             .andStubReturn(new String[] {"sometoken", "othertoken"});
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
         replay(request);
@@ -357,7 +355,7 @@ public class OAuthAccessResourceRequestT
 
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.GET);
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN)).andStubReturn(new String[]
{"sometoken"});
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(new String[]
{"sometoken"});
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
         replay(request);
 
@@ -373,9 +371,10 @@ public class OAuthAccessResourceRequestT
     @Test
     public void testGetAccessTokenWrongQueryRequest() throws Exception {
         HttpServletRequest request = createMock(HttpServletRequest.class);
-        expect(request.getParameter(OAuth.OAUTH_TOKEN)).andStubReturn(null);
+        expect(request.getParameter(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(null);
+        expect(request.getParameterValues(OAuth.OAUTH_TOKEN)).andStubReturn(null);      
 
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN))
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN))
             .andStubReturn(new String[] {null});
 
         replay(request);
@@ -392,10 +391,10 @@ public class OAuthAccessResourceRequestT
     @Test
     public void testGetAccessTokenWrongHeaderRequest() throws Exception {
         HttpServletRequest request = createMock(HttpServletRequest.class);
-        expect(request.getParameter(OAuth.OAUTH_TOKEN)).andStubReturn(null);
+        expect(request.getParameter(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(null);
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
         expect(request.getHeader("Authorization")).andStubReturn(null);
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN))
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN))
             .andStubReturn(new String[] {null});
 
         replay(request);
@@ -412,13 +411,14 @@ public class OAuthAccessResourceRequestT
     @Test
     public void testGetAccessTokenWrongBodyRequest() throws Exception {
         HttpServletRequest request = createMock(HttpServletRequest.class);
-        expect(request.getParameter(OAuth.OAUTH_TOKEN)).andStubReturn(null);
+        expect(request.getParameter(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(null);
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
         expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.POST);
         expect(request.getContentType()).andStubReturn(OAuth.ContentType.URL_ENCODED);
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN))
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN))
             .andStubReturn(new String[] {null});
-
+        expect(request.getParameterValues(OAuth.OAUTH_TOKEN))
+        .andStubReturn(new String[] {null});
         replay(request);
 
         try {
@@ -435,11 +435,11 @@ public class OAuthAccessResourceRequestT
         HttpServletRequest request = createMock(HttpServletRequest.class);
 
         //test body
-        expect(request.getParameter(OAuth.OAUTH_TOKEN)).andStubReturn("sometoken");
+        expect(request.getParameter(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn("sometoken");
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
         expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.POST);
         expect(request.getContentType()).andStubReturn(OAuth.ContentType.URL_ENCODED);
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN))
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN))
             .andStubReturn(new String[] {"sometoken"});
 
         replay(request);
@@ -455,10 +455,10 @@ public class OAuthAccessResourceRequestT
 
         reset(request);
         //test header
-        expect(request.getParameter(OAuth.OAUTH_TOKEN)).andStubReturn("sometoken");
+        expect(request.getParameter(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn("sometoken");
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
         expect(request.getHeader("Authorization")).andStubReturn(AUTHORIZATION_HEADER_OAUTH2);
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN))
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN))
             .andStubReturn(new String[] {"sometoken"});
 
         replay(request);
@@ -473,9 +473,9 @@ public class OAuthAccessResourceRequestT
 
         reset(request);
         //test uri query
-        expect(request.getParameter(OAuth.OAUTH_TOKEN)).andStubReturn("sometoken");
+        expect(request.getParameter(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn("sometoken");
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN))
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN))
             .andStubReturn(new String[] {"sometoken"});
 
         replay(request);
@@ -488,12 +488,14 @@ public class OAuthAccessResourceRequestT
     @Test
     public void testMultipleStylesValidRequest() throws Exception {
         HttpServletRequest request = createMock(HttpServletRequest.class);
-        expect(request.getParameter(OAuth.OAUTH_TOKEN)).andStubReturn(null);
+        expect(request.getParameter(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(null);
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
         expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.POST);
         expect(request.getContentType()).andStubReturn(OAuth.ContentType.URL_ENCODED);
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN))
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN))
             .andStubReturn(new String[] {null});
+        expect(request.getParameterValues(OAuth.OAUTH_TOKEN))
+        .andStubReturn(new String[] {null});
         expect(request.getHeader("Authorization")).andStubReturn(AUTHORIZATION_HEADER_OAUTH2);
 
         replay(request);
@@ -510,11 +512,11 @@ public class OAuthAccessResourceRequestT
     @Test
     public void testMultipleStylesInvalidRequest() throws Exception {
         HttpServletRequest request = createMock(HttpServletRequest.class);
-        expect(request.getParameter(OAuth.OAUTH_TOKEN)).andStubReturn("sometoken");
+        expect(request.getParameter(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn("sometoken");
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
         expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.POST);
         expect(request.getContentType()).andStubReturn(OAuth.ContentType.URL_ENCODED);
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN))
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN))
             .andStubReturn(new String[] {"sometoken"});
         expect(request.getHeader("Authorization")).andStubReturn(AUTHORIZATION_HEADER_OAUTH2);
 

Modified: incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/extractor/BodyTokenExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/extractor/BodyTokenExtractorTest.java?rev=1243677&r1=1243676&r2=1243677&view=diff
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/extractor/BodyTokenExtractorTest.java
(original)
+++ incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/extractor/BodyTokenExtractorTest.java
Mon Feb 13 20:24:15 2012
@@ -21,18 +21,17 @@
 
 package org.apache.amber.oauth2.rs.extractor;
 
+import static org.easymock.EasyMock.createStrictMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
 import javax.servlet.http.HttpServletRequest;
 
 import junit.framework.Assert;
 
-import org.apache.amber.oauth2.rs.extractor.BodyTokenExtractor;
-import org.junit.Test;
 import org.apache.amber.oauth2.common.OAuth;
-
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
+import org.junit.Test;
 
 
 /**
@@ -46,7 +45,7 @@ public class BodyTokenExtractorTest {
     public void testGetAccessToken() throws Exception {
 
         HttpServletRequest request = createStrictMock(HttpServletRequest.class);
-        expect(request.getParameter(OAuth.OAUTH_TOKEN)).andStubReturn("sometoken");
+        expect(request.getParameter(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn("sometoken");
         replay(request);
         BodyTokenExtractor bte = new BodyTokenExtractor();
         Assert.assertEquals("sometoken", bte.getAccessToken(request));
@@ -57,6 +56,7 @@ public class BodyTokenExtractorTest {
     public void testGetAccessTokenNull() throws Exception {
 
         HttpServletRequest request = createStrictMock(HttpServletRequest.class);
+        expect(request.getParameter(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(null);
         expect(request.getParameter(OAuth.OAUTH_TOKEN)).andStubReturn(null);
         replay(request);
         BodyTokenExtractor bte = new BodyTokenExtractor();

Modified: incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/extractor/QueryTokenExtractorTest.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/extractor/QueryTokenExtractorTest.java?rev=1243677&r1=1243676&r2=1243677&view=diff
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/extractor/QueryTokenExtractorTest.java
(original)
+++ incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/extractor/QueryTokenExtractorTest.java
Mon Feb 13 20:24:15 2012
@@ -45,7 +45,7 @@ public class QueryTokenExtractorTest {
     public void testGetAccessToken() throws Exception {
 
         HttpServletRequest request = createStrictMock(HttpServletRequest.class);
-        expect(request.getParameter(OAuth.OAUTH_TOKEN)).andStubReturn("sometoken");
+        expect(request.getParameter(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn("sometoken");
         replay(request);
         QueryTokenExtractor qte = new QueryTokenExtractor();
         Assert.assertEquals("sometoken", qte.getAccessToken(request));

Modified: incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/validator/BodyOAuthValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/validator/BodyOAuthValidatorTest.java?rev=1243677&r1=1243676&r2=1243677&view=diff
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/validator/BodyOAuthValidatorTest.java
(original)
+++ incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/validator/BodyOAuthValidatorTest.java
Mon Feb 13 20:24:15 2012
@@ -21,6 +21,11 @@
 
 package org.apache.amber.oauth2.rs.validator;
 
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
 import javax.servlet.http.HttpServletRequest;
 
 import junit.framework.Assert;
@@ -28,14 +33,8 @@ import junit.framework.Assert;
 import org.apache.amber.oauth2.common.OAuth;
 import org.apache.amber.oauth2.common.error.OAuthError;
 import org.apache.amber.oauth2.common.exception.OAuthProblemException;
-import org.apache.amber.oauth2.rs.validator.BodyOAuthValidator;
 import org.junit.Test;
 
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-
 /**
  * @author Maciej Machulak (m.p.machulak@ncl.ac.uk)
  * @author Lukasz Moren (lukasz.moren@ncl.ac.uk)
@@ -101,7 +100,7 @@ public class BodyOAuthValidatorTest {
         expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.POST);
         expect(request.getContentType()).andStubReturn(OAuth.ContentType.URL_ENCODED);
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn("HMAC-SHA1");
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN)).andStubReturn(new String[]
{"access_token"});
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(new String[]
{"access_token"});
         replay(request);
         try {
             BodyOAuthValidator bov = new BodyOAuthValidator();
@@ -120,6 +119,7 @@ public class BodyOAuthValidatorTest {
         expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.POST);
         expect(request.getContentType()).andStubReturn(OAuth.ContentType.URL_ENCODED);
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(null);
         expect(request.getParameterValues(OAuth.OAUTH_TOKEN)).andStubReturn(null);
         replay(request);
         try {
@@ -139,7 +139,7 @@ public class BodyOAuthValidatorTest {
         expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.POST);
         expect(request.getContentType()).andStubReturn(OAuth.ContentType.URL_ENCODED);
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN))
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN))
             .andStubReturn(new String[] {"access_token1", "access_token2"});
         replay(request);
         try {
@@ -159,7 +159,7 @@ public class BodyOAuthValidatorTest {
         expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.POST);
         expect(request.getContentType()).andStubReturn(OAuth.ContentType.URL_ENCODED);
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN)).andStubReturn(new String[]
{"access_token"});
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(new String[]
{"access_token"});
         replay(request);
         BodyOAuthValidator bov = new BodyOAuthValidator();
         bov.performAllValidations(request);

Modified: incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/validator/QueryOAuthValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/validator/QueryOAuthValidatorTest.java?rev=1243677&r1=1243676&r2=1243677&view=diff
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/validator/QueryOAuthValidatorTest.java
(original)
+++ incubator/amber/trunk/oauth-2.0/oauth2-resourceserver/src/test/java/org/apache/amber/oauth2/rs/validator/QueryOAuthValidatorTest.java
Mon Feb 13 20:24:15 2012
@@ -21,6 +21,11 @@
 
 package org.apache.amber.oauth2.rs.validator;
 
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
 import javax.servlet.http.HttpServletRequest;
 
 import junit.framework.Assert;
@@ -28,14 +33,8 @@ import junit.framework.Assert;
 import org.apache.amber.oauth2.common.OAuth;
 import org.apache.amber.oauth2.common.error.OAuthError;
 import org.apache.amber.oauth2.common.exception.OAuthProblemException;
-import org.apache.amber.oauth2.rs.validator.QueryOAuthValidator;
-import org.junit.Test;
 import org.apache.amber.oauth2.common.utils.OAuthUtils;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
+import org.junit.Test;
 
 /**
  * @author Maciej Machulak (m.p.machulak@ncl.ac.uk)
@@ -50,7 +49,7 @@ public class QueryOAuthValidatorTest {
 
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn("HMAC-SHA1");
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN)).andStubReturn(new String[]
{"access_token"});
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(new String[]
{"access_token"});
         replay(request);
         try {
             QueryOAuthValidator qov = new QueryOAuthValidator();
@@ -69,6 +68,7 @@ public class QueryOAuthValidatorTest {
 
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(null);
         expect(request.getParameterValues(OAuth.OAUTH_TOKEN)).andStubReturn(null);
         replay(request);
         try {
@@ -88,7 +88,7 @@ public class QueryOAuthValidatorTest {
 
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN))
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN))
             .andStubReturn(new String[] {"access_token1", "access_token2"});
         replay(request);
         try {
@@ -108,7 +108,7 @@ public class QueryOAuthValidatorTest {
 
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
-        expect(request.getParameterValues(OAuth.OAUTH_TOKEN)).andStubReturn(new String[]
{"access_token1"});
+        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(new String[]
{"access_token1"});
         replay(request);
         QueryOAuthValidator qov = new QueryOAuthValidator();
         qov.performAllValidations(request);



Mime
View raw message