From e749dad93d9d203a86ef7c2b35b106c2c3f68c21 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Fri, 15 Aug 2014 15:16:31 -0400 Subject: Fixed missing TPS token attributes. The missing token policy attribute has been added to token database. The REST services, CLI, and UI have been fixed accordingly. Other missing attributes in tokenRecord object class are unused. Ticket #1085 --- .../com/netscape/certsrv/tps/token/TokenData.java | 17 ++++++ .../com/netscape/cmstools/tps/token/TokenCLI.java | 1 + base/tps-tomcat/shared/webapps/tps/js/token.js | 6 ++- base/tps-tomcat/shared/webapps/tps/ui/index.html | 4 +- base/tps-tomcat/shared/webapps/tps/ui/token.html | 2 + base/tps-tomcat/shared/webapps/tps/ui/tokens.html | 62 ++++++++++++---------- .../org/dogtagpki/server/tps/dbs/TokenRecord.java | 42 +++++++++++++++ .../dogtagpki/server/tps/rest/TokenService.java | 9 ++++ 8 files changed, 111 insertions(+), 32 deletions(-) diff --git a/base/common/src/com/netscape/certsrv/tps/token/TokenData.java b/base/common/src/com/netscape/certsrv/tps/token/TokenData.java index 27ee1fa20..235e86fea 100644 --- a/base/common/src/com/netscape/certsrv/tps/token/TokenData.java +++ b/base/common/src/com/netscape/certsrv/tps/token/TokenData.java @@ -57,6 +57,7 @@ public class TokenData { TokenStatus status; String appletID; String keyInfo; + String policy; Date createTimestamp; Date modifyTimestamp; @@ -125,6 +126,15 @@ public class TokenData { this.keyInfo = keyInfo; } + @XmlElement(name="Policy") + public String getPolicy() { + return policy; + } + + public void setPolicy(String policy) { + this.policy = policy; + } + @XmlElement(name="CreateTimestamp") public Date getCreateTimestamp() { return createTimestamp; @@ -162,6 +172,7 @@ public class TokenData { result = prime * result + ((keyInfo == null) ? 0 : keyInfo.hashCode()); result = prime * result + ((link == null) ? 0 : link.hashCode()); result = prime * result + ((modifyTimestamp == null) ? 0 : modifyTimestamp.hashCode()); + result = prime * result + ((policy == null) ? 0 : policy.hashCode()); result = prime * result + ((status == null) ? 0 : status.hashCode()); result = prime * result + ((tokenID == null) ? 0 : tokenID.hashCode()); result = prime * result + ((type == null) ? 0 : type.hashCode()); @@ -208,6 +219,11 @@ public class TokenData { return false; } else if (!modifyTimestamp.equals(other.modifyTimestamp)) return false; + if (policy == null) { + if (other.policy != null) + return false; + } else if (!policy.equals(other.policy)) + return false; if (status != other.status) return false; if (tokenID == null) { @@ -256,6 +272,7 @@ public class TokenData { before.setStatus(TokenStatus.ACTIVE); before.setAppletID("APPLET1234"); before.setKeyInfo("key info"); + before.setPolicy("FORCE_FORMAT=YES"); before.setCreateTimestamp(new Date()); before.setModifyTimestamp(new Date()); diff --git a/base/java-tools/src/com/netscape/cmstools/tps/token/TokenCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/token/TokenCLI.java index df3ab2890..40d1f9447 100644 --- a/base/java-tools/src/com/netscape/cmstools/tps/token/TokenCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/tps/token/TokenCLI.java @@ -56,6 +56,7 @@ public class TokenCLI extends CLI { if (token.getStatus() != null) System.out.println(" Status: " + token.getStatus()); if (token.getAppletID() != null) System.out.println(" Applet ID: " + token.getAppletID()); if (token.getKeyInfo() != null) System.out.println(" Key Info: " + token.getKeyInfo()); + if (token.getPolicy() != null) System.out.println(" Policy: " + token.getPolicy()); if (token.getCreateTimestamp() != null) System.out.println(" Date Created: " + token.getCreateTimestamp()); if (token.getModifyTimestamp() != null) System.out.println(" Date Modified: " + token.getModifyTimestamp()); diff --git a/base/tps-tomcat/shared/webapps/tps/js/token.js b/base/tps-tomcat/shared/webapps/tps/js/token.js index 085003a1e..2ea17714e 100644 --- a/base/tps-tomcat/shared/webapps/tps/js/token.js +++ b/base/tps-tomcat/shared/webapps/tps/js/token.js @@ -40,6 +40,7 @@ var TokenModel = Model.extend({ statusLabel: TokenStatus[response.Status], appletID: response.AppletID, keyInfo: response.KeyInfo, + policy: response.Policy, createTimestamp: response.CreateTimestamp, modifyTimestamp: response.ModifyTimestamp }; @@ -53,6 +54,7 @@ var TokenModel = Model.extend({ Status: attributes.status, AppletID: attributes.appletID, KeyInfo: attributes.keyInfo, + Policy: attributes.policy, CreateTimestamp: attributes.createTimestamp, ModifyTimestamp: attributes.modifyTimestamp }; @@ -91,6 +93,7 @@ var TokenCollection = Collection.extend({ statusLabel: TokenStatus[entry.Status], appletID: entry.AppletID, keyInfo: entry.KeyInfo, + policy: entry.Policy, createTimestamp: entry.CreateTimestamp, modifyTimestamp: entry.ModifyTimestamp }); @@ -191,7 +194,8 @@ var TokenTableItem = TableItem.extend({ el: $("#token-status-dialog"), title: "Change Token Status", readonly: ["tokenID", "userID", "type", - "appletID", "keyInfo", "createTimestamp", "modifyTimestamp"], + "appletID", "keyInfo", "policy", + "createTimestamp", "modifyTimestamp"], actions: ["cancel", "save"] }); diff --git a/base/tps-tomcat/shared/webapps/tps/ui/index.html b/base/tps-tomcat/shared/webapps/tps/ui/index.html index d1fa78b67..eddceefd7 100644 --- a/base/tps-tomcat/shared/webapps/tps/ui/index.html +++ b/base/tps-tomcat/shared/webapps/tps/ui/index.html @@ -272,7 +272,7 @@ $(function() { el: content, url: "token.html", model: new TokenModel({ id: id }), - editable: ["userID", "type", "appletID", "keyInfo"] + editable: ["userID", "type", "appletID", "keyInfo", "policy"] }).open(); }); @@ -283,7 +283,7 @@ $(function() { model: new TokenModel(), mode: "add", title: "New Token", - editable: ["tokenID", "userID", "type", "appletID", "keyInfo"], + editable: ["tokenID", "userID", "type", "appletID", "keyInfo", "policy"], parentHash: "#tokens" }).open(); }); diff --git a/base/tps-tomcat/shared/webapps/tps/ui/token.html b/base/tps-tomcat/shared/webapps/tps/ui/token.html index 6d34af5d2..78384acfe 100644 --- a/base/tps-tomcat/shared/webapps/tps/ui/token.html +++ b/base/tps-tomcat/shared/webapps/tps/ui/token.html @@ -54,6 +54,8 @@

