78720a
From 1e6afa85e7d129c09bd922108201a2b12aec34b2 Mon Sep 17 00:00:00 2001
78720a
From: Chris Kelley <ckelley@redhat.com>
78720a
Date: Fri, 17 Mar 2023 11:21:01 +0000
78720a
Subject: [PATCH 1/4] Fix token filtering in TPS UI
78720a
78720a
Only the filter created from input in the search bar was being
78720a
used to compose the ldapsearch query. The attributes were passed
78720a
across from the client and into the processing method but were not
78720a
then passed on to the database.
78720a
78720a
Resolves #2179305
78720a
78720a
(cherry picked from commit a4d8c4bde3c76b169745b495aa5f9f037727bbc9)
78720a
---
78720a
 base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java | 7 ++-----
78720a
 1 file changed, 2 insertions(+), 5 deletions(-)
78720a
78720a
diff --git a/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java b/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java
78720a
index 5256a66..68b49c2 100644
78720a
--- a/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java
78720a
+++ b/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java
78720a
@@ -25,7 +25,6 @@ import java.util.ArrayList;
78720a
 import java.util.Collection;
78720a
 import java.util.Date;
78720a
 import java.util.HashMap;
78720a
-import java.util.Iterator;
78720a
 import java.util.List;
78720a
 import java.util.Map;
78720a
 import java.util.MissingResourceException;
78720a
@@ -39,9 +38,7 @@ import org.dogtagpki.server.tps.dbs.ActivityDatabase;
78720a
 import org.dogtagpki.server.tps.dbs.TokenDatabase;
78720a
 import org.dogtagpki.server.tps.dbs.TokenRecord;
78720a
 import org.dogtagpki.server.tps.engine.TPSEngine;
78720a
-import org.jboss.resteasy.plugins.providers.atom.Link;
78720a
 
78720a
-import com.netscape.cms.realm.PKIPrincipal;
78720a
 import com.netscape.certsrv.apps.CMS;
78720a
 import com.netscape.certsrv.base.BadRequestException;
78720a
 import com.netscape.certsrv.base.IConfigStore;
78720a
@@ -57,8 +54,8 @@ import com.netscape.certsrv.tps.token.TokenData.TokenStatusData;
78720a
 import com.netscape.certsrv.tps.token.TokenResource;
78720a
 import com.netscape.certsrv.tps.token.TokenStatus;
78720a
 import com.netscape.certsrv.user.UserResource;
78720a
-import com.netscape.certsrv.usrgrp.IUGSubsystem;
78720a
 import com.netscape.certsrv.usrgrp.IUser;
78720a
+import com.netscape.cms.realm.PKIPrincipal;
78720a
 import com.netscape.cms.servlet.base.SubsystemService;
78720a
 
78720a
 import netscape.ldap.LDAPException;
