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wqMRtUNgxXfOoLXOBBqfSqnt05/OLIyEYrHZ0Wr8B6JDKq0N74W/H+fyXRy936F5vce6oWwHPsCSCJBTpt3a1je9QxeS/mRTkA+HqlGZA6wA0MkZzuSSSoDreIDaCKrYOA2OU3cbrSslGpi0e11ek8xWJU0vg7uWCjuXwbk8cc50n7wflM8zg=="; ExternalResourcesOCSPSource ocspSource = new ExternalResourcesOCSPSource(new ByteArrayInputStream(Utils.fromBase64(ocspResponse))); CertificateToken userUniversign = DSSUtils.loadCertificateFromBase64EncodedString( "MIIEjjCCA3agAwIBAgIQfCokxd5pp8RnZZOUHNbq0zANBgkqhkiG9w0BAQsFADBuMQswCQYDVQQGEwJGUjEgMB4GA1UEChMXQ3J5cHRvbG9nIEludGVybmF0aW9uYWwxHDAaBgNVBAsTEzAwMDIgNDM5MTI5MTY0MDAwMjYxHzAdBgNVBAMTFlVuaXZlcnNpZ24gQ0EgaGFyZHdhcmUwHhcNMTIwNzA2MTkzNzI0WhcNMTcwNzA2MTkzNzI0WjBrMQswCQYDVQQGEwJGUjERMA8GA1UEBxMITkFOVEVSUkUxFzAVBgNVBAoTDkFYQSBGUkFOQ0UgVklFMRcwFQYDVQQLEw4wMDAyIDMxMDQ5OTk1OTEXMBUGA1UEAxMOQVhBIEZSQU5DRSBWSUUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDPbheD3Lk34Rv+SBwS3duDqzKNEHoNen48pzVbt6wFQf9bqpE9YPZh+jb+bnRUXLbv77vaWBfCZGOfrybDv/mqpmTkdYk6F+D7ddwQuF7OVmE+VqeOgoBc+Vo1LDzjowDPOmyH938DB1ZUzI8r2mw60rR9laqLI7kO6OT/9fodJMz1eE2G6LEzXvOj+V0PhDg3FX+vF+pLFUmI53x3L+zM8AZofUCY0oaUpY1hgWR4on5K1Oy0me63UHkslEjFS5jYff4EE+z/eZY7+e3FMqwzFm5al60w1djzsHUVod+CkIASs71VgAYSYOQyckwmKaFs6325JHAu5DH5a62WVq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+sdJkP/OrIHKfHydMk3ayeAxnnieOj8EU+Z5w3fpekOGOtb4VUTESWU/xQfDZcNaauNRU2DYFi1eDypfVnyD8tORDoFVaAqzdIJuMJ06jJB5fnmNBXU7GOQFLcdK7hy3ZDmPNh5FNGnaQRrlY2st7lXfV3mu9AgHmjPjxrbAwgo1GzLRY0byI9bfitN0sLT+d"); List<RevocationToken<OCSP>> ocspTokens = ocspSource.getRevocationTokens(userUniversign, caUniversign); assertEquals(1, ocspTokens.size()); OCSPToken ocspToken = (OCSPToken) ocspTokens.get(0); assertNotNull(ocspToken); assertNotNull(ocspToken.getArchiveCutOff()); assertNotNull(ocspToken.getThisUpdate()); assertNotNull(ocspToken.getNextUpdate()); assertNotNull(ocspToken.getProductionDate()); assertNotNull(ocspToken.getBasicOCSPResp()); assertNull(ocspToken.getExpiredCertsOnCRL()); assertEquals(CertificateStatus.GOOD, ocspToken.getStatus()); assertFalse(ocspToken.isCertHashPresent()); assertFalse(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);  }