>From b3bf3073b7135352cd85c271c79c23221ddce1e8 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata@redhat.com>
Date: Sat, 16 Apr 2016 03:48:40 +0200
Subject: [PATCH] Replaced TPS OP_DO_TOKEN activity.

For clarity the TPS operatons that generate OP_DO_TOKEN activity
has been modified to generate OP_MODIFY instead, except for the
changeTokenStatus() which will generate OP_STATUS_CHANGE.

https://fedorahosted.org/pki/ticket/2268
---
 base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java        |  8 ++++----
 .../src/org/dogtagpki/server/tps/dbs/ActivityDatabase.java   |  5 ++++-
 base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java | 12 ++++++------
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java b/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java
index 7a12466b8f9d0c29704012ffebcf1ff225393842..54d89ec26c05157a225c8ea33a6ee57afa02fc2c 100644
--- a/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java
+++ b/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java
@@ -402,7 +402,7 @@ public class TPSTokendb {
                     ", keyType: " + keyType +
                     ", state: " + tokenReason;
 
-            tdbActivity(ActivityDatabase.OP_DO_TOKEN, tdbGetTokenEntry(cuid),
+            tdbActivity(ActivityDatabase.OP_MODIFY, tdbGetTokenEntry(cuid),
                     ipAddress, activityMsg, "success", remoteUser);
 
             return false;
@@ -418,13 +418,13 @@ public class TPSTokendb {
             Date now = new Date();
             if (now.after(notAfter)) {
                 activityMsg = "revocation not enabled for expired cert: " + cert.getSerialNumber();
-                tdbActivity(ActivityDatabase.OP_DO_TOKEN, tdbGetTokenEntry(cuid),
+                tdbActivity(ActivityDatabase.OP_MODIFY, tdbGetTokenEntry(cuid),
                         ipAddress, activityMsg, "success", remoteUser);
                 return false;
             }
             if (now.before(notBefore)) {
                 activityMsg = "revocation not enabled for cert that is not yet valid: " + cert.getSerialNumber();
-                tdbActivity(ActivityDatabase.OP_DO_TOKEN, tdbGetTokenEntry(cuid),
+                tdbActivity(ActivityDatabase.OP_MODIFY, tdbGetTokenEntry(cuid),
                         ipAddress, activityMsg, "success", remoteUser);
                 return false;
             }
@@ -439,7 +439,7 @@ public class TPSTokendb {
                 activityMsg = "revocation not permitted as certificate " + cert.getSerialNumber() +
                         " is shared by anothr active token";
 
-                tdbActivity(ActivityDatabase.OP_DO_TOKEN, tdbGetTokenEntry(cuid),
+                tdbActivity(ActivityDatabase.OP_MODIFY, tdbGetTokenEntry(cuid),
                         ipAddress, activityMsg, "success", remoteUser);
 
                 return false;
diff --git a/base/tps/src/org/dogtagpki/server/tps/dbs/ActivityDatabase.java b/base/tps/src/org/dogtagpki/server/tps/dbs/ActivityDatabase.java
index c15ff92550362ab63b61c10a78f8fc0de521a901..4719ef9d2c60689c68b2361b28bf85e29d08e454 100644
--- a/base/tps/src/org/dogtagpki/server/tps/dbs/ActivityDatabase.java
+++ b/base/tps/src/org/dogtagpki/server/tps/dbs/ActivityDatabase.java
@@ -36,7 +36,7 @@ import com.netscape.cmsutil.ldap.LDAPUtil;
  * @author Endi S. Dewata
  */
 public class ActivityDatabase extends LDAPDatabase<ActivityRecord> {
-    public final static String OP_DO_TOKEN = "do_token";
+
     public final static String OP_ADD = "add"; // add a token
     public final static String OP_DELETE = "delete"; // delete a token
     //public final static String OP_MODIFY_AUDIT_SIGNING = "modify_audit_signing";
@@ -46,6 +46,9 @@ public class ActivityDatabase extends LDAPDatabase<ActivityRecord> {
     public final static String OP_PIN_RESET = "pin_reset";
     public final static String OP_FORMAT = "format";
 
+    public final static String OP_MODIFY = "modify";
+    public final static String OP_STATUS_CHANGE = "status_change";
+
     public ActivityDatabase(IDBSubsystem dbSubsystem, String baseDN) throws EBaseException {
         super("Activity", dbSubsystem, baseDN, ActivityRecord.class);
     }
diff --git a/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java b/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java
index 3dcc5a547f02899ae38f76028efddc9ff45bd900..33ad03a8d5b8e2876c7bd56e7708c8b01d0dc43c 100644
--- a/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java
+++ b/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java
@@ -460,7 +460,7 @@ public class TokenService extends PKIService implements TokenResource {
             tokenRecord.setPolicy(tokenData.getPolicy());
             auditModParams.put("Policy", tokenData.getPolicy());
             database.updateRecord(tokenID, tokenRecord);
-            subsystem.tdb.tdbActivity(ActivityDatabase.OP_DO_TOKEN, tokenRecord,
+            subsystem.tdb.tdbActivity(ActivityDatabase.OP_MODIFY, tokenRecord,
                     ipAddress, msg, "success", remoteUser);
 
             tokenData = createTokenData(database.getRecord(tokenID));
@@ -473,7 +473,7 @@ public class TokenService extends PKIService implements TokenResource {
             CMS.debug(e);
 
             msg = msg + ": " + e.getMessage();
-            subsystem.tdb.tdbActivity(ActivityDatabase.OP_DO_TOKEN, tokenRecord,
+            subsystem.tdb.tdbActivity(ActivityDatabase.OP_MODIFY, tokenRecord,
                     ipAddress, msg, "failure",
                     remoteUser);
 
@@ -554,7 +554,7 @@ public class TokenService extends PKIService implements TokenResource {
             }
 
             database.updateRecord(tokenID, tokenRecord);
-            subsystem.tdb.tdbActivity(ActivityDatabase.OP_DO_TOKEN, tokenRecord,
+            subsystem.tdb.tdbActivity(ActivityDatabase.OP_MODIFY, tokenRecord,
                     ipAddress, msg, "success", remoteUser);
 
             tokenData = createTokenData(database.getRecord(tokenID));
@@ -567,7 +567,7 @@ public class TokenService extends PKIService implements TokenResource {
             CMS.debug(e);
 
             msg = msg + ": " + e.getMessage();
-            subsystem.tdb.tdbActivity(ActivityDatabase.OP_DO_TOKEN, tokenRecord,
+            subsystem.tdb.tdbActivity(ActivityDatabase.OP_MODIFY, tokenRecord,
                     ipAddress, msg, "failure",
                     remoteUser);
 
@@ -662,7 +662,7 @@ public class TokenService extends PKIService implements TokenResource {
             // audit in setTokenStatus()
             setTokenStatus(tokenRecord, tokenStatus, ipAddress, remoteUser, auditModParams);
             database.updateRecord(tokenID, tokenRecord);
-            subsystem.tdb.tdbActivity(ActivityDatabase.OP_DO_TOKEN, tokenRecord,
+            subsystem.tdb.tdbActivity(ActivityDatabase.OP_STATUS_CHANGE, tokenRecord,
                     ipAddress, msg, "success",
                     remoteUser);
 
@@ -674,7 +674,7 @@ public class TokenService extends PKIService implements TokenResource {
             CMS.debug(e);
 
             msg = msg + ": " + e.getMessage();
-            subsystem.tdb.tdbActivity(ActivityDatabase.OP_DO_TOKEN, tokenRecord,
+            subsystem.tdb.tdbActivity(ActivityDatabase.OP_STATUS_CHANGE, tokenRecord,
                     ipAddress, msg, "failure",
                     remoteUser);
 
-- 
2.5.5