78720a
@@ -411,7 +408,7 @@ public class TokenService extends SubsystemService implements TokenResource {
78720a
 
78720a
         String method = "TokenService.retrieveTokensWithoutVLV: ";
78720a
 
78720a
-        List<TokenRecord> tokens = (List<TokenRecord>) database.findRecords(filter);
78720a
+        List<TokenRecord> tokens = (List<TokenRecord>) database.findRecords(filter, attributes);
78720a
         int total = tokens.size();
78720a
         CMS.debug(method + "total: " + total);
78720a
 
78720a
-- 
78720a
1.8.3.1
78720a
78720a
78720a
From 1ad110d0c3a5d4fe452353bdc33b04d23f869584 Mon Sep 17 00:00:00 2001
78720a
From: Chris Kelley <ckelley@redhat.com>
78720a
Date: Fri, 17 Mar 2023 11:24:32 +0000
78720a
Subject: [PATCH 2/4] Fix token filtering in TPS UI
78720a
78720a
Only the filter created from input in the search bar was being
78720a
used to compose the ldapsearch query. The attributes were passed
78720a
across from the client and into the processing method but were not
78720a
then passed on to the database.
78720a
78720a
Resolves #2179305
78720a
78720a
(cherry picked from commit a6a412ed3a0f6b42656814c798151a0572c80c91)
78720a
---
78720a
 base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java | 5 ++++-
78720a
 1 file changed, 4 insertions(+), 1 deletion(-)
78720a
78720a
diff --git a/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java b/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java
78720a
index 68b49c2..e21953f 100644
78720a
--- a/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java
78720a
+++ b/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java
78720a
@@ -25,6 +25,7 @@ import java.util.ArrayList;
78720a
 import java.util.Collection;
78720a
 import java.util.Date;
78720a
 import java.util.HashMap;
78720a
+import java.util.Iterator;
78720a
 import java.util.List;
78720a
 import java.util.Map;
78720a
 import java.util.MissingResourceException;
78720a
@@ -38,7 +39,9 @@ import org.dogtagpki.server.tps.dbs.ActivityDatabase;
78720a
 import org.dogtagpki.server.tps.dbs.TokenDatabase;
78720a
 import org.dogtagpki.server.tps.dbs.TokenRecord;
78720a
 import org.dogtagpki.server.tps.engine.TPSEngine;
78720a
+import org.jboss.resteasy.plugins.providers.atom.Link;
78720a
 
78720a
+import com.netscape.cms.realm.PKIPrincipal;
78720a
 import com.netscape.certsrv.apps.CMS;
78720a
 import com.netscape.certsrv.base.BadRequestException;
78720a
 import com.netscape.certsrv.base.IConfigStore;
78720a
@@ -54,8 +57,8 @@ import com.netscape.certsrv.tps.token.TokenData.TokenStatusData;
78720a
 import com.netscape.certsrv.tps.token.TokenResource;
78720a
 import com.netscape.certsrv.tps.token.TokenStatus;
78720a
 import com.netscape.certsrv.user.UserResource;
78720a
+import com.netscape.certsrv.usrgrp.IUGSubsystem;
78720a
 import com.netscape.certsrv.usrgrp.IUser;
78720a
-import com.netscape.cms.realm.PKIPrincipal;
78720a
 import com.netscape.cms.servlet.base.SubsystemService;
78720a
 
78720a
 import netscape.ldap.LDAPException;
78720a
-- 
78720a
1.8.3.1
78720a
78720a
78720a
From e1f0f4d62d2de51a7c655f56896be07aca0c4c8d Mon Sep 17 00:00:00 2001
78720a
From: Christina Fu <cfu@redhat.com>
78720a
Date: Tue, 24 Jan 2023 17:47:01 -0800
78720a
Subject: [PATCH 3/4] Bug2092522_StatusChange per config for revokeCert and
78720a
 revokeExpiredCert
78720a
78720a
This patch fixes "part 1" and "part 3" of Bug 2092522 where it is reported that
78720a
 1. if op.enroll.xxx.revokeCert=false, an error message is received at attempt to change token status. e.g.
78720a
"certificate revocation (serial 0x100024e) not enabled for tokenType: KeyGR, keyType: encryption, state: terminated"
78720a
 2. It also should addresses the request in comment#6 regarding expired cert.
78720a
  For that to work, one needs to enable:
78720a
"op.enroll." + tokenType + ".keyGen." + keyType + ".recovery." + tokenReason + ".revokeExpiredCerts"
78720a
78720a
fixes part 1&3 of https://bugzilla.redhat.com/show_bug.cgi?id=2092522
78720a
78720a
(cherry picked from commit 5560fe03f02a113583ba6b7f93e191d602b75876)
78720a
---
78720a
 base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java | 14 ++++++++++----
78720a
 1 file changed, 10 insertions(+), 4 deletions(-)
78720a
78720a
diff --git a/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java b/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java
78720a
index 147f346..c57a6f4 100644
78720a
--- a/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java
78720a
+++ b/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java
78720a
@@ -671,9 +671,14 @@ public class TPSTokendb {
78720a
             tdbActivity(ActivityDatabase.OP_CERT_REVOCATION, tokenRecord,
78720a
                     ipAddress, logMsg, "success", remoteUser);
78720a
 
78720a
-        } catch (Exception e) {
78720a
+        } catch (TPSException e) {
78720a
             logMsg = "certificate not revoked: " + cert.getSerialNumber() + ": " + e;
78720a
             CMS.debug(method + ": " + logMsg);
78720a
+            if (e.getStatus() == TPSStatus.STATUS_NO_ERROR) {
78720a
+                tdbActivity(ActivityDatabase.OP_TOKEN_MODIFY, tokenRecord,
78720a
+                        ipAddress, e.getMessage(), "success", remoteUser);
78720a
+                return;
78720a
+            }
78720a
 
78720a
             tdbActivity(ActivityDatabase.OP_CERT_REVOCATION, tokenRecord,
78720a
                     ipAddress, e.getMessage(), "failure", remoteUser);
78720a
@@ -787,7 +792,8 @@ public class TPSTokendb {
78720a
                     "certificate revocation (serial " + cert.getSerialNumber() +
78720a
                     ") not enabled for tokenType: " + tokenType +
78720a
                     ", keyType: " + keyType +
78720a
-                    ", state: " + tokenReason);
78720a
+                    ", state: " + tokenReason,
78720a
+                    TPSStatus.STATUS_NO_ERROR);
78720a
         }
