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/01/12 18:14:56 UTC
cxf-fediz git commit: Adding a page for presenting more complete info
about Client and prototyping the code/pages for removing the client,
resetting a secret, and managing client access/refresh tokens and code grants
Repository: cxf-fediz
Updated Branches:
refs/heads/master f46137383 -> 159bf90ef
Adding a page for presenting more complete info about Client and prototyping the code/pages for removing the client, resetting a secret, and managing client access/refresh tokens and code grants
Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/159bf90e
Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/159bf90e
Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/159bf90e
Branch: refs/heads/master
Commit: 159bf90ef220ffa8b5dfb42f2b7ffc6f10c15f86
Parents: f461373
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Tue Jan 12 17:14:37 2016 +0000
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Tue Jan 12 17:14:37 2016 +0000
----------------------------------------------------------------------
.../fediz/service/oidc/ClientAccessTokens.java | 48 +++++++
.../fediz/service/oidc/ClientCodeGrants.java | 48 +++++++
.../fediz/service/oidc/ClientRefreshTokens.java | 48 +++++++
.../service/oidc/ClientRegistrationService.java | 71 +++++++++
.../main/webapp/WEB-INF/applicationContext.xml | 1 +
.../src/main/webapp/WEB-INF/views/client.jsp | 143 +++++++++++++++++++
.../webapp/WEB-INF/views/clientAccessTokens.jsp | 85 +++++++++++
.../webapp/WEB-INF/views/clientCodeGrants.jsp | 85 +++++++++++
.../WEB-INF/views/clientRefreshTokens.jsp | 85 +++++++++++
.../webapp/WEB-INF/views/registeredClients.jsp | 27 ++--
10 files changed, 628 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/159bf90e/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientAccessTokens.java
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientAccessTokens.java b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientAccessTokens.java
new file mode 100644
index 0000000..061e61d
--- /dev/null
+++ b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientAccessTokens.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.fediz.service.oidc;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.cxf.rs.security.oauth2.common.Client;
+import org.apache.cxf.rs.security.oauth2.common.ServerAccessToken;
+
+public class ClientAccessTokens {
+ private Client client;
+ private List<ServerAccessToken> accessTokens = new LinkedList<ServerAccessToken>();
+ public ClientAccessTokens(Client c, List<ServerAccessToken> accessTokens) {
+ this.client = c;
+ this.accessTokens = accessTokens;
+ }
+ public Client getClient() {
+ return client;
+ }
+ public void setClient(Client client) {
+ this.client = client;
+ }
+ public List<ServerAccessToken> getAccessTokens() {
+ return accessTokens;
+ }
+ public void setAccessTokens(List<ServerAccessToken> accessTokens) {
+ this.accessTokens = accessTokens;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/159bf90e/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientCodeGrants.java
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientCodeGrants.java b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientCodeGrants.java
new file mode 100644
index 0000000..6134fcc
--- /dev/null
+++ b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientCodeGrants.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.fediz.service.oidc;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.cxf.rs.security.oauth2.common.Client;
+import org.apache.cxf.rs.security.oauth2.grants.code.ServerAuthorizationCodeGrant;
+
+public class ClientCodeGrants {
+ private Client client;
+ private List<ServerAuthorizationCodeGrant> codeGrants = new LinkedList<ServerAuthorizationCodeGrant>();
+ public ClientCodeGrants(Client c, List<ServerAuthorizationCodeGrant> codeGrants) {
+ this.client = c;
+ this.setCodeGrants(codeGrants);
+ }
+ public Client getClient() {
+ return client;
+ }
+ public void setClient(Client client) {
+ this.client = client;
+ }
+ public List<ServerAuthorizationCodeGrant> getCodeGrants() {
+ return codeGrants;
+ }
+ public void setCodeGrants(List<ServerAuthorizationCodeGrant> codeGrants) {
+ this.codeGrants = codeGrants;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/159bf90e/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientRefreshTokens.java
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientRefreshTokens.java b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientRefreshTokens.java
new file mode 100644
index 0000000..12f246f
--- /dev/null
+++ b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/ClientRefreshTokens.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.fediz.service.oidc;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.cxf.rs.security.oauth2.common.Client;
+import org.apache.cxf.rs.security.oauth2.tokens.refresh.RefreshToken;
+
+public class ClientRefreshTokens {
+ private Client client;
+ private List<RefreshToken> refreshTokens = new LinkedList<RefreshToken>();
+ public ClientRefreshTokens(Client c, List<RefreshToken> refreshTokens) {
+ this.client = c;
+ this.refreshTokens = refreshTokens;
+ }
+ public Client getClient() {
+ return client;
+ }
+ public void setClient(Client client) {
+ this.client = client;
+ }
+ public List<RefreshToken> getRefreshTokens() {
+ return refreshTokens;
+ }
+ public void setRefreshTokens(List<RefreshToken> refreshTokens) {
+ this.refreshTokens = refreshTokens;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/159bf90e/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 da6b96b..6e4f295 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.Collection;
import java.util.Collections;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -31,6 +32,7 @@ import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
@@ -67,6 +69,73 @@ public class ClientRegistrationService {
return getClientRegistrations();
}
+ @GET
+ @Produces(MediaType.TEXT_HTML)
+ @Path("/{id}")
+ public Client getRegisteredClient(@PathParam("id") String id) {
+ for (Client c : getClientRegistrations()) {
+ if (c.getClientId().equals(id)) {
+ return c;
+ }
+ }
+ return null;
+ }
+
+
+ @POST
+ @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
+ @Produces(MediaType.TEXT_HTML)
+ @Path("/{id}/remove")
+ public Collection<Client> removeClient(@PathParam("id") String id) {
+ Collection<Client> clients = getClientRegistrations();
+ for (Iterator<Client> it = clients.iterator(); it.hasNext();) {
+ Client c = it.next();
+ if (c.getClientId().equals(id)) {
+ it.remove();
+ manager.removeClient(id);
+ break;
+ }
+ }
+ return clients;
+ }
+ @POST
+ @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
+ @Produces(MediaType.TEXT_HTML)
+ @Path("/{id}/reset")
+ public Client resetClient(@PathParam("id") String id) {
+ Client c = getRegisteredClient(id);
+ if (c.isConfidential()) {
+ c.setClientSecret(generateClientSecret());
+ }
+ manager.setClient(c);
+ return c;
+ }
+
+ @GET
+ @Produces(MediaType.TEXT_HTML)
+ @Path("/{id}/at")
+ public ClientAccessTokens getClientAccessTokens(@PathParam("id") String id) {
+ Client c = getRegisteredClient(id);
+ return new ClientAccessTokens(c, manager.getAccessTokens(c));
+ }
+
+ @GET
+ @Produces(MediaType.TEXT_HTML)
+ @Path("/{id}/rt")
+ public ClientRefreshTokens getClientRefreshTokens(@PathParam("id") String id) {
+ Client c = getRegisteredClient(id);
+ return new ClientRefreshTokens(c, manager.getRefreshTokens(c));
+ }
+
+ @GET
+ @Produces(MediaType.TEXT_HTML)
+ @Path("/{id}/codes")
+ public ClientCodeGrants getClientCodeGrants(@PathParam("id") String id) {
+ Client c = getRegisteredClient(id);
+ return new ClientCodeGrants(c, manager.getCodeGrants(c));
+ }
+
+
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.TEXT_HTML)
@@ -91,6 +160,8 @@ public class ClientRegistrationService {
UserSubject userSubject = new UserSubject(userName);
newClient.setResourceOwnerSubject(userSubject);
+ newClient.setRegisteredAt(System.currentTimeMillis() / 1000);
+
return registerNewClient(newClient);
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/159bf90e/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 85f5e41..4e3b004 100644
--- a/services/oidc/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/services/oidc/src/main/webapp/WEB-INF/applicationContext.xml
@@ -115,6 +115,7 @@
<property name="resourcePaths">
<map>
<entry key="/clients" value="/WEB-INF/views/registeredClients.jsp"/>
+ <entry key="/remove" value="/WEB-INF/views/registeredClients.jsp"/>
</map>
</property>
</bean>
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/159bf90e/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
new file mode 100644
index 0000000..c704511
--- /dev/null
+++ b/services/oidc/src/main/webapp/WEB-INF/views/client.jsp
@@ -0,0 +1,143 @@
+<%@ page import="org.apache.cxf.rs.security.oauth2.common.Client"%>
+<%@ page import="java.text.SimpleDateFormat"%>
+<%@ page import="java.util.Date"%>
+<%@ page import="java.util.Locale"%>
+<%@ page import="java.util.TimeZone"%>
+<%@ page import="javax.servlet.http.HttpServletRequest" %>
+
+<%
+ Client client = (Client)request.getAttribute("data");
+ String basePath = request.getContextPath() + request.getServletPath();
+ if (!basePath.endsWith("/")) {
+ basePath += "/";
+ }
+%>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>API Client Information</title>
+ <STYLE TYPE="text/css">
+ table {
+ border-collapse: collapse;
+ }
+ table th {
+ background-color: #f0f0f0;
+ border-color: #ccc;
+ border-style: solid;
+ border-width: 1px;
+ padding: 3px 4px;
+ text-align: center;
+ }
+ table td {
+ border-color: #ccc;
+ border-style: solid;
+ border-width: 1px;
+ padding: 3px 4px;
+ }
+
+.form {
+ max-width: 425px;
+ margin-bottom: 25px;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.form-line {
+ margin: 6 0 6 0;
+ padding: 12 36 12 36;
+}
+
+.form-submit-button {
+ padding: 4px;
+ text-align: center;
+}
+
+ </STYLE>
+</head>
+<body>
+<div class="padded">
+<h1><%= client.getApplicationName() %></h1>
+<br/>
+<table border="1">
+ <%
+ SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm", Locale.US);
+ dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
+ %>
+ <tr><th>Identifier</th><th>Secret</th><th>Creation Date</th><th>Redirect URIs</th></tr>
+ <tr>
+ <td><input type="text" name="clientId" size="15" readonly="readonly" value="<%= client.getClientId() %>" /></td>
+ <td>
+ <%
+ if (client.getClientSecret() != null) {
+ %>
+ <input type="text" name="clientSecret" size="25" readonly="readonly" value="<%= client.getClientSecret() %>" />
+ <%
+ } else {
+ %>
+ <i>Unavailable for public client</i>
+ <%
+ }
+ %>
+ </td>
+ <td>
+ <%
+ Date date = new Date(client.getRegisteredAt() * 1000);
+ String created = dateFormat.format(date);
+ %>
+ <%= created %><br/>
+
+ </td>
+ <td>
+ <% if(client.getRedirectUris() != null) {
+ for (String redirectURI : client.getRedirectUris()) {
+ %>
+ <%= redirectURI %><br/>
+ <% }
+ } %>
+ </td>
+ </tr>
+
+</table>
+<br/>
+<table border="0">
+<tr>
+<%
+ if (client.getClientSecret() != null) {
+%>
+<td>
+<form action="/fediz-oidc/clients/<%= client.getClientId() + "/reset"%>" method="POST">
+ <div data-type="control_button" class="form-line">
+ <button class="form-submit-button" type="submit">Reset Secret</button>
+ </div>
+</form>
+</td>
+<%
+ }
+%>
+<td>
+<form action="/fediz-oidc/clients/<%= client.getClientId() + "/remove"%>" method="POST">
+ <div data-type="control_button" class="form-line">
+ <button class="form-submit-button" type="submit">Delete Client</button>
+ </div>
+</form>
+</td>
+</tr>
+</table>
+<br/>
+<p>
+<p><a href="<%= basePath + "clients/" + client.getClientId() + "/at" %>">Current Access Tokens</a></p>
+</p>
+<p>
+<p><a href="<%= basePath + "clients/" + client.getClientId() + "/rt" %>">Current Refresh Tokens</a></p>
+</p>
+<p>
+<p><a href="<%= basePath + "clients/" + client.getClientId() + "/codes" %>">Current Code Grants</a></p>
+</p>
+<br/>
+<p>
+<p>Return to <a href="<%=basePath%>clients">registered Clients</a></p>
+</p>
+<br/>
+</div>
+</body>
+</html>
+
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/159bf90e/services/oidc/src/main/webapp/WEB-INF/views/clientAccessTokens.jsp
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/webapp/WEB-INF/views/clientAccessTokens.jsp b/services/oidc/src/main/webapp/WEB-INF/views/clientAccessTokens.jsp
new file mode 100644
index 0000000..a2884e4
--- /dev/null
+++ b/services/oidc/src/main/webapp/WEB-INF/views/clientAccessTokens.jsp
@@ -0,0 +1,85 @@
+<%@ page import="org.apache.cxf.rs.security.oauth2.common.Client"%>
+<%@ page import="org.apache.cxf.rs.security.oauth2.common.ServerAccessToken"%>
+<%@ page import="java.text.SimpleDateFormat"%>
+<%@ page import="java.util.Date"%>
+<%@ page import="java.util.List"%>
+<%@ page import="java.util.Locale"%>
+<%@ page import="java.util.TimeZone"%>
+<%@ page import="javax.servlet.http.HttpServletRequest" %>
+<%@ page import="org.apache.cxf.fediz.service.oidc.ClientAccessTokens" %>
+
+<%
+ ClientAccessTokens tokens = (ClientAccessTokens)request.getAttribute("data");
+ Client client = tokens.getClient();
+ String basePath = request.getContextPath() + request.getServletPath();
+ if (!basePath.endsWith("/")) {
+ basePath += "/";
+ }
+%>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>Client Access Tokens</title>
+ <STYLE TYPE="text/css">
+ table {
+ border-collapse: collapse;
+ }
+ table th {
+ background-color: #f0f0f0;
+ border-color: #ccc;
+ border-style: solid;
+ border-width: 1px;
+ padding: 3px 4px;
+ text-align: center;
+ }
+ table td {
+ border-color: #ccc;
+ border-style: solid;
+ border-width: 1px;
+ padding: 3px 4px;
+ }
+ </STYLE>
+</head>
+<body>
+<div class="padded">
+<h1>Access Tokens issued to <%= client.getApplicationName() + "(" + client.getClientId() + ")"%>"</h1>
+<br/>
+<table border="1">
+ <tr><th>Identifier</th><th>Issue Date</th><th>Expiry Date</th></tr>
+ <%
+ SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss", Locale.US);
+ dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
+
+ for (ServerAccessToken token : tokens.getAccessTokens()) {
+ %>
+ <tr>
+ <td><input type="text" name="tokenId" size="15" readonly="readonly" value="<%= token.getTokenKey() %>" /></td>
+ <td>
+ <%
+ Date date = new Date(token.getIssuedAt() * 1000);
+ String issued = dateFormat.format(date);
+ %>
+ <%= issued %><br/>
+ </td>
+ <td>
+ <%
+ Date date = new Date((token.getIssuedAt() + token.getExpiresIn()) * 1000);
+ String expires = dateFormat.format(date);
+ %>
+ <%= expires %><br/>
+ </td>
+ </tr>
+ <%
+ }
+ %>
+
+</table>
+
+<br/>
+<br/>
+<p>
+<a href="<%= basePath + "clients/" + client.getId() %>">Return</a>
+</p>
+</div>
+</body>
+</html>
+
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/159bf90e/services/oidc/src/main/webapp/WEB-INF/views/clientCodeGrants.jsp
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/webapp/WEB-INF/views/clientCodeGrants.jsp b/services/oidc/src/main/webapp/WEB-INF/views/clientCodeGrants.jsp
new file mode 100644
index 0000000..c3afa50
--- /dev/null
+++ b/services/oidc/src/main/webapp/WEB-INF/views/clientCodeGrants.jsp
@@ -0,0 +1,85 @@
+<%@ page import="org.apache.cxf.rs.security.oauth2.common.Client"%>
+<%@ page import="org.apache.cxf.rs.security.oauth2.grants.code.ServerAuthorizationCodeGrant"%>
+<%@ page import="java.text.SimpleDateFormat"%>
+<%@ page import="java.util.Date"%>
+<%@ page import="java.util.List"%>
+<%@ page import="java.util.Locale"%>
+<%@ page import="java.util.TimeZone"%>
+<%@ page import="javax.servlet.http.HttpServletRequest" %>
+<%@ page import="org.apache.cxf.fediz.service.oidc.ClientCodeGrants" %>
+
+<%
+ ClientCodeGrants tokens = (ClientCodeGrants)request.getAttribute("data");
+ Client client = tokens.getClient();
+ String basePath = request.getContextPath() + request.getServletPath();
+ if (!basePath.endsWith("/")) {
+ basePath += "/";
+ }
+%>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>Client Refresh Tokens</title>
+ <STYLE TYPE="text/css">
+ table {
+ border-collapse: collapse;
+ }
+ table th {
+ background-color: #f0f0f0;
+ border-color: #ccc;
+ border-style: solid;
+ border-width: 1px;
+ padding: 3px 4px;
+ text-align: center;
+ }
+ table td {
+ border-color: #ccc;
+ border-style: solid;
+ border-width: 1px;
+ padding: 3px 4px;
+ }
+ </STYLE>
+</head>
+<body>
+<div class="padded">
+<h1>Code Grants issued to <%= client.getApplicationName() + "(" + client.getClientId() + ")"%>"</h1>
+<br/>
+<table border="1">
+ <tr><th>Identifier</th><th>Issue Date</th><th>Expiry Date</th></tr>
+ <%
+ SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss", Locale.US);
+ dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
+
+ for (ServerAuthorizationCodeGrant token : tokens.getCodeGrants()) {
+ %>
+ <tr>
+ <td><input type="text" name="tokenId" size="15" readonly="readonly" value="<%= token.getCode() %>" /></td>
+ <td>
+ <%
+ Date date = new Date(token.getIssuedAt() * 1000);
+ String issued = dateFormat.format(date);
+ %>
+ <%= issued %><br/>
+ </td>
+ <td>
+ <%
+ Date date = new Date((token.getIssuedAt() + token.getExpiresIn()) * 1000);
+ String expires = dateFormat.format(date);
+ %>
+ <%= expires %><br/>
+ </td>
+ </tr>
+ <%
+ }
+ %>
+
+</table>
+
+<br/>
+<br/>
+<p>
+<a href="<%= basePath + "clients/" + client.getId() %>">Return</a>
+</p>
+</div>
+</body>
+</html>
+
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/159bf90e/services/oidc/src/main/webapp/WEB-INF/views/clientRefreshTokens.jsp
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/webapp/WEB-INF/views/clientRefreshTokens.jsp b/services/oidc/src/main/webapp/WEB-INF/views/clientRefreshTokens.jsp
new file mode 100644
index 0000000..ddfab90
--- /dev/null
+++ b/services/oidc/src/main/webapp/WEB-INF/views/clientRefreshTokens.jsp
@@ -0,0 +1,85 @@
+<%@ page import="org.apache.cxf.rs.security.oauth2.common.Client"%>
+<%@ page import="org.apache.cxf.rs.security.oauth2.tokens.refresh.RefreshToken"%>
+<%@ page import="java.text.SimpleDateFormat"%>
+<%@ page import="java.util.Date"%>
+<%@ page import="java.util.List"%>
+<%@ page import="java.util.Locale"%>
+<%@ page import="java.util.TimeZone"%>
+<%@ page import="javax.servlet.http.HttpServletRequest" %>
+<%@ page import="org.apache.cxf.fediz.service.oidc.ClientRefreshTokens" %>
+
+<%
+ ClientRefreshTokens tokens = (ClientRefreshTokens)request.getAttribute("data");
+ Client client = tokens.getClient();
+ String basePath = request.getContextPath() + request.getServletPath();
+ if (!basePath.endsWith("/")) {
+ basePath += "/";
+ }
+%>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>Client Refresh Tokens</title>
+ <STYLE TYPE="text/css">
+ table {
+ border-collapse: collapse;
+ }
+ table th {
+ background-color: #f0f0f0;
+ border-color: #ccc;
+ border-style: solid;
+ border-width: 1px;
+ padding: 3px 4px;
+ text-align: center;
+ }
+ table td {
+ border-color: #ccc;
+ border-style: solid;
+ border-width: 1px;
+ padding: 3px 4px;
+ }
+ </STYLE>
+</head>
+<body>
+<div class="padded">
+<h1>Refresh Tokens issued to <%= client.getApplicationName() + "(" + client.getClientId() + ")"%>"</h1>
+<br/>
+<table border="1">
+ <tr><th>Identifier</th><th>Issue Date</th><th>Expiry Date</th></tr>
+ <%
+ SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss", Locale.US);
+ dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
+
+ for (RefreshToken token : tokens.getRefreshTokens()) {
+ %>
+ <tr>
+ <td><input type="text" name="tokenId" size="15" readonly="readonly" value="<%= token.getTokenKey() %>" /></td>
+ <td>
+ <%
+ Date date = new Date(token.getIssuedAt() * 1000);
+ String issued = dateFormat.format(date);
+ %>
+ <%= issued %><br/>
+ </td>
+ <td>
+ <%
+ Date date = new Date((token.getIssuedAt() + token.getExpiresIn()) * 1000);
+ String expires = dateFormat.format(date);
+ %>
+ <%= expires %><br/>
+ </td>
+ </tr>
+ <%
+ }
+ %>
+
+</table>
+
+<br/>
+<br/>
+<p>
+<a href="<%= basePath + "clients/" + client.getId() %>">Return</a>
+</p>
+</div>
+</body>
+</html>
+
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/159bf90e/services/oidc/src/main/webapp/WEB-INF/views/registeredClients.jsp
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/webapp/WEB-INF/views/registeredClients.jsp b/services/oidc/src/main/webapp/WEB-INF/views/registeredClients.jsp
index ce8ed9f..ee1455c 100644
--- a/services/oidc/src/main/webapp/WEB-INF/views/registeredClients.jsp
+++ b/services/oidc/src/main/webapp/WEB-INF/views/registeredClients.jsp
@@ -1,5 +1,9 @@
<%@ page import="org.apache.cxf.rs.security.oauth2.common.Client"%>
+<%@ page import="java.text.SimpleDateFormat"%>
<%@ page import="java.util.Collection"%>
+<%@ page import="java.util.Date"%>
+<%@ page import="java.util.Locale"%>
+<%@ page import="java.util.TimeZone"%>
<%@ page import="javax.servlet.http.HttpServletRequest" %>
<%
@@ -37,25 +41,22 @@
<h1>Registered API Clients</h1>
<br/>
<table border="1">
- <tr><th>Client Name</th><th>Client Identifier</th><th>Client Secret</th><th>Redirect URIs</th></tr>
+ <tr><th>Name</th><th>Identifier</th><th>Creation Date</th><th>Redirect URIs</th></tr>
<%
+ SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMM yyyy", Locale.US);
+ dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
+
for (Client client : regs) {
%>
<tr>
- <td><%= client.getApplicationName() %></td>
+ <td><a href="<%= basePath + "clients/" + client.getClientId() %>"><%= client.getApplicationName() %></a></td>
<td><input type="text" name="clientId" size="15" readonly="readonly" value="<%= client.getClientId() %>" /></td>
<td>
- <%
- if (client.getClientSecret() != null) {
- %>
- <input type="text" name="clientSecret" size="25" readonly="readonly" value="<%= client.getClientSecret() %>" />
- <%
- } else {
- %>
- <i>Unavailable for public client</i>
- <%
- }
- %>
+ <%
+ Date date = new Date(client.getRegisteredAt() * 1000);
+ String created = dateFormat.format(date);
+ %>
+ <%= created %><br/>
</td>
<td>
<% if(client.getRedirectUris() != null) {