+ +

diff --git a/base/tps-tomcat/shared/webapps/tps/ui/tokens.html b/base/tps-tomcat/shared/webapps/tps/ui/tokens.html index 98ae769aa..aca579a68 100644 --- a/base/tps-tomcat/shared/webapps/tps/ui/tokens.html +++ b/base/tps-tomcat/shared/webapps/tps/ui/tokens.html @@ -27,7 +27,7 @@ - + @@ -58,13 +59,14 @@ + -
+ @@ -45,6 +45,7 @@ Status Applet ID Key InfoPolicy Created Modified
${statusLabel} ${appletID} ${keyInfo}${policy} ${createTimestamp} ${modifyTimestamp}
+
Total: 0 entries
@@ -96,35 +98,37 @@ diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/TokenRecord.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/TokenRecord.java index 11fecce58..a1aef5720 100644 --- a/base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/TokenRecord.java +++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/TokenRecord.java @@ -33,6 +33,32 @@ public class TokenRecord extends DBRecord { private static final long serialVersionUID = 1L; + /** + * objectClasses: ( tokenRecord-oid + * NAME 'tokenRecord' + * DESC 'CMS defined class' + * SUP top + * STRUCTURAL + * MUST cn + * MAY ( + * dateOfCreate $ + * dateOfModify $ + * modified $ (unused) + * tokenReason $ + * tokenUserID $ + * tokenStatus $ + * tokenAppletID $ + * keyInfo $ + * tokenPolicy $ + * extensions $ (unused) + * numberOfResets $ (unused) + * numberOfEnrollments $ (unused) + * numberOfRenewals $ (unused) + * numberOfRecoveries $ (unused) + * userCertificate $ (unused) + * tokenType ) + * X-ORIGIN 'user defined' ) + */ String id; String userID; String type; @@ -40,6 +66,7 @@ public class TokenRecord extends DBRecord { String reason; String appletID; String keyInfo; + String policy; Date createTimestamp; Date modifyTimestamp; @@ -106,6 +133,15 @@ public class TokenRecord extends DBRecord { this.keyInfo = keyInfo; } + @DBAttribute("tokenPolicy") + public String getPolicy() { + return policy; + } + + public void setPolicy(String policy) { + this.policy = policy; + } + @DBAttribute("dateOfCreate") public Date getCreateTimestamp() { return createTimestamp; @@ -133,6 +169,7 @@ public class TokenRecord extends DBRecord { result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((keyInfo == null) ? 0 : keyInfo.hashCode()); result = prime * result + ((modifyTimestamp == null) ? 0 : modifyTimestamp.hashCode()); + result = prime * result + ((policy == null) ? 0 : policy.hashCode()); result = prime * result + ((reason == null) ? 0 : reason.hashCode()); result = prime * result + ((status == null) ? 0 : status.hashCode()); result = prime * result + ((type == null) ? 0 : type.hashCode()); @@ -174,6 +211,11 @@ public class TokenRecord extends DBRecord { return false; } else if (!modifyTimestamp.equals(other.modifyTimestamp)) return false; + if (policy == null) { + if (other.policy != null) + return false; + } else if (!policy.equals(other.policy)) + return false; if (reason == null) { if (other.reason != null) return false; diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/TokenService.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/TokenService.java index 09adf5491..84046a964 100644 --- a/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/TokenService.java +++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/TokenService.java @@ -164,6 +164,7 @@ public class TokenService extends PKIService implements TokenResource { tokenData.setStatus(getTokenStatus(tokenRecord)); tokenData.setAppletID(tokenRecord.getAppletID()); tokenData.setKeyInfo(tokenRecord.getKeyInfo()); + tokenData.setPolicy(tokenRecord.getPolicy()); tokenData.setCreateTimestamp(tokenRecord.getCreateTimestamp()); tokenData.setModifyTimestamp(tokenRecord.getModifyTimestamp()); @@ -190,6 +191,7 @@ public class TokenService extends PKIService implements TokenResource { setTokenStatus(tokenRecord, tokenData.getStatus()); tokenRecord.setAppletID(tokenData.getAppletID()); tokenRecord.setKeyInfo(tokenData.getKeyInfo()); + tokenRecord.setPolicy(tokenData.getPolicy()); tokenRecord.setCreateTimestamp(tokenData.getCreateTimestamp()); tokenRecord.setModifyTimestamp(tokenData.getModifyTimestamp()); @@ -330,6 +332,7 @@ public class TokenService extends PKIService implements TokenResource { tokenRecord.setType(tokenData.getType()); tokenRecord.setAppletID(tokenData.getAppletID()); tokenRecord.setKeyInfo(tokenData.getKeyInfo()); + tokenRecord.setPolicy(tokenData.getPolicy()); database.updateRecord(tokenID, tokenRecord); subsystem.tdb.tdbActivity(subsystem, ActivityDatabase.OP_DO_TOKEN, tokenRecord, ipAddress, msg, "success", @@ -393,6 +396,12 @@ public class TokenService extends PKIService implements TokenResource { tokenRecord.setKeyInfo(keyInfo); } + // update policy if specified + String policy = tokenData.getPolicy(); + if (policy != null) { + tokenRecord.setPolicy(policy); + } + database.updateRecord(tokenID, tokenRecord); subsystem.tdb.tdbActivity(subsystem, ActivityDatabase.OP_DO_TOKEN, tokenRecord, ipAddress, msg, "success", -- cgit