Skip to content

Commit

Permalink
Move CAEngine.trackUpdate() to AuthorityMonitor
Browse files Browse the repository at this point in the history
  • Loading branch information
edewata committed Oct 3, 2023
1 parent f3683cf commit 4b48613
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
24 changes: 24 additions & 0 deletions base/ca/src/main/java/com/netscape/ca/AuthorityMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
*
Expand Down
27 changes: 2 additions & 25 deletions base/ca/src/main/java/org/dogtagpki/server/ca/CAEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 4b48613

Please sign in to comment.