cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: More code verifier work
Date Tue, 17 Nov 2015 16:12:14 GMT
Repository: cxf
Updated Branches:
  refs/heads/master e492a2227 -> 63a1088a9


More code verifier work


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

Branch: refs/heads/master
Commit: 63a1088a9253da0452497440e900d35a5415c3c9
Parents: e492a22
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Tue Nov 17 16:12:02 2015 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Tue Nov 17 16:12:02 2015 +0000

----------------------------------------------------------------------
 .../oauth2/client/ClientCodeRequestFilter.java  | 26 ++++++++++++++------
 1 file changed, 18 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/63a1088a/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 ac09dfc..f69b3b9 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
@@ -155,8 +155,9 @@ public class ClientCodeRequestFilter implements ContainerRequestFilter
{
     }
     protected void setCodeVerifier(UriBuilder ub, MultivaluedMap<String, String> redirectState)
{
         if (codeVerifierTransformer != null) {
+            String codeVerifier = redirectState.getFirst(OAuthConstants.AUTHORIZATION_CODE_VERIFIER);
             ub.queryParam(OAuthConstants.AUTHORIZATION_CODE_CHALLENGE, 
-                          redirectState.getFirst(OAuthConstants.AUTHORIZATION_CODE_VERIFIER));
+                          codeVerifierTransformer.transformCodeVerifier(codeVerifier));
             ub.queryParam(OAuthConstants.AUTHORIZATION_CODE_CHALLENGE_METHOD, 
                           codeVerifierTransformer.getChallengeMethod());
         }
@@ -220,17 +221,26 @@ public class ClientCodeRequestFilter implements ContainerRequestFilter
{
 
     protected MultivaluedMap<String, String> createRedirectState(ContainerRequestContext
rc, UriInfo ui) {
         if (clientStateManager == null) {
-            return null;
+            return new MetadataMap<String, String>();
+        }
+        String codeVerifier = null;
+        MultivaluedMap<String, String> codeRequestState = toCodeRequestState(rc, ui);
+        if (codeVerifierTransformer != null) {
+            codeVerifier = Base64UrlUtility.encode(CryptoUtils.generateSecureRandomBytes(32));
+            codeRequestState.putSingle(OAuthConstants.AUTHORIZATION_CODE_VERIFIER, 
+                                       codeVerifier);
         }
-        return clientStateManager.toRedirectState(mc, 
-                                                  toCodeRequestState(rc, ui));
+        MultivaluedMap<String, String> redirectState = 
+            clientStateManager.toRedirectState(mc, codeRequestState);
+        if (codeVerifier != null) {
+            redirectState.putSingle(OAuthConstants.AUTHORIZATION_CODE_VERIFIER, codeVerifier);
+        }
+        return redirectState;
     }
     protected MultivaluedMap<String, String> toCodeRequestState(ContainerRequestContext
rc, UriInfo ui) {
         MultivaluedMap<String, String> state = toRequestState(rc, ui);
-        if (codeVerifierTransformer != null) {
-            String codeVerifier = Base64UrlUtility.encode(CryptoUtils.generateSecureRandomBytes(32));
-            state.putSingle(OAuthConstants.AUTHORIZATION_CODE_VERIFIER, 
-                          codeVerifierTransformer.transformCodeVerifier(codeVerifier));
+        if (state == null) {
+            state = new MetadataMap<String, String>();
         }
         return state;
     }


Mime
View raw message