From 4b48613e094898343f66862ad045c4798f6da8c4 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Mon, 2 Oct 2023 19:31:59 -0500 Subject: [PATCH] Move CAEngine.trackUpdate() to AuthorityMonitor --- .../com/netscape/ca/AuthorityMonitor.java | 24 +++++++++++++++++ .../org/dogtagpki/server/ca/CAEngine.java | 27 ++----------------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/base/ca/src/main/java/com/netscape/ca/AuthorityMonitor.java b/base/ca/src/main/java/com/netscape/ca/AuthorityMonitor.java index 89dfe799989..0c63e930cc7 100644 --- a/base/ca/src/main/java/com/netscape/ca/AuthorityMonitor.java +++ b/base/ca/src/main/java/com/netscape/ca/AuthorityMonitor.java @@ -30,10 +30,12 @@ import com.netscape.certsrv.ca.ECAException; import com.netscape.certsrv.ldap.ELdapException; import com.netscape.certsrv.util.AsyncLoader; +import com.netscape.cmsutil.ldap.LDAPPostReadControl; import com.netscape.cmsutil.ldap.LDAPUtil; import netscape.ldap.LDAPAttribute; import netscape.ldap.LDAPConnection; +import netscape.ldap.LDAPControl; import netscape.ldap.LDAPEntry; import netscape.ldap.LDAPException; import netscape.ldap.LDAPSearchConstraints; @@ -277,6 +279,28 @@ private synchronized void handleDELETE(LDAPEntry entry) { } } + public synchronized void trackUpdate(AuthorityID aid, LDAPControl[] responseControls) { + + LDAPPostReadControl control = (LDAPPostReadControl) + LDAPUtil.getControl(LDAPPostReadControl.class, responseControls); + + LDAPEntry entry = control.getEntry(); + + LDAPAttribute attr = entry.getAttribute("entryUSN"); + if (attr != null) { + BigInteger entryUSN = new BigInteger(attr.getStringValueArray()[0]); + logger.debug("AuthorityMonitor: tracking entryUSN: " + entryUSN); + entryUSNs.put(aid, entryUSN); + } + + attr = entry.getAttribute("nsUniqueId"); + if (attr != null) { + String nsUniqueId = attr.getStringValueArray()[0]; + logger.info("AuthorityMonitor: tracking nsUniqueId: " + nsUniqueId); + nsUniqueIds.put(aid, nsUniqueId); + } + } + /** * Stop the activityMonitor thread * diff --git a/base/ca/src/main/java/org/dogtagpki/server/ca/CAEngine.java b/base/ca/src/main/java/org/dogtagpki/server/ca/CAEngine.java index 60523a3deab..893219bb3c1 100644 --- a/base/ca/src/main/java/org/dogtagpki/server/ca/CAEngine.java +++ b/base/ca/src/main/java/org/dogtagpki/server/ca/CAEngine.java @@ -103,7 +103,6 @@ import com.netscape.cmscore.request.RequestQueue; import com.netscape.cmsutil.crypto.CryptoUtil; import com.netscape.cmsutil.ldap.LDAPPostReadControl; -import com.netscape.cmsutil.ldap.LDAPUtil; import netscape.ldap.LDAPAttribute; import netscape.ldap.LDAPAttributeSet; @@ -1254,28 +1253,6 @@ public LDAPConstraints getUpdateConstraints() { return cons; } - public synchronized void trackUpdate(AuthorityID aid, LDAPControl[] responseControls) { - - LDAPPostReadControl control = (LDAPPostReadControl) - LDAPUtil.getControl(LDAPPostReadControl.class, responseControls); - - LDAPEntry entry = control.getEntry(); - - LDAPAttribute attr = entry.getAttribute("entryUSN"); - if (attr != null) { - BigInteger entryUSN = new BigInteger(attr.getStringValueArray()[0]); - logger.debug("CAEngine: tracking entryUSN: " + entryUSN); - authorityMonitor.entryUSNs.put(aid, entryUSN); - } - - attr = entry.getAttribute("nsUniqueId"); - if (attr != null) { - String nsUniqueId = attr.getStringValueArray()[0]; - logger.info("CAEngine: tracking nsUniqueId: " + nsUniqueId); - authorityMonitor.nsUniqueIds.put(aid, nsUniqueId); - } - } - public synchronized void addAuthorityEntry(AuthorityID aid, LDAPEntry entry) throws EBaseException { LDAPConnection conn = connectionFactory.getConn(); @@ -1292,7 +1269,7 @@ public synchronized void addAuthorityEntry(AuthorityID aid, LDAPEntry entry) thr connectionFactory.returnConn(conn); } - trackUpdate(aid, responseControls); + authorityMonitor.trackUpdate(aid, responseControls); } public synchronized void modifyAuthorityEntry(AuthorityID aid, LDAPModificationSet mods) throws EBaseException { @@ -1312,7 +1289,7 @@ public synchronized void modifyAuthorityEntry(AuthorityID aid, LDAPModificationS connectionFactory.returnConn(conn); } - trackUpdate(aid, responseControls); + authorityMonitor.trackUpdate(aid, responseControls); } public synchronized void deleteAuthorityEntry(AuthorityID aid) throws EBaseException {