use of org.bouncycastle.cert.ocsp.OCSPReq in project ddf by codice.
the class OcspChecker method logRequest.
private void logRequest(OCSPReq ocspRequest) {
StringBuilder logBuilder = new StringBuilder();
logBuilder.append("OCSP Request:\n");
logBuilder.append(" TBSRequest:\n");
logBuilder.append(" version: " + getValueOrDefault(ocspRequest.getVersionNumber(), "") + "\n");
logBuilder.append(" requestorName: " + getValueOrDefault(ocspRequest.getRequestorName(), "").toString() + "\n");
logBuilder.append(" requestList:\n");
Req[] requests = ocspRequest.getRequestList();
if (requests != null) {
for (int i = 0; i < requests.length; i++) {
logBuilder.append(" Certificate " + i + "\n");
CertificateID cert = requests[i].getCertID();
if (cert != null) {
logBuilder.append(" hashAlgorithm: " + getValueOrDefault(cert.getHashAlgOID(), "").toString() + "\n");
logBuilder.append(" issuerNameHash: " + getValueOrDefault(Arrays.toString(cert.getIssuerNameHash()), "") + "\n");
logBuilder.append(" issuerKeyHash: " + getValueOrDefault(Arrays.toString(cert.getIssuerKeyHash()), "") + "\n");
logBuilder.append(" cert serial number: " + getValueOrDefault(cert.getSerialNumber(), "").toString() + "\n");
}
}
}
LOGGER.trace(logBuilder.toString());
}
use of org.bouncycastle.cert.ocsp.OCSPReq in project ddf by codice.
the class OcspCheckerTest method testSendOcspRequestBrokenServerUrls.
@Test
public void testSendOcspRequestBrokenServerUrls() throws Exception {
brokenEndpoints.add(new URI("https://brokenurl:8993"));
brokenEndpoints.add(new URI("https://brokenurl2:8993"));
brokenEndpoints.add(new URI("https://brokenurl3:8993"));
List<URI> ocspServerUrls = new ArrayList<>(brokenEndpoints);
brokenEndpoints.add(new URI(EMBEDDED_OCSP_SERVER_URL));
OcspChecker ocspChecker = new OcspChecker(factory, eventAdmin);
ocspChecker.setSecurityLogger(mock(SecurityLogger.class));
ocspChecker.setOcspEnabled(true);
ocspChecker.setOcspServerUrls(ocspServerUrls.stream().map(URI::toString).collect(Collectors.toList()));
OCSPReq ocspReq = ocspChecker.generateOcspRequest(trustedCertBc);
Map<URI, CertificateStatus> ocspStatuses = ocspChecker.sendOcspRequests(trustedCertX509, ocspReq);
assertStatuses(ocspStatuses);
}
use of org.bouncycastle.cert.ocsp.OCSPReq in project ddf by codice.
the class OcspCheckerTest method testSendOcspRequestsRevokedEmbeddedUrl.
@Test
public void testSendOcspRequestsRevokedEmbeddedUrl() throws Exception {
unknownEndpoints.add(new URI("https://unknownurl:8993"));
unknownEndpoints.add(new URI("https://unknownurl2:8993"));
revokedEndpoints.add(new URI(EMBEDDED_OCSP_SERVER_URL));
List<URI> ocspServerUrls = new ArrayList<>(unknownEndpoints);
OcspChecker ocspChecker = new OcspChecker(factory, eventAdmin);
ocspChecker.setSecurityLogger(mock(SecurityLogger.class));
ocspChecker.setOcspEnabled(true);
ocspChecker.setOcspServerUrls(ocspServerUrls.stream().map(URI::toString).collect(Collectors.toList()));
OCSPReq ocspReq = ocspChecker.generateOcspRequest(trustedCertBc);
Map<URI, CertificateStatus> ocspStatuses = ocspChecker.sendOcspRequests(trustedCertX509, ocspReq);
assertStatuses(ocspStatuses);
}
use of org.bouncycastle.cert.ocsp.OCSPReq in project ddf by codice.
the class OcspCheckerTest method testSendOcspRequestsUnknownStatus.
@Test
public void testSendOcspRequestsUnknownStatus() throws Exception {
unknownEndpoints.add(new URI("https://unknownurl:8993"));
brokenEndpoints.add(new URI(EMBEDDED_OCSP_SERVER_URL));
List<URI> ocspServerUrls = new ArrayList<>(unknownEndpoints);
OcspChecker ocspChecker = new OcspChecker(factory, eventAdmin);
ocspChecker.setSecurityLogger(mock(SecurityLogger.class));
ocspChecker.setOcspEnabled(true);
ocspChecker.setOcspServerUrls(ocspServerUrls.stream().map(URI::toString).collect(Collectors.toList()));
OCSPReq ocspReq = ocspChecker.generateOcspRequest(trustedCertBc);
Map<URI, CertificateStatus> ocspStatuses = ocspChecker.sendOcspRequests(trustedCertX509, ocspReq);
assertStatuses(ocspStatuses);
}
use of org.bouncycastle.cert.ocsp.OCSPReq in project ddf by codice.
the class OcspCheckerTest method testSendOcspRequestsGoodStatus.
@Test
public void testSendOcspRequestsGoodStatus() throws Exception {
goodEndpoints.add(new URI("https://goodurl:8993"));
brokenEndpoints.add(new URI(EMBEDDED_OCSP_SERVER_URL));
List<URI> ocspServerUrls = new ArrayList<>(goodEndpoints);
OcspChecker ocspChecker = new OcspChecker(factory, eventAdmin);
ocspChecker.setSecurityLogger(mock(SecurityLogger.class));
ocspChecker.setOcspEnabled(true);
ocspChecker.setOcspServerUrls(ocspServerUrls.stream().map(URI::toString).collect(Collectors.toList()));
OCSPReq ocspReq = ocspChecker.generateOcspRequest(trustedCertBc);
Map<URI, CertificateStatus> ocspStatuses = ocspChecker.sendOcspRequests(trustedCertX509, ocspReq);
assertStatuses(ocspStatuses);
}
Aggregations