Skip to content

Commit

Permalink
Add CAEngine.createCA()
Browse files Browse the repository at this point in the history
The code that creates the CertificateAuthority object in
CAEngine.readAuthority() has been moved into createCA().
  • Loading branch information
edewata committed Oct 5, 2023
1 parent cfac403 commit 2d10490
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions base/ca/src/main/java/org/dogtagpki/server/ca/CAEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,29 @@ public CertificateAuthority createCA(
return ca;
}

public CertificateAuthority createCA(AuthorityRecord record) throws Exception {

CertId certID = record.getSerialNumber();
BigInteger serialNumber = certID == null ? null : certID.toBigInteger();

CertificateAuthority ca = new CertificateAuthority(
record.getAuthorityDN(),
record.getAuthorityID(),
record.getParentID(),
serialNumber,
record.getKeyNickname(),
record.getKeyHosts(),
record.getDescription(),
record.getEnabled());

CAEngineConfig engineConfig = getConfig();
CAConfig caConfig = engineConfig.getCAConfig();
ca.setCMSEngine(this);
ca.init(caConfig);

return ca;
}

public void startKeyRetriever(CertificateAuthority ca) throws EBaseException {

AuthorityID authorityID = ca.getAuthorityID();
Expand Down Expand Up @@ -1461,25 +1484,8 @@ record = getAuthorityRecord(entry);
}
}

String keyNick = record.getKeyNickname();
Collection<String> keyHosts = record.getKeyHosts();

AuthorityID parentAID = record.getParentID();

CertId certID = record.getSerialNumber();
BigInteger serial = certID == null ? null : certID.toBigInteger();

boolean enabled = record.getEnabled();

try {
CertificateAuthority ca = new CertificateAuthority(
dn, aid, parentAID, serial,
keyNick, keyHosts, desc, enabled);

CAEngineConfig engineConfig = getConfig();
CAConfig caConfig = engineConfig.getCAConfig();
ca.setCMSEngine(this);
ca.init(caConfig);
CertificateAuthority ca = createCA(record);

authorityMonitor.addCA(aid, ca);
authorityMonitor.entryUSNs.put(aid, newEntryUSN);
Expand Down

0 comments on commit 2d10490

Please sign in to comment.