diff --git a/authtoken-validation/pom.xml b/authtoken-validation/pom.xml
new file mode 100644
index 00000000..238e505b
--- /dev/null
+++ b/authtoken-validation/pom.xml
@@ -0,0 +1,58 @@
+
+
+ 4.0.0
+
+
+ eu.webeid.security
+ web-eid-authtoken-validation
+ 4.0.0-SNAPSHOT
+
+
+ authtoken-validation
+ jar
+ authtoken-validation
+ Web eID authentication token validation library for Java
+
+
+
+ io.jsonwebtoken
+ jjwt-impl
+ ${jjwt.version}
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ ${jackson.version}
+
+
+ org.bouncycastle
+ bcprov-jdk18on
+ ${bouncycastle.version}
+
+
+ org.bouncycastle
+ bcpkix-jdk18on
+ ${bouncycastle.version}
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.5.0
+
+
+
+ test-jar
+
+
+
+
+
+
+
diff --git a/authtoken-validation/src/main/java/eu/webeid/ocsp/service/FallbackOcspService.java b/authtoken-validation/src/main/java/eu/webeid/ocsp/service/FallbackOcspService.java
new file mode 100644
index 00000000..378dfeb3
--- /dev/null
+++ b/authtoken-validation/src/main/java/eu/webeid/ocsp/service/FallbackOcspService.java
@@ -0,0 +1,11 @@
+package eu.webeid.ocsp.service;
+
+import java.time.Duration;
+
+public interface FallbackOcspService extends OcspService {
+ Duration getMaxThisUpdateAge();
+
+ Duration getMaxNextUpdateAge();
+
+ FallbackOcspService getNextFallback();
+}
diff --git a/src/main/java/eu/webeid/ocsp/service/OcspService.java b/authtoken-validation/src/main/java/eu/webeid/ocsp/service/OcspService.java
similarity index 100%
rename from src/main/java/eu/webeid/ocsp/service/OcspService.java
rename to authtoken-validation/src/main/java/eu/webeid/ocsp/service/OcspService.java
diff --git a/authtoken-validation/src/main/java/eu/webeid/ocsp/service/OcspServiceProvider.java b/authtoken-validation/src/main/java/eu/webeid/ocsp/service/OcspServiceProvider.java
new file mode 100644
index 00000000..17eea5dd
--- /dev/null
+++ b/authtoken-validation/src/main/java/eu/webeid/ocsp/service/OcspServiceProvider.java
@@ -0,0 +1,12 @@
+// SPDX-FileCopyrightText: Estonian Information System Authority
+// SPDX-License-Identifier: MIT
+
+package eu.webeid.ocsp.service;
+
+import eu.webeid.security.exceptions.AuthTokenException;
+
+import java.security.cert.X509Certificate;
+
+public interface OcspServiceProvider {
+ OcspService getService(X509Certificate certificate, X509Certificate issuerCertificate) throws AuthTokenException;
+}
diff --git a/src/main/java/eu/webeid/security/authtoken/WebEidAuthToken.java b/authtoken-validation/src/main/java/eu/webeid/security/authtoken/WebEidAuthToken.java
similarity index 100%
rename from src/main/java/eu/webeid/security/authtoken/WebEidAuthToken.java
rename to authtoken-validation/src/main/java/eu/webeid/security/authtoken/WebEidAuthToken.java
diff --git a/src/main/java/eu/webeid/security/certificate/CertificateData.java b/authtoken-validation/src/main/java/eu/webeid/security/certificate/CertificateData.java
similarity index 100%
rename from src/main/java/eu/webeid/security/certificate/CertificateData.java
rename to authtoken-validation/src/main/java/eu/webeid/security/certificate/CertificateData.java
diff --git a/src/main/java/eu/webeid/security/certificate/CertificateLoader.java b/authtoken-validation/src/main/java/eu/webeid/security/certificate/CertificateLoader.java
similarity index 100%
rename from src/main/java/eu/webeid/security/certificate/CertificateLoader.java
rename to authtoken-validation/src/main/java/eu/webeid/security/certificate/CertificateLoader.java
diff --git a/src/main/java/eu/webeid/security/certificate/CertificateValidator.java b/authtoken-validation/src/main/java/eu/webeid/security/certificate/CertificateValidator.java
similarity index 100%
rename from src/main/java/eu/webeid/security/certificate/CertificateValidator.java
rename to authtoken-validation/src/main/java/eu/webeid/security/certificate/CertificateValidator.java
diff --git a/src/main/java/eu/webeid/security/certificate/OcspNonceExtension.java b/authtoken-validation/src/main/java/eu/webeid/security/certificate/OcspNonceExtension.java
similarity index 100%
rename from src/main/java/eu/webeid/security/certificate/OcspNonceExtension.java
rename to authtoken-validation/src/main/java/eu/webeid/security/certificate/OcspNonceExtension.java
diff --git a/src/main/java/eu/webeid/security/certificate/SubjectCertificatePolicies.java b/authtoken-validation/src/main/java/eu/webeid/security/certificate/SubjectCertificatePolicies.java
similarity index 100%
rename from src/main/java/eu/webeid/security/certificate/SubjectCertificatePolicies.java
rename to authtoken-validation/src/main/java/eu/webeid/security/certificate/SubjectCertificatePolicies.java
diff --git a/src/main/java/eu/webeid/security/challenge/ChallengeNonce.java b/authtoken-validation/src/main/java/eu/webeid/security/challenge/ChallengeNonce.java
similarity index 100%
rename from src/main/java/eu/webeid/security/challenge/ChallengeNonce.java
rename to authtoken-validation/src/main/java/eu/webeid/security/challenge/ChallengeNonce.java
diff --git a/src/main/java/eu/webeid/security/challenge/ChallengeNonceGenerator.java b/authtoken-validation/src/main/java/eu/webeid/security/challenge/ChallengeNonceGenerator.java
similarity index 100%
rename from src/main/java/eu/webeid/security/challenge/ChallengeNonceGenerator.java
rename to authtoken-validation/src/main/java/eu/webeid/security/challenge/ChallengeNonceGenerator.java
diff --git a/src/main/java/eu/webeid/security/challenge/ChallengeNonceGeneratorBuilder.java b/authtoken-validation/src/main/java/eu/webeid/security/challenge/ChallengeNonceGeneratorBuilder.java
similarity index 100%
rename from src/main/java/eu/webeid/security/challenge/ChallengeNonceGeneratorBuilder.java
rename to authtoken-validation/src/main/java/eu/webeid/security/challenge/ChallengeNonceGeneratorBuilder.java
diff --git a/src/main/java/eu/webeid/security/challenge/ChallengeNonceGeneratorImpl.java b/authtoken-validation/src/main/java/eu/webeid/security/challenge/ChallengeNonceGeneratorImpl.java
similarity index 100%
rename from src/main/java/eu/webeid/security/challenge/ChallengeNonceGeneratorImpl.java
rename to authtoken-validation/src/main/java/eu/webeid/security/challenge/ChallengeNonceGeneratorImpl.java
diff --git a/src/main/java/eu/webeid/security/challenge/ChallengeNonceStore.java b/authtoken-validation/src/main/java/eu/webeid/security/challenge/ChallengeNonceStore.java
similarity index 100%
rename from src/main/java/eu/webeid/security/challenge/ChallengeNonceStore.java
rename to authtoken-validation/src/main/java/eu/webeid/security/challenge/ChallengeNonceStore.java
diff --git a/src/main/java/eu/webeid/security/exceptions/AuthTokenException.java b/authtoken-validation/src/main/java/eu/webeid/security/exceptions/AuthTokenException.java
similarity index 100%
rename from src/main/java/eu/webeid/security/exceptions/AuthTokenException.java
rename to authtoken-validation/src/main/java/eu/webeid/security/exceptions/AuthTokenException.java
diff --git a/src/main/java/eu/webeid/security/exceptions/AuthTokenParseException.java b/authtoken-validation/src/main/java/eu/webeid/security/exceptions/AuthTokenParseException.java
similarity index 100%
rename from src/main/java/eu/webeid/security/exceptions/AuthTokenParseException.java
rename to authtoken-validation/src/main/java/eu/webeid/security/exceptions/AuthTokenParseException.java
diff --git a/src/main/java/eu/webeid/security/exceptions/AuthTokenSignatureValidationException.java b/authtoken-validation/src/main/java/eu/webeid/security/exceptions/AuthTokenSignatureValidationException.java
similarity index 100%
rename from src/main/java/eu/webeid/security/exceptions/AuthTokenSignatureValidationException.java
rename to authtoken-validation/src/main/java/eu/webeid/security/exceptions/AuthTokenSignatureValidationException.java
diff --git a/src/main/java/eu/webeid/security/exceptions/CertificateDecodingException.java b/authtoken-validation/src/main/java/eu/webeid/security/exceptions/CertificateDecodingException.java
similarity index 100%
rename from src/main/java/eu/webeid/security/exceptions/CertificateDecodingException.java
rename to authtoken-validation/src/main/java/eu/webeid/security/exceptions/CertificateDecodingException.java
diff --git a/src/main/java/eu/webeid/security/exceptions/CertificateExpiredException.java b/authtoken-validation/src/main/java/eu/webeid/security/exceptions/CertificateExpiredException.java
similarity index 100%
rename from src/main/java/eu/webeid/security/exceptions/CertificateExpiredException.java
rename to authtoken-validation/src/main/java/eu/webeid/security/exceptions/CertificateExpiredException.java
diff --git a/src/main/java/eu/webeid/security/exceptions/CertificateNotTrustedException.java b/authtoken-validation/src/main/java/eu/webeid/security/exceptions/CertificateNotTrustedException.java
similarity index 100%
rename from src/main/java/eu/webeid/security/exceptions/CertificateNotTrustedException.java
rename to authtoken-validation/src/main/java/eu/webeid/security/exceptions/CertificateNotTrustedException.java
diff --git a/src/main/java/eu/webeid/security/exceptions/CertificateNotYetValidException.java b/authtoken-validation/src/main/java/eu/webeid/security/exceptions/CertificateNotYetValidException.java
similarity index 100%
rename from src/main/java/eu/webeid/security/exceptions/CertificateNotYetValidException.java
rename to authtoken-validation/src/main/java/eu/webeid/security/exceptions/CertificateNotYetValidException.java
diff --git a/src/main/java/eu/webeid/security/exceptions/CertificateRevocationCheckFailedException.java b/authtoken-validation/src/main/java/eu/webeid/security/exceptions/CertificateRevocationCheckFailedException.java
similarity index 100%
rename from src/main/java/eu/webeid/security/exceptions/CertificateRevocationCheckFailedException.java
rename to authtoken-validation/src/main/java/eu/webeid/security/exceptions/CertificateRevocationCheckFailedException.java
diff --git a/src/main/java/eu/webeid/security/exceptions/CertificateRevokedException.java b/authtoken-validation/src/main/java/eu/webeid/security/exceptions/CertificateRevokedException.java
similarity index 100%
rename from src/main/java/eu/webeid/security/exceptions/CertificateRevokedException.java
rename to authtoken-validation/src/main/java/eu/webeid/security/exceptions/CertificateRevokedException.java
diff --git a/src/main/java/eu/webeid/security/exceptions/ChallengeNonceExpiredException.java b/authtoken-validation/src/main/java/eu/webeid/security/exceptions/ChallengeNonceExpiredException.java
similarity index 100%
rename from src/main/java/eu/webeid/security/exceptions/ChallengeNonceExpiredException.java
rename to authtoken-validation/src/main/java/eu/webeid/security/exceptions/ChallengeNonceExpiredException.java
diff --git a/src/main/java/eu/webeid/security/exceptions/ChallengeNonceNotFoundException.java b/authtoken-validation/src/main/java/eu/webeid/security/exceptions/ChallengeNonceNotFoundException.java
similarity index 100%
rename from src/main/java/eu/webeid/security/exceptions/ChallengeNonceNotFoundException.java
rename to authtoken-validation/src/main/java/eu/webeid/security/exceptions/ChallengeNonceNotFoundException.java
diff --git a/src/main/java/eu/webeid/security/exceptions/ChallengeNullOrEmptyException.java b/authtoken-validation/src/main/java/eu/webeid/security/exceptions/ChallengeNullOrEmptyException.java
similarity index 100%
rename from src/main/java/eu/webeid/security/exceptions/ChallengeNullOrEmptyException.java
rename to authtoken-validation/src/main/java/eu/webeid/security/exceptions/ChallengeNullOrEmptyException.java
diff --git a/src/main/java/eu/webeid/security/exceptions/JceException.java b/authtoken-validation/src/main/java/eu/webeid/security/exceptions/JceException.java
similarity index 100%
rename from src/main/java/eu/webeid/security/exceptions/JceException.java
rename to authtoken-validation/src/main/java/eu/webeid/security/exceptions/JceException.java
diff --git a/src/main/java/eu/webeid/security/exceptions/UserCertificateDisallowedPolicyException.java b/authtoken-validation/src/main/java/eu/webeid/security/exceptions/UserCertificateDisallowedPolicyException.java
similarity index 100%
rename from src/main/java/eu/webeid/security/exceptions/UserCertificateDisallowedPolicyException.java
rename to authtoken-validation/src/main/java/eu/webeid/security/exceptions/UserCertificateDisallowedPolicyException.java
diff --git a/src/main/java/eu/webeid/security/exceptions/UserCertificateMissingPurposeException.java b/authtoken-validation/src/main/java/eu/webeid/security/exceptions/UserCertificateMissingPurposeException.java
similarity index 100%
rename from src/main/java/eu/webeid/security/exceptions/UserCertificateMissingPurposeException.java
rename to authtoken-validation/src/main/java/eu/webeid/security/exceptions/UserCertificateMissingPurposeException.java
diff --git a/src/main/java/eu/webeid/security/exceptions/UserCertificateParseException.java b/authtoken-validation/src/main/java/eu/webeid/security/exceptions/UserCertificateParseException.java
similarity index 100%
rename from src/main/java/eu/webeid/security/exceptions/UserCertificateParseException.java
rename to authtoken-validation/src/main/java/eu/webeid/security/exceptions/UserCertificateParseException.java
diff --git a/src/main/java/eu/webeid/security/exceptions/UserCertificateWrongPurposeException.java b/authtoken-validation/src/main/java/eu/webeid/security/exceptions/UserCertificateWrongPurposeException.java
similarity index 100%
rename from src/main/java/eu/webeid/security/exceptions/UserCertificateWrongPurposeException.java
rename to authtoken-validation/src/main/java/eu/webeid/security/exceptions/UserCertificateWrongPurposeException.java
diff --git a/src/main/java/eu/webeid/security/util/Base64Decoder.java b/authtoken-validation/src/main/java/eu/webeid/security/util/Base64Decoder.java
similarity index 100%
rename from src/main/java/eu/webeid/security/util/Base64Decoder.java
rename to authtoken-validation/src/main/java/eu/webeid/security/util/Base64Decoder.java
diff --git a/src/main/java/eu/webeid/security/util/DateAndTime.java b/authtoken-validation/src/main/java/eu/webeid/security/util/DateAndTime.java
similarity index 100%
rename from src/main/java/eu/webeid/security/util/DateAndTime.java
rename to authtoken-validation/src/main/java/eu/webeid/security/util/DateAndTime.java
diff --git a/src/main/java/eu/webeid/security/util/Strings.java b/authtoken-validation/src/main/java/eu/webeid/security/util/Strings.java
similarity index 100%
rename from src/main/java/eu/webeid/security/util/Strings.java
rename to authtoken-validation/src/main/java/eu/webeid/security/util/Strings.java
diff --git a/src/main/java/eu/webeid/security/validator/AuthTokenSignatureValidator.java b/authtoken-validation/src/main/java/eu/webeid/security/validator/AuthTokenSignatureValidator.java
similarity index 100%
rename from src/main/java/eu/webeid/security/validator/AuthTokenSignatureValidator.java
rename to authtoken-validation/src/main/java/eu/webeid/security/validator/AuthTokenSignatureValidator.java
diff --git a/src/main/java/eu/webeid/security/validator/AuthTokenValidationConfiguration.java b/authtoken-validation/src/main/java/eu/webeid/security/validator/AuthTokenValidationConfiguration.java
similarity index 100%
rename from src/main/java/eu/webeid/security/validator/AuthTokenValidationConfiguration.java
rename to authtoken-validation/src/main/java/eu/webeid/security/validator/AuthTokenValidationConfiguration.java
diff --git a/src/main/java/eu/webeid/security/validator/AuthTokenValidator.java b/authtoken-validation/src/main/java/eu/webeid/security/validator/AuthTokenValidator.java
similarity index 100%
rename from src/main/java/eu/webeid/security/validator/AuthTokenValidator.java
rename to authtoken-validation/src/main/java/eu/webeid/security/validator/AuthTokenValidator.java
diff --git a/src/main/java/eu/webeid/security/validator/AuthTokenValidatorBuilder.java b/authtoken-validation/src/main/java/eu/webeid/security/validator/AuthTokenValidatorBuilder.java
similarity index 100%
rename from src/main/java/eu/webeid/security/validator/AuthTokenValidatorBuilder.java
rename to authtoken-validation/src/main/java/eu/webeid/security/validator/AuthTokenValidatorBuilder.java
diff --git a/src/main/java/eu/webeid/security/validator/AuthTokenValidatorImpl.java b/authtoken-validation/src/main/java/eu/webeid/security/validator/AuthTokenValidatorImpl.java
similarity index 100%
rename from src/main/java/eu/webeid/security/validator/AuthTokenValidatorImpl.java
rename to authtoken-validation/src/main/java/eu/webeid/security/validator/AuthTokenValidatorImpl.java
diff --git a/src/main/java/eu/webeid/security/validator/ValidationInfo.java b/authtoken-validation/src/main/java/eu/webeid/security/validator/ValidationInfo.java
similarity index 100%
rename from src/main/java/eu/webeid/security/validator/ValidationInfo.java
rename to authtoken-validation/src/main/java/eu/webeid/security/validator/ValidationInfo.java
diff --git a/src/main/java/eu/webeid/security/validator/certvalidators/SubjectCertificatePolicyValidator.java b/authtoken-validation/src/main/java/eu/webeid/security/validator/certvalidators/SubjectCertificatePolicyValidator.java
similarity index 100%
rename from src/main/java/eu/webeid/security/validator/certvalidators/SubjectCertificatePolicyValidator.java
rename to authtoken-validation/src/main/java/eu/webeid/security/validator/certvalidators/SubjectCertificatePolicyValidator.java
diff --git a/src/main/java/eu/webeid/security/validator/certvalidators/SubjectCertificatePurposeValidator.java b/authtoken-validation/src/main/java/eu/webeid/security/validator/certvalidators/SubjectCertificatePurposeValidator.java
similarity index 100%
rename from src/main/java/eu/webeid/security/validator/certvalidators/SubjectCertificatePurposeValidator.java
rename to authtoken-validation/src/main/java/eu/webeid/security/validator/certvalidators/SubjectCertificatePurposeValidator.java
diff --git a/src/main/java/eu/webeid/security/validator/revocationcheck/CertificateRevocationChecker.java b/authtoken-validation/src/main/java/eu/webeid/security/validator/revocationcheck/CertificateRevocationChecker.java
similarity index 100%
rename from src/main/java/eu/webeid/security/validator/revocationcheck/CertificateRevocationChecker.java
rename to authtoken-validation/src/main/java/eu/webeid/security/validator/revocationcheck/CertificateRevocationChecker.java
diff --git a/src/main/java/eu/webeid/security/validator/revocationcheck/RevocationInfo.java b/authtoken-validation/src/main/java/eu/webeid/security/validator/revocationcheck/RevocationInfo.java
similarity index 100%
rename from src/main/java/eu/webeid/security/validator/revocationcheck/RevocationInfo.java
rename to authtoken-validation/src/main/java/eu/webeid/security/validator/revocationcheck/RevocationInfo.java
diff --git a/src/main/java/eu/webeid/security/validator/revocationcheck/RevocationMode.java b/authtoken-validation/src/main/java/eu/webeid/security/validator/revocationcheck/RevocationMode.java
similarity index 100%
rename from src/main/java/eu/webeid/security/validator/revocationcheck/RevocationMode.java
rename to authtoken-validation/src/main/java/eu/webeid/security/validator/revocationcheck/RevocationMode.java
diff --git a/src/test/java/eu/webeid/security/certificate/CertificateDataTest.java b/authtoken-validation/src/test/java/eu/webeid/security/certificate/CertificateDataTest.java
similarity index 100%
rename from src/test/java/eu/webeid/security/certificate/CertificateDataTest.java
rename to authtoken-validation/src/test/java/eu/webeid/security/certificate/CertificateDataTest.java
diff --git a/src/test/java/eu/webeid/security/certificate/CertificateValidatorTest.java b/authtoken-validation/src/test/java/eu/webeid/security/certificate/CertificateValidatorTest.java
similarity index 100%
rename from src/test/java/eu/webeid/security/certificate/CertificateValidatorTest.java
rename to authtoken-validation/src/test/java/eu/webeid/security/certificate/CertificateValidatorTest.java
diff --git a/src/test/java/eu/webeid/security/certificate/OcspNonceExtensionTest.java b/authtoken-validation/src/test/java/eu/webeid/security/certificate/OcspNonceExtensionTest.java
similarity index 100%
rename from src/test/java/eu/webeid/security/certificate/OcspNonceExtensionTest.java
rename to authtoken-validation/src/test/java/eu/webeid/security/certificate/OcspNonceExtensionTest.java
diff --git a/src/test/java/eu/webeid/security/certificate/PlatformOcspNetworkTest.java b/authtoken-validation/src/test/java/eu/webeid/security/certificate/PlatformOcspNetworkTest.java
similarity index 100%
rename from src/test/java/eu/webeid/security/certificate/PlatformOcspNetworkTest.java
rename to authtoken-validation/src/test/java/eu/webeid/security/certificate/PlatformOcspNetworkTest.java
diff --git a/src/test/java/eu/webeid/security/challenge/ChallengeNonceGeneratorTest.java b/authtoken-validation/src/test/java/eu/webeid/security/challenge/ChallengeNonceGeneratorTest.java
similarity index 100%
rename from src/test/java/eu/webeid/security/challenge/ChallengeNonceGeneratorTest.java
rename to authtoken-validation/src/test/java/eu/webeid/security/challenge/ChallengeNonceGeneratorTest.java
diff --git a/src/test/java/eu/webeid/security/challenge/InMemoryChallengeNonceStore.java b/authtoken-validation/src/test/java/eu/webeid/security/challenge/InMemoryChallengeNonceStore.java
similarity index 100%
rename from src/test/java/eu/webeid/security/challenge/InMemoryChallengeNonceStore.java
rename to authtoken-validation/src/test/java/eu/webeid/security/challenge/InMemoryChallengeNonceStore.java
diff --git a/src/test/java/eu/webeid/security/testutil/AbstractTestWithValidator.java b/authtoken-validation/src/test/java/eu/webeid/security/testutil/AbstractTestWithValidator.java
similarity index 100%
rename from src/test/java/eu/webeid/security/testutil/AbstractTestWithValidator.java
rename to authtoken-validation/src/test/java/eu/webeid/security/testutil/AbstractTestWithValidator.java
diff --git a/src/test/java/eu/webeid/security/testutil/AuthTokenValidators.java b/authtoken-validation/src/test/java/eu/webeid/security/testutil/AuthTokenValidators.java
similarity index 100%
rename from src/test/java/eu/webeid/security/testutil/AuthTokenValidators.java
rename to authtoken-validation/src/test/java/eu/webeid/security/testutil/AuthTokenValidators.java
diff --git a/src/test/java/eu/webeid/security/testutil/Certificates.java b/authtoken-validation/src/test/java/eu/webeid/security/testutil/Certificates.java
similarity index 100%
rename from src/test/java/eu/webeid/security/testutil/Certificates.java
rename to authtoken-validation/src/test/java/eu/webeid/security/testutil/Certificates.java
diff --git a/src/test/java/eu/webeid/security/testutil/DateMocker.java b/authtoken-validation/src/test/java/eu/webeid/security/testutil/DateMocker.java
similarity index 100%
rename from src/test/java/eu/webeid/security/testutil/DateMocker.java
rename to authtoken-validation/src/test/java/eu/webeid/security/testutil/DateMocker.java
diff --git a/src/test/java/eu/webeid/security/testutil/LocalOcspResponder.java b/authtoken-validation/src/test/java/eu/webeid/security/testutil/LocalOcspResponder.java
similarity index 100%
rename from src/test/java/eu/webeid/security/testutil/LocalOcspResponder.java
rename to authtoken-validation/src/test/java/eu/webeid/security/testutil/LocalOcspResponder.java
diff --git a/src/test/java/eu/webeid/security/testutil/OcspResponses.java b/authtoken-validation/src/test/java/eu/webeid/security/testutil/OcspResponses.java
similarity index 100%
rename from src/test/java/eu/webeid/security/testutil/OcspResponses.java
rename to authtoken-validation/src/test/java/eu/webeid/security/testutil/OcspResponses.java
diff --git a/src/test/java/eu/webeid/security/testutil/ResourceUtil.java b/authtoken-validation/src/test/java/eu/webeid/security/testutil/ResourceUtil.java
similarity index 100%
rename from src/test/java/eu/webeid/security/testutil/ResourceUtil.java
rename to authtoken-validation/src/test/java/eu/webeid/security/testutil/ResourceUtil.java
diff --git a/src/test/java/eu/webeid/security/testutil/TestCertificateBuilder.java b/authtoken-validation/src/test/java/eu/webeid/security/testutil/TestCertificateBuilder.java
similarity index 100%
rename from src/test/java/eu/webeid/security/testutil/TestCertificateBuilder.java
rename to authtoken-validation/src/test/java/eu/webeid/security/testutil/TestCertificateBuilder.java
diff --git a/src/test/java/eu/webeid/security/validator/AuthTokenAlgorithmTest.java b/authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenAlgorithmTest.java
similarity index 100%
rename from src/test/java/eu/webeid/security/validator/AuthTokenAlgorithmTest.java
rename to authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenAlgorithmTest.java
diff --git a/src/test/java/eu/webeid/security/validator/AuthTokenCertificateBelgianIdCardTest.java b/authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenCertificateBelgianIdCardTest.java
similarity index 100%
rename from src/test/java/eu/webeid/security/validator/AuthTokenCertificateBelgianIdCardTest.java
rename to authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenCertificateBelgianIdCardTest.java
diff --git a/src/test/java/eu/webeid/security/validator/AuthTokenCertificateFinnishIdCardTest.java b/authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenCertificateFinnishIdCardTest.java
similarity index 100%
rename from src/test/java/eu/webeid/security/validator/AuthTokenCertificateFinnishIdCardTest.java
rename to authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenCertificateFinnishIdCardTest.java
diff --git a/src/test/java/eu/webeid/security/validator/AuthTokenCertificateTest.java b/authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenCertificateTest.java
similarity index 100%
rename from src/test/java/eu/webeid/security/validator/AuthTokenCertificateTest.java
rename to authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenCertificateTest.java
diff --git a/src/test/java/eu/webeid/security/validator/AuthTokenSignatureTest.java b/authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenSignatureTest.java
similarity index 100%
rename from src/test/java/eu/webeid/security/validator/AuthTokenSignatureTest.java
rename to authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenSignatureTest.java
diff --git a/src/test/java/eu/webeid/security/validator/AuthTokenSignatureValidatorTest.java b/authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenSignatureValidatorTest.java
similarity index 100%
rename from src/test/java/eu/webeid/security/validator/AuthTokenSignatureValidatorTest.java
rename to authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenSignatureValidatorTest.java
diff --git a/src/test/java/eu/webeid/security/validator/AuthTokenStructureTest.java b/authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenStructureTest.java
similarity index 100%
rename from src/test/java/eu/webeid/security/validator/AuthTokenStructureTest.java
rename to authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenStructureTest.java
diff --git a/src/test/java/eu/webeid/security/validator/AuthTokenValidationConfigurationTest.java b/authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenValidationConfigurationTest.java
similarity index 100%
rename from src/test/java/eu/webeid/security/validator/AuthTokenValidationConfigurationTest.java
rename to authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenValidationConfigurationTest.java
diff --git a/src/test/java/eu/webeid/security/validator/AuthTokenValidationInfoTest.java b/authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenValidationInfoTest.java
similarity index 100%
rename from src/test/java/eu/webeid/security/validator/AuthTokenValidationInfoTest.java
rename to authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenValidationInfoTest.java
diff --git a/src/test/java/eu/webeid/security/validator/AuthTokenValidatorBuilderTest.java b/authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenValidatorBuilderTest.java
similarity index 100%
rename from src/test/java/eu/webeid/security/validator/AuthTokenValidatorBuilderTest.java
rename to authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenValidatorBuilderTest.java
diff --git a/src/test/java/eu/webeid/security/validator/AuthTokenValidatorValidationOrderTest.java b/authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenValidatorValidationOrderTest.java
similarity index 92%
rename from src/test/java/eu/webeid/security/validator/AuthTokenValidatorValidationOrderTest.java
rename to authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenValidatorValidationOrderTest.java
index 155cb17e..19d7e8a3 100644
--- a/src/test/java/eu/webeid/security/validator/AuthTokenValidatorValidationOrderTest.java
+++ b/authtoken-validation/src/test/java/eu/webeid/security/validator/AuthTokenValidatorValidationOrderTest.java
@@ -3,9 +3,9 @@
package eu.webeid.security.validator;
-import eu.webeid.ocsp.exceptions.UserCertificateRevokedException;
import eu.webeid.security.authtoken.WebEidAuthToken;
import eu.webeid.security.certificate.CertificateData;
+import eu.webeid.security.exceptions.CertificateRevokedException;
import eu.webeid.security.testutil.AuthTokenValidators;
import eu.webeid.security.util.DateAndTime;
import eu.webeid.security.validator.revocationcheck.CertificateRevocationChecker;
@@ -50,7 +50,9 @@ void tearDown() {
@Test
void whenRevocationCheckFails_thenSignatureIsNotValidated() throws Exception {
CertificateRevocationChecker checker = mock(CertificateRevocationChecker.class);
- when(checker.validateCertificateNotRevoked(any(), any())).thenThrow(new UserCertificateRevokedException());
+ CertificateRevokedException exception = new CertificateRevokedException(mock(X509Certificate.class), null);
+ when(checker.validateCertificateNotRevoked(any(), any()))
+ .thenThrow(exception);
AuthTokenValidator validator = AuthTokenValidators.getDefaultAuthTokenValidatorBuilder()
.withCertificateRevocationChecker(checker)
.build();
@@ -59,7 +61,7 @@ void whenRevocationCheckFails_thenSignatureIsNotValidated() throws Exception {
// An invalid challenge nonce would fail signature validation, so getting the revocation
// failure instead shows that revocation is checked first.
assertThatThrownBy(() -> validator.validate(token, "invalidToken"))
- .isInstanceOf(UserCertificateRevokedException.class);
+ .isInstanceOf(CertificateRevokedException.class);
}
@Test
diff --git a/src/test/java/eu/webeid/security/validator/certvalidators/SubjectCertificatePolicyValidatorTest.java b/authtoken-validation/src/test/java/eu/webeid/security/validator/certvalidators/SubjectCertificatePolicyValidatorTest.java
similarity index 100%
rename from src/test/java/eu/webeid/security/validator/certvalidators/SubjectCertificatePolicyValidatorTest.java
rename to authtoken-validation/src/test/java/eu/webeid/security/validator/certvalidators/SubjectCertificatePolicyValidatorTest.java
diff --git a/src/test/resources/DEMO_of_ESTEID-SK_2018_AIA_OCSP_RESPONDER_2018.cer b/authtoken-validation/src/test/resources/DEMO_of_ESTEID-SK_2018_AIA_OCSP_RESPONDER_2018.cer
similarity index 100%
rename from src/test/resources/DEMO_of_ESTEID-SK_2018_AIA_OCSP_RESPONDER_2018.cer
rename to authtoken-validation/src/test/resources/DEMO_of_ESTEID-SK_2018_AIA_OCSP_RESPONDER_2018.cer
diff --git a/src/test/resources/DVV TEST Certificates - G5E.crt b/authtoken-validation/src/test/resources/DVV TEST Certificates - G5E.crt
similarity index 100%
rename from src/test/resources/DVV TEST Certificates - G5E.crt
rename to authtoken-validation/src/test/resources/DVV TEST Certificates - G5E.crt
diff --git a/src/test/resources/ESTEID2018.cer b/authtoken-validation/src/test/resources/ESTEID2018.cer
similarity index 100%
rename from src/test/resources/ESTEID2018.cer
rename to authtoken-validation/src/test/resources/ESTEID2018.cer
diff --git a/src/test/resources/TEST_of_EE_Certification_Centre_Root_CA.cer b/authtoken-validation/src/test/resources/TEST_of_EE_Certification_Centre_Root_CA.cer
similarity index 100%
rename from src/test/resources/TEST_of_EE_Certification_Centre_Root_CA.cer
rename to authtoken-validation/src/test/resources/TEST_of_EE_Certification_Centre_Root_CA.cer
diff --git a/src/test/resources/TEST_of_ESTEID-SK_2015.cer b/authtoken-validation/src/test/resources/TEST_of_ESTEID-SK_2015.cer
similarity index 100%
rename from src/test/resources/TEST_of_ESTEID-SK_2015.cer
rename to authtoken-validation/src/test/resources/TEST_of_ESTEID-SK_2015.cer
diff --git a/src/test/resources/TEST_of_ESTEID2018.cer b/authtoken-validation/src/test/resources/TEST_of_ESTEID2018.cer
similarity index 100%
rename from src/test/resources/TEST_of_ESTEID2018.cer
rename to authtoken-validation/src/test/resources/TEST_of_ESTEID2018.cer
diff --git a/src/test/resources/TEST_of_SK_OCSP_RESPONDER_2020.cer b/authtoken-validation/src/test/resources/TEST_of_SK_OCSP_RESPONDER_2020.cer
similarity index 100%
rename from src/test/resources/TEST_of_SK_OCSP_RESPONDER_2020.cer
rename to authtoken-validation/src/test/resources/TEST_of_SK_OCSP_RESPONDER_2020.cer
diff --git a/src/test/resources/TEST_of_self-signed_OCSP_RESPONDER.cer b/authtoken-validation/src/test/resources/TEST_of_self-signed_OCSP_RESPONDER.cer
similarity index 100%
rename from src/test/resources/TEST_of_self-signed_OCSP_RESPONDER.cer
rename to authtoken-validation/src/test/resources/TEST_of_self-signed_OCSP_RESPONDER.cer
diff --git a/src/test/resources/VRK TEST CA for Test Purposes - G4.crt b/authtoken-validation/src/test/resources/VRK TEST CA for Test Purposes - G4.crt
similarity index 100%
rename from src/test/resources/VRK TEST CA for Test Purposes - G4.crt
rename to authtoken-validation/src/test/resources/VRK TEST CA for Test Purposes - G4.crt
diff --git a/src/test/resources/eID TEST EC Citizen CA.cer b/authtoken-validation/src/test/resources/eID TEST EC Citizen CA.cer
similarity index 100%
rename from src/test/resources/eID TEST EC Citizen CA.cer
rename to authtoken-validation/src/test/resources/eID TEST EC Citizen CA.cer
diff --git a/src/test/resources/ocsp_response.der b/authtoken-validation/src/test/resources/ocsp_response.der
similarity index 100%
rename from src/test/resources/ocsp_response.der
rename to authtoken-validation/src/test/resources/ocsp_response.der
diff --git a/src/test/resources/ocsp_response_revoked.der b/authtoken-validation/src/test/resources/ocsp_response_revoked.der
similarity index 100%
rename from src/test/resources/ocsp_response_revoked.der
rename to authtoken-validation/src/test/resources/ocsp_response_revoked.der
diff --git a/src/test/resources/ocsp_response_unauthorized.der b/authtoken-validation/src/test/resources/ocsp_response_unauthorized.der
similarity index 100%
rename from src/test/resources/ocsp_response_unauthorized.der
rename to authtoken-validation/src/test/resources/ocsp_response_unauthorized.der
diff --git a/src/test/resources/ocsp_response_unknown.der b/authtoken-validation/src/test/resources/ocsp_response_unknown.der
similarity index 100%
rename from src/test/resources/ocsp_response_unknown.der
rename to authtoken-validation/src/test/resources/ocsp_response_unknown.der
diff --git a/src/test/resources/ocsp_response_unknown_self_signed.der b/authtoken-validation/src/test/resources/ocsp_response_unknown_self_signed.der
similarity index 100%
rename from src/test/resources/ocsp_response_unknown_self_signed.der
rename to authtoken-validation/src/test/resources/ocsp_response_unknown_self_signed.der
diff --git a/src/test/resources/ocsp_response_with_2_responder_certs.der b/authtoken-validation/src/test/resources/ocsp_response_with_2_responder_certs.der
similarity index 100%
rename from src/test/resources/ocsp_response_with_2_responder_certs.der
rename to authtoken-validation/src/test/resources/ocsp_response_with_2_responder_certs.der
diff --git a/src/test/resources/ocsp_response_with_2_responses.der b/authtoken-validation/src/test/resources/ocsp_response_with_2_responses.der
similarity index 100%
rename from src/test/resources/ocsp_response_with_2_responses.der
rename to authtoken-validation/src/test/resources/ocsp_response_with_2_responses.der
diff --git a/pom.xml b/pom.xml
index 790dd9ee..4adbff08 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,13 +5,19 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- authtoken-validation
+ web-eid-authtoken-validation
eu.webeid.security
4.0.0-SNAPSHOT
- jar
- authtoken-validation
+ pom
+ web-eid-authtoken-validation
Web eID authentication token validation library for Java
+
+ authtoken-validation
+ web-eid-ocsp
+ web-eid-resilient-ocsp
+
+
17
0.13.0
@@ -44,60 +50,11 @@
-
- io.jsonwebtoken
- jjwt-impl
- ${jjwt.version}
-
-
- com.fasterxml.jackson.core
- jackson-databind
- ${jackson.version}
-
org.slf4j
slf4j-api
${slf4j.version}
-
- org.bouncycastle
- bcprov-jdk18on
- ${bouncycastle.version}
-
-
- org.bouncycastle
- bcpkix-jdk18on
- ${bouncycastle.version}
-
-
- io.github.resilience4j
- resilience4j-all
- ${resilience4j.version}
-
-
- io.github.resilience4j
- resilience4j-bulkhead
-
-
- io.github.resilience4j
- resilience4j-cache
-
-
- io.github.resilience4j
- resilience4j-ratelimiter
-
-
- io.github.resilience4j
- resilience4j-timelimiter
-
-
-
-
- io.github.resilience4j
- resilience4j-vavr
- ${resilience4j.version}
-
-
org.junit.jupiter
junit-jupiter
diff --git a/web-eid-ocsp/pom.xml b/web-eid-ocsp/pom.xml
new file mode 100644
index 00000000..f3f1d112
--- /dev/null
+++ b/web-eid-ocsp/pom.xml
@@ -0,0 +1,48 @@
+
+
+ 4.0.0
+
+ eu.webeid.security
+ web-eid-authtoken-validation
+ 4.0.0-SNAPSHOT
+
+
+ web-eid-ocsp
+
+
+
+ eu.webeid.security
+ authtoken-validation
+ ${project.parent.version}
+
+
+
+ eu.webeid.security
+ authtoken-validation
+ ${project.parent.version}
+ tests
+ test
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.5.0
+
+
+
+ test-jar
+
+
+
+
+
+
+
+
diff --git a/src/main/java/eu/webeid/ocsp/OcspCertificateRevocationChecker.java b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/OcspCertificateRevocationChecker.java
similarity index 100%
rename from src/main/java/eu/webeid/ocsp/OcspCertificateRevocationChecker.java
rename to web-eid-ocsp/src/main/java/eu/webeid/ocsp/OcspCertificateRevocationChecker.java
diff --git a/src/main/java/eu/webeid/ocsp/README.md b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/README.md
similarity index 98%
rename from src/main/java/eu/webeid/ocsp/README.md
rename to web-eid-ocsp/src/main/java/eu/webeid/ocsp/README.md
index 75c64af9..f1d8d837 100644
--- a/src/main/java/eu/webeid/ocsp/README.md
+++ b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/README.md
@@ -72,6 +72,7 @@ import eu.webeid.ocsp.OcspCertificateRevocationChecker;
import eu.webeid.ocsp.client.OcspClientImpl;
import eu.webeid.ocsp.service.AiaOcspServiceConfiguration;
import eu.webeid.ocsp.service.OcspServiceProvider;
+import eu.webeid.ocsp.service.OcspServiceProviderImpl;
import eu.webeid.security.certificate.CertificateValidator;
import eu.webeid.security.validator.AuthTokenValidator;
import eu.webeid.security.validator.AuthTokenValidatorBuilder;
@@ -86,7 +87,7 @@ AiaOcspServiceConfiguration aiaConfiguration = new AiaOcspServiceConfiguration(
OcspCertificateRevocationChecker.DEFAULT_NEXT_UPDATE_AGE,
true // Require the Key Usage extension in responder certificates.
);
-OcspServiceProvider services = new OcspServiceProvider(null, aiaConfiguration);
+OcspServiceProvider services = new OcspServiceProviderImpl(null, aiaConfiguration);
OcspCertificateRevocationChecker checker = new OcspCertificateRevocationChecker(
OcspClientImpl.build(Duration.ofSeconds(5)),
services,
@@ -128,7 +129,7 @@ DesignatedOcspServiceConfiguration designated = new DesignatedOcspServiceConfigu
OcspCertificateRevocationChecker.DEFAULT_NEXT_UPDATE_AGE,
true // Require the Key Usage extension in responder certificates.
);
-OcspServiceProvider services = new OcspServiceProvider(designated, aiaConfiguration);
+OcspServiceProvider services = new OcspServiceProviderImpl(designated, aiaConfiguration);
```
The provider selects the designated service only when the validated direct issuer certificate equals one of its configured `supportedIssuers`. Supply the same encoded issuer certificates that validation may select as direct issuers; a reissued CA certificate with the same name and key does not match. On a mismatch, the provider uses the certificate's AIA OCSP URL. The designated responder certificate is pinned locally and need not be issued by the CAs it serves.
@@ -162,7 +163,7 @@ FallbackOcspServiceConfiguration fallback = new FallbackOcspServiceConfiguration
OcspCertificateRevocationChecker.DEFAULT_NEXT_UPDATE_AGE,
true // Require the Key Usage extension in responder certificates.
);
-OcspServiceProvider services = new OcspServiceProvider(null, aiaConfiguration, List.of(fallback));
+OcspServiceProvider services = new OcspServiceProviderImpl(null, aiaConfiguration, List.of(fallback));
ResilientOcspCertificateRevocationChecker checker = new ResilientOcspCertificateRevocationChecker(
OcspClientImpl.build(Duration.ofSeconds(5)),
services,
diff --git a/src/main/java/eu/webeid/ocsp/client/OcspClient.java b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/client/OcspClient.java
similarity index 100%
rename from src/main/java/eu/webeid/ocsp/client/OcspClient.java
rename to web-eid-ocsp/src/main/java/eu/webeid/ocsp/client/OcspClient.java
diff --git a/src/main/java/eu/webeid/ocsp/client/OcspClientImpl.java b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/client/OcspClientImpl.java
similarity index 100%
rename from src/main/java/eu/webeid/ocsp/client/OcspClientImpl.java
rename to web-eid-ocsp/src/main/java/eu/webeid/ocsp/client/OcspClientImpl.java
diff --git a/src/main/java/eu/webeid/ocsp/exceptions/OCSPCertificateException.java b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/exceptions/OCSPCertificateException.java
similarity index 100%
rename from src/main/java/eu/webeid/ocsp/exceptions/OCSPCertificateException.java
rename to web-eid-ocsp/src/main/java/eu/webeid/ocsp/exceptions/OCSPCertificateException.java
diff --git a/src/main/java/eu/webeid/ocsp/exceptions/OCSPClientException.java b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/exceptions/OCSPClientException.java
similarity index 100%
rename from src/main/java/eu/webeid/ocsp/exceptions/OCSPClientException.java
rename to web-eid-ocsp/src/main/java/eu/webeid/ocsp/exceptions/OCSPClientException.java
diff --git a/src/main/java/eu/webeid/ocsp/exceptions/OcspResponderUriMessageAppender.java b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/exceptions/OcspResponderUriMessageAppender.java
similarity index 100%
rename from src/main/java/eu/webeid/ocsp/exceptions/OcspResponderUriMessageAppender.java
rename to web-eid-ocsp/src/main/java/eu/webeid/ocsp/exceptions/OcspResponderUriMessageAppender.java
diff --git a/src/main/java/eu/webeid/ocsp/exceptions/UserCertificateOCSPCheckFailedException.java b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/exceptions/UserCertificateOCSPCheckFailedException.java
similarity index 100%
rename from src/main/java/eu/webeid/ocsp/exceptions/UserCertificateOCSPCheckFailedException.java
rename to web-eid-ocsp/src/main/java/eu/webeid/ocsp/exceptions/UserCertificateOCSPCheckFailedException.java
diff --git a/src/main/java/eu/webeid/ocsp/exceptions/UserCertificateOCSPException.java b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/exceptions/UserCertificateOCSPException.java
similarity index 100%
rename from src/main/java/eu/webeid/ocsp/exceptions/UserCertificateOCSPException.java
rename to web-eid-ocsp/src/main/java/eu/webeid/ocsp/exceptions/UserCertificateOCSPException.java
diff --git a/src/main/java/eu/webeid/ocsp/exceptions/UserCertificateRevokedException.java b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/exceptions/UserCertificateRevokedException.java
similarity index 100%
rename from src/main/java/eu/webeid/ocsp/exceptions/UserCertificateRevokedException.java
rename to web-eid-ocsp/src/main/java/eu/webeid/ocsp/exceptions/UserCertificateRevokedException.java
diff --git a/src/main/java/eu/webeid/ocsp/exceptions/UserCertificateUnknownStatusException.java b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/exceptions/UserCertificateUnknownStatusException.java
similarity index 100%
rename from src/main/java/eu/webeid/ocsp/exceptions/UserCertificateUnknownStatusException.java
rename to web-eid-ocsp/src/main/java/eu/webeid/ocsp/exceptions/UserCertificateUnknownStatusException.java
diff --git a/src/main/java/eu/webeid/ocsp/protocol/DigestCalculatorImpl.java b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/protocol/DigestCalculatorImpl.java
similarity index 100%
rename from src/main/java/eu/webeid/ocsp/protocol/DigestCalculatorImpl.java
rename to web-eid-ocsp/src/main/java/eu/webeid/ocsp/protocol/DigestCalculatorImpl.java
diff --git a/src/main/java/eu/webeid/ocsp/protocol/IssuerDistinguishedName.java b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/protocol/IssuerDistinguishedName.java
similarity index 100%
rename from src/main/java/eu/webeid/ocsp/protocol/IssuerDistinguishedName.java
rename to web-eid-ocsp/src/main/java/eu/webeid/ocsp/protocol/IssuerDistinguishedName.java
diff --git a/src/main/java/eu/webeid/ocsp/protocol/OcspRequestBuilder.java b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/protocol/OcspRequestBuilder.java
similarity index 100%
rename from src/main/java/eu/webeid/ocsp/protocol/OcspRequestBuilder.java
rename to web-eid-ocsp/src/main/java/eu/webeid/ocsp/protocol/OcspRequestBuilder.java
diff --git a/src/main/java/eu/webeid/ocsp/protocol/OcspResponseValidator.java b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/protocol/OcspResponseValidator.java
similarity index 100%
rename from src/main/java/eu/webeid/ocsp/protocol/OcspResponseValidator.java
rename to web-eid-ocsp/src/main/java/eu/webeid/ocsp/protocol/OcspResponseValidator.java
diff --git a/src/main/java/eu/webeid/ocsp/protocol/OcspUrl.java b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/protocol/OcspUrl.java
similarity index 100%
rename from src/main/java/eu/webeid/ocsp/protocol/OcspUrl.java
rename to web-eid-ocsp/src/main/java/eu/webeid/ocsp/protocol/OcspUrl.java
diff --git a/src/main/java/eu/webeid/ocsp/service/AiaOcspService.java b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/service/AiaOcspService.java
similarity index 100%
rename from src/main/java/eu/webeid/ocsp/service/AiaOcspService.java
rename to web-eid-ocsp/src/main/java/eu/webeid/ocsp/service/AiaOcspService.java
diff --git a/src/main/java/eu/webeid/ocsp/service/AiaOcspServiceConfiguration.java b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/service/AiaOcspServiceConfiguration.java
similarity index 100%
rename from src/main/java/eu/webeid/ocsp/service/AiaOcspServiceConfiguration.java
rename to web-eid-ocsp/src/main/java/eu/webeid/ocsp/service/AiaOcspServiceConfiguration.java
diff --git a/src/main/java/eu/webeid/ocsp/service/DesignatedOcspService.java b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/service/DesignatedOcspService.java
similarity index 100%
rename from src/main/java/eu/webeid/ocsp/service/DesignatedOcspService.java
rename to web-eid-ocsp/src/main/java/eu/webeid/ocsp/service/DesignatedOcspService.java
diff --git a/src/main/java/eu/webeid/ocsp/service/DesignatedOcspServiceConfiguration.java b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/service/DesignatedOcspServiceConfiguration.java
similarity index 100%
rename from src/main/java/eu/webeid/ocsp/service/DesignatedOcspServiceConfiguration.java
rename to web-eid-ocsp/src/main/java/eu/webeid/ocsp/service/DesignatedOcspServiceConfiguration.java
diff --git a/src/main/java/eu/webeid/ocsp/service/OcspServiceProvider.java b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/service/OcspServiceProviderImpl.java
similarity index 86%
rename from src/main/java/eu/webeid/ocsp/service/OcspServiceProvider.java
rename to web-eid-ocsp/src/main/java/eu/webeid/ocsp/service/OcspServiceProviderImpl.java
index 079f1b89..be4220fc 100644
--- a/src/main/java/eu/webeid/ocsp/service/OcspServiceProvider.java
+++ b/web-eid-ocsp/src/main/java/eu/webeid/ocsp/service/OcspServiceProviderImpl.java
@@ -11,17 +11,17 @@
import java.util.Map;
import java.util.Objects;
-public class OcspServiceProvider {
+public class OcspServiceProviderImpl implements OcspServiceProvider {
private final DesignatedOcspService designatedOcspService;
private final AiaOcspServiceConfiguration aiaOcspServiceConfiguration;
private final Map fallbackOcspServiceMap;
- public OcspServiceProvider(DesignatedOcspServiceConfiguration designatedOcspServiceConfiguration, AiaOcspServiceConfiguration aiaOcspServiceConfiguration) {
+ public OcspServiceProviderImpl(DesignatedOcspServiceConfiguration designatedOcspServiceConfiguration, AiaOcspServiceConfiguration aiaOcspServiceConfiguration) {
this(designatedOcspServiceConfiguration, aiaOcspServiceConfiguration, null);
}
- public OcspServiceProvider(DesignatedOcspServiceConfiguration designatedOcspServiceConfiguration, AiaOcspServiceConfiguration aiaOcspServiceConfiguration, Collection fallbackOcspServiceConfigurations) {
+ public OcspServiceProviderImpl(DesignatedOcspServiceConfiguration designatedOcspServiceConfiguration, AiaOcspServiceConfiguration aiaOcspServiceConfiguration, Collection fallbackOcspServiceConfigurations) {
designatedOcspService = designatedOcspServiceConfiguration != null ?
new DesignatedOcspService(designatedOcspServiceConfiguration)
: null;
@@ -52,6 +52,7 @@ private static Map buildFallbackOcspServic
* @return either the designated or AIA OCSP service instance
* @throws UserCertificateOCSPException when the AIA OCSP responder URL cannot be resolved from the certificate
*/
+ @Override
public OcspService getService(X509Certificate certificate, X509Certificate issuerCertificate) throws UserCertificateOCSPException {
if (designatedOcspService != null && designatedOcspService.supportsIssuer(issuerCertificate)) {
return designatedOcspService;
diff --git a/src/test/java/eu/webeid/ocsp/OcspCertificateRevocationCheckerNetworkTest.java b/web-eid-ocsp/src/test/java/eu/webeid/ocsp/OcspCertificateRevocationCheckerNetworkTest.java
similarity index 98%
rename from src/test/java/eu/webeid/ocsp/OcspCertificateRevocationCheckerNetworkTest.java
rename to web-eid-ocsp/src/test/java/eu/webeid/ocsp/OcspCertificateRevocationCheckerNetworkTest.java
index b3c07b1f..e57858b9 100644
--- a/src/test/java/eu/webeid/ocsp/OcspCertificateRevocationCheckerNetworkTest.java
+++ b/web-eid-ocsp/src/test/java/eu/webeid/ocsp/OcspCertificateRevocationCheckerNetworkTest.java
@@ -8,7 +8,7 @@
import eu.webeid.ocsp.exceptions.UserCertificateOCSPCheckFailedException;
import eu.webeid.ocsp.service.AiaOcspServiceConfiguration;
import eu.webeid.ocsp.service.DesignatedOcspServiceConfiguration;
-import eu.webeid.ocsp.service.OcspServiceProvider;
+import eu.webeid.ocsp.service.OcspServiceProviderImpl;
import eu.webeid.security.certificate.CertificateValidator;
import eu.webeid.security.exceptions.CertificateRevocationCheckFailedException;
import eu.webeid.security.exceptions.CertificateRevokedException;
@@ -256,7 +256,7 @@ private OcspCertificateRevocationChecker customChecker(DesignatedOcspServiceConf
List intermediates) throws Exception {
return new OcspCertificateRevocationChecker(
OcspClientImpl.build(Duration.ofSeconds(2)),
- new OcspServiceProvider(designated, new AiaOcspServiceConfiguration(Set.of(),
+ new OcspServiceProviderImpl(designated, new AiaOcspServiceConfiguration(Set.of(),
CertificateValidator.buildTrustAnchorsFromCertificates(anchors),
CertificateValidator.buildCertStoreFromCertificates(intermediates),
OcspCertificateRevocationChecker.DEFAULT_THIS_UPDATE_AGE, OcspCertificateRevocationChecker.DEFAULT_NEXT_UPDATE_AGE, true)),
diff --git a/src/test/java/eu/webeid/ocsp/OcspCertificateRevocationCheckerTest.java b/web-eid-ocsp/src/test/java/eu/webeid/ocsp/OcspCertificateRevocationCheckerTest.java
similarity index 100%
rename from src/test/java/eu/webeid/ocsp/OcspCertificateRevocationCheckerTest.java
rename to web-eid-ocsp/src/test/java/eu/webeid/ocsp/OcspCertificateRevocationCheckerTest.java
diff --git a/src/test/java/eu/webeid/ocsp/client/OcspClientImplTest.java b/web-eid-ocsp/src/test/java/eu/webeid/ocsp/client/OcspClientImplTest.java
similarity index 100%
rename from src/test/java/eu/webeid/ocsp/client/OcspClientImplTest.java
rename to web-eid-ocsp/src/test/java/eu/webeid/ocsp/client/OcspClientImplTest.java
diff --git a/src/test/java/eu/webeid/ocsp/client/OcspClientOverrideTest.java b/web-eid-ocsp/src/test/java/eu/webeid/ocsp/client/OcspClientOverrideTest.java
similarity index 100%
rename from src/test/java/eu/webeid/ocsp/client/OcspClientOverrideTest.java
rename to web-eid-ocsp/src/test/java/eu/webeid/ocsp/client/OcspClientOverrideTest.java
diff --git a/src/test/java/eu/webeid/ocsp/protocol/IssuerDistinguishedNameTest.java b/web-eid-ocsp/src/test/java/eu/webeid/ocsp/protocol/IssuerDistinguishedNameTest.java
similarity index 100%
rename from src/test/java/eu/webeid/ocsp/protocol/IssuerDistinguishedNameTest.java
rename to web-eid-ocsp/src/test/java/eu/webeid/ocsp/protocol/IssuerDistinguishedNameTest.java
diff --git a/src/test/java/eu/webeid/ocsp/protocol/OcspResponseValidatorTest.java b/web-eid-ocsp/src/test/java/eu/webeid/ocsp/protocol/OcspResponseValidatorTest.java
similarity index 100%
rename from src/test/java/eu/webeid/ocsp/protocol/OcspResponseValidatorTest.java
rename to web-eid-ocsp/src/test/java/eu/webeid/ocsp/protocol/OcspResponseValidatorTest.java
diff --git a/src/test/java/eu/webeid/ocsp/protocol/OcspUrlTest.java b/web-eid-ocsp/src/test/java/eu/webeid/ocsp/protocol/OcspUrlTest.java
similarity index 100%
rename from src/test/java/eu/webeid/ocsp/protocol/OcspUrlTest.java
rename to web-eid-ocsp/src/test/java/eu/webeid/ocsp/protocol/OcspUrlTest.java
diff --git a/src/test/java/eu/webeid/ocsp/service/AiaOcspServiceConfigurationTest.java b/web-eid-ocsp/src/test/java/eu/webeid/ocsp/service/AiaOcspServiceConfigurationTest.java
similarity index 100%
rename from src/test/java/eu/webeid/ocsp/service/AiaOcspServiceConfigurationTest.java
rename to web-eid-ocsp/src/test/java/eu/webeid/ocsp/service/AiaOcspServiceConfigurationTest.java
diff --git a/src/test/java/eu/webeid/ocsp/service/OcspServiceMaker.java b/web-eid-ocsp/src/test/java/eu/webeid/ocsp/service/OcspServiceMaker.java
similarity index 88%
rename from src/test/java/eu/webeid/ocsp/service/OcspServiceMaker.java
rename to web-eid-ocsp/src/test/java/eu/webeid/ocsp/service/OcspServiceMaker.java
index 44f5c599..83eb33fc 100644
--- a/src/test/java/eu/webeid/ocsp/service/OcspServiceMaker.java
+++ b/web-eid-ocsp/src/test/java/eu/webeid/ocsp/service/OcspServiceMaker.java
@@ -40,19 +40,19 @@ public class OcspServiceMaker {
}
public static OcspServiceProvider getAiaOcspServiceProvider() throws JceException {
- return new OcspServiceProvider(null, getAiaOcspServiceConfiguration());
+ return new OcspServiceProviderImpl(null, getAiaOcspServiceConfiguration());
}
public static OcspServiceProvider getAiaOcspServiceProviderWithEsteid2018NonceDisabled() throws JceException {
- return new OcspServiceProvider(null, getAiaOcspServiceConfiguration(false));
+ return new OcspServiceProviderImpl(null, getAiaOcspServiceConfiguration(false));
}
public static OcspServiceProvider getDesignatedOcspServiceProvider() throws CertificateException, IOException, OCSPCertificateException, JceException {
- return new OcspServiceProvider(getDesignatedOcspServiceConfiguration(), getAiaOcspServiceConfiguration());
+ return new OcspServiceProviderImpl(getDesignatedOcspServiceConfiguration(), getAiaOcspServiceConfiguration());
}
public static OcspServiceProvider getDesignatedOcspServiceProvider(boolean doesSupportNonce) throws CertificateException, IOException, JceException, OCSPCertificateException {
- return new OcspServiceProvider(getDesignatedOcspServiceConfiguration(doesSupportNonce), getAiaOcspServiceConfiguration());
+ return new OcspServiceProviderImpl(getDesignatedOcspServiceConfiguration(doesSupportNonce), getAiaOcspServiceConfiguration());
}
public static OcspServiceProvider getDesignatedOcspServiceProvider(String ocspServiceAccessLocation) throws CertificateException, IOException, OCSPCertificateException, JceException {
@@ -60,7 +60,7 @@ public static OcspServiceProvider getDesignatedOcspServiceProvider(String ocspSe
}
public static OcspServiceProvider getDesignatedOcspServiceProvider(boolean doesSupportNonce, String ocspServiceAccessLocation) throws CertificateException, IOException, OCSPCertificateException, JceException {
- return new OcspServiceProvider(getDesignatedOcspServiceConfiguration(doesSupportNonce, ocspServiceAccessLocation), getAiaOcspServiceConfiguration());
+ return new OcspServiceProviderImpl(getDesignatedOcspServiceConfiguration(doesSupportNonce, ocspServiceAccessLocation), getAiaOcspServiceConfiguration());
}
private static AiaOcspServiceConfiguration getAiaOcspServiceConfiguration() throws JceException {
diff --git a/web-eid-ocsp/src/test/java/eu/webeid/ocsp/service/OcspServiceProviderTest.java b/web-eid-ocsp/src/test/java/eu/webeid/ocsp/service/OcspServiceProviderTest.java
new file mode 100644
index 00000000..923c8f4a
--- /dev/null
+++ b/web-eid-ocsp/src/test/java/eu/webeid/ocsp/service/OcspServiceProviderTest.java
@@ -0,0 +1,114 @@
+// SPDX-FileCopyrightText: Estonian Information System Authority
+// SPDX-License-Identifier: MIT
+
+package eu.webeid.ocsp.service;
+
+import eu.webeid.ocsp.OcspCertificateRevocationChecker;
+import eu.webeid.ocsp.exceptions.OCSPCertificateException;
+import eu.webeid.security.certificate.CertificateValidator;
+import org.bouncycastle.cert.X509CertificateHolder;
+import org.junit.jupiter.api.Test;
+import eu.webeid.security.testutil.LocalOcspResponder;
+
+import java.net.URI;
+import java.time.Duration;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+
+import static eu.webeid.ocsp.service.OcspServiceMaker.getAiaOcspServiceProvider;
+import static eu.webeid.ocsp.service.OcspServiceMaker.getDesignatedOcspServiceProvider;
+import static eu.webeid.security.testutil.Certificates.getDemoEsteidSk2018AiaOcspResponder;
+import static eu.webeid.security.testutil.Certificates.getJaakKristjanEsteid2018Cert;
+import static eu.webeid.security.testutil.Certificates.getTestEsteid2018CA;
+import static eu.webeid.security.testutil.Certificates.getMariliisEsteid2015Cert;
+import static eu.webeid.security.testutil.Certificates.getTestEsteid2015CA;
+import static eu.webeid.security.testutil.Certificates.getTestSelfSignedOcspResponder;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+
+class OcspServiceProviderTest {
+
+ @Test
+ void whenDesignatedOcspServiceConfigurationProvided_thenCreatesDesignatedOcspService() throws Exception {
+ final OcspServiceProvider ocspServiceProvider = getDesignatedOcspServiceProvider();
+ final OcspService service = ocspServiceProvider.getService(getJaakKristjanEsteid2018Cert(), getTestEsteid2018CA());
+ assertThat(service.getAccessLocation()).isEqualTo(new URI("http://demo.sk.ee/ocsp"));
+ assertThat(service.doesSupportNonce()).isTrue();
+ assertThat(service.getMaxThisUpdateAge()).isEqualTo(Duration.ofMinutes(3));
+ assertThat(service.getMaxNextUpdateAge()).isEqualTo(Duration.ofMinutes(20));
+ assertThatCode(() ->
+ service.validateResponderCertificate(new X509CertificateHolder(getTestSelfSignedOcspResponder().getEncoded()), getTestEsteid2018CA(), new Date(1630000000000L)))
+ .doesNotThrowAnyException();
+ assertThatCode(() ->
+ service.validateResponderCertificate(new X509CertificateHolder(getTestEsteid2018CA().getEncoded()), getTestEsteid2018CA(), new Date(1630000000000L)))
+ .isInstanceOf(OCSPCertificateException.class)
+ .hasMessage("Responder certificate from the OCSP response is not equal to the configured designated OCSP responder certificate");
+ }
+
+ @Test
+ void whenAiaOcspServiceConfigurationProvided_thenCreatesAiaOcspService() throws Exception {
+ final OcspServiceProvider ocspServiceProvider = getAiaOcspServiceProvider();
+ final OcspService service2018 = ocspServiceProvider.getService(getJaakKristjanEsteid2018Cert(), getTestEsteid2018CA());
+ assertThat(service2018.getAccessLocation()).isEqualTo(new URI("http://aia.demo.sk.ee/esteid2018"));
+ assertThat(service2018.doesSupportNonce()).isTrue();
+
+ final OcspService service2015 = ocspServiceProvider.getService(getMariliisEsteid2015Cert(), getTestEsteid2015CA());
+ assertThat(service2015.getAccessLocation()).isEqualTo(new URI("http://aia.demo.sk.ee/esteid2015"));
+ assertThat(service2015.doesSupportNonce()).isFalse();
+ assertThat(service2018.getMaxThisUpdateAge()).isEqualTo(Duration.ofMinutes(3));
+ assertThat(service2018.getMaxNextUpdateAge()).isEqualTo(Duration.ofMinutes(20));
+ assertThatCode(() ->
+ service2018.validateResponderCertificate(new X509CertificateHolder(getDemoEsteidSk2018AiaOcspResponder().getEncoded()), getTestEsteid2018CA(), new Date(1630000000000L)))
+ .doesNotThrowAnyException();
+ }
+
+ @Test
+ void whenAiaResponderCertificateLacksOcspSigningUsage_thenThrows() throws Exception {
+ final OcspServiceProvider ocspServiceProvider = getAiaOcspServiceProvider();
+ final OcspService service2018 = ocspServiceProvider.getService(getJaakKristjanEsteid2018Cert(), getTestEsteid2018CA());
+ final X509CertificateHolder wrongResponderCert = new X509CertificateHolder(getMariliisEsteid2015Cert().getEncoded());
+ assertThatExceptionOfType(OCSPCertificateException.class)
+ .isThrownBy(() ->
+ service2018.validateResponderCertificate(wrongResponderCert, getTestEsteid2018CA(), new Date(1630000000000L)))
+ .withMessageContaining("does not contain the Extended Key Usage extension required for OCSP response signing");
+ }
+
+ @Test
+ void whenDifferentIssuersHaveSameName_thenDesignatedServiceAppliesOnlyToConfiguredCertificate() throws Exception {
+ try (LocalOcspResponder first = new LocalOcspResponder();
+ LocalOcspResponder second = new LocalOcspResponder()) {
+ first.start();
+ second.start();
+ final var authorities = List.of(first.issuer(), second.issuer());
+ final var designated = new DesignatedOcspServiceConfiguration(
+ first.designatedUri(), first.responderCertificate(), List.of(first.issuer()), true,
+ OcspCertificateRevocationChecker.DEFAULT_THIS_UPDATE_AGE, OcspCertificateRevocationChecker.DEFAULT_NEXT_UPDATE_AGE, true);
+ final var aia = new AiaOcspServiceConfiguration(Set.of(),
+ CertificateValidator.buildTrustAnchorsFromCertificates(authorities),
+ CertificateValidator.buildCertStoreFromCertificates(authorities),
+ OcspCertificateRevocationChecker.DEFAULT_THIS_UPDATE_AGE, OcspCertificateRevocationChecker.DEFAULT_NEXT_UPDATE_AGE, true);
+ final var provider = new OcspServiceProviderImpl(designated, aia);
+
+ assertThat(first.issuer().getSubjectX500Principal()).isEqualTo(second.issuer().getSubjectX500Principal());
+ assertThat(first.issuer()).isNotEqualTo(second.issuer());
+ assertThat(provider.getService(first.subject(), first.issuer())).isInstanceOf(DesignatedOcspService.class);
+ assertThat(provider.getService(second.subject(), second.issuer())).isInstanceOf(AiaOcspService.class);
+ }
+ }
+
+}
+
+// Old disabled example AuthTokenValidator test with designated OCSP check.
+//
+// @Test
+// @Disabled("A new designated test OCSP responder certificate was issued whose validity period no longer overlaps with the revoked certificate")
+// void whenCertificateIsRevoked_thenOcspCheckWithDesignatedOcspServiceFails() throws Exception {
+// mockDate("2020-01-01", mockedClock);
+// final AuthTokenValidator validatorWithOcspCheck = AuthTokenValidators.getAuthTokenValidatorWithDesignatedOcspCheck();
+// final WebEidAuthToken token = replaceTokenField(AUTH_TOKEN, "X5C", REVOKED_CERT);
+// assertThatThrownBy(() -> validatorWithOcspCheck
+// .validate(token, VALID_CHALLENGE_NONCE))
+// .isInstanceOf(UserCertificateRevokedException.class);
+// }
diff --git a/web-eid-resilient-ocsp/pom.xml b/web-eid-resilient-ocsp/pom.xml
new file mode 100644
index 00000000..af0fdfb0
--- /dev/null
+++ b/web-eid-resilient-ocsp/pom.xml
@@ -0,0 +1,65 @@
+
+
+ 4.0.0
+
+ eu.webeid.security
+ web-eid-authtoken-validation
+ 4.0.0-SNAPSHOT
+
+
+ web-eid-resilient-ocsp
+
+
+
+ eu.webeid.security
+ web-eid-ocsp
+ ${project.parent.version}
+
+
+ io.github.resilience4j
+ resilience4j-all
+ ${resilience4j.version}
+
+
+ io.github.resilience4j
+ resilience4j-bulkhead
+
+
+ io.github.resilience4j
+ resilience4j-cache
+
+
+ io.github.resilience4j
+ resilience4j-ratelimiter
+
+
+ io.github.resilience4j
+ resilience4j-timelimiter
+
+
+
+
+ io.github.resilience4j
+ resilience4j-vavr
+ ${resilience4j.version}
+
+
+
+ eu.webeid.security
+ authtoken-validation
+ ${project.parent.version}
+ tests
+ test
+
+
+ eu.webeid.security
+ web-eid-ocsp
+ ${project.parent.version}
+ tests
+ test
+
+
+
+
diff --git a/src/main/java/eu/webeid/ocsp/service/FallbackOcspServiceConfiguration.java b/web-eid-resilient-ocsp/src/main/java/eu/webeid/ocsp/service/FallbackOcspServiceConfiguration.java
similarity index 100%
rename from src/main/java/eu/webeid/ocsp/service/FallbackOcspServiceConfiguration.java
rename to web-eid-resilient-ocsp/src/main/java/eu/webeid/ocsp/service/FallbackOcspServiceConfiguration.java
diff --git a/src/main/java/eu/webeid/ocsp/service/FallbackOcspService.java b/web-eid-resilient-ocsp/src/main/java/eu/webeid/ocsp/service/ResilientFallbackOcspService.java
similarity index 93%
rename from src/main/java/eu/webeid/ocsp/service/FallbackOcspService.java
rename to web-eid-resilient-ocsp/src/main/java/eu/webeid/ocsp/service/ResilientFallbackOcspService.java
index d23e3da1..1d9cf414 100644
--- a/src/main/java/eu/webeid/ocsp/service/FallbackOcspService.java
+++ b/web-eid-resilient-ocsp/src/main/java/eu/webeid/ocsp/service/ResilientFallbackOcspService.java
@@ -24,27 +24,27 @@
import static eu.webeid.security.certificate.CertificateValidator.requireCertificateIsValidOnDate;
-public class FallbackOcspService implements OcspService {
+public class ResilientFallbackOcspService implements FallbackOcspService {
private final JcaX509CertificateConverter certificateConverter = new JcaX509CertificateConverter();
private final URI url;
private final boolean supportsNonce;
private final X509Certificate trustedResponderCertificate;
private final X509Certificate issuerCertificate;
- private final FallbackOcspService nextFallback;
+ private final ResilientFallbackOcspService nextFallback;
private final Set trustedCACertificateAnchors;
private final CertStore trustedCACertificateCertStore;
private final Duration maxThisUpdateAge;
private final Duration maxNextUpdateAge;
private final boolean isKeyUsageRequired;
- public FallbackOcspService(FallbackOcspServiceConfiguration configuration) {
+ public ResilientFallbackOcspService(FallbackOcspServiceConfiguration configuration) {
this.url = configuration.getAccessLocation();
this.supportsNonce = configuration.doesSupportNonce();
this.trustedResponderCertificate = configuration.getResponderCertificate();
this.issuerCertificate = configuration.getIssuerCertificate();
this.nextFallback = configuration.getNextFallbackConfiguration() != null
- ? new FallbackOcspService(configuration.getNextFallbackConfiguration())
+ ? new ResilientFallbackOcspService(configuration.getNextFallbackConfiguration())
: null;
this.trustedCACertificateAnchors = configuration.getTrustedCACertificateAnchors();
this.trustedCACertificateCertStore = configuration.getTrustedCACertificateCertStore();
@@ -127,7 +127,8 @@ private void validateResponderCertificateAgainstTrustedCa(X509Certificate respon
);
}
- public FallbackOcspService getNextFallback() {
+ @Override
+ public ResilientFallbackOcspService getNextFallback() {
return nextFallback;
}
}
diff --git a/src/main/java/eu/webeid/resilientocsp/ResilientOcspCertificateRevocationChecker.java b/web-eid-resilient-ocsp/src/main/java/eu/webeid/resilientocsp/ResilientOcspCertificateRevocationChecker.java
similarity index 100%
rename from src/main/java/eu/webeid/resilientocsp/ResilientOcspCertificateRevocationChecker.java
rename to web-eid-resilient-ocsp/src/main/java/eu/webeid/resilientocsp/ResilientOcspCertificateRevocationChecker.java
diff --git a/src/main/java/eu/webeid/resilientocsp/exceptions/ResilientUserCertificateOCSPCheckFailedException.java b/web-eid-resilient-ocsp/src/main/java/eu/webeid/resilientocsp/exceptions/ResilientUserCertificateOCSPCheckFailedException.java
similarity index 100%
rename from src/main/java/eu/webeid/resilientocsp/exceptions/ResilientUserCertificateOCSPCheckFailedException.java
rename to web-eid-resilient-ocsp/src/main/java/eu/webeid/resilientocsp/exceptions/ResilientUserCertificateOCSPCheckFailedException.java
diff --git a/src/main/java/eu/webeid/resilientocsp/exceptions/ResilientUserCertificateRevokedException.java b/web-eid-resilient-ocsp/src/main/java/eu/webeid/resilientocsp/exceptions/ResilientUserCertificateRevokedException.java
similarity index 100%
rename from src/main/java/eu/webeid/resilientocsp/exceptions/ResilientUserCertificateRevokedException.java
rename to web-eid-resilient-ocsp/src/main/java/eu/webeid/resilientocsp/exceptions/ResilientUserCertificateRevokedException.java
diff --git a/src/main/java/eu/webeid/resilientocsp/exceptions/ResilientUserCertificateUnknownStatusException.java b/web-eid-resilient-ocsp/src/main/java/eu/webeid/resilientocsp/exceptions/ResilientUserCertificateUnknownStatusException.java
similarity index 100%
rename from src/main/java/eu/webeid/resilientocsp/exceptions/ResilientUserCertificateUnknownStatusException.java
rename to web-eid-resilient-ocsp/src/main/java/eu/webeid/resilientocsp/exceptions/ResilientUserCertificateUnknownStatusException.java
diff --git a/src/test/java/eu/webeid/ocsp/service/AiaOcspServiceTest.java b/web-eid-resilient-ocsp/src/test/java/eu/webeid/ocsp/service/AiaOcspServiceTest.java
similarity index 96%
rename from src/test/java/eu/webeid/ocsp/service/AiaOcspServiceTest.java
rename to web-eid-resilient-ocsp/src/test/java/eu/webeid/ocsp/service/AiaOcspServiceTest.java
index 92ee8b76..4edc457d 100644
--- a/src/test/java/eu/webeid/ocsp/service/AiaOcspServiceTest.java
+++ b/web-eid-resilient-ocsp/src/test/java/eu/webeid/ocsp/service/AiaOcspServiceTest.java
@@ -29,7 +29,7 @@
/**
* Unit tests for the {@link AiaOcspService} behaviour introduced in commit e2bd57e3:
* nonce support is now keyed on the certificate's issuer distinguished name (previously the OCSP URL),
- * and the service carries an optional {@link FallbackOcspService}.
+ * and the service carries an optional {@link ResilientFallbackOcspService}.
*/
class AiaOcspServiceTest {
@@ -88,7 +88,7 @@ void whenFallbackServiceProvided_thenGetFallbackServiceReturnsIt() throws Except
FALLBACK_URI, getDemoEsteidSk2018AiaOcspResponder(), true,
null, getTestEsteid2018CA(), trustedCaAnchors, trustedCaCertStore,
DEFAULT_THIS_UPDATE_AGE, DEFAULT_NEXT_UPDATE_AGE, true);
- FallbackOcspService fallback = new FallbackOcspService(fallbackConfiguration);
+ ResilientFallbackOcspService fallback = new ResilientFallbackOcspService(fallbackConfiguration);
AiaOcspService service = new AiaOcspService(configuration, esteid2018UserCert, fallback);
diff --git a/src/test/java/eu/webeid/ocsp/service/FallbackOcspServiceConfigurationTest.java b/web-eid-resilient-ocsp/src/test/java/eu/webeid/ocsp/service/FallbackOcspServiceConfigurationTest.java
similarity index 100%
rename from src/test/java/eu/webeid/ocsp/service/FallbackOcspServiceConfigurationTest.java
rename to web-eid-resilient-ocsp/src/test/java/eu/webeid/ocsp/service/FallbackOcspServiceConfigurationTest.java
diff --git a/src/test/java/eu/webeid/ocsp/service/FallbackOcspServiceTest.java b/web-eid-resilient-ocsp/src/test/java/eu/webeid/ocsp/service/FallbackOcspServiceTest.java
similarity index 93%
rename from src/test/java/eu/webeid/ocsp/service/FallbackOcspServiceTest.java
rename to web-eid-resilient-ocsp/src/test/java/eu/webeid/ocsp/service/FallbackOcspServiceTest.java
index 81e4a770..f1dbb4c4 100644
--- a/src/test/java/eu/webeid/ocsp/service/FallbackOcspServiceTest.java
+++ b/web-eid-resilient-ocsp/src/test/java/eu/webeid/ocsp/service/FallbackOcspServiceTest.java
@@ -73,7 +73,7 @@ void whenConfigurationIsProvided_thenAccessorsReturnConfiguredValues() throws Ex
null, getTestEsteid2018CA(), trustedCaAnchors, trustedCaCertStore,
DEFAULT_THIS_UPDATE_AGE, DEFAULT_NEXT_UPDATE_AGE, true);
- FallbackOcspService service = new FallbackOcspService(configuration);
+ ResilientFallbackOcspService service = new ResilientFallbackOcspService(configuration);
assertThat(service.getAccessLocation()).isEqualTo(PRIMARY_FALLBACK_URI);
assertThat(service.doesSupportNonce()).isTrue();
@@ -91,7 +91,7 @@ null, getTestEsteid2018CA(), trustedCaAnchors, trustedCaCertStore,
secondaryConfiguration, getTestEsteid2018CA(), trustedCaAnchors, trustedCaCertStore,
DEFAULT_THIS_UPDATE_AGE, DEFAULT_NEXT_UPDATE_AGE, true);
- FallbackOcspService primary = new FallbackOcspService(primaryConfiguration);
+ FallbackOcspService primary = new ResilientFallbackOcspService(primaryConfiguration);
FallbackOcspService secondary = primary.getNextFallback();
assertThat(secondary).isNotNull();
@@ -106,7 +106,7 @@ void whenResponderCertificateIsPinnedAndMatches_thenValidationSucceeds() throws
PRIMARY_FALLBACK_URI, aiaOcspResponderCert, true,
null, getTestEsteid2018CA(), trustedCaAnchors, trustedCaCertStore,
DEFAULT_THIS_UPDATE_AGE, DEFAULT_NEXT_UPDATE_AGE, true);
- FallbackOcspService service = new FallbackOcspService(configuration);
+ ResilientFallbackOcspService service = new ResilientFallbackOcspService(configuration);
X509CertificateHolder matchingHolder = new X509CertificateHolder(aiaOcspResponderCert.getEncoded());
assertThatCode(() ->
@@ -120,7 +120,7 @@ void whenResponderCertificateIsPinnedAndDiffers_thenThrows() throws Exception {
PRIMARY_FALLBACK_URI, aiaOcspResponderCert, true,
null, getTestEsteid2018CA(), trustedCaAnchors, trustedCaCertStore,
DEFAULT_THIS_UPDATE_AGE, DEFAULT_NEXT_UPDATE_AGE, true);
- FallbackOcspService service = new FallbackOcspService(configuration);
+ ResilientFallbackOcspService service = new ResilientFallbackOcspService(configuration);
X509CertificateHolder differentHolder = new X509CertificateHolder(esteid2018CaCert.getEncoded());
assertThatExceptionOfType(OCSPCertificateException.class)
@@ -135,7 +135,7 @@ void whenResponderCertificateIsNotPinnedButTrustedByCa_thenValidationSucceeds()
PRIMARY_FALLBACK_URI, null, true,
null, getTestEsteid2018CA(), trustedCaAnchors, trustedCaCertStore,
DEFAULT_THIS_UPDATE_AGE, DEFAULT_NEXT_UPDATE_AGE, true);
- FallbackOcspService service = new FallbackOcspService(configuration);
+ ResilientFallbackOcspService service = new ResilientFallbackOcspService(configuration);
// The DEMO AIA responder certificate chains to the TEST of ESTEID2018 CA, which is a trusted anchor.
X509CertificateHolder responderHolder = new X509CertificateHolder(aiaOcspResponderCert.getEncoded());
@@ -150,7 +150,7 @@ void whenResponderCertificateIsNotPinnedAndLacksSigningExtension_thenThrows() th
PRIMARY_FALLBACK_URI, null, true,
null, getTestEsteid2018CA(), trustedCaAnchors, trustedCaCertStore,
DEFAULT_THIS_UPDATE_AGE, DEFAULT_NEXT_UPDATE_AGE, true);
- FallbackOcspService service = new FallbackOcspService(configuration);
+ ResilientFallbackOcspService service = new ResilientFallbackOcspService(configuration);
X509CertificateHolder nonSigningHolder = new X509CertificateHolder(nonSigningUserCert.getEncoded());
assertThatExceptionOfType(OCSPCertificateException.class)
@@ -169,7 +169,7 @@ void whenResponderCertificateLacksKeyUsageExtension_thenThrows() throws Exceptio
PRIMARY_FALLBACK_URI, null, true,
null, getTestEsteid2018CA(), trustedCaAnchors, trustedCaCertStore,
DEFAULT_THIS_UPDATE_AGE, DEFAULT_NEXT_UPDATE_AGE, true);
- FallbackOcspService service = new FallbackOcspService(configuration);
+ ResilientFallbackOcspService service = new ResilientFallbackOcspService(configuration);
X509CertificateHolder noKeyUsageHolder = new X509CertificateHolder(ocspResponder2020Cert.getEncoded());
assertThatExceptionOfType(OCSPCertificateException.class)
@@ -184,7 +184,7 @@ void whenResponderCertificateIsNotIssuedBySubjectIssuer_thenThrows() throws Exce
PRIMARY_FALLBACK_URI, null, true,
null, getTestEsteid2018CA(), trustedCaAnchors, trustedCaCertStore,
DEFAULT_THIS_UPDATE_AGE, DEFAULT_NEXT_UPDATE_AGE, true);
- FallbackOcspService service = new FallbackOcspService(configuration);
+ ResilientFallbackOcspService service = new ResilientFallbackOcspService(configuration);
// The self-signed responder certificate satisfies every OCSP responder extension requirement, but it was
// not issued by the subject certificate's issuer, so it is rejected before PKIX path building.
X509CertificateHolder untrustedButEkuValidHolder = new X509CertificateHolder(selfSignedOcspResponderCert.getEncoded());
@@ -201,7 +201,7 @@ void whenResponderCertificateHolderConversionFails_thenThrows() throws Exception
PRIMARY_FALLBACK_URI, aiaOcspResponderCert, true,
null, getTestEsteid2018CA(), trustedCaAnchors, trustedCaCertStore,
DEFAULT_THIS_UPDATE_AGE, DEFAULT_NEXT_UPDATE_AGE, true);
- FallbackOcspService service = new FallbackOcspService(configuration);
+ ResilientFallbackOcspService service = new ResilientFallbackOcspService(configuration);
// Make JcaX509CertificateConverter.getCertificate(holder) fail: the converter calls holder.getEncoded()
// and wraps the resulting IOException into a CertificateException, which the service catches and rewraps.
X509CertificateHolder unconvertibleHolder = mock(X509CertificateHolder.class);
@@ -220,7 +220,7 @@ void whenResponderCertificateIsExpiredAtValidationDate_thenThrows() throws Excep
PRIMARY_FALLBACK_URI, aiaOcspResponderCert, true,
null, getTestEsteid2018CA(), trustedCaAnchors, trustedCaCertStore,
DEFAULT_THIS_UPDATE_AGE, DEFAULT_NEXT_UPDATE_AGE, true);
- FallbackOcspService service = new FallbackOcspService(configuration);
+ ResilientFallbackOcspService service = new ResilientFallbackOcspService(configuration);
X509CertificateHolder responderHolder = new X509CertificateHolder(aiaOcspResponderCert.getEncoded());
Date farFuture = new Date(4102444800000L); // 2100-01-01
diff --git a/src/test/java/eu/webeid/ocsp/service/OcspServiceConfigurationTest.java b/web-eid-resilient-ocsp/src/test/java/eu/webeid/ocsp/service/OcspServiceConfigurationTest.java
similarity index 100%
rename from src/test/java/eu/webeid/ocsp/service/OcspServiceConfigurationTest.java
rename to web-eid-resilient-ocsp/src/test/java/eu/webeid/ocsp/service/OcspServiceConfigurationTest.java
diff --git a/src/test/java/eu/webeid/ocsp/service/OcspServiceProviderTest.java b/web-eid-resilient-ocsp/src/test/java/eu/webeid/ocsp/service/ResilientOcspServiceProviderTest.java
similarity index 76%
rename from src/test/java/eu/webeid/ocsp/service/OcspServiceProviderTest.java
rename to web-eid-resilient-ocsp/src/test/java/eu/webeid/ocsp/service/ResilientOcspServiceProviderTest.java
index 1537f5a3..3c74768a 100644
--- a/src/test/java/eu/webeid/ocsp/service/OcspServiceProviderTest.java
+++ b/web-eid-resilient-ocsp/src/test/java/eu/webeid/ocsp/service/ResilientOcspServiceProviderTest.java
@@ -6,6 +6,7 @@
import eu.webeid.ocsp.OcspCertificateRevocationChecker;
import eu.webeid.ocsp.exceptions.OCSPCertificateException;
import eu.webeid.security.certificate.CertificateValidator;
+import eu.webeid.security.testutil.LocalOcspResponder;
import org.bouncycastle.asn1.x509.BasicConstraints;
import org.bouncycastle.asn1.x509.ExtendedKeyUsage;
import org.bouncycastle.asn1.x509.Extension;
@@ -15,13 +16,11 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
-import eu.webeid.security.testutil.LocalOcspResponder;
import java.net.URI;
import java.security.cert.CertStore;
import java.security.cert.TrustAnchor;
import java.security.cert.X509Certificate;
-import java.time.Duration;
import java.util.Date;
import java.util.List;
import java.util.Optional;
@@ -29,87 +28,17 @@
import static eu.webeid.ocsp.service.OcspServiceMaker.getAiaOcspServiceProvider;
import static eu.webeid.ocsp.service.OcspServiceMaker.getDesignatedOcspServiceConfiguration;
-import static eu.webeid.ocsp.service.OcspServiceMaker.getDesignatedOcspServiceProvider;
import static eu.webeid.security.testutil.Certificates.getDemoEsteidSk2018AiaOcspResponder;
import static eu.webeid.security.testutil.Certificates.getJaakKristjanEsteid2018Cert;
-import static eu.webeid.security.testutil.Certificates.getTestEsteid2018CA;
-import static eu.webeid.security.testutil.Certificates.getMariliisEsteid2015Cert;
import static eu.webeid.security.testutil.Certificates.getTestEsteid2015CA;
+import static eu.webeid.security.testutil.Certificates.getTestEsteid2018CA;
import static eu.webeid.security.testutil.Certificates.getTestSelfSignedOcspResponder;
import static eu.webeid.security.testutil.TestCertificateBuilder.buildCertificate;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-class OcspServiceProviderTest {
-
- @Test
- void whenDesignatedOcspServiceConfigurationProvided_thenCreatesDesignatedOcspService() throws Exception {
- final OcspServiceProvider ocspServiceProvider = getDesignatedOcspServiceProvider();
- final OcspService service = ocspServiceProvider.getService(getJaakKristjanEsteid2018Cert(), getTestEsteid2018CA());
- assertThat(service.getAccessLocation()).isEqualTo(new URI("http://demo.sk.ee/ocsp"));
- assertThat(service.doesSupportNonce()).isTrue();
- assertThat(service.getMaxThisUpdateAge()).isEqualTo(Duration.ofMinutes(3));
- assertThat(service.getMaxNextUpdateAge()).isEqualTo(Duration.ofMinutes(20));
- assertThatCode(() ->
- service.validateResponderCertificate(new X509CertificateHolder(getTestSelfSignedOcspResponder().getEncoded()), getTestEsteid2018CA(), new Date(1630000000000L)))
- .doesNotThrowAnyException();
- assertThatCode(() ->
- service.validateResponderCertificate(new X509CertificateHolder(getTestEsteid2018CA().getEncoded()), getTestEsteid2018CA(), new Date(1630000000000L)))
- .isInstanceOf(OCSPCertificateException.class)
- .hasMessage("Responder certificate from the OCSP response is not equal to the configured designated OCSP responder certificate");
- }
-
- @Test
- void whenAiaOcspServiceConfigurationProvided_thenCreatesAiaOcspService() throws Exception {
- final OcspServiceProvider ocspServiceProvider = getAiaOcspServiceProvider();
- final OcspService service2018 = ocspServiceProvider.getService(getJaakKristjanEsteid2018Cert(), getTestEsteid2018CA());
- assertThat(service2018.getAccessLocation()).isEqualTo(new URI("http://aia.demo.sk.ee/esteid2018"));
- assertThat(service2018.doesSupportNonce()).isTrue();
-
- final OcspService service2015 = ocspServiceProvider.getService(getMariliisEsteid2015Cert(), getTestEsteid2015CA());
- assertThat(service2015.getAccessLocation()).isEqualTo(new URI("http://aia.demo.sk.ee/esteid2015"));
- assertThat(service2015.doesSupportNonce()).isFalse();
- assertThat(service2018.getMaxThisUpdateAge()).isEqualTo(Duration.ofMinutes(3));
- assertThat(service2018.getMaxNextUpdateAge()).isEqualTo(Duration.ofMinutes(20));
- assertThatCode(() ->
- service2018.validateResponderCertificate(new X509CertificateHolder(getDemoEsteidSk2018AiaOcspResponder().getEncoded()), getTestEsteid2018CA(), new Date(1630000000000L)))
- .doesNotThrowAnyException();
- }
-
- @Test
- void whenAiaResponderCertificateLacksOcspSigningUsage_thenThrows() throws Exception {
- final OcspServiceProvider ocspServiceProvider = getAiaOcspServiceProvider();
- final OcspService service2018 = ocspServiceProvider.getService(getJaakKristjanEsteid2018Cert(), getTestEsteid2018CA());
- final X509CertificateHolder wrongResponderCert = new X509CertificateHolder(getMariliisEsteid2015Cert().getEncoded());
- assertThatExceptionOfType(OCSPCertificateException.class)
- .isThrownBy(() ->
- service2018.validateResponderCertificate(wrongResponderCert, getTestEsteid2018CA(), new Date(1630000000000L)))
- .withMessageContaining("does not contain the Extended Key Usage extension required for OCSP response signing");
- }
-
- @Test
- void whenDifferentIssuersHaveSameName_thenDesignatedServiceAppliesOnlyToConfiguredCertificate() throws Exception {
- try (LocalOcspResponder first = new LocalOcspResponder();
- LocalOcspResponder second = new LocalOcspResponder()) {
- first.start();
- second.start();
- final var authorities = List.of(first.issuer(), second.issuer());
- final var designated = new DesignatedOcspServiceConfiguration(
- first.designatedUri(), first.responderCertificate(), List.of(first.issuer()), true,
- OcspCertificateRevocationChecker.DEFAULT_THIS_UPDATE_AGE, OcspCertificateRevocationChecker.DEFAULT_NEXT_UPDATE_AGE, true);
- final var aia = new AiaOcspServiceConfiguration(Set.of(),
- CertificateValidator.buildTrustAnchorsFromCertificates(authorities),
- CertificateValidator.buildCertStoreFromCertificates(authorities),
- OcspCertificateRevocationChecker.DEFAULT_THIS_UPDATE_AGE, OcspCertificateRevocationChecker.DEFAULT_NEXT_UPDATE_AGE, true);
- final var provider = new OcspServiceProvider(designated, aia);
-
- assertThat(first.issuer().getSubjectX500Principal()).isEqualTo(second.issuer().getSubjectX500Principal());
- assertThat(first.issuer()).isNotEqualTo(second.issuer());
- assertThat(provider.getService(first.subject(), first.issuer())).isInstanceOf(DesignatedOcspService.class);
- assertThat(provider.getService(second.subject(), second.issuer())).isInstanceOf(AiaOcspService.class);
- }
- }
+class ResilientOcspServiceProviderTest {
@Test
void whenDifferentIssuersHaveSameName_thenFallbackServiceAppliesOnlyToConfiguredCertificate() throws Exception {
@@ -131,7 +60,7 @@ void whenDifferentIssuersHaveSameName_thenFallbackServiceAppliesOnlyToConfigured
CertificateValidator.buildTrustAnchorsFromCertificates(List.of(first.issuer())),
CertificateValidator.buildCertStoreFromCertificates(List.of(first.issuer())),
OcspCertificateRevocationChecker.DEFAULT_THIS_UPDATE_AGE, OcspCertificateRevocationChecker.DEFAULT_NEXT_UPDATE_AGE, true);
- final var provider = new OcspServiceProvider(null, aia, List.of(fallback));
+ final var provider = new OcspServiceProviderImpl(null, aia, List.of(fallback));
assertThat(first.issuer().getSubjectX500Principal()).isEqualTo(second.issuer().getSubjectX500Principal());
assertThat(first.issuer()).isNotEqualTo(second.issuer());
@@ -155,7 +84,7 @@ void whenFallbackResponderIsDelegatedByAnotherTrustedCa_thenThrows(boolean sameI
CertificateValidator.buildTrustAnchorsFromCertificates(List.of(responder.issuer(), responder.otherIssuer())),
CertificateValidator.buildCertStoreFromCertificates(List.of(responder.issuer(), responder.otherIssuer())),
OcspCertificateRevocationChecker.DEFAULT_THIS_UPDATE_AGE, OcspCertificateRevocationChecker.DEFAULT_NEXT_UPDATE_AGE, true);
- final var service = new FallbackOcspService(configuration);
+ final var service = new ResilientFallbackOcspService(configuration);
final var responderCertificate = new X509CertificateHolder(responder.responderCertificate().getEncoded());
assertThatExceptionOfType(OCSPCertificateException.class)
@@ -179,7 +108,7 @@ void whenFallbackServiceIsUsedForDifferentIssuer_thenThrows() throws Exception {
CertificateValidator.buildTrustAnchorsFromCertificates(List.of(first.issuer())),
CertificateValidator.buildCertStoreFromCertificates(List.of(first.issuer())),
OcspCertificateRevocationChecker.DEFAULT_THIS_UPDATE_AGE, OcspCertificateRevocationChecker.DEFAULT_NEXT_UPDATE_AGE, true);
- final var service = new FallbackOcspService(configuration);
+ final var service = new ResilientFallbackOcspService(configuration);
final var responderCertificate = new X509CertificateHolder(first.responderCertificate().getEncoded());
assertThatExceptionOfType(OCSPCertificateException.class)
@@ -238,7 +167,7 @@ void whenAiaOcspResponderCertMissingOcspSigningEku_thenThrows() throws Exception
@Test
void whenFallbackOcspResponderCertIsCA_thenThrows() throws Exception {
- final FallbackOcspService service = newFallbackOcspServiceWithoutPinnedResponder();
+ final ResilientFallbackOcspService service = newFallbackOcspServiceWithoutPinnedResponder();
final X509Certificate caResponder = buildCertificate(
new Extension(Extension.basicConstraints, true, new BasicConstraints(0).getEncoded()));
final X509CertificateHolder caResponderCert = new X509CertificateHolder(caResponder.getEncoded());
@@ -252,7 +181,7 @@ void whenFallbackOcspResponderCertIsCA_thenThrows() throws Exception {
@Test
void whenFallbackOcspResponderCertMissingKeyUsageDigitalSignatureAndNonRepudiation_thenThrows() throws Exception {
- final FallbackOcspService service = newFallbackOcspServiceWithoutPinnedResponder();
+ final ResilientFallbackOcspService service = newFallbackOcspServiceWithoutPinnedResponder();
final X509Certificate responderWithoutDigitalSignature = buildCertificate(
new Extension(Extension.keyUsage, true, new KeyUsage(KeyUsage.keyEncipherment).getEncoded()));
final X509CertificateHolder responderCert = new X509CertificateHolder(responderWithoutDigitalSignature.getEncoded());
@@ -266,7 +195,7 @@ void whenFallbackOcspResponderCertMissingKeyUsageDigitalSignatureAndNonRepudiati
@Test
void whenFallbackOcspResponderCertMissingOcspSigningEku_thenThrows() throws Exception {
- final FallbackOcspService service = newFallbackOcspServiceWithoutPinnedResponder();
+ final ResilientFallbackOcspService service = newFallbackOcspServiceWithoutPinnedResponder();
final X509Certificate responderWithoutOcspSigning = buildCertificate(
new Extension(Extension.keyUsage, true, new KeyUsage(KeyUsage.digitalSignature).getEncoded()),
new Extension(Extension.extendedKeyUsage, true,
@@ -280,7 +209,7 @@ void whenFallbackOcspResponderCertMissingOcspSigningEku_thenThrows() throws Exce
" Extended Key Usage extension does not contain OCSP Signing, which is required for OCSP response signing");
}
- private static FallbackOcspService newFallbackOcspServiceWithoutPinnedResponder() throws Exception {
+ private static ResilientFallbackOcspService newFallbackOcspServiceWithoutPinnedResponder() throws Exception {
final List trustedCAs = List.of(getTestEsteid2018CA());
final Set trustAnchors = CertificateValidator.buildTrustAnchorsFromCertificates(trustedCAs);
final CertStore certStore = CertificateValidator.buildCertStoreFromCertificates(trustedCAs);
@@ -288,16 +217,16 @@ private static FallbackOcspService newFallbackOcspServiceWithoutPinnedResponder(
URI.create("http://fallback.demo.sk.ee/ocsp"), null, true, null, getTestEsteid2018CA(), trustAnchors, certStore,
OcspCertificateRevocationChecker.DEFAULT_THIS_UPDATE_AGE,
OcspCertificateRevocationChecker.DEFAULT_NEXT_UPDATE_AGE, true);
- return new FallbackOcspService(configuration);
+ return new ResilientFallbackOcspService(configuration);
}
@Test
void whenFallbackOcspServiceConfigurationProvided_thenAiaServiceCarriesMatchingFallback() throws Exception {
X509Certificate userCert = getJaakKristjanEsteid2018Cert();
List trustedCertificates = List.of(getTestEsteid2018CA(), getTestEsteid2015CA());
- Set trustedAnchors =
+ Set trustedAnchors =
CertificateValidator.buildTrustAnchorsFromCertificates(trustedCertificates);
- java.security.cert.CertStore trustedStore =
+ CertStore trustedStore =
CertificateValidator.buildCertStoreFromCertificates(trustedCertificates);
URI fallbackUri = URI.create("http://fallback.test/ocsp");
FallbackOcspServiceConfiguration fallbackConfiguration = new FallbackOcspServiceConfiguration(
@@ -306,7 +235,7 @@ null, getTestEsteid2018CA(), trustedAnchors, trustedStore,
OcspCertificateRevocationChecker.DEFAULT_THIS_UPDATE_AGE,
OcspCertificateRevocationChecker.DEFAULT_NEXT_UPDATE_AGE, true);
- OcspServiceProvider provider = new OcspServiceProvider(null, getAiaOcspServiceProvider2018Configuration(),
+ OcspServiceProvider provider = new OcspServiceProviderImpl(null, getAiaOcspServiceProvider2018Configuration(),
List.of(fallbackConfiguration));
OcspService service = provider.getService(userCert, getTestEsteid2018CA());
@@ -330,9 +259,9 @@ null, getTestEsteid2018CA(), trustedAnchors, trustedStore,
void whenFallbackOcspServiceConfigurationDoesNotMatchIssuer_thenAiaServiceCarriesNoFallback() throws Exception {
X509Certificate userCert = getJaakKristjanEsteid2018Cert();
List trustedCertificates = List.of(getTestEsteid2018CA(), getTestEsteid2015CA());
- Set trustedAnchors =
+ Set trustedAnchors =
CertificateValidator.buildTrustAnchorsFromCertificates(trustedCertificates);
- java.security.cert.CertStore trustedStore =
+ CertStore trustedStore =
CertificateValidator.buildCertStoreFromCertificates(trustedCertificates);
FallbackOcspServiceConfiguration fallbackConfiguration = new FallbackOcspServiceConfiguration(
URI.create("http://fallback.test/ocsp"), null, true,
@@ -340,7 +269,7 @@ null, getTestEsteid2015CA(), trustedAnchors, trustedStore,
OcspCertificateRevocationChecker.DEFAULT_THIS_UPDATE_AGE,
OcspCertificateRevocationChecker.DEFAULT_NEXT_UPDATE_AGE, true);
- OcspServiceProvider provider = new OcspServiceProvider(null, getAiaOcspServiceProvider2018Configuration(),
+ OcspServiceProvider provider = new OcspServiceProviderImpl(null, getAiaOcspServiceProvider2018Configuration(),
List.of(fallbackConfiguration));
OcspService service = provider.getService(userCert, getTestEsteid2018CA());
@@ -350,7 +279,7 @@ null, getTestEsteid2015CA(), trustedAnchors, trustedStore,
@Test
void whenFallbackConfigurationsIsNull_thenServiceHasNoFallback() throws Exception {
X509Certificate userCert = getJaakKristjanEsteid2018Cert();
- OcspServiceProvider provider = new OcspServiceProvider(null, getAiaOcspServiceProvider2018Configuration(), null);
+ OcspServiceProvider provider = new OcspServiceProviderImpl(null, getAiaOcspServiceProvider2018Configuration(), null);
OcspService service = provider.getService(userCert, getTestEsteid2018CA());
@@ -362,7 +291,7 @@ void whenFallbackConfigurationsIsNull_thenServiceHasNoFallback() throws Exceptio
@Test
void whenFallbackConfigurationsIsEmpty_thenServiceHasNoFallback() throws Exception {
X509Certificate userCert = getJaakKristjanEsteid2018Cert();
- OcspServiceProvider provider = new OcspServiceProvider(null, getAiaOcspServiceProvider2018Configuration(), List.of());
+ OcspServiceProvider provider = new OcspServiceProviderImpl(null, getAiaOcspServiceProvider2018Configuration(), List.of());
OcspService service = provider.getService(userCert, getTestEsteid2018CA());
@@ -373,9 +302,9 @@ void whenFallbackConfigurationsIsEmpty_thenServiceHasNoFallback() throws Excepti
@Test
void whenFallbackConfiguredForIssuerSupportedByDesignatedService_thenThrows() throws Exception {
List trustedCertificates = List.of(getTestEsteid2018CA(), getTestEsteid2015CA());
- Set trustedAnchors =
+ Set trustedAnchors =
CertificateValidator.buildTrustAnchorsFromCertificates(trustedCertificates);
- java.security.cert.CertStore trustedStore =
+ CertStore trustedStore =
CertificateValidator.buildCertStoreFromCertificates(trustedCertificates);
FallbackOcspServiceConfiguration fallbackConfiguration = new FallbackOcspServiceConfiguration(
URI.create("http://fallback.test/ocsp"), getDemoEsteidSk2018AiaOcspResponder(), true,
@@ -386,7 +315,7 @@ null, getTestEsteid2018CA(), trustedAnchors, trustedStore,
AiaOcspServiceConfiguration aiaConfiguration = getAiaOcspServiceProvider2018Configuration();
assertThatExceptionOfType(IllegalArgumentException.class)
- .isThrownBy(() -> new OcspServiceProvider(designatedConfiguration, aiaConfiguration, List.of(fallbackConfiguration)))
+ .isThrownBy(() -> new OcspServiceProviderImpl(designatedConfiguration, aiaConfiguration, List.of(fallbackConfiguration)))
.withMessage("Fallback OCSP service must not be configured for an issuer that is supported by the designated OCSP service");
}
@@ -394,9 +323,9 @@ null, getTestEsteid2018CA(), trustedAnchors, trustedStore,
void whenFallbackConfiguredForIssuerNotSupportedByDesignatedService_thenAiaServiceCarriesFallback() throws Exception {
X509Certificate userCert = getJaakKristjanEsteid2018Cert();
List trustedCertificates = List.of(getTestEsteid2018CA(), getTestEsteid2015CA());
- Set trustedAnchors =
+ Set trustedAnchors =
CertificateValidator.buildTrustAnchorsFromCertificates(trustedCertificates);
- java.security.cert.CertStore trustedStore =
+ CertStore trustedStore =
CertificateValidator.buildCertStoreFromCertificates(trustedCertificates);
URI fallbackUri = URI.create("http://fallback.test/ocsp");
FallbackOcspServiceConfiguration fallbackConfiguration = new FallbackOcspServiceConfiguration(
@@ -409,7 +338,7 @@ null, getTestEsteid2018CA(), trustedAnchors, trustedStore,
OcspCertificateRevocationChecker.DEFAULT_THIS_UPDATE_AGE,
OcspCertificateRevocationChecker.DEFAULT_NEXT_UPDATE_AGE, true);
- OcspServiceProvider provider = new OcspServiceProvider(designatedConfiguration,
+ OcspServiceProvider provider = new OcspServiceProviderImpl(designatedConfiguration,
getAiaOcspServiceProvider2018Configuration(), List.of(fallbackConfiguration));
OcspService service = provider.getService(userCert, getTestEsteid2018CA());
@@ -422,9 +351,9 @@ null, getTestEsteid2018CA(), trustedAnchors, trustedStore,
void whenDuplicateIssuerFallbackConfigurations_thenLastOneWins() throws Exception {
X509Certificate userCert = getJaakKristjanEsteid2018Cert();
List trustedCertificates = List.of(getTestEsteid2018CA(), getTestEsteid2015CA());
- Set trustedAnchors =
+ Set trustedAnchors =
CertificateValidator.buildTrustAnchorsFromCertificates(trustedCertificates);
- java.security.cert.CertStore trustedStore =
+ CertStore trustedStore =
CertificateValidator.buildCertStoreFromCertificates(trustedCertificates);
URI firstFallbackUri = URI.create("http://fallback-first.test/ocsp");
URI lastFallbackUri = URI.create("http://fallback-last.test/ocsp");
@@ -439,7 +368,7 @@ null, getTestEsteid2018CA(), trustedAnchors, trustedStore,
OcspCertificateRevocationChecker.DEFAULT_THIS_UPDATE_AGE,
OcspCertificateRevocationChecker.DEFAULT_NEXT_UPDATE_AGE, true);
- OcspServiceProvider provider = new OcspServiceProvider(null, getAiaOcspServiceProvider2018Configuration(),
+ OcspServiceProvider provider = new OcspServiceProviderImpl(null, getAiaOcspServiceProvider2018Configuration(),
List.of(firstConfiguration, lastConfiguration));
OcspService service = provider.getService(userCert, getTestEsteid2018CA());
diff --git a/src/test/java/eu/webeid/resilientocsp/ResilientOcspCertificateRevocationCheckerTest.java b/web-eid-resilient-ocsp/src/test/java/eu/webeid/resilientocsp/ResilientOcspCertificateRevocationCheckerTest.java
similarity index 99%
rename from src/test/java/eu/webeid/resilientocsp/ResilientOcspCertificateRevocationCheckerTest.java
rename to web-eid-resilient-ocsp/src/test/java/eu/webeid/resilientocsp/ResilientOcspCertificateRevocationCheckerTest.java
index 2142bb85..a98920c6 100644
--- a/src/test/java/eu/webeid/resilientocsp/ResilientOcspCertificateRevocationCheckerTest.java
+++ b/web-eid-resilient-ocsp/src/test/java/eu/webeid/resilientocsp/ResilientOcspCertificateRevocationCheckerTest.java
@@ -8,10 +8,9 @@
import eu.webeid.ocsp.exceptions.OCSPClientException;
import eu.webeid.ocsp.exceptions.UserCertificateOCSPException;
import eu.webeid.ocsp.exceptions.UserCertificateUnknownStatusException;
-import eu.webeid.ocsp.service.FallbackOcspService;
import eu.webeid.ocsp.service.OcspService;
-import eu.webeid.security.util.DateAndTime;
import eu.webeid.ocsp.service.OcspServiceProvider;
+import eu.webeid.ocsp.service.ResilientFallbackOcspService;
import eu.webeid.resilientocsp.ResilientOcspCertificateRevocationChecker.CircuitBreakerStatistics;
import eu.webeid.resilientocsp.exceptions.ResilientUserCertificateOCSPCheckFailedException;
import eu.webeid.resilientocsp.exceptions.ResilientUserCertificateRevokedException;
@@ -51,9 +50,9 @@
import static eu.webeid.security.testutil.Certificates.getTestEsteid2018CA;
import static eu.webeid.security.testutil.DateMocker.mockDate;
import static eu.webeid.security.testutil.OcspResponses.buildOcspResponseBodyWithInvalidSignature;
+import static eu.webeid.security.testutil.ResourceUtil.bytesFromResource;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-import static eu.webeid.security.testutil.ResourceUtil.bytesFromResource;
import static org.awaitility.Awaitility.await;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
@@ -1454,9 +1453,9 @@ private ResilientOcspCertificateRevocationChecker build() throws Exception {
}
private OcspServiceProvider buildMockServiceProvider() throws Exception {
- FallbackOcspService nextFallback = null;
+ ResilientFallbackOcspService nextFallback = null;
for (int i = fallbackUris.length - 1; i >= 0; i--) {
- FallbackOcspService fallbackService = mock(FallbackOcspService.class);
+ ResilientFallbackOcspService fallbackService = mock(ResilientFallbackOcspService.class);
when(fallbackService.getAccessLocation()).thenReturn(fallbackUris[i]);
when(fallbackService.doesSupportNonce()).thenReturn(false);
when(fallbackService.getNextFallback()).thenReturn(nextFallback);