You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2016/02/12 16:07:25 UTC
cxf-fediz git commit: Adding a Restrictions table to client.jsp which
can grow vertically,
ensuting the client names are unique by adding numbers if needed,
as per GDC example
Repository: cxf-fediz
Updated Branches:
refs/heads/master fddb661bd -> 05cb33d60
Adding a Restrictions table to client.jsp which can grow vertically, ensuting the client names are unique by adding numbers if needed, as per GDC example
Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/05cb33d6
Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/05cb33d6
Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/05cb33d6
Branch: refs/heads/master
Commit: 05cb33d60439602a07c31e9a1560b880511e5ffa
Parents: fddb661
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Fri Feb 12 15:07:09 2016 +0000
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Fri Feb 12 15:07:09 2016 +0000
----------------------------------------------------------------------
.../oidc/clients/ClientRegistrationService.java | 43 ++++++++-
.../src/main/webapp/WEB-INF/views/client.jsp | 91 ++++++++++++++------
.../webapp/WEB-INF/views/registerClient.jsp | 2 +-
3 files changed, 108 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/05cb33d6/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/clients/ClientRegistrationService.java
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/clients/ClientRegistrationService.java b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/clients/ClientRegistrationService.java
index f8eef3f..87edee5 100644
--- a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/clients/ClientRegistrationService.java
+++ b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/clients/ClientRegistrationService.java
@@ -23,13 +23,16 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
@@ -57,7 +60,8 @@ import org.apache.cxf.rt.security.crypto.CryptoUtils;
@Path("/")
public class ClientRegistrationService {
- private Map<String, Collection<Client>> registrations = new ConcurrentHashMap<String, Collection<Client>>();
+ private Map<String, Collection<Client>> registrations = new HashMap<String, Collection<Client>>();
+ private Map<String, Set<String>> clientNames = new HashMap<String, Set<String>>();
private OAuthDataProvider dataProvider;
private ClientRegistrationProvider clientProvider;
private Map<String, String> homeRealms = new LinkedHashMap<String, String>();
@@ -231,7 +235,12 @@ public class ClientRegistrationService {
newClient.setRegisteredAt(System.currentTimeMillis() / 1000);
// Client Realm
- newClient.setHomeRealm(homeRealm);
+ if (homeRealm != null) {
+ newClient.setHomeRealm(homeRealm);
+ if (homeRealms.containsKey(homeRealm)) {
+ newClient.getProperties().put("homeRealmAlias", homeRealms.get(homeRealm));
+ }
+ }
// Client Redirect URIs
if (!StringUtils.isEmpty(redirectURI)) {
@@ -318,6 +327,28 @@ public class ClientRegistrationService {
}
protected RegisteredClients registerNewClient(Client newClient) {
+ String userName = newClient.getResourceOwnerSubject().getLogin();
+ Set<String> names = clientNames.get(userName);
+ if (names == null) {
+ names = new HashSet<String>();
+ clientNames.put(userName, names);
+ } else if (names.contains(newClient.getApplicationName())) {
+ String newName = newClient.getApplicationName();
+ SortedSet<Integer> numbers = new TreeSet<Integer>();
+ for (String name : names) {
+ if (name.startsWith(newName) && !name.equals(newName)) {
+ try {
+ numbers.add(Integer.valueOf(name.substring(newName.length())));
+ } catch (Exception ex) {
+ // can be characters, continue;
+ }
+ }
+ }
+ int nextNumber = numbers.isEmpty() ? 2 : numbers.last() + 1;
+ newClient.setApplicationName(newName + nextNumber);
+ }
+ names.add(newClient.getApplicationName());
+
clientProvider.setClient(newClient);
Collection<Client> clientRegistrations = getClientRegistrations();
clientRegistrations.add(newClient);
@@ -353,6 +384,12 @@ public class ClientRegistrationService {
for (Client c : clientProvider.getClients(null)) {
String userName = c.getResourceOwnerSubject().getLogin();
getClientRegistrations(userName).add(c);
+ Set<String> names = clientNames.get(userName);
+ if (names == null) {
+ names = new HashSet<String>();
+ clientNames.put(userName, names);
+ }
+ names.add(c.getApplicationName());
}
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/05cb33d6/services/oidc/src/main/webapp/WEB-INF/views/client.jsp
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/webapp/WEB-INF/views/client.jsp b/services/oidc/src/main/webapp/WEB-INF/views/client.jsp
index 3f2ad38..574804d 100644
--- a/services/oidc/src/main/webapp/WEB-INF/views/client.jsp
+++ b/services/oidc/src/main/webapp/WEB-INF/views/client.jsp
@@ -7,6 +7,11 @@
<%
Client client = (Client)request.getAttribute("data");
+ String clientType = client.isConfidential() ? "Confidential" : "Public";
+ String homeRealmAlias = client.getProperties().get("homeRealmAlias");
+ if (homeRealmAlias == null || homeRealmAlias.trim().isEmpty()) {
+ homeRealmAlias = "Default - User selection at login";
+ }
String basePath = request.getContextPath() + request.getServletPath();
if (!basePath.endsWith("/")) {
basePath += "/";
@@ -24,14 +29,14 @@
border-color: #ccc;
border-style: solid;
border-width: 1px;
- padding: 3px 4px;
+ padding: 3px 4px;
text-align: center;
}
table td {
border-color: #ccc;
border-style: solid;
- border-width: 1px;
- padding: 3px 4px;
+ border-width: 1px;
+ padding: 3px 4px;
}
@@ -55,7 +60,7 @@
.form-line {
margin: 6 0 6 0;
- padding: 12 36 12 36;
+ padding: 12 12 12 12;
}
.form-submit-button {
@@ -74,10 +79,14 @@
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm", Locale.US);
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
%>
- <tr><th>ID</th><th>Secret</th><th>Creation Date</th><th>Redirect URI</th></tr>
+ <tr><th>ID</th><th>Type</th><th>Secret</th><th>Creation Date</th></tr>
<tr>
<td>
<%= client.getClientId() %>
+ </td>
+ <td>
+ <%= clientType %>
+ </td>
<td>
<%
if (client.getClientSecret() != null) {
@@ -86,7 +95,7 @@
<%
} else {
%>
- <i>Unavailable for public client</i>
+ <i>Unavailable</i>
<%
}
%>
@@ -99,18 +108,58 @@
<%= created %><br/>
</td>
- <td>
- <% if(client.getRedirectUris() != null) {
+
+ </tr>
+
+</table>
+<br/>
+<h2>Restrictions:</h2>
+<p/>
+<table>
+<tr>
+<td>
+<b>Home Realm</b>
+</td>
+<td>
+ <%= homeRealmAlias %>
+</td>
+</tr>
+<tr>
+<td>
+<b>Redirect URL</b>
+</td>
+<td>
+<% if(client.getRedirectUris() != null) {
for (String redirectURI : client.getRedirectUris()) {
%>
<%= redirectURI %><br/>
<% }
} %>
- </td>
- </tr>
-
+</td>
+</tr>
+<tr>
+<td>
+<b>Audience URL</b>
+</td>
+<td>
+<% if(client.getRegisteredAudiences() != null) {
+ for (String audURI : client.getRegisteredAudiences()) {
+ %>
+ <%= audURI %><br/>
+ <% }
+ } %>
+</td>
+</tr>
</table>
<br/>
+<p>
+<p><a href="<%= basePath + "clients/" + client.getClientId() + "/tokens" %>">Issued Tokens</a></p>
+</p>
+<p>
+<p><a href="<%= basePath + "clients/" + client.getClientId() + "/codes" %>">Issued Code Grants</a></p>
+</p>
+
+<br/>
<table class="table_no_border">
<tr>
<%
@@ -118,31 +167,25 @@
%>
<td class="td_no_border">
<form name="resetSecretForm" action="<%=basePath%>clients/<%= client.getClientId() + "/reset"%>" method="POST">
- <div data-type="control_button" class="form-line">
- <button name="submit_reset_button" class="form-submit-button" type="submit">Reset Secret</button>
- </div>
+ <div data-type="control_button" class="form-line">
+ <button name="submit_reset_button" class="form-submit-button" type="submit">Reset Client Secret</button>
</form>
+ </div>
</td>
<%
}
%>
<td class="td_no_border">
<form name="deleteForm" action="<%=basePath%>clients/<%= client.getClientId() + "/remove"%>" method="POST">
- <div data-type="control_button" class="form-line">
- <button name="submit_delete_button" class="form-submit-button" type="submit">Delete Client</button>
- </div>
+ <div data-type="control_button" class="form-line">
+ <button name="submit_delete_button" class="form-submit-button" type="submit">Delete Client</button>
+ </div>
</form>
</td>
</tr>
</table>
<br/>
-<p>
-<p><a href="<%= basePath + "clients/" + client.getClientId() + "/tokens" %>">Issued Tokens</a></p>
-</p>
-<p>
-<p><a href="<%= basePath + "clients/" + client.getClientId() + "/codes" %>">Issued Code Grants</a></p>
-</p>
-<br/>
+
<p>
<p>Return to <a href="<%=basePath%>clients">registered Clients</a></p>
</p>
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/05cb33d6/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 5a9dd36..e73c503 100644
--- a/services/oidc/src/main/webapp/WEB-INF/views/registerClient.jsp
+++ b/services/oidc/src/main/webapp/WEB-INF/views/registerClient.jsp
@@ -79,7 +79,7 @@ input, select, button {
</select>
</div>
<div class="form-line">
- <label for="client_redirectURI" id="label_redirect" class="form-label"> Redirect URI </label>
+ <label for="client_redirectURI" id="label_redirect" class="form-label"> Redirect URL </label>
<input type="text" value="" size="40" name="client_redirectURI"
placeholder="URL of the client to consume OIDC service response"
id="input_6" data-type="input-textbox" />