cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Minor updates to OAuth2 filters
Date Tue, 16 Jun 2015 15:02:20 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 7a7a60c08 -> f30d69ed5


Minor updates to OAuth2 filters


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/f30d69ed
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/f30d69ed
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/f30d69ed

Branch: refs/heads/3.0.x-fixes
Commit: f30d69ed5c30535af6b96a91c3eed88c79199435
Parents: 7a7a60c
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Tue Jun 16 15:58:21 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Tue Jun 16 16:02:01 2015 +0100

----------------------------------------------------------------------
 .../oauth2/client/ClientCodeRequestFilter.java     |  2 +-
 .../client/MemoryClientCodeStateManager.java       | 17 ++++++++++-------
 2 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/f30d69ed/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/ClientCodeRequestFilter.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/ClientCodeRequestFilter.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/ClientCodeRequestFilter.java
index 97577d1..707d799 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/ClientCodeRequestFilter.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/ClientCodeRequestFilter.java
@@ -107,7 +107,7 @@ public class ClientCodeRequestFilter implements ContainerRequestFilter
{
 
     private Response createCodeResponse(ContainerRequestContext rc, UriInfo ui) {
         MultivaluedMap<String, String> redirectState = createRedirectState(rc, ui);
-        String theState = redirectState != null ? redirectState.getFirst(OAuthConstants.SCOPE)
: null;
+        String theState = redirectState != null ? redirectState.getFirst(OAuthConstants.STATE)
: null;
         String redirectScope = redirectState != null ? redirectState.getFirst(OAuthConstants.SCOPE)
: null;
         String theScope = redirectScope != null ? redirectScope : scopes;
         URI uri = OAuthClientUtils.getAuthorizationURI(authorizationServiceUri, 

http://git-wip-us.apache.org/repos/asf/cxf/blob/f30d69ed/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/MemoryClientCodeStateManager.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/MemoryClientCodeStateManager.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/MemoryClientCodeStateManager.java
index 5e5b316..994a842 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/MemoryClientCodeStateManager.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/client/MemoryClientCodeStateManager.java
@@ -24,6 +24,8 @@ import javax.ws.rs.core.MultivaluedMap;
 
 import org.apache.cxf.jaxrs.ext.MessageContext;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
+import org.apache.cxf.rs.security.oauth2.utils.OAuthConstants;
+import org.apache.cxf.rs.security.oauth2.utils.OAuthUtils;
 
 public class MemoryClientCodeStateManager implements ClientCodeStateManager {
     private ConcurrentHashMap<String, MultivaluedMap<String, String>> map = 
@@ -32,17 +34,18 @@ public class MemoryClientCodeStateManager implements ClientCodeStateManager
{
     @Override
     public MultivaluedMap<String, String> toRedirectState(MessageContext mc, 
                                                           MultivaluedMap<String, String>
requestState) {
-        String name = mc.getSecurityContext().getUserPrincipal().getName();
-        String hashCode = Integer.toString(name.hashCode());
-        map.put(hashCode, requestState);
-        return new MetadataMap<String, String>();
+        String stateParam = OAuthUtils.generateRandomTokenKey();
+        map.put(stateParam, requestState);
+        
+        MultivaluedMap<String, String> redirectMap = new MetadataMap<String, String>();
+        redirectMap.putSingle(OAuthConstants.STATE, stateParam);
+        return redirectMap;
     }
 
     @Override
     public MultivaluedMap<String, String> fromRedirectState(MessageContext mc, 
                                                             MultivaluedMap<String, String>
redirectState) {
-        String name = mc.getSecurityContext().getUserPrincipal().getName();
-        String hashCode = Integer.toString(name.hashCode());
-        return map.remove(hashCode);
+        String stateParam = redirectState.getFirst(OAuthConstants.STATE);
+        return map.remove(stateParam);
     }
 }


Mime
View raw message