@Test public void testOCSPCertHash() { CertificateToken user = DSSUtils.loadCertificate(new File("src/test/resources/sk_user.cer")); CertificateToken caToken = DSSUtils.loadCertificate(new File("src/test/resources/sk_ca.cer")); assertTrue(user.isSignedBy(caToken)); ExternalResourcesOCSPSource ocspSource = new ExternalResourcesOCSPSource("/sk_ocsp.bin"); List<RevocationToken<OCSP>> ocspTokens = ocspSource.getRevocationTokens(user, caToken); assertEquals(1, ocspTokens.size()); OCSPToken ocspToken = (OCSPToken) ocspTokens.get(0); assertNotNull(ocspToken); assertNotNull(ocspToken.getRevocationDate()); assertTrue(ocspToken.isCertHashPresent()); assertTrue(ocspToken.isCertHashMatch()); }
@Override public List<RevocationToken<OCSP>> getRevocationTokens(CertificateToken certificate, CertificateToken issuer) { Objects.requireNonNull(certificate, "The certificate to be verified cannot be null"); Objects.requireNonNull(issuer, "The issuer of the certificate to be verified cannot be null"); List<RevocationToken<OCSP>> result = new ArrayList<>(); final Set<EncapsulatedRevocationTokenIdentifier> collectedBinaries = getAllRevocationBinaries(); LOG.trace("--> OfflineOCSPSource queried for {} contains: {} element(s).", certificate.getDSSIdAsString(), collectedBinaries.size()); for (EncapsulatedRevocationTokenIdentifier binary : collectedBinaries) { OCSPResponseBinary ocspBinary = (OCSPResponseBinary) binary; BasicOCSPResp basicOCSPResp = ocspBinary.getBasicOCSPResp(); SingleResp latestSingleResponse = DSSRevocationUtils.getLatestSingleResponse(basicOCSPResp, certificate, issuer); if (latestSingleResponse != null) { OCSPToken ocspToken = new OCSPToken(basicOCSPResp, latestSingleResponse, certificate, issuer); addRevocation(ocspToken, ocspBinary); result.add(ocspToken); } } LOG.trace("--> OfflineOCSPSource found result(s) : {}", result.size()); return result; }
OfflineOCSPSource extends OfflineRevocationSource<OCSP> { @Override public List<RevocationToken<OCSP>> getRevocationTokens(CertificateToken certificate, CertificateToken issuer) { Objects.requireNonNull(certificate, "The certificate to be verified cannot be null"); Objects.requireNonNull(issuer, "The issuer of the certificate to be verified cannot be null"); List<RevocationToken<OCSP>> result = new ArrayList<>(); final Set<EncapsulatedRevocationTokenIdentifier> collectedBinaries = getAllRevocationBinaries(); LOG.trace("--> OfflineOCSPSource queried for {} contains: {} element(s).", certificate.getDSSIdAsString(), collectedBinaries.size()); for (EncapsulatedRevocationTokenIdentifier binary : collectedBinaries) { OCSPResponseBinary ocspBinary = (OCSPResponseBinary) binary; BasicOCSPResp basicOCSPResp = ocspBinary.getBasicOCSPResp(); SingleResp latestSingleResponse = DSSRevocationUtils.getLatestSingleResponse(basicOCSPResp, certificate, issuer); if (latestSingleResponse != null) { OCSPToken ocspToken = new OCSPToken(basicOCSPResp, latestSingleResponse, certificate, issuer); addRevocation(ocspToken, ocspBinary); result.add(ocspToken); } } LOG.trace("--> OfflineOCSPSource found result(s) : {}", result.size()); return result; } }
OfflineOCSPSource extends OfflineRevocationSource<OCSP> { @Override public List<RevocationToken<OCSP>> getRevocationTokens(CertificateToken certificate, CertificateToken issuer) { Objects.requireNonNull(certificate, "The certificate to be verified cannot be null"); Objects.requireNonNull(issuer, "The issuer of the certificate to be verified cannot be null"); List<RevocationToken<OCSP>> result = new ArrayList<>(); final Set<EncapsulatedRevocationTokenIdentifier> collectedBinaries = getAllRevocationBinaries(); LOG.trace("--> OfflineOCSPSource queried for {} contains: {} element(s).", certificate.getDSSIdAsString(), collectedBinaries.size()); for (EncapsulatedRevocationTokenIdentifier binary : collectedBinaries) { OCSPResponseBinary ocspBinary = (OCSPResponseBinary) binary; BasicOCSPResp basicOCSPResp = ocspBinary.getBasicOCSPResp(); SingleResp latestSingleResponse = DSSRevocationUtils.getLatestSingleResponse(basicOCSPResp, certificate, issuer); if (latestSingleResponse != null) { OCSPToken ocspToken = new OCSPToken(basicOCSPResp, latestSingleResponse, certificate, issuer); addRevocation(ocspToken, ocspBinary); result.add(ocspToken); } } LOG.trace("--> OfflineOCSPSource found result(s) : {}", result.size()); return result; } protected  OfflineOCSPSource(); }
OfflineOCSPSource extends OfflineRevocationSource<OCSP> { @Override public List<RevocationToken<OCSP>> getRevocationTokens(CertificateToken certificate, CertificateToken issuer) { Objects.requireNonNull(certificate, "The certificate to be verified cannot be null"); Objects.requireNonNull(issuer, "The issuer of the certificate to be verified cannot be null"); List<RevocationToken<OCSP>> result = new ArrayList<>(); final Set<EncapsulatedRevocationTokenIdentifier> collectedBinaries = getAllRevocationBinaries(); LOG.trace("--> OfflineOCSPSource queried for {} contains: {} element(s).", certificate.getDSSIdAsString(), collectedBinaries.size()); for (EncapsulatedRevocationTokenIdentifier binary : collectedBinaries) { OCSPResponseBinary ocspBinary = (OCSPResponseBinary) binary; BasicOCSPResp basicOCSPResp = ocspBinary.getBasicOCSPResp(); SingleResp latestSingleResponse = DSSRevocationUtils.getLatestSingleResponse(basicOCSPResp, certificate, issuer); if (latestSingleResponse != null) { OCSPToken ocspToken = new OCSPToken(basicOCSPResp, latestSingleResponse, certificate, issuer); addRevocation(ocspToken, ocspBinary); result.add(ocspToken); } } LOG.trace("--> OfflineOCSPSource found result(s) : {}", result.size()); return result; } protected  OfflineOCSPSource(); @Override List<RevocationToken<OCSP>> getRevocationTokens(CertificateToken certificate, CertificateToken issuer); }
OfflineOCSPSource extends OfflineRevocationSource<OCSP> { @Override public List<RevocationToken<OCSP>> getRevocationTokens(CertificateToken certificate, CertificateToken issuer) { Objects.requireNonNull(certificate, "The certificate to be verified cannot be null"); Objects.requireNonNull(issuer, "The issuer of the certificate to be verified cannot be null"); List<RevocationToken<OCSP>> result = new ArrayList<>(); final Set<EncapsulatedRevocationTokenIdentifier> collectedBinaries = getAllRevocationBinaries(); LOG.trace("--> OfflineOCSPSource queried for {} contains: {} element(s).", certificate.getDSSIdAsString(), collectedBinaries.size()); for (EncapsulatedRevocationTokenIdentifier binary : collectedBinaries) { OCSPResponseBinary ocspBinary = (OCSPResponseBinary) binary; BasicOCSPResp basicOCSPResp = ocspBinary.getBasicOCSPResp(); SingleResp latestSingleResponse = DSSRevocationUtils.getLatestSingleResponse(basicOCSPResp, certificate, issuer); if (latestSingleResponse != null) { OCSPToken ocspToken = new OCSPToken(basicOCSPResp, latestSingleResponse, certificate, issuer); addRevocation(ocspToken, ocspBinary); result.add(ocspToken); } } LOG.trace("--> OfflineOCSPSource found result(s) : {}", result.size()); return result; } protected  OfflineOCSPSource(); @Override List<RevocationToken<OCSP>> getRevocationTokens(CertificateToken certificate, CertificateToken issuer);  }