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iInaYNKJIT/e1wEYNm7hLHADBGXvmAYrXR5i3FVr/mZkIV/4L+HXmymvb82fqgxG0YjFnaKVn6w/Fa7yYd/vw2uaItgscf1YHewApDgglVrH1Tdjuk+bqv5WRi5j2Qsj1Yr6tSPwiRuhFA0m2kHwOI8w7QUmecFLTqG4flVSOmlGhHUCAwEAAaOBuzCBuDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zBCBgNVHSAEOzA5MDcGBWA4CQEBMC4wLAYIKwYBBQUHAgEWIGh0dHA6Ly9yZXBvc2l0b3J5LmVpZC5iZWxnaXVtLmJlMB0GA1UdDgQWBBSFiuv0xbu+DlkDlN7WgAEV4xCcOTARBglghkgBhvhCAQEEBAMCAAcwHwYDVR0jBBgwFoAUhYrr9MW7vg5ZA5Te1oABFeMQnDkwDQYJKoZIhvcNAQEFBQADggEBAFHYhd27V2/MoGy1oyCcUwnzSgEMdL8rs5qauhjyC4isHLMzr87lEwEnkoRYmhC598wUkmt0FoqW6FHvv/pKJaeJtmMrXZRY0c8RcrYeuTlBFk0pvDVTC9rejg7NqZV3JcqUWumyaa7YwBO+mPyWnIR/VRPmPIfjvCCkpDZoa01gZhz5v6yAlGYuuUGK02XThIAC71AdXkbc98m6tTR8KvPG2F9fVJ3bTc0R5/0UAoNmXsimABKgX77OFP67H6dh96tK8QYUn8pJQsKpvO2FsauBQeYNxUJpU4c5nUwfAA4+Bw11V0SoU7Q2dmSZ3G7rPUZuFF1eR1ONeE3gJ7uOhXY="; CertificateToken certToValidate = DSSUtils.loadCertificateFromBase64EncodedString(certToValidateB64); OfflineCRLSource crlSource = new MockCRLSource(); crlSource.addBinary(CRLUtils.buildCRLBinary(Utils.fromBase64(crlB64)), RevocationOrigin.EXTERNAL); assertEquals(0, crlSource.getRevocationTokens(certToValidate, certToValidate).size()); CertificateToken certWrongKeySize = DSSUtils.loadCertificateFromBase64EncodedString(certWrongKeySizeB64); assertEquals(0, crlSource.getRevocationTokens(certToValidate, certWrongKeySize).size()); CertificateToken caCert = DSSUtils.loadCertificateFromBase64EncodedString(caCertB64); assertEquals(1, crlSource.getRevocationTokens(certToValidate, caCert).size()); assertEquals(1, crlSource.getRevocationTokens(certToValidate, caCert).size()); }
@Override public List<RevocationToken<CRL>> getRevocationTokens(final CertificateToken certificateToken, final CertificateToken issuerToken) { Objects.requireNonNull(certificateToken, "The certificate to be verified cannot be null"); Objects.requireNonNull(issuerToken, "The issuer of the certificate to be verified cannot be null"); List<RevocationToken<CRL>> result = new ArrayList<>(); final Set<EncapsulatedRevocationTokenIdentifier> collectedBinaries = getAllRevocationBinaries(); LOG.trace("--> OfflineCRLSource queried for {} contains: {} element(s).", certificateToken.getDSSIdAsString(), collectedBinaries.size()); for (EncapsulatedRevocationTokenIdentifier binary : collectedBinaries) { CRLBinary crlBinary = (CRLBinary) binary; try { CRLValidity crlValidity = CRLUtils.buildCRLValidity(crlBinary, issuerToken); if (crlValidity.isValid() && isInCertificateValidityRange(crlValidity, certificateToken)) { final CRLToken crlToken = new CRLToken(certificateToken, crlValidity); addRevocation(crlToken, crlBinary); result.add(crlToken); } } catch (Exception e) { LOG.warn("Unable to retrieve the CRLValidity for CRL with ID '{}' : {}", crlBinary.asXmlId(), e.getMessage()); } } LOG.trace("--> OfflineCRLSource found result(s) : {}", result.size()); return result; }
OfflineCRLSource extends OfflineRevocationSource<CRL> { @Override public List<RevocationToken<CRL>> getRevocationTokens(final CertificateToken certificateToken, final CertificateToken issuerToken) { Objects.requireNonNull(certificateToken, "The certificate to be verified cannot be null"); Objects.requireNonNull(issuerToken, "The issuer of the certificate to be verified cannot be null"); List<RevocationToken<CRL>> result = new ArrayList<>(); final Set<EncapsulatedRevocationTokenIdentifier> collectedBinaries = getAllRevocationBinaries(); LOG.trace("--> OfflineCRLSource queried for {} contains: {} element(s).", certificateToken.getDSSIdAsString(), collectedBinaries.size()); for (EncapsulatedRevocationTokenIdentifier binary : collectedBinaries) { CRLBinary crlBinary = (CRLBinary) binary; try { CRLValidity crlValidity = CRLUtils.buildCRLValidity(crlBinary, issuerToken); if (crlValidity.isValid() && isInCertificateValidityRange(crlValidity, certificateToken)) { final CRLToken crlToken = new CRLToken(certificateToken, crlValidity); addRevocation(crlToken, crlBinary); result.add(crlToken); } } catch (Exception e) { LOG.warn("Unable to retrieve the CRLValidity for CRL with ID '{}' : {}", crlBinary.asXmlId(), e.getMessage()); } } LOG.trace("--> OfflineCRLSource found result(s) : {}", result.size()); return result; } }
OfflineCRLSource extends OfflineRevocationSource<CRL> { @Override public List<RevocationToken<CRL>> getRevocationTokens(final CertificateToken certificateToken, final CertificateToken issuerToken) { Objects.requireNonNull(certificateToken, "The certificate to be verified cannot be null"); Objects.requireNonNull(issuerToken, "The issuer of the certificate to be verified cannot be null"); List<RevocationToken<CRL>> result = new ArrayList<>(); final Set<EncapsulatedRevocationTokenIdentifier> collectedBinaries = getAllRevocationBinaries(); LOG.trace("--> OfflineCRLSource queried for {} contains: {} element(s).", certificateToken.getDSSIdAsString(), collectedBinaries.size()); for (EncapsulatedRevocationTokenIdentifier binary : collectedBinaries) { CRLBinary crlBinary = (CRLBinary) binary; try { CRLValidity crlValidity = CRLUtils.buildCRLValidity(crlBinary, issuerToken); if (crlValidity.isValid() && isInCertificateValidityRange(crlValidity, certificateToken)) { final CRLToken crlToken = new CRLToken(certificateToken, crlValidity); addRevocation(crlToken, crlBinary); result.add(crlToken); } } catch (Exception e) { LOG.warn("Unable to retrieve the CRLValidity for CRL with ID '{}' : {}", crlBinary.asXmlId(), e.getMessage()); } } LOG.trace("--> OfflineCRLSource found result(s) : {}", result.size()); return result; } protected  OfflineCRLSource(); }
OfflineCRLSource extends OfflineRevocationSource<CRL> { @Override public List<RevocationToken<CRL>> getRevocationTokens(final CertificateToken certificateToken, final CertificateToken issuerToken) { Objects.requireNonNull(certificateToken, "The certificate to be verified cannot be null"); Objects.requireNonNull(issuerToken, "The issuer of the certificate to be verified cannot be null"); List<RevocationToken<CRL>> result = new ArrayList<>(); final Set<EncapsulatedRevocationTokenIdentifier> collectedBinaries = getAllRevocationBinaries(); LOG.trace("--> OfflineCRLSource queried for {} contains: {} element(s).", certificateToken.getDSSIdAsString(), collectedBinaries.size()); for (EncapsulatedRevocationTokenIdentifier binary : collectedBinaries) { CRLBinary crlBinary = (CRLBinary) binary; try { CRLValidity crlValidity = CRLUtils.buildCRLValidity(crlBinary, issuerToken); if (crlValidity.isValid() && isInCertificateValidityRange(crlValidity, certificateToken)) { final CRLToken crlToken = new CRLToken(certificateToken, crlValidity); addRevocation(crlToken, crlBinary); result.add(crlToken); } } catch (Exception e) { LOG.warn("Unable to retrieve the CRLValidity for CRL with ID '{}' : {}", crlBinary.asXmlId(), e.getMessage()); } } LOG.trace("--> OfflineCRLSource found result(s) : {}", result.size()); return result; } protected  OfflineCRLSource(); @Override List<RevocationToken<CRL>> getRevocationTokens(final CertificateToken certificateToken, final CertificateToken issuerToken); }
OfflineCRLSource extends OfflineRevocationSource<CRL> { @Override public List<RevocationToken<CRL>> getRevocationTokens(final CertificateToken certificateToken, final CertificateToken issuerToken) { Objects.requireNonNull(certificateToken, "The certificate to be verified cannot be null"); Objects.requireNonNull(issuerToken, "The issuer of the certificate to be verified cannot be null"); List<RevocationToken<CRL>> result = new ArrayList<>(); final Set<EncapsulatedRevocationTokenIdentifier> collectedBinaries = getAllRevocationBinaries(); LOG.trace("--> OfflineCRLSource queried for {} contains: {} element(s).", certificateToken.getDSSIdAsString(), collectedBinaries.size()); for (EncapsulatedRevocationTokenIdentifier binary : collectedBinaries) { CRLBinary crlBinary = (CRLBinary) binary; try { CRLValidity crlValidity = CRLUtils.buildCRLValidity(crlBinary, issuerToken); if (crlValidity.isValid() && isInCertificateValidityRange(crlValidity, certificateToken)) { final CRLToken crlToken = new CRLToken(certificateToken, crlValidity); addRevocation(crlToken, crlBinary); result.add(crlToken); } } catch (Exception e) { LOG.warn("Unable to retrieve the CRLValidity for CRL with ID '{}' : {}", crlBinary.asXmlId(), e.getMessage()); } } LOG.trace("--> OfflineCRLSource found result(s) : {}", result.size()); return result; } protected  OfflineCRLSource(); @Override List<RevocationToken<CRL>> getRevocationTokens(final CertificateToken certificateToken, final CertificateToken issuerToken);  }