cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1416601 - in /cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services: AbstractOAuthService.java AccessTokenService.java ImplicitGrantService.java
Date Mon, 03 Dec 2012 17:57:40 GMT
Author: sergeyb
Date: Mon Dec  3 17:57:38 2012
New Revision: 1416601

URL: http://svn.apache.org/viewvc?rev=1416601&view=rev
Log:
[CXF-4669] Updating ImplicitGrantService to report expires_in, thanks to Steven Tippetts

Modified:
    cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractOAuthService.java
    cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java
    cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/ImplicitGrantService.java

Modified: cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractOAuthService.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractOAuthService.java?rev=1416601&r1=1416600&r2=1416601&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractOAuthService.java
(original)
+++ cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractOAuthService.java
Mon Dec  3 17:57:38 2012
@@ -43,6 +43,15 @@ public abstract class AbstractOAuthServi
     private MessageContext mc;
     private OAuthDataProvider dataProvider;
     private boolean blockUnsecureRequests;
+    private boolean writeOptionalParameters = true;
+    
+    public void setWriteOptionalParameters(boolean write) {
+        writeOptionalParameters = write;
+    }
+    
+    public boolean isWriteOptionalParameters() { 
+        return writeOptionalParameters;
+    }
     
     @Context 
     public void setMessageContext(MessageContext context) {

Modified: cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java?rev=1416601&r1=1416600&r2=1416601&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java
(original)
+++ cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java
Mon Dec  3 17:57:38 2012
@@ -52,13 +52,8 @@ import org.apache.cxf.rs.security.oauth2
 @Path("/token")
 public class AccessTokenService extends AbstractOAuthService {
     private List<AccessTokenGrantHandler> grantHandlers = Collections.emptyList();
-    private boolean writeOptionalParameters = true;
     private boolean writeCustomErrors;
     
-    public void setWriteOptionalParameters(boolean write) {
-        writeOptionalParameters = write;
-    }
-    
     public void setWriteCustomErrors(boolean write) {
         writeCustomErrors = write;
     }
@@ -109,7 +104,7 @@ public class AccessTokenService extends 
         ClientAccessToken clientToken = new ClientAccessToken(serverToken.getTokenType(),
                                                               serverToken.getTokenKey());
         clientToken.setRefreshToken(serverToken.getRefreshToken());
-        if (writeOptionalParameters) {
+        if (isWriteOptionalParameters()) {
             clientToken.setExpiresIn(serverToken.getExpiresIn());
             List<OAuthPermission> perms = serverToken.getScopes();
             if (!perms.isEmpty()) {

Modified: cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/ImplicitGrantService.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/ImplicitGrantService.java?rev=1416601&r1=1416600&r2=1416601&view=diff
==============================================================================
--- cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/ImplicitGrantService.java
(original)
+++ cxf/trunk/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/ImplicitGrantService.java
Mon Dec  3 17:57:38 2012
@@ -79,9 +79,11 @@ public class ImplicitGrantService extend
         sb.append(OAuthConstants.ACCESS_TOKEN).append("=").append(token.getTokenKey());
         sb.append("&")
             .append(OAuthConstants.ACCESS_TOKEN_TYPE).append("=").append(token.getTokenType());
-        //TODO: token parameters should also be included probably
-        //      though it's not obvious the embedded client can deal with
-        //      MAC tokens or other sophisticated tokens 
+        if (isWriteOptionalParameters()) {
+            sb.append("&").append(OAuthConstants.ACCESS_TOKEN_EXPIRES_IN)
+                .append("=").append(token.getExpiresIn());
+            //TODO: also report the approved scope and other parameters if any  
+        }
         return Response.seeOther(URI.create(sb.toString())).build();
     }
     



Mime
View raw message