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 update to the dynamic reg service code
Date Tue, 27 Sep 2016 11:36:14 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 8e1b9741f -> 728e60aa5


Minor update to the dynamic reg service code


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

Branch: refs/heads/master
Commit: 728e60aa55ea19693efdcf96c9a2232fe2bc8edc
Parents: 8e1b974
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Tue Sep 27 12:35:59 2016 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Tue Sep 27 12:35:59 2016 +0100

----------------------------------------------------------------------
 .../services/DynamicRegistrationService.java       | 17 +++++++++++++++--
 .../cxf/rs/security/oauth2/utils/OAuthUtils.java   | 11 +++++++++++
 .../security/oidc/OIDCDynamicRegistrationTest.java | 14 +++++++-------
 3 files changed, 33 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/728e60aa/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/DynamicRegistrationService.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/DynamicRegistrationService.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/DynamicRegistrationService.java
index e4c252c..ab6cb46 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/DynamicRegistrationService.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/DynamicRegistrationService.java
@@ -135,8 +135,21 @@ public class DynamicRegistrationService extends AbstractOAuthService
{
         return fromClientToClientRegistration(client);
     }
 
-    protected ClientRegistration fromClientToClientRegistration(Client client) {
-        return new ClientRegistration();
+    protected ClientRegistration fromClientToClientRegistration(Client c) {
+        ClientRegistration reg = new ClientRegistration();
+        reg.setClientName(c.getApplicationName());
+        reg.setGrantTypes(c.getAllowedGrantTypes());
+        reg.setApplicationType(c.isConfidential() ? "web" : "native");
+        reg.setRedirectUris(c.getRedirectUris());
+        reg.setScope(OAuthUtils.convertListOfScopesToString(c.getRegisteredScopes()));
+        if (c.getApplicationWebUri() != null) {
+            reg.setClientUri(c.getApplicationWebUri());
+        }
+        if (c.getApplicationLogoUri() != null) {
+            reg.setLogoUri(c.getApplicationLogoUri());
+        }
+        //etc
+        return reg;
     }
     
     protected Client readClient(String clientId) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/728e60aa/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthUtils.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthUtils.java
index d08969b..ab2e88c 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthUtils.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthUtils.java
@@ -344,4 +344,15 @@ public final class OAuthUtils {
             return sigAlgo;
         }
     }
+
+    public static String convertListOfScopesToString(List<String> registeredScopes)
{
+        StringBuilder sb = new StringBuilder();
+        for (String s : registeredScopes) {
+            if (sb.length() > 0) {
+                sb.append(", ");
+            }
+            sb.append(s);
+        }
+        return sb.toString();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/728e60aa/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCDynamicRegistrationTest.java
----------------------------------------------------------------------
diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCDynamicRegistrationTest.java
b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCDynamicRegistrationTest.java
index 74c6f97..f85a181 100644
--- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCDynamicRegistrationTest.java
+++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCDynamicRegistrationTest.java
@@ -105,13 +105,13 @@ public class OIDCDynamicRegistrationTest extends AbstractBusClientServerTestBase
         wc.authorization(new ClientAccessToken("Bearer", regAccessToken));
         ClientRegistration clientRegResp = wc.get(ClientRegistration.class);
         assertNotNull(clientRegResp);
-//        assertEquals("web", clientRegResp.getApplicationType());
-//        assertEquals("dynamic_client", clientRegResp.getClientName());
-//        assertEquals("openid", clientRegResp.getScope());
-//        assertEquals(Collections.singletonList("authorization_code"), 
-//                     clientRegResp.getGrantTypes());
-//        assertEquals(Collections.singletonList("https://a/b/c"), 
-//                     clientRegResp.getRedirectUris());
+        assertEquals("web", clientRegResp.getApplicationType());
+        assertEquals("dynamic_client", clientRegResp.getClientName());
+        assertEquals("openid", clientRegResp.getScope());
+        assertEquals(Collections.singletonList("authorization_code"), 
+                     clientRegResp.getGrantTypes());
+        assertEquals(Collections.singletonList("https://a/b/c"), 
+                     clientRegResp.getRedirectUris());
         
         assertEquals(200, wc.delete().getStatus());
     }


Mime
View raw message