Skip to content

Commit

Permalink
Replace PKISocketFactory.engine with auditor
Browse files Browse the repository at this point in the history
  • Loading branch information
edewata committed Apr 28, 2023
1 parent 5ef226d commit 34d0508
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public void publish(LDAPConnection conn, String dn, Object certObj)
String cert_nick = mConfig.getString("clientCertNickname", null);

PKISocketFactory sslSocket = new PKISocketFactory();
sslSocket.setCMSEngine(engine);
sslSocket.setAuditor(engine.getAuditor());
sslSocket.addSocketListener(engine.getClientSocketListener());
sslSocket.setSecure(true);
sslSocket.setClientCertNickname(cert_nick);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void publish(LDAPConnection conn, String dn, Object crlObj) throws ELdapE
String cert_nick = mConfig.getString("clientCertNickname", null);

PKISocketFactory sslSocket = new PKISocketFactory();
sslSocket.setCMSEngine(engine);
sslSocket.setAuditor(engine.getAuditor());
sslSocket.addSocketListener(engine.getClientSocketListener());
sslSocket.setSecure(true);
sslSocket.setClientCertNickname(cert_nick);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public void publish(LDAPConnection conn, String dn, Object certObj) throws ELdap
String cert_nick = mConfig.getString("clientCertNickname", null);

PKISocketFactory sslSocket = new PKISocketFactory();
sslSocket.setCMSEngine(engine);
sslSocket.setAuditor(engine.getAuditor());
sslSocket.addSocketListener(engine.getClientSocketListener());
sslSocket.setSecure(true);
sslSocket.setClientCertNickname(cert_nick);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ private void testSetLDAPDest(HttpServletRequest req, HttpServletResponse resp)
certNickName = authConfig.getClientCertNickname();

PKISocketFactory socketFactory = new PKISocketFactory();
socketFactory.setCMSEngine(engine);
socketFactory.setAuditor(engine.getAuditor());
socketFactory.addSocketListener(engine.getClientSocketListener());
socketFactory.setSecure(true);
socketFactory.setClientCertNickname(certNickName);
Expand Down Expand Up @@ -796,7 +796,7 @@ private void testSetLDAPDest(HttpServletRequest req, HttpServletResponse resp)
} else {
try {
PKISocketFactory socketFactory = new PKISocketFactory();
socketFactory.setCMSEngine(engine);
socketFactory.setAuditor(engine.getAuditor());
socketFactory.addSocketListener(engine.getClientSocketListener());
socketFactory.setSecure(secure);
socketFactory.init(socketConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ public int testLDAPConnection(String name, LdapConnInfo info, String binddn, Str
PKISocketConfig socketConfig = mConfig.getSocketConfig();

PKISocketFactory socketFactory = new PKISocketFactory();
socketFactory.setCMSEngine(this);
socketFactory.setAuditor(auditor);
socketFactory.addSocketListener(clientSocketListener);
socketFactory.setSecure(info.getSecure());
socketFactory.init(socketConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ protected void makeMinimum(boolean errorIfDown) throws ELdapException {

PKISocketFactory socketFactory = new PKISocketFactory();
if (engine != null) {
socketFactory.setCMSEngine(engine);
socketFactory.setAuditor(engine.getAuditor());
socketFactory.addSocketListener(engine.getClientSocketListener());
}
socketFactory.setSecure(mConnInfo.getSecure());
Expand Down Expand Up @@ -349,7 +349,7 @@ public synchronized LDAPConnection getConn(boolean waitForConn)
try {
PKISocketFactory socketFactory = new PKISocketFactory();
if (engine != null) {
socketFactory.setCMSEngine(engine);
socketFactory.setAuditor(engine.getAuditor());
socketFactory.addSocketListener(engine.getClientSocketListener());
}
socketFactory.setSecure(mConnInfo.getSecure());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ private LdapBoundConnection makeNewConnection(boolean errorIfDown) throws ELdapE
try {
PKISocketFactory socketFactory = new PKISocketFactory();
if (engine != null) {
socketFactory.setCMSEngine(engine);
socketFactory.setAuditor(engine.getAuditor());
socketFactory.addSocketListener(engine.getClientSocketListener());
}
socketFactory.setSecure(mConnInfo.getSecure());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

import com.netscape.certsrv.logging.SignedAuditEvent;
import com.netscape.certsrv.logging.event.ClientAccessSessionEstablishEvent;
import com.netscape.cmscore.apps.CMSEngine;
import com.netscape.cmscore.logging.Auditor;
import com.netscape.cmsutil.crypto.CryptoUtil;

Expand All @@ -50,7 +49,7 @@ public class PKISocketFactory implements LDAPSSLSocketFactoryExt {

public static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PKISocketFactory.class);

private CMSEngine engine;
private Auditor auditor;
private boolean secure;
private String clientCertNickname;
private boolean mClientAuth = false;
Expand Down Expand Up @@ -87,12 +86,12 @@ public PKISocketFactory(String clientCertNickname, boolean external) {
init();
}

public CMSEngine getCMSEngine() {
return engine;
public Auditor getAuditor() {
return auditor;
}

public void setCMSEngine(CMSEngine engine) {
this.engine = engine;
public void setAuditor(Auditor engine) {
this.auditor = engine;
}

public boolean getSecure() {
Expand Down Expand Up @@ -251,7 +250,7 @@ public Socket makeSocket(String host, int port) throws LDAPException {
s.setKeepAlive(keepAlive);

} catch (Exception e) {
if (engine != null) {
if (auditor != null) {
// for auditing
String localIP = "localhost";
try {
Expand All @@ -260,7 +259,6 @@ public Socket makeSocket(String host, int port) throws LDAPException {
// default to "localhost";
}

Auditor auditor = engine.getAuditor();
SignedAuditEvent auditEvent = ClientAccessSessionEstablishEvent.createFailureEvent(
localIP,
host,
Expand Down

0 comments on commit 34d0508

Please sign in to comment.