cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1176408 [3/3] - in /cxf/trunk: distribution/src/main/release/samples/oauth/ distribution/src/main/release/samples/oauth/client/ distribution/src/main/release/samples/oauth/client/src/ distribution/src/main/release/samples/oauth/client/src/...
Date Tue, 27 Sep 2011 14:47:33 GMT
Modified: cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/filters/AbstractAuthFilter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/filters/AbstractAuthFilter.java?rev=1176408&r1=1176407&r2=1176408&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/filters/AbstractAuthFilter.java
(original)
+++ cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/filters/AbstractAuthFilter.java
Tue Sep 27 14:47:30 2011
@@ -82,7 +82,7 @@ public class AbstractAuthFilter {
                 throw new OAuthProblemException();
             }
             //check valid scope
-            if (!checkScopes(req, accessToken.getScopes())) {
+            if (!checkRequestURI(req, accessToken.getUris())) {
                 throw new OAuthProblemException();
             }
             if (accessToken.getHttpVerbs() != null 
@@ -94,7 +94,7 @@ public class AbstractAuthFilter {
         } else {
             String consumerKey = oAuthMessage.getParameter(OAuth.OAUTH_CONSUMER_KEY);
             authInfo = dataProvider.getClient(consumerKey);
-            if (!checkScopes(req, authInfo.getScopes())) {
+            if (!checkRequestURI(req, authInfo.getUris())) {
                 throw new OAuthProblemException();
             }
         }
@@ -105,21 +105,21 @@ public class AbstractAuthFilter {
         
     }
 
-    protected boolean checkScopes(HttpServletRequest request, List<String> scopes)
{
-        if (scopes == null) {
+    protected boolean checkRequestURI(HttpServletRequest request, List<String> uris)
{
+        if (uris == null) {
             return true;
         }
         String servletPath = request.getPathInfo();
         boolean foundValidScope = false;
-        for (String scope : scopes) {
-            boolean wildcard = scope.endsWith("*");
+        for (String uri : uris) {
+            boolean wildcard = uri.endsWith("*");
             if (wildcard) {
-                if (servletPath.startsWith(scope.substring(0, scope.length() - 1))) {
+                if (servletPath.startsWith(uri.substring(0, uri.length() - 1))) {
                     foundValidScope = true;
                     break;
                 }
             } else {
-                if (scope.equals(servletPath)) {
+                if (uri.equals(servletPath)) {
                     foundValidScope = true;
                     break;
                 }

Modified: cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/filters/OAuthInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/filters/OAuthInfo.java?rev=1176408&r1=1176407&r2=1176408&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/filters/OAuthInfo.java
(original)
+++ cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/filters/OAuthInfo.java
Tue Sep 27 14:47:30 2011
@@ -44,7 +44,7 @@ public class OAuthInfo {
     
     public List<String> getRoles() {
         List<OAuthPermission> permissions = provider.getPermissionsInfo(
-            token != null ? token.getPermissions() : client.getPermissions());
+            token != null ? token.getScopes() : client.getScopes());
         List<String> authorities = new ArrayList<String>();
         if (permissions != null) {
             for (OAuthPermission permission : permissions) {

Modified: cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/AuthorizationRequestHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/AuthorizationRequestHandler.java?rev=1176408&r1=1176407&r2=1176408&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/AuthorizationRequestHandler.java
(original)
+++ cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/AuthorizationRequestHandler.java
Tue Sep 27 14:47:30 2011
@@ -68,8 +68,8 @@ public class AuthorizationRequestHandler
             OAuthAuthorizationData secData = new OAuthAuthorizationData();
             if (!compareRequestSessionTokens(request)) {
                 secData.setPermissions(
-                        dataProvider.getPermissionsInfo(token.getPermissions()));
-                secData.setScopes(token.getScopes());
+                        dataProvider.getPermissionsInfo(token.getScopes()));
+                secData.setUris(token.getUris());
                 addAuthenticityTokenToSession(secData, request);
                 return Response.ok(addAdditionalParams(secData, token)).build();
             }

Modified: cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/RequestTokenHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/RequestTokenHandler.java?rev=1176408&r1=1176407&r2=1176408&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/RequestTokenHandler.java
(original)
+++ cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/RequestTokenHandler.java
Tue Sep 27 14:47:30 2011
@@ -18,7 +18,6 @@
  */
 package org.apache.cxf.rs.security.oauth.services;
 
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -55,8 +54,6 @@ public class RequestTokenHandler {
         };
     
     private long tokenLifetime = 3600L;
-    private String defaultPermission;
-    private String defaultScope;
     
     public Response handle(HttpServletRequest request, OAuthDataProvider dataProvider) {
         try {
@@ -80,20 +77,14 @@ public class RequestTokenHandler {
             String callback = oAuthMessage.getParameter(OAuth.OAUTH_CALLBACK);
             validateCallbackURL(client, callback);
 
-            List<String> permissions = OAuthUtils.parsePermissionsFromRequest(oAuthMessage);
-            if (permissions.isEmpty() && defaultPermission != null) {
-                permissions = Collections.singletonList(defaultPermission);
-            }
             List<String> scopes = OAuthUtils.parseScopesFromRequest(oAuthMessage);
-            if (scopes.isEmpty() && defaultScope != null) {
-                scopes = Collections.singletonList(defaultScope);    
-            }
+            List<String> uris = OAuthUtils.parseUrisFromRequest(oAuthMessage);
             
             RequestTokenRegistration reg = new RequestTokenRegistration();
             reg.setClient(client);
             reg.setState(oAuthMessage.getParameter("state"));
+            reg.setUris(uris);
             reg.setScopes(scopes);
-            reg.setPermissions(permissions);
             reg.setLifetime(tokenLifetime);
             
             RequestToken requestToken = dataProvider.createRequestToken(reg);
@@ -146,13 +137,5 @@ public class RequestTokenHandler {
     public void setTokenLifetime(long tokenLifetime) {
         this.tokenLifetime = tokenLifetime;
     }
-
-    public void setDefaultPermission(String defaultPermission) {
-        this.defaultPermission = defaultPermission;
-    }
-    
-    public void setDefaultScope(String defaultScope) {
-        this.defaultScope = defaultScope;
-    }
-        
+            
 }

Modified: cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/utils/OAuthConstants.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/utils/OAuthConstants.java?rev=1176408&r1=1176407&r2=1176408&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/utils/OAuthConstants.java
(original)
+++ cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/utils/OAuthConstants.java
Tue Sep 27 14:47:30 2011
@@ -28,8 +28,8 @@ public final class OAuthConstants {
     public static final String VERIFIER_INVALID = "verifier_invalid";
 
     public static final String AUTHENTICITY_TOKEN = "session_authenticity_token";
+    public static final String X_OAUTH_URI = "x_oauth_uri";
     public static final String X_OAUTH_SCOPE = "x_oauth_scope";
-    public static final String X_OAUTH_PERMISSION = "x_oauth_permission";
 
     public static final String AUTHORIZATION_DECISION_KEY = "oauthDecision";
     public static final String AUTHORIZATION_DECISION_ALLOW = "allow";

Modified: cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/utils/OAuthUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/utils/OAuthUtils.java?rev=1176408&r1=1176407&r2=1176408&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/utils/OAuthUtils.java
(original)
+++ cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/utils/OAuthUtils.java
Tue Sep 27 14:47:30 2011
@@ -143,13 +143,13 @@ public final class OAuthUtils {
         return scopeList;
     }
 
-    public static List<String> parsePermissionsFromRequest(OAuthMessage message) throws
IOException {
-        return parseParamFromRequest(message.getParameter(OAuthConstants.X_OAUTH_PERMISSION));
-    }
-    
     public static List<String> parseScopesFromRequest(OAuthMessage message) throws
IOException {
         return parseParamFromRequest(message.getParameter(OAuthConstants.X_OAUTH_SCOPE));
     }
+    
+    public static List<String> parseUrisFromRequest(OAuthMessage message) throws IOException
{
+        return parseParamFromRequest(message.getParameter(OAuthConstants.X_OAUTH_URI));
+    }
 
     /**
      * Translates parameters into <code>application/x-www-form-urlencoded</code>
String



Mime
View raw message