From 3fad7b7220d4f7c37b3df596815fc500ce1de279 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Wed, 3 Feb 2016 23:54:56 +0100 Subject: [PATCH] Fixed token add operation. The TokenService has been fixed to allow adding a new token with empty attributes via the UI or CLI. The TPS UI has been modified to hide the status, create timestamp, and modify timestamp fields when adding a new token. The CLI has been modified to provide the parameters to specify the attribute values. https://fedorahosted.org/pki/ticket/1646 --- .../netscape/cmstools/tps/token/TokenAddCLI.java | 35 ++++++++++++++-- base/tps/shared/webapps/tps/js/token.js | 13 ++++++ base/tps/shared/webapps/tps/ui/token.html | 8 ++-- base/tps/shared/webapps/tps/ui/tokens.html | 6 +-- .../dogtagpki/server/tps/rest/TokenService.java | 49 +++++++++++++++------- 5 files changed, 85 insertions(+), 26 deletions(-) diff --git a/base/java-tools/src/com/netscape/cmstools/tps/token/TokenAddCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/token/TokenAddCLI.java index a63df2e8005ad9161a2c90c7c88953abc6a85be4..9252dceacafcdec3fd9709803b92766c932559ca 100644 --- a/base/java-tools/src/com/netscape/cmstools/tps/token/TokenAddCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/tps/token/TokenAddCLI.java @@ -42,13 +42,28 @@ public class TokenAddCLI extends CLI { } public void printHelp() { - formatter.printHelp(getFullName() + " --user [OPTIONS...]", options); + formatter.printHelp(getFullName() + " [OPTIONS...]", options); } public void createOptions() { Option option = new Option(null, "user", true, "User ID"); option.setArgName("User ID"); - option.setRequired(true); + options.addOption(option); + + option = new Option(null, "type", true, "Type"); + option.setArgName("Type"); + options.addOption(option); + + option = new Option(null, "applet", true, "Applet ID"); + option.setArgName("Applet ID"); + options.addOption(option); + + option = new Option(null, "key-info", true, "Key info"); + option.setArgName("Key info"); + options.addOption(option); + + option = new Option(null, "policy", true, "Policy"); + option.setArgName("Policy"); options.addOption(option); } @@ -83,7 +98,21 @@ public class TokenAddCLI extends CLI { TokenData tokenData = new TokenData(); tokenData.setTokenID(tokenID); - tokenData.setUserID(cmd.getOptionValue("user")); + + String userID = cmd.getOptionValue("user"); + tokenData.setUserID(userID); + + String type = cmd.getOptionValue("type"); + tokenData.setType(type); + + String appletID = cmd.getOptionValue("applet"); + tokenData.setAppletID(appletID); + + String keyInfo = cmd.getOptionValue("key-info"); + tokenData.setKeyInfo(keyInfo); + + String policy = cmd.getOptionValue("policy"); + tokenData.setPolicy(policy); tokenData = tokenCLI.tokenClient.addToken(tokenData); diff --git a/base/tps/shared/webapps/tps/js/token.js b/base/tps/shared/webapps/tps/js/token.js index a2d25fd6eaf39161fd6fb0e611929789ef87851d..e21cb3176544e7cb934f965a123c8396c919cb5e 100644 --- a/base/tps/shared/webapps/tps/js/token.js +++ b/base/tps/shared/webapps/tps/js/token.js @@ -195,8 +195,21 @@ var TokenPage = EntryPage.extend({ if (self.mode == "add") { self.changeStatusAction.hide(); + self.$("label[name='createTimestamp']").hide(); + self.$("input[name='createTimestamp']").hide(); + self.$("label[name='modifyTimestamp']").hide(); + self.$("input[name='modifyTimestamp']").hide(); + self.$("label[name='status']").hide(); + self.$("input[name='statusLabel']").hide(); + } else { self.changeStatusAction.show(); + self.$("label[name='createTimestamp']").show(); + self.$("input[name='createTimestamp']").show(); + self.$("label[name='modifyTimestamp']").show(); + self.$("input[name='modifyTimestamp']").show(); + self.$("label[name='status']").show(); + self.$("input[name='statusLabel']").show(); } } }); diff --git a/base/tps/shared/webapps/tps/ui/token.html b/base/tps/shared/webapps/tps/ui/token.html index 90b9c72a585f5723e47d7830b4a70805088a2fd4..16e92f444654d4cf48871f40f1d714eb96debb9b 100644 --- a/base/tps/shared/webapps/tps/ui/token.html +++ b/base/tps/shared/webapps/tps/ui/token.html @@ -49,18 +49,18 @@

- -



- +
- +
+ +
diff --git a/base/tps/shared/webapps/tps/ui/tokens.html b/base/tps/shared/webapps/tps/ui/tokens.html index 42a93cd93ff45c920e7dc22e88004a2e3a439665..ec89de958a17bba09b181e8bbe3d15b6c8287cad 100644 --- a/base/tps/shared/webapps/tps/ui/tokens.html +++ b/base/tps/shared/webapps/tps/ui/tokens.html @@ -105,9 +105,6 @@

- -

@@ -118,6 +115,9 @@

+ +