cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf-fediz git commit: Making available realms known at the client reg time, the default is still an empty value if the property is not set
Date Wed, 18 Nov 2015 12:43:10 GMT
Repository: cxf-fediz
Updated Branches:
  refs/heads/master 07fde8129 -> 1fc7ea23f


Making available realms known at the client reg time, the default is still an empty value
if the property is not set


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

Branch: refs/heads/master
Commit: 1fc7ea23f4b1b172da86094c33ea3dc35aa546af
Parents: 07fde81
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Wed Nov 18 12:42:54 2015 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Wed Nov 18 12:42:54 2015 +0000

----------------------------------------------------------------------
 .../service/oidc/ClientRegistrationService.java | 10 +++++--
 .../cxf/fediz/service/oidc/RegisterClient.java  | 10 +++++++
 .../main/webapp/WEB-INF/applicationContext.xml  | 13 +++++++--
 .../webapp/WEB-INF/views/registerClient.jsp     | 29 +++++++++++++++++---
 4 files changed, 53 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/1fc7ea23/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientRegistrationService.java
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientRegistrationService.java
b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientRegistrationService.java
index f5f6721..e8bacd5 100644
--- a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientRegistrationService.java
+++ b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientRegistrationService.java
@@ -22,6 +22,7 @@ package org.apache.cxf.fediz.service.oidc;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -47,7 +48,8 @@ public class ClientRegistrationService {
     
     private Map<String, Map<String, Consumer>> registrations = 
             new ConcurrentHashMap<String, Map<String, Consumer>>();
-    private OAuthDataManager manager;    
+    private OAuthDataManager manager;
+    private Map<String, String> homeRealms = new LinkedHashMap<String, String>();
     @Context
     private SecurityContext sc;
     
@@ -56,7 +58,7 @@ public class ClientRegistrationService {
     @Produces(MediaType.TEXT_HTML)
     @Path("/")
     public RegisterClient registerStart() {
-        return new RegisterClient();
+        return new RegisterClient(homeRealms);
     }
     
     @POST
@@ -110,5 +112,9 @@ public class ClientRegistrationService {
     public void setDataProvider(OAuthDataManager m) {
         this.manager = m;
     }
+
+    public void setHomeRealms(Map<String, String> homeRealms) {
+        this.homeRealms = homeRealms;
+    }
 }
 

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/1fc7ea23/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/RegisterClient.java
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/RegisterClient.java
b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/RegisterClient.java
index 9a8c7a2..9a3b0b2 100644
--- a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/RegisterClient.java
+++ b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/RegisterClient.java
@@ -18,6 +18,16 @@
  */
 package org.apache.cxf.fediz.service.oidc;
 
+import java.util.Map;
+
 public class RegisterClient {
+    private Map<String, String> homeRealms;
+    public RegisterClient(Map<String, String> homeRealms) {
+        this.homeRealms = homeRealms;
+    }
+    public Map<String, String> getHomeRealms() {
+        return homeRealms;
+    }
+    
 
 }

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/1fc7ea23/services/oidc/src/main/webapp/WEB-INF/applicationContext.xml
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/webapp/WEB-INF/applicationContext.xml b/services/oidc/src/main/webapp/WEB-INF/applicationContext.xml
index 2ebfc87..06d0ce6 100644
--- a/services/oidc/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/services/oidc/src/main/webapp/WEB-INF/applicationContext.xml
@@ -47,11 +47,18 @@
     
     <bean id="keyPasswordProvider" class="org.apache.cxf.fediz.service.oidc.PrivateKeyPasswordProviderImpl"/>
     
+    <bean id="clientRegService" class="org.apache.cxf.fediz.service.oidc.ClientRegistrationService">
+       <property name="dataProvider" ref="oauthProvider"/>
+       <property name="homeRealms">
+          <map>
+            <entry key="urn:org:apache:cxf:fediz:idp:realm-A" value="IDP of Realm A" />
+            <entry key="urn:org:apache:cxf:fediz:idp:realm-B" value="IDP of Realm B" />
+          </map>
+       </property>
+    </bean>
     <jaxrs:server address="/client">
         <jaxrs:serviceBeans>
-            <bean id="clientRegService" class="org.apache.cxf.fediz.service.oidc.ClientRegistrationService">
-               <property name="dataProvider" ref="oauthProvider"/>
-             </bean>
+            <ref bean="clientRegService"/>
         </jaxrs:serviceBeans>
         <jaxrs:providers>
             <ref bean="viewProvider"/>

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/1fc7ea23/services/oidc/src/main/webapp/WEB-INF/views/registerClient.jsp
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/webapp/WEB-INF/views/registerClient.jsp b/services/oidc/src/main/webapp/WEB-INF/views/registerClient.jsp
index e32630e..a414dd9 100644
--- a/services/oidc/src/main/webapp/WEB-INF/views/registerClient.jsp
+++ b/services/oidc/src/main/webapp/WEB-INF/views/registerClient.jsp
@@ -1,5 +1,6 @@
-<%@ page import="javax.servlet.http.HttpServletRequest" %>
+<%@ page import="javax.servlet.http.HttpServletRequest,java.util.Map,java.util.Iterator,org.apache.cxf.fediz.service.oidc.RegisterClient"
%>
 <%
+    RegisterClient reg = (RegisterClient)request.getAttribute("data");
     String basePath = request.getContextPath() + request.getServletPath();
     if (!basePath.endsWith("/")) {
         basePath += "/";
@@ -68,10 +69,30 @@
             <td colspan="2">&nbsp;</td>
         </tr>
         <tr>
-            <td><big><big><big>Home Realm URI:</big></big></big></td>
+            <td><big><big><big>Home Realm:</big></big></big></td>
             <td>
-              <input type="text" size="50" name="homeRealm" 
-                     value=""/>
+               
+               <select name="homeRealm">
+                <%
+                   if (!reg.getHomeRealms().entrySet().isEmpty()) {
+                      Iterator<Map.Entry<String, String>> it = reg.getHomeRealms().entrySet().iterator();
+                      Map.Entry<String, String> firstEntry = it.next();
+                %>
+                      <option value="<%= firstEntry.getKey() %>" selected><%=
firstEntry.getValue() %></option>
+                <%      
+                      while (it.hasNext()) {
+                          Map.Entry<String, String> e = it.next();
+                %>
+                   <option value="<%= e.getKey() %>"><%= e.getValue() %></option>
+                <%
+                      }
+                   } else {
+                %>   
+                   <option value="" selected>Default</option>
+                <%
+                   }
+                %>
+                </select>
             </td>
         </tr>
         <tr>


Mime
View raw message