From 648de7a10fb4c7d43c6550b577617067c70bbf7e Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Tue, 7 Apr 2015 22:01:54 -0400 Subject: 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/1164 --- .../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/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 ++++++++++++----- 10 files changed, 56 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 fc11c9a27..1381c660a 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 7b8757006..90deaaa8d 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 b79c9c81d..9cbdad6da 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/tps/shared/webapps/tps/index.html b/base/tps/shared/webapps/tps/index.html index c48da3307..71d333450 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 016b56ee0..c8e8d5d02 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 2ea17714e..c1f27b132 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 a87c2dd32..52e229f7b 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 eddceefd7..74adeadd1 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 78384acfe..8be08f09a 100644 --- a/base/tps/shared/webapps/tps/ui/token.html +++ b/base/tps/shared/webapps/tps/ui/token.html @@ -29,6 +29,7 @@