Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Felix Dittrich <31076102+f11h@users.noreply.github.com>
  • Loading branch information
tence and f11h committed Oct 6, 2023
1 parent 4b2052f commit add4ac2
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public void exec(ImportJobContext context, String... args) throws ImportJobStepE
certificateUtils.getCertThumbprint(x509CertificateHolder),
null,
countryCode,
certificateType, null));//TODO: domain null?
certificateType,
null));

} catch (Exception e) {
throw new ImportJobStepException(true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ public void exec(ImportJobContext context, String... args) throws ImportJobStepE
String domain = null;
try {
domain = matcher.group("DOMAIN");
} catch (IllegalArgumentException e) {
//ignore
} catch (IllegalArgumentException ignored) {
}


Expand Down Expand Up @@ -101,7 +100,7 @@ private ImportJobContext.CertificateEntry parsePem(byte[] file, ImportJobContext
null,
countryCode,
certificateType,
domain);
domain);
} else {
throw new ImportJobStepException(true, "Failed to parse Certificate as X509Certificate");
}
Expand Down Expand Up @@ -137,7 +136,7 @@ private ImportJobContext.CertificateEntry parseJson(byte[] file, ImportJobContex
json.trustAnchorSignature,
countryCode,
certificateType,
domain);
domain);

} catch (DatabindException e) {
throw new ImportJobStepException(true, "Failed to parse JSON: " + e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ private void addCertificate(ImportJobContext context, X509Certificate certificat
certificateUtils.getCertThumbprint(certificate),
null,
TEST_COUNTRY_CODE,
certificateType, null));
certificateType,
null));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ private void addCertificate(ImportJobContext context, X509Certificate certificat
certificateUtils.getCertThumbprint(certificate),
null,
TEST_COUNTRY_CODE,
certificateType, null));
certificateType,
null));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private void addCertificate(ImportJobContext context, X509Certificate certificat
certificateUtils.getCertThumbprint(certificate),
null,
countryCode,
certificateType, null));
certificateType,
null));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void testSaveTrustedPartyWithNonDefaultDomain(String type) throws Exception {
CertificateTestUtils.generateCertificate(keyPair, TEST_COUNTRY_CODE, "Testcert 1");

ImportJobContext context = new ImportJobContext();
addCertificateForDomain(context, certificate1, ImportJobContext.CertificateType.valueOf(type), TEST_DUMMY_SIGNATURE,
addCertificateToContext(context, certificate1, ImportJobContext.CertificateType.valueOf(type), TEST_DUMMY_SIGNATURE,
TEST_COUNTRY_CODE, TEST_RACSEL_DDVC_DOMAIN);

ArgumentCaptor<TrustedPartyEntity> trustedPartyEntityArgumentCaptor =
Expand Down Expand Up @@ -364,7 +364,7 @@ private void addCertificate(ImportJobContext context, X509Certificate certificat
certificateType, null));
}

private void addCertificateForDomain(ImportJobContext context, X509Certificate certificate,
private void addCertificateToContext(ImportJobContext context, X509Certificate certificate,
ImportJobContext.CertificateType certificateType, String signature, String countryCode, String domain)
throws CertificateEncodingException, IOException {
context.getParsedCertificates().add(new ImportJobContext.CertificateEntry(
Expand All @@ -375,6 +375,7 @@ private void addCertificateForDomain(ImportJobContext context, X509Certificate c
certificateUtils.getCertThumbprint(certificate),
signature,
countryCode,
certificateType, domain));
certificateType,
domain));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ private void addCertificate(ImportJobContext context, X509Certificate certificat
certificateUtils.getCertThumbprint(certificate),
signature,
countryCode,
certificateType, null));
certificateType,
null));
}
}

0 comments on commit add4ac2

Please sign in to comment.