78720a
 
78720a
         // check if expired certificates should be revoked.
78720a
@@ -801,11 +807,11 @@ public class TPSTokendb {
78720a
             Date now = new Date();
78720a
             if (now.after(notAfter)) {
78720a
                 throw new TPSException(
78720a
-                        "revocation not enabled for expired cert: " + cert.getSerialNumber());
78720a
+                        "revocation not enabled for expired cert: " + cert.getSerialNumber(), TPSStatus.STATUS_NO_ERROR);
78720a
             }
78720a
             if (now.before(notBefore)) {
78720a
                 throw new TPSException(
78720a
-                        "revocation not enabled for cert that is not yet valid: " + cert.getSerialNumber());
78720a
+                        "revocation not enabled for cert that is not yet valid: " + cert.getSerialNumber(), TPSStatus.STATUS_NO_ERROR);
78720a
             }
78720a
         }
78720a
 
78720a
-- 
78720a
1.8.3.1
78720a
78720a
78720a
From 2e8d3dfa75370d1e8d64da458ebd1dde6b370204 Mon Sep 17 00:00:00 2001
78720a
From: Christina Fu <cfu@redhat.com>
78720a
Date: Mon, 20 Mar 2023 16:13:42 -0700
78720a
Subject: [PATCH 4/4] 
78720a
 Bug2176233_part2_StatusChange_holdRevocationUntilLastCredential
78720a
78720a
This patch requires the previous commit that addresses part 1&3 of the
78720a
    bug.  This previous commit for bug 2092522 must be applied first.
78720a
78720a
    This patch addresses "part 2" of the original Bug 2092522
78720a
    ("part 2" has been cloned to bug 2176233).
78720a
    The issue reported regards holdRevocationUntilLastCredential
78720a
    when if set, and if there are shared tokens existing, an error
78720a
    Exception is thrown.
78720a
78720a
    fixes part 2 of https://bugzilla.redhat.com/show_bug.cgi?id=2176233
78720a
78720a
(cherry picked from commit f3e34a63b7d016920c1aa9792fdbc42d3b9a9b14)
78720a
---
78720a
 base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java | 5 +++--
78720a
 1 file changed, 3 insertions(+), 2 deletions(-)
78720a
78720a
diff --git a/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java b/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java
78720a
index c57a6f4..e27512a 100644
78720a
--- a/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java
78720a
+++ b/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java
78720a
@@ -824,8 +824,9 @@ public class TPSTokendb {
78720a
             if (!isLastActiveSharedCert(cert.getSerialNumber(), cert.getIssuedBy(), tokenRecord.getId())) {
78720a
                 msg = "revocation not permitted as certificate " + cert.getSerialNumber() +
78720a
                         " is shared by another active token";
78720a
-                CMS.debug(method + " holdRevocation true; " + msg);
78720a
-                throw new TPSException(msg);
78720a
+                CMS.debug(method + " holdRevocationUntilLastCredential true; " + msg);
78720a
+                throw new TPSException(msg,
78720a
+                    TPSStatus.STATUS_NO_ERROR);
78720a
             }
78720a
         }
78720a
         CMS.debug(method + "revocation allowed.");
78720a
-- 
78720a
1.8.3.1
78720a