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/13 14:49:22 UTC

cxf-fediz git commit: Prototyping the code for removing tokens/grants

Repository: cxf-fediz
Updated Branches:
  refs/heads/master 8c95c3488 -> 4f4e74267


Prototyping the code for removing tokens/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/4f4e7426
Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/4f4e7426
Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/4f4e7426

Branch: refs/heads/master
Commit: 4f4e742675f53b4368e09f0c2d607b74725b8a89
Parents: 8c95c34
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Wed Jan 13 13:49:00 2016 +0000
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Wed Jan 13 13:49:00 2016 +0000

----------------------------------------------------------------------
 .../service/oidc/ClientRegistrationService.java | 31 ++++++++++++++++++++
 .../webapp/WEB-INF/views/clientAccessTokens.jsp |  7 +++++
 .../webapp/WEB-INF/views/clientCodeGrants.jsp   |  7 +++++
 .../WEB-INF/views/clientRefreshTokens.jsp       |  7 +++++
 4 files changed, 52 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/4f4e7426/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 6e4f295..f5c10bf 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
@@ -42,6 +42,7 @@ import org.apache.cxf.common.util.Base64UrlUtility;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.rs.security.oauth2.common.Client;
 import org.apache.cxf.rs.security.oauth2.common.UserSubject;
+import org.apache.cxf.rs.security.oauth2.utils.OAuthConstants;
 import org.apache.cxf.rt.security.crypto.CryptoUtils;
 
 @Path("/")
@@ -118,6 +119,16 @@ public class ClientRegistrationService {
         Client c = getRegisteredClient(id);
         return new ClientAccessTokens(c, manager.getAccessTokens(c));
     }
+    @POST
+    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
+    @Produces(MediaType.TEXT_HTML)
+    @Path("/{id}/at/{tokenId}/revoke")
+    public ClientAccessTokens revokeClientAccessToken(@PathParam("id") String id,
+                                                      @PathParam("tokenId") String tokenId) {
+        Client c = getRegisteredClient(id);
+        manager.revokeToken(c, tokenId, OAuthConstants.ACCESS_TOKEN);
+        return new ClientAccessTokens(c, manager.getAccessTokens(c));
+    }
     
     @GET
     @Produces(MediaType.TEXT_HTML)
@@ -127,6 +138,17 @@ public class ClientRegistrationService {
         return new ClientRefreshTokens(c, manager.getRefreshTokens(c));
     }
     
+    @POST
+    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
+    @Produces(MediaType.TEXT_HTML)
+    @Path("/{id}/rt/{tokenId}/revoke")
+    public ClientRefreshTokens revokeClientRefreshToken(@PathParam("id") String id,
+                                                      @PathParam("tokenId") String tokenId) {
+        Client c = getRegisteredClient(id);
+        manager.revokeToken(c, tokenId, OAuthConstants.REFRESH_TOKEN);
+        return new ClientRefreshTokens(c, manager.getRefreshTokens(c));
+    }
+    
     @GET
     @Produces(MediaType.TEXT_HTML)
     @Path("/{id}/codes")
@@ -135,6 +157,15 @@ public class ClientRegistrationService {
         return new ClientCodeGrants(c, manager.getCodeGrants(c));
     }
     
+    @POST
+    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
+    @Produces(MediaType.TEXT_HTML)
+    @Path("/{id}/codes/{code}/revoke")
+    public ClientCodeGrants revokeClientCodeGrant(@PathParam("id") String id,
+                                                  @PathParam("code") String code) {
+        manager.removeCodeGrant(code);
+        return getClientCodeGrants(id);
+    }
     
     @POST
     @Consumes(MediaType.APPLICATION_FORM_URLENCODED)

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/4f4e7426/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
index dffc02f..511757d 100644
--- a/services/oidc/src/main/webapp/WEB-INF/views/clientAccessTokens.jsp
+++ b/services/oidc/src/main/webapp/WEB-INF/views/clientAccessTokens.jsp
@@ -67,6 +67,13 @@
 		   %>
            <%=    expires %><br/>
            </td>
+           <td>
+               <form action="/fediz-oidc/clients/<%= client.getClientId() + "/at/" + token.getTokenKey() + "/revoke"%>" method="POST">
+		         <div data-type="control_button" class="form-line">
+				   <button class="form-submit-button" type="submit">Delete</button>
+		         </div>
+               </form>
+           </td>
        </tr>
     <%   
        }

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/4f4e7426/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
index ff13a13..59a8d1d 100644
--- a/services/oidc/src/main/webapp/WEB-INF/views/clientCodeGrants.jsp
+++ b/services/oidc/src/main/webapp/WEB-INF/views/clientCodeGrants.jsp
@@ -67,6 +67,13 @@
 		   %>
            <%=    expires %><br/>
            </td>
+           <td>
+               <form action="/fediz-oidc/clients/<%= client.getClientId() + "/codes/" + token.getTokenKey() + "/revoke"%>" method="POST">
+		         <div data-type="control_button" class="form-line">
+				   <button class="form-submit-button" type="submit">Delete</button>
+		         </div>
+               </form>
+           </td>
        </tr>
     <%   
        }

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/4f4e7426/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
index 473f491..04d615d 100644
--- a/services/oidc/src/main/webapp/WEB-INF/views/clientRefreshTokens.jsp
+++ b/services/oidc/src/main/webapp/WEB-INF/views/clientRefreshTokens.jsp
@@ -67,6 +67,13 @@
 		   %>
            <%=    expires %><br/>
            </td>
+           <td>
+               <form action="/fediz-oidc/clients/<%= client.getClientId() + "/rt/" + token.getTokenKey() + "/revoke"%>" method="POST">
+		         <div data-type="control_button" class="form-line">
+				   <button class="form-submit-button" type="submit">Delete</button>
+		         </div>
+               </form>
+           </td>
        </tr>
     <%   
        }