diff options
author | Endi S. Dewata <edewata@redhat.com> | 2015-04-07 22:01:54 -0400 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2015-04-08 14:38:26 -0400 |
commit | 648de7a10fb4c7d43c6550b577617067c70bbf7e (patch) | |
tree | b4c0c95358314c3c4f5b46bd0465852c7baffc9c | |
parent | c4ee90c89a0b3c61b18f865e6650b27e156a9dcb (diff) | |
download | pki-648de7a10fb4c7d43c6550b577617067c70bbf7e.tar.gz pki-648de7a10fb4c7d43c6550b577617067c70bbf7e.tar.xz pki-648de7a10fb4c7d43c6550b577617067c70bbf7e.zip |
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
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 --- --> <html> <head> + <title>Token Processing System</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="/pki/css/patternfly.css" rel="stylesheet" media="screen, print"> <script src="/pki/js/jquery.js"></script> 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 @@ <div class="pki-header"> <ol class="breadcrumb"> <li><a href="#">Home</a></li> + <li class="pki-breadcrumb-tokens" style="display: none;"><a href="#tokens">Tokens</a></li> + <li class="pki-breadcrumb-token" style="display: none;"><a href="#tokens/${tokenID}">Token ${id}</a></li> <li class="active"><strong>Certificates</strong></li> </ol> 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 --- --> <html> <head> + <title>Token Processing System</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="/pki/css/patternfly.css" rel="stylesheet" media="screen, print"> <link href="/pki/css/pki-ui.css" rel="stylesheet" type="text/css"> @@ -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 @@ <span class="pki-menu" style="display: none;"> <a name="edit" href="#">Edit</a><br> <a name="changeStatus" href="#">Change Status</a><br> +<a name="showCerts" href="#">Show Certificates</a><br> </span> <span class="pki-buttons" style="display: none;"> diff --git a/base/tps/src/org/dogtagpki/server/tps/rest/TPSCertService.java b/base/tps/src/org/dogtagpki/server/tps/rest/TPSCertService.java index 75314cd5d..074d3d034 100644 --- a/base/tps/src/org/dogtagpki/server/tps/rest/TPSCertService.java +++ b/base/tps/src/org/dogtagpki/server/tps/rest/TPSCertService.java @@ -21,7 +21,9 @@ package org.dogtagpki.server.tps.rest; import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URLEncoder; +import java.util.HashMap; import java.util.Iterator; +import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Context; @@ -61,7 +63,7 @@ public class TPSCertService extends PKIService implements TPSCertResource { private HttpServletRequest servletRequest; public TPSCertService() { - System.out.println("TPSCertService.<init>()"); + CMS.debug("TPSCertService.<init>()"); } public TPSCertData createCertData(TPSCertRecord certRecord) { @@ -108,14 +110,19 @@ public class TPSCertService extends PKIService implements TPSCertResource { } @Override - public Response findCerts(String filter, Integer start, Integer size) { + public Response findCerts(String filter, String tokenID, Integer start, Integer size) { - System.out.println("TPSCertService.findCerts()"); + CMS.debug("TPSCertService.findCerts(" + filter + ", " + tokenID + ", " + start + ", " + size + ")"); if (filter != null && filter.length() < MIN_FILTER_LENGTH) { throw new BadRequestException("Filter is too short."); } + Map<String, String> attributes = new HashMap<String, String>(); + if (tokenID != null) { + attributes.put("tokenID", tokenID); + } + start = start == null ? 0 : start; size = size == null ? DEFAULT_SIZE : size; @@ -123,7 +130,7 @@ public class TPSCertService extends PKIService implements TPSCertResource { TPSSubsystem subsystem = (TPSSubsystem)CMS.getSubsystem(TPSSubsystem.ID); TPSCertDatabase database = subsystem.getCertDatabase(); - Iterator<TPSCertRecord> activities = database.findRecords(filter).iterator(); + Iterator<TPSCertRecord> activities = database.findRecords(filter, attributes).iterator(); TPSCertCollection response = new TPSCertCollection(); int i = 0; @@ -163,7 +170,7 @@ public class TPSCertService extends PKIService implements TPSCertResource { if (certID == null) throw new BadRequestException("Certificate ID is null."); - System.out.println("TPSCertService.getCert(\"" + certID + "\")"); + CMS.debug("TPSCertService.getCert(\"" + certID + "\")"); try { TPSSubsystem subsystem = (TPSSubsystem)CMS.getSubsystem(TPSSubsystem.ID); |