cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1181720 - in /cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth: data/ services/
Date Tue, 11 Oct 2011 11:31:11 GMT
Author: sergeyb
Date: Tue Oct 11 11:31:11 2011
New Revision: 1181720

URL: http://svn.apache.org/viewvc?rev=1181720&view=rev
Log:
[CXF-2759] Adding replyTo to OAuthAuthorizationData to make it easier to build forms

Modified:
    cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/data/OAuthAuthorizationData.java
    cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/AbstractOAuthService.java
    cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/AuthorizationRequestHandler.java
    cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/AuthorizationRequestService.java
    cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/OAuthDefaultServices.java

Modified: cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/data/OAuthAuthorizationData.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/data/OAuthAuthorizationData.java?rev=1181720&r1=1181719&r2=1181720&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/data/OAuthAuthorizationData.java
(original)
+++ cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/data/OAuthAuthorizationData.java
Tue Oct 11 11:31:11 2011
@@ -29,7 +29,8 @@ public class OAuthAuthorizationData impl
     private String oauthToken;
     private String authenticityToken;
     private String applicationName;
-    private String userName;
+    private String applicationURI;
+    private String replyTo;
     private List<? extends Permission> permissions;
     private List<String> uris;
 
@@ -56,14 +57,6 @@ public class OAuthAuthorizationData impl
         this.applicationName = applicationName;
     }
 
-    public String getUserName() {
-        return userName;
-    }
-
-    public void setUserName(String userName) {
-        this.userName = userName;
-    }
-
     public List<? extends Permission> getPermissions() {
         return permissions;
     }
@@ -87,4 +80,20 @@ public class OAuthAuthorizationData impl
     public String getAuthenticityToken() {
         return authenticityToken;
     }
+
+    public void setReplyTo(String replyTo) {
+        this.replyTo = replyTo;
+    }
+
+    public String getReplyTo() {
+        return replyTo;
+    }
+
+    public void setApplicationURI(String applicationURI) {
+        this.applicationURI = applicationURI;
+    }
+
+    public String getApplicationURI() {
+        return applicationURI;
+    }
 }

Modified: cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/AbstractOAuthService.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/AbstractOAuthService.java?rev=1181720&r1=1181719&r2=1181720&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/AbstractOAuthService.java
(original)
+++ cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/AbstractOAuthService.java
Tue Oct 11 11:31:11 2011
@@ -20,6 +20,7 @@ package org.apache.cxf.rs.security.oauth
 
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.core.Context;
+import javax.ws.rs.core.UriInfo;
 
 import org.apache.cxf.jaxrs.ext.MessageContext;
 import org.apache.cxf.rs.security.oauth.provider.OAuthDataProvider;
@@ -47,4 +48,8 @@ public abstract class AbstractOAuthServi
     protected HttpServletRequest getHttpRequest() {
         return mc.getHttpServletRequest();
     }
+    
+    protected UriInfo getUriInfo() {
+        return mc.getUriInfo();
+    }
 }

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=1181720&r1=1181719&r2=1181720&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 Oct 11 11:31:11 2011
@@ -67,11 +67,9 @@ public class AuthorizationRequestHandler
             
             OAuthAuthorizationData secData = new OAuthAuthorizationData();
             if (!compareRequestSessionTokens(request)) {
-                secData.setPermissions(
-                        dataProvider.getPermissionsInfo(token.getScopes()));
-                secData.setUris(token.getUris());
                 addAuthenticityTokenToSession(secData, request);
-                return Response.ok(addAdditionalParams(secData, token)).build();
+                return Response.ok(
+                        addAdditionalParams(secData, dataProvider, token)).build();
             }
             
             String decision = request.getParameter(OAuthConstants.AUTHORIZATION_DECISION_KEY);
@@ -125,11 +123,16 @@ public class AuthorizationRequestHandler
     }
     
     protected OAuthAuthorizationData addAdditionalParams(OAuthAuthorizationData secData,
+                                                         OAuthDataProvider dataProvider,
                                                          RequestToken token) {
         secData.setOauthToken(token.getTokenString());
         secData.setApplicationName(token.getClient().getApplicationName()); 
-        secData.setUserName(token.getClient().getLoginName());
-      
+        secData.setApplicationURI(token.getClient().getApplicationURI());
+        
+        secData.setPermissions(
+                dataProvider.getPermissionsInfo(token.getScopes()));
+        secData.setUris(token.getUris());
+        
         return secData;
     }
     

Modified: cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/AuthorizationRequestService.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/AuthorizationRequestService.java?rev=1181720&r1=1181719&r2=1181720&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/AuthorizationRequestService.java
(original)
+++ cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/AuthorizationRequestService.java
Tue Oct 11 11:31:11 2011
@@ -26,6 +26,8 @@ import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.Response;
 
+import org.apache.cxf.rs.security.oauth.data.OAuthAuthorizationData;
+
 
 /**
  * This resource handles the End User authorising
@@ -46,7 +48,12 @@ public class AuthorizationRequestService
     @Path("/authorize")
     @Produces({"application/xhtml+xml", "text/html", "application/xml", "application/json"
})
     public Response authorize() {
-        return handler.handle(getHttpRequest(), getDataProvider());
+        Response response = handler.handle(getHttpRequest(), getDataProvider());
+        if (response.getEntity() instanceof OAuthAuthorizationData) {
+            String replyTo = getUriInfo().getBaseUriBuilder().path("authorizeDecision").build().toString();
+            ((OAuthAuthorizationData)response.getEntity()).setReplyTo(replyTo);
+        }
+        return response;
     }
 
     @GET

Modified: cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/OAuthDefaultServices.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/OAuthDefaultServices.java?rev=1181720&r1=1181719&r2=1181720&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/OAuthDefaultServices.java
(original)
+++ cxf/trunk/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/OAuthDefaultServices.java
Tue Oct 11 11:31:11 2011
@@ -69,6 +69,13 @@ public class OAuthDefaultServices {
     public Response getRequestToken() {
         return requestTokenService.getRequestToken();
     }
+    
+    @GET
+    @Path("/initiate")
+    @Produces("application/x-www-form-urlencoded")
+    public Response getRequestTokenWithGET() {
+        return requestTokenService.getRequestToken();
+    }
 
     @GET
     @Path("/authorize")
@@ -93,6 +100,13 @@ public class OAuthDefaultServices {
     @GET
     @Path("/token")
     @Produces("application/x-www-form-urlencoded")
+    public Response getAccessTokenWithGET() {
+        return accessTokenService.getAccessToken();
+    }
+    
+    @POST
+    @Path("/token")
+    @Produces("application/x-www-form-urlencoded")
     public Response getAccessToken() {
         return accessTokenService.getAccessToken();
     }



Mime
View raw message