[Pki-devel] [PATCH] 517 Fixed missing TPS token attributes.

Endi Sukma Dewata edewata at redhat.com
Fri Aug 15 19:28:22 UTC 2014


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

-- 
Endi S. Dewata

-------------- next part --------------
From 5f96fde08fce2794495c99c101f206002184f968 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata at redhat.com>
Date: Fri, 15 Aug 2014 15:16:31 -0400
Subject: [PATCH] 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 27ee1fa203f083b41843af9405914121a2571c13..235e86feaebeafec5d6263e3658a53791fb845de 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 df3ab289029ccafa73337fd62de372af4b863c19..40d1f944700b8c7dedeacf535aea0dd72f66e530 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 085003a1e5905257f47bb4ee54d5010f30e54725..2ea17714e5463bc5acad4b3f5b37f8b1dbed69b2 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 d1fa78b6756e47ccd90f063eb0cf36639c5725b2..eddceefd7795450822118e66f481e2b95b53f31d 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 6d34af5d253b3ab2c5d74dc52b957417d90e1d17..78384acfea06d558e7108bf419f1e04ad4103596 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 @@
     <input name="appletID" readonly="readonly"><br>
     <label>Key Info</label>
     <input name="keyInfo" readonly="readonly"><br>
+    <label>Policy</label>
+    <input name="policy" readonly="readonly"><br>
     <label>Created</label>
     <input name="createTimestamp" readonly="readonly"><br>
     <label>Modified</label>
diff --git a/base/tps-tomcat/shared/webapps/tps/ui/tokens.html b/base/tps-tomcat/shared/webapps/tps/ui/tokens.html
index 98ae769aa0dee6cb9b898f1a97c95746b8d0f20a..aca579a68966a90394c71b199914f13f4433fa46 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 @@
 <table name="tokens">
 <thead>
     <tr>
-         <th class="pki-table-actions" colspan="9">
+         <th class="pki-table-actions" colspan="10">
              <span name="search">
                  <input name="search" type="text" placeholder="Search...">
              </span>
@@ -45,6 +45,7 @@
         <th>Status</th>
         <th>Applet ID</th>
         <th>Key Info</th>
+        <th>Policy</th>
         <th>Created</th>
         <th>Modified</th>
     </tr>
@@ -58,13 +59,14 @@
         <td name="status"><a href="#tokens/${id}/status">${statusLabel}</a></td>
         <td name="appletID">${appletID}</td>
         <td name="keyInfo">${keyInfo}</td>
+        <td name="policy">${policy}</td>
         <td name="created">${createTimestamp}</td>
         <td name="modified">${modifyTimestamp}</td>
     </tr>
 </tbody>
 <tfoot>
     <tr>
-         <th class="pki-table-actions" colspan="9">
+         <th class="pki-table-actions" colspan="10">
              <div class="pki-table-info">
                  Total: <span name="totalEntries">0</span> entries
              </div>
@@ -96,35 +98,37 @@
                 <h4 class="modal-title">Change Token Status</h4>
             </div>
             <div class="modal-body">
-		        <fieldset>
-		            <label>Token ID</label>
-		            <input name="tokenID" readonly="readonly"><br>
-		            <label>User ID</label>
-		            <input name="userID" readonly="readonly"><br>
-		            <label>Type</label>
-		            <input name="type" readonly="readonly"><br>
-		            <label>Status</label>
-		            <select name="status">
-		            <option value="UNINITIALIZED">Uninitialized</option>
-		            <option value="ACTIVE">Active</option>
-		            <option value="TEMP_LOST">Temporarily lost</option>
-		            <option value="PERM_LOST">Permanently lost</option>
-		            <option value="DAMAGED">Physically damaged</option>
-		            <option value="TERMINATED">Terminated</option>
-		            </select><br>
-		            <label>Applet ID</label>
-		            <input name="appletID" readonly="readonly"><br>
-		            <label>Key Info</label>
-		            <input name="keyInfo" readonly="readonly"><br>
-		            <label>Created</label>
-		            <input name="createTimestamp" readonly="readonly"><br>
-		            <label>Modified</label>
-		            <input name="modifyTimestamp" readonly="readonly"><br>
-		        </fieldset>
+                <fieldset>
+                    <label>Token ID</label>
+                    <input name="tokenID" readonly="readonly"><br>
+                    <label>User ID</label>
+                    <input name="userID" readonly="readonly"><br>
+                    <label>Type</label>
+                    <input name="type" readonly="readonly"><br>
+                    <label>Status</label>
+                    <select name="status">
+                    <option value="UNINITIALIZED">Uninitialized</option>
+                    <option value="ACTIVE">Active</option>
+                    <option value="TEMP_LOST">Temporarily lost</option>
+                    <option value="PERM_LOST">Permanently lost</option>
+                    <option value="DAMAGED">Physically damaged</option>
+                    <option value="TERMINATED">Terminated</option>
+                    </select><br>
+                    <label>Applet ID</label>
+                    <input name="appletID" readonly="readonly"><br>
+                    <label>Key Info</label>
+                    <input name="keyInfo" readonly="readonly"><br>
+                    <label>Policy</label>
+                    <input name="policy" readonly="readonly"><br>
+                    <label>Created</label>
+                    <input name="createTimestamp" readonly="readonly"><br>
+                    <label>Modified</label>
+                    <input name="modifyTimestamp" readonly="readonly"><br>
+                </fieldset>
             </div>
             <div class="modal-footer">
-	            <button name="save" class="btn btn-primary">Save</button>
-	            <button name="cancel" class="btn btn-default" data-dismiss="modal">Cancel</button>
+                <button name="save" class="btn btn-primary">Save</button>
+                <button name="cancel" class="btn btn-default" data-dismiss="modal">Cancel</button>
             </div>
         </div>
     </div>
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 11fecce58d0a1830eea3e1919a40adbc599c5aa0..a1aef5720830bdf9f621a8d54630bcf6c8319bd3 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 09adf5491240eb6017ce9fb9d15a5ecea7ac78ab..84046a964375cc7f9884249d311bd099c59008d7 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",
-- 
1.8.4.2



More information about the Pki-devel mailing list