From 75ca07f43550789fe65c6234bb11d1d832bd0d40 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Tue, 7 Apr 2015 22:01:54 -0400 Subject: [PATCH] Added interface to show TPS token certificates. The TPS REST service, CLI, and UI have been modified to provide an interface to search for certificates belonging to a token. https://fedorahosted.org/pki/ticket/1143 --- .../com/netscape/certsrv/tps/cert/TPSCertClient.java | 4 ++-- .../com/netscape/certsrv/tps/cert/TPSCertResource.java | 1 + .../com/netscape/cmstools/tps/cert/TPSCertFindCLI.java | 10 ++++++++-- base/server/share/webapps/pki/js/pki-ui.js | 8 ++++++++ base/tps/shared/webapps/tps/index.html | 1 + base/tps/shared/webapps/tps/js/cert.js | 11 ++++++++++- base/tps/shared/webapps/tps/js/token.js | 8 ++++++++ base/tps/shared/webapps/tps/ui/certs.html | 2 ++ base/tps/shared/webapps/tps/ui/index.html | 12 +++++++++++- base/tps/shared/webapps/tps/ui/token.html | 1 + .../org/dogtagpki/server/tps/rest/TPSCertService.java | 17 ++++++++++++----- 11 files changed, 64 insertions(+), 11 deletions(-) diff --git a/base/common/src/com/netscape/certsrv/tps/cert/TPSCertClient.java b/base/common/src/com/netscape/certsrv/tps/cert/TPSCertClient.java index fc11c9a27c79e96f2aac1ad13f9d25a99a559092..1381c660ad611b9ff460aff511402b9e2b6c7c81 100644 --- a/base/common/src/com/netscape/certsrv/tps/cert/TPSCertClient.java +++ b/base/common/src/com/netscape/certsrv/tps/cert/TPSCertClient.java @@ -40,8 +40,8 @@ public class TPSCertClient extends Client { resource = createProxy(TPSCertResource.class); } - public TPSCertCollection findCerts(String filter, Integer start, Integer size) { - Response response = resource.findCerts(filter, start, size); + public TPSCertCollection findCerts(String filter, String tokenID, Integer start, Integer size) { + Response response = resource.findCerts(filter, tokenID, start, size); return client.getEntity(response, TPSCertCollection.class); } diff --git a/base/common/src/com/netscape/certsrv/tps/cert/TPSCertResource.java b/base/common/src/com/netscape/certsrv/tps/cert/TPSCertResource.java index 7b87570066798b69b91317e32e3e0ee6be4eb6f6..90deaaa8d672fe84dab79b61fdec7064eb2af880 100644 --- a/base/common/src/com/netscape/certsrv/tps/cert/TPSCertResource.java +++ b/base/common/src/com/netscape/certsrv/tps/cert/TPSCertResource.java @@ -36,6 +36,7 @@ public interface TPSCertResource { @ClientResponseType(entityType=TPSCertCollection.class) public Response findCerts( @QueryParam("filter") String filter, + @QueryParam("tokenID") String tokenID, @QueryParam("start") Integer start, @QueryParam("size") Integer size); diff --git a/base/java-tools/src/com/netscape/cmstools/tps/cert/TPSCertFindCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/cert/TPSCertFindCLI.java index b79c9c81de725f4168c98e7f836bbfedddf5e73d..9cbdad6da5ea26a618c8fda05a575ced9b4942d0 100644 --- a/base/java-tools/src/com/netscape/cmstools/tps/cert/TPSCertFindCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/tps/cert/TPSCertFindCLI.java @@ -48,7 +48,11 @@ public class TPSCertFindCLI extends CLI { } public void createOptions() { - Option option = new Option(null, "start", true, "Page start"); + Option option = new Option(null, "token", true, "Token ID"); + option.setArgName("ID"); + options.addOption(option); + + option = new Option(null, "start", true, "Page start"); option.setArgName("start"); options.addOption(option); @@ -79,13 +83,15 @@ public class TPSCertFindCLI extends CLI { String[] cmdArgs = cmd.getArgs(); String filter = cmdArgs.length > 0 ? cmdArgs[0] : null; + String tokenID = cmd.getOptionValue("token"); + String s = cmd.getOptionValue("start"); Integer start = s == null ? null : Integer.valueOf(s); s = cmd.getOptionValue("size"); Integer size = s == null ? null : Integer.valueOf(s); - TPSCertCollection result = certCLI.certClient.findCerts(filter, start, size); + TPSCertCollection result = certCLI.certClient.findCerts(filter, tokenID, start, size); MainCLI.printMessage(result.getTotal() + " entries matched"); if (result.getTotal() == 0) return; diff --git a/base/server/share/webapps/pki/js/pki-ui.js b/base/server/share/webapps/pki/js/pki-ui.js index 7d8e6eef6c14ae1d913a191cc834d6a279e48333..e2bcc56accf3e8f37b8509861124e0e03ee056bb 100644 --- a/base/server/share/webapps/pki/js/pki-ui.js +++ b/base/server/share/webapps/pki/js/pki-ui.js @@ -1110,3 +1110,11 @@ var EntryPage = Page.extend({ self.entry[name] = value; } }); + +var CollectionPage = Page.extend({ + initialize: function(options) { + var self = this; + CollectionPage.__super__.initialize.call(self, options); + self.collection = options.collection; + } +}); diff --git a/base/tps/shared/webapps/tps/index.html b/base/tps/shared/webapps/tps/index.html index c48da330729875db1870fcb766547967a5910098..71d33345017e5da9db63ebaa23fee35f5b145e42 100644 --- a/base/tps/shared/webapps/tps/index.html +++ b/base/tps/shared/webapps/tps/index.html @@ -17,6 +17,7 @@ --- END COPYRIGHT BLOCK --- --> + Token Processing System diff --git a/base/tps/shared/webapps/tps/js/cert.js b/base/tps/shared/webapps/tps/js/cert.js index 016b56ee012e4bce98d37106e1e4a8d05e955e22..c8e8d5d02ca4fa59024d45ae9abae4d84375e314 100644 --- a/base/tps/shared/webapps/tps/js/cert.js +++ b/base/tps/shared/webapps/tps/js/cert.js @@ -90,9 +90,18 @@ var CertificatesPage = Page.extend({ load: function() { var self = this; + if (self.collection && self.collection.options && self.collection.options.tokenID) { + $(".pki-breadcrumb-tokens").show(); + $(".pki-breadcrumb-token a") + .attr("href", "#tokens/" + self.collection.options.tokenID) + .text("Token " + self.collection.options.tokenID); + $(".pki-breadcrumb-token").show(); + $(".pki-title").text("Certificates for Token " + self.collection.options.tokenID); + } + var table = new CertificatesTable({ el: $("table[name='certificates']"), - collection: new CertificateCollection() + collection: self.collection }); table.render(); diff --git a/base/tps/shared/webapps/tps/js/token.js b/base/tps/shared/webapps/tps/js/token.js index 2ea17714e5463bc5acad4b3f5b37f8b1dbed69b2..c1f27b13248b4072fbd4f61072c28ed3c7505a8f 100644 --- a/base/tps/shared/webapps/tps/js/token.js +++ b/base/tps/shared/webapps/tps/js/token.js @@ -153,6 +153,14 @@ var TokenPage = EntryPage.extend({ dialog.open(); }); + + self.showCertsLink = $("a[name='showCerts']", self.menu); + + self.showCertsLink.click(function(e) { + + e.preventDefault(); + window.location.hash = window.location.hash + "/certs"; + }); }, renderContent: function() { var self = this; diff --git a/base/tps/shared/webapps/tps/ui/certs.html b/base/tps/shared/webapps/tps/ui/certs.html index a87c2dd3239165c70e28dee1fdc5f0579d2bbb93..52e229f7bac26536076873a83f98ea379b8ac516 100644 --- a/base/tps/shared/webapps/tps/ui/certs.html +++ b/base/tps/shared/webapps/tps/ui/certs.html @@ -18,6 +18,8 @@
diff --git a/base/tps/shared/webapps/tps/ui/index.html b/base/tps/shared/webapps/tps/ui/index.html index eddceefd7795450822118e66f481e2b95b53f31d..74adeadd14a7355c67dd92bba9c03958221d9023 100644 --- a/base/tps/shared/webapps/tps/ui/index.html +++ b/base/tps/shared/webapps/tps/ui/index.html @@ -17,6 +17,7 @@ --- END COPYRIGHT BLOCK --- --> + Token Processing System @@ -117,7 +118,8 @@ $(function() { router.route("certs", "certs", function() { new CertificatesPage({ el: content, - url: "certs.html" + url: "certs.html", + collection: new CertificateCollection() }).open(); }); @@ -276,6 +278,14 @@ $(function() { }).open(); }); + router.route("tokens/:id/certs", "certs", function(id) { + new CertificatesPage({ + el: content, + url: "certs.html", + collection: new CertificateCollection({ tokenID: id }) + }).open(); + }); + router.route("new-token", "new-token", function() { new TokenPage({ el: content, diff --git a/base/tps/shared/webapps/tps/ui/token.html b/base/tps/shared/webapps/tps/ui/token.html index 78384acfea06d558e7108bf419f1e04ad4103596..8be08f09ac27531c1485e099cf5f67616c178dca 100644 --- a/base/tps/shared/webapps/tps/ui/token.html +++ b/base/tps/shared/webapps/tps/ui/token.html @@ -29,6 +29,7 @@