Skip to content

Commit d0263ba

Browse files
authored
Update RevocationStrategy name to RevocationCheckingStrategy (#1283)
1 parent 51ec3f3 commit d0263ba

File tree

9 files changed

+68
-62
lines changed

9 files changed

+68
-62
lines changed

driver/src/main/java/org/neo4j/driver/Config.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ public enum Strategy {
691691
private final Strategy strategy;
692692
private final List<File> certFiles;
693693
private boolean hostnameVerificationEnabled = true;
694-
private RevocationStrategy revocationStrategy = RevocationStrategy.NO_CHECKS;
694+
private RevocationCheckingStrategy revocationCheckingStrategy = RevocationCheckingStrategy.NO_CHECKS;
695695

696696
private TrustStrategy(Strategy strategy) {
697697
this(strategy, Collections.emptyList());
@@ -802,8 +802,8 @@ public static TrustStrategy trustAllCertificates() {
802802
* The revocation strategy used for verifying certificates.
803803
* @return this {@link TrustStrategy}'s revocation strategy
804804
*/
805-
public RevocationStrategy revocationStrategy() {
806-
return revocationStrategy;
805+
public RevocationCheckingStrategy revocationCheckingStrategy() {
806+
return revocationCheckingStrategy;
807807
}
808808

809809
/**
@@ -812,7 +812,7 @@ public RevocationStrategy revocationStrategy() {
812812
* @return the current trust strategy
813813
*/
814814
public TrustStrategy withoutCertificateRevocationChecks() {
815-
this.revocationStrategy = RevocationStrategy.NO_CHECKS;
815+
this.revocationCheckingStrategy = RevocationCheckingStrategy.NO_CHECKS;
816816
return this;
817817
}
818818

@@ -824,7 +824,7 @@ public TrustStrategy withoutCertificateRevocationChecks() {
824824
* @return the current trust strategy
825825
*/
826826
public TrustStrategy withVerifyIfPresentRevocationChecks() {
827-
this.revocationStrategy = RevocationStrategy.VERIFY_IF_PRESENT;
827+
this.revocationCheckingStrategy = RevocationCheckingStrategy.VERIFY_IF_PRESENT;
828828
return this;
829829
}
830830

@@ -838,7 +838,7 @@ public TrustStrategy withVerifyIfPresentRevocationChecks() {
838838
* @return the current trust strategy
839839
*/
840840
public TrustStrategy withStrictRevocationChecks() {
841-
this.revocationStrategy = RevocationStrategy.STRICT;
841+
this.revocationCheckingStrategy = RevocationCheckingStrategy.STRICT;
842842
return this;
843843
}
844844
}

driver/src/main/java/org/neo4j/driver/RevocationStrategy.java renamed to driver/src/main/java/org/neo4j/driver/RevocationCheckingStrategy.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,18 @@
1818
*/
1919
package org.neo4j.driver;
2020

21-
public enum RevocationStrategy {
21+
/**
22+
* Defines strategy for revocation checks.
23+
*/
24+
public enum RevocationCheckingStrategy {
2225
/** Don't do any OCSP revocation checks, regardless whether there are stapled revocation statuses or not. */
2326
NO_CHECKS,
2427
/** Verify OCSP revocation checks when the revocation status is stapled to the certificate, continue if not. */
2528
VERIFY_IF_PRESENT,
2629
/** Require stapled revocation status and verify OCSP revocation checks, fail if no revocation status is stapled to the certificate. */
2730
STRICT;
2831

29-
public static boolean requiresRevocationChecking(RevocationStrategy revocationStrategy) {
30-
return revocationStrategy.equals(STRICT) || revocationStrategy.equals(VERIFY_IF_PRESENT);
32+
public static boolean requiresRevocationChecking(RevocationCheckingStrategy revocationCheckingStrategy) {
33+
return revocationCheckingStrategy.equals(STRICT) || revocationCheckingStrategy.equals(VERIFY_IF_PRESENT);
3134
}
3235
}

driver/src/main/java/org/neo4j/driver/internal/SecuritySettings.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import java.io.Serializable;
2727
import java.security.GeneralSecurityException;
2828
import org.neo4j.driver.Config;
29-
import org.neo4j.driver.RevocationStrategy;
29+
import org.neo4j.driver.RevocationCheckingStrategy;
3030
import org.neo4j.driver.exceptions.ClientException;
3131
import org.neo4j.driver.internal.security.SecurityPlan;
3232
import org.neo4j.driver.internal.security.SecurityPlanImpl;
@@ -67,7 +67,7 @@ private boolean hasEqualTrustStrategy(SecuritySettings other) {
6767
return t1.isHostnameVerificationEnabled() == t2.isHostnameVerificationEnabled()
6868
&& t1.strategy() == t2.strategy()
6969
&& t1.certFiles().equals(t2.certFiles())
70-
&& t1.revocationStrategy() == t2.revocationStrategy();
70+
&& t1.revocationCheckingStrategy() == t2.revocationCheckingStrategy();
7171
}
7272

7373
public SecurityPlan createSecurityPlan(String uriScheme) {
@@ -93,9 +93,9 @@ private void assertSecuritySettingsNotUserConfigured(String uriScheme) {
9393

9494
private SecurityPlan createSecurityPlanFromScheme(String scheme) throws GeneralSecurityException, IOException {
9595
if (isHighTrustScheme(scheme)) {
96-
return SecurityPlanImpl.forSystemCASignedCertificates(true, RevocationStrategy.NO_CHECKS);
96+
return SecurityPlanImpl.forSystemCASignedCertificates(true, RevocationCheckingStrategy.NO_CHECKS);
9797
} else {
98-
return SecurityPlanImpl.forAllCertificates(false, RevocationStrategy.NO_CHECKS);
98+
return SecurityPlanImpl.forAllCertificates(false, RevocationCheckingStrategy.NO_CHECKS);
9999
}
100100
}
101101

@@ -107,16 +107,16 @@ private static SecurityPlan createSecurityPlanImpl(boolean encrypted, Config.Tru
107107
throws GeneralSecurityException, IOException {
108108
if (encrypted) {
109109
boolean hostnameVerificationEnabled = trustStrategy.isHostnameVerificationEnabled();
110-
RevocationStrategy revocationStrategy = trustStrategy.revocationStrategy();
110+
RevocationCheckingStrategy revocationCheckingStrategy = trustStrategy.revocationCheckingStrategy();
111111
switch (trustStrategy.strategy()) {
112112
case TRUST_CUSTOM_CA_SIGNED_CERTIFICATES:
113113
return SecurityPlanImpl.forCustomCASignedCertificates(
114-
trustStrategy.certFiles(), hostnameVerificationEnabled, revocationStrategy);
114+
trustStrategy.certFiles(), hostnameVerificationEnabled, revocationCheckingStrategy);
115115
case TRUST_SYSTEM_CA_SIGNED_CERTIFICATES:
116116
return SecurityPlanImpl.forSystemCASignedCertificates(
117-
hostnameVerificationEnabled, revocationStrategy);
117+
hostnameVerificationEnabled, revocationCheckingStrategy);
118118
case TRUST_ALL_CERTIFICATES:
119-
return SecurityPlanImpl.forAllCertificates(hostnameVerificationEnabled, revocationStrategy);
119+
return SecurityPlanImpl.forAllCertificates(hostnameVerificationEnabled, revocationCheckingStrategy);
120120
default:
121121
throw new ClientException("Unknown TLS authentication strategy: "
122122
+ trustStrategy.strategy().name());

driver/src/main/java/org/neo4j/driver/internal/security/SecurityPlan.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
package org.neo4j.driver.internal.security;
2020

2121
import javax.net.ssl.SSLContext;
22-
import org.neo4j.driver.RevocationStrategy;
22+
import org.neo4j.driver.RevocationCheckingStrategy;
2323

2424
/**
2525
* A SecurityPlan consists of encryption and trust details.
@@ -31,5 +31,5 @@ public interface SecurityPlan {
3131

3232
boolean requiresHostnameVerification();
3333

34-
RevocationStrategy revocationStrategy();
34+
RevocationCheckingStrategy revocationCheckingStrategy();
3535
}

driver/src/main/java/org/neo4j/driver/internal/security/SecurityPlanImpl.java

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
*/
1919
package org.neo4j.driver.internal.security;
2020

21-
import static org.neo4j.driver.RevocationStrategy.VERIFY_IF_PRESENT;
22-
import static org.neo4j.driver.RevocationStrategy.requiresRevocationChecking;
21+
import static org.neo4j.driver.RevocationCheckingStrategy.VERIFY_IF_PRESENT;
22+
import static org.neo4j.driver.RevocationCheckingStrategy.requiresRevocationChecking;
2323
import static org.neo4j.driver.internal.util.CertificateTool.loadX509Cert;
2424

2525
import java.io.File;
@@ -41,36 +41,39 @@
4141
import javax.net.ssl.TrustManager;
4242
import javax.net.ssl.TrustManagerFactory;
4343
import javax.net.ssl.X509TrustManager;
44-
import org.neo4j.driver.RevocationStrategy;
44+
import org.neo4j.driver.RevocationCheckingStrategy;
4545

4646
/**
4747
* A SecurityPlan consists of encryption and trust details.
4848
*/
4949
public class SecurityPlanImpl implements SecurityPlan {
5050
public static SecurityPlan forAllCertificates(
51-
boolean requiresHostnameVerification, RevocationStrategy revocationStrategy)
51+
boolean requiresHostnameVerification, RevocationCheckingStrategy revocationCheckingStrategy)
5252
throws GeneralSecurityException {
5353
SSLContext sslContext = SSLContext.getInstance("TLS");
5454
sslContext.init(new KeyManager[0], new TrustManager[] {new TrustAllTrustManager()}, null);
5555

56-
return new SecurityPlanImpl(true, sslContext, requiresHostnameVerification, revocationStrategy);
56+
return new SecurityPlanImpl(true, sslContext, requiresHostnameVerification, revocationCheckingStrategy);
5757
}
5858

5959
public static SecurityPlan forCustomCASignedCertificates(
60-
List<File> certFiles, boolean requiresHostnameVerification, RevocationStrategy revocationStrategy)
60+
List<File> certFiles,
61+
boolean requiresHostnameVerification,
62+
RevocationCheckingStrategy revocationCheckingStrategy)
6163
throws GeneralSecurityException, IOException {
62-
SSLContext sslContext = configureSSLContext(certFiles, revocationStrategy);
63-
return new SecurityPlanImpl(true, sslContext, requiresHostnameVerification, revocationStrategy);
64+
SSLContext sslContext = configureSSLContext(certFiles, revocationCheckingStrategy);
65+
return new SecurityPlanImpl(true, sslContext, requiresHostnameVerification, revocationCheckingStrategy);
6466
}
6567

6668
public static SecurityPlan forSystemCASignedCertificates(
67-
boolean requiresHostnameVerification, RevocationStrategy revocationStrategy)
69+
boolean requiresHostnameVerification, RevocationCheckingStrategy revocationCheckingStrategy)
6870
throws GeneralSecurityException, IOException {
69-
SSLContext sslContext = configureSSLContext(Collections.emptyList(), revocationStrategy);
70-
return new SecurityPlanImpl(true, sslContext, requiresHostnameVerification, revocationStrategy);
71+
SSLContext sslContext = configureSSLContext(Collections.emptyList(), revocationCheckingStrategy);
72+
return new SecurityPlanImpl(true, sslContext, requiresHostnameVerification, revocationCheckingStrategy);
7173
}
7274

73-
private static SSLContext configureSSLContext(List<File> customCertFiles, RevocationStrategy revocationStrategy)
75+
private static SSLContext configureSSLContext(
76+
List<File> customCertFiles, RevocationCheckingStrategy revocationCheckingStrategy)
7477
throws GeneralSecurityException, IOException {
7578
KeyStore trustedKeyStore = KeyStore.getInstance(KeyStore.getDefaultType());
7679
trustedKeyStore.load(null, null);
@@ -83,7 +86,7 @@ private static SSLContext configureSSLContext(List<File> customCertFiles, Revoca
8386
}
8487

8588
PKIXBuilderParameters pkixBuilderParameters =
86-
configurePKIXBuilderParameters(trustedKeyStore, revocationStrategy);
89+
configurePKIXBuilderParameters(trustedKeyStore, revocationCheckingStrategy);
8790

8891
SSLContext sslContext = SSLContext.getInstance("TLS");
8992
TrustManagerFactory trustManagerFactory =
@@ -101,11 +104,11 @@ private static SSLContext configureSSLContext(List<File> customCertFiles, Revoca
101104
}
102105

103106
private static PKIXBuilderParameters configurePKIXBuilderParameters(
104-
KeyStore trustedKeyStore, RevocationStrategy revocationStrategy)
107+
KeyStore trustedKeyStore, RevocationCheckingStrategy revocationCheckingStrategy)
105108
throws InvalidAlgorithmParameterException, KeyStoreException {
106109
PKIXBuilderParameters pkixBuilderParameters = null;
107110

108-
if (requiresRevocationChecking(revocationStrategy)) {
111+
if (requiresRevocationChecking(revocationCheckingStrategy)) {
109112
// Configure certificate revocation checking (X509CertSelector() selects all certificates)
110113
pkixBuilderParameters = new PKIXBuilderParameters(trustedKeyStore, new X509CertSelector());
111114

@@ -115,7 +118,7 @@ private static PKIXBuilderParameters configurePKIXBuilderParameters(
115118
// enables status_request extension in client hello
116119
System.setProperty("jdk.tls.client.enableStatusRequestExtension", "true");
117120

118-
if (revocationStrategy.equals(VERIFY_IF_PRESENT)) {
121+
if (revocationCheckingStrategy.equals(VERIFY_IF_PRESENT)) {
119122
// enables soft-fail behaviour if no stapled response found.
120123
Security.setProperty("ocsp.enable", "true");
121124
}
@@ -146,23 +149,23 @@ private static void loadSystemCertificates(KeyStore trustedKeyStore) throws Gene
146149
}
147150

148151
public static SecurityPlan insecure() {
149-
return new SecurityPlanImpl(false, null, false, RevocationStrategy.NO_CHECKS);
152+
return new SecurityPlanImpl(false, null, false, RevocationCheckingStrategy.NO_CHECKS);
150153
}
151154

152155
private final boolean requiresEncryption;
153156
private final SSLContext sslContext;
154157
private final boolean requiresHostnameVerification;
155-
private final RevocationStrategy revocationStrategy;
158+
private final RevocationCheckingStrategy revocationCheckingStrategy;
156159

157160
private SecurityPlanImpl(
158161
boolean requiresEncryption,
159162
SSLContext sslContext,
160163
boolean requiresHostnameVerification,
161-
RevocationStrategy revocationStrategy) {
164+
RevocationCheckingStrategy revocationCheckingStrategy) {
162165
this.requiresEncryption = requiresEncryption;
163166
this.sslContext = sslContext;
164167
this.requiresHostnameVerification = requiresHostnameVerification;
165-
this.revocationStrategy = revocationStrategy;
168+
this.revocationCheckingStrategy = revocationCheckingStrategy;
166169
}
167170

168171
@Override
@@ -181,8 +184,8 @@ public boolean requiresHostnameVerification() {
181184
}
182185

183186
@Override
184-
public RevocationStrategy revocationStrategy() {
185-
return revocationStrategy;
187+
public RevocationCheckingStrategy revocationCheckingStrategy() {
188+
return revocationCheckingStrategy;
186189
}
187190

188191
private static class TrustAllTrustManager implements X509TrustManager {

driver/src/test/java/org/neo4j/driver/ConfigTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
import static org.junit.jupiter.api.Assertions.assertThrows;
2727
import static org.junit.jupiter.api.Assertions.assertTrue;
2828
import static org.mockito.Mockito.mock;
29-
import static org.neo4j.driver.RevocationStrategy.NO_CHECKS;
30-
import static org.neo4j.driver.RevocationStrategy.STRICT;
31-
import static org.neo4j.driver.RevocationStrategy.VERIFY_IF_PRESENT;
29+
import static org.neo4j.driver.RevocationCheckingStrategy.NO_CHECKS;
30+
import static org.neo4j.driver.RevocationCheckingStrategy.STRICT;
31+
import static org.neo4j.driver.RevocationCheckingStrategy.VERIFY_IF_PRESENT;
3232
import static org.neo4j.driver.internal.handlers.pulln.FetchSizeUtil.DEFAULT_FETCH_SIZE;
3333

3434
import java.io.File;
@@ -282,16 +282,16 @@ void shouldEnableAndDisableHostnameVerificationOnTrustStrategy() {
282282
@Test
283283
void shouldEnableAndDisableCertificateRevocationChecksOnTestStrategy() {
284284
Config.TrustStrategy trustStrategy = Config.TrustStrategy.trustSystemCertificates();
285-
assertEquals(NO_CHECKS, trustStrategy.revocationStrategy());
285+
assertEquals(NO_CHECKS, trustStrategy.revocationCheckingStrategy());
286286

287287
assertSame(trustStrategy, trustStrategy.withoutCertificateRevocationChecks());
288-
assertEquals(NO_CHECKS, trustStrategy.revocationStrategy());
288+
assertEquals(NO_CHECKS, trustStrategy.revocationCheckingStrategy());
289289

290290
assertSame(trustStrategy, trustStrategy.withStrictRevocationChecks());
291-
assertEquals(STRICT, trustStrategy.revocationStrategy());
291+
assertEquals(STRICT, trustStrategy.revocationCheckingStrategy());
292292

293293
assertSame(trustStrategy, trustStrategy.withVerifyIfPresentRevocationChecks());
294-
assertEquals(VERIFY_IF_PRESENT, trustStrategy.revocationStrategy());
294+
assertEquals(VERIFY_IF_PRESENT, trustStrategy.revocationCheckingStrategy());
295295
}
296296

297297
@Test
@@ -429,8 +429,8 @@ void shouldSerialize() throws Exception {
429429
config.trustStrategy().isHostnameVerificationEnabled(),
430430
verify.trustStrategy().isHostnameVerificationEnabled());
431431
assertEquals(
432-
config.trustStrategy().revocationStrategy(),
433-
verify.trustStrategy().revocationStrategy());
432+
config.trustStrategy().revocationCheckingStrategy(),
433+
verify.trustStrategy().revocationCheckingStrategy());
434434
assertEquals(config.userAgent(), verify.userAgent());
435435
assertEquals(config.isMetricsEnabled(), verify.isMetricsEnabled());
436436
assertEquals(config.metricsAdapter(), verify.metricsAdapter());

driver/src/test/java/org/neo4j/driver/integration/ChannelConnectorImplIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
import org.junit.jupiter.api.extension.RegisterExtension;
5050
import org.neo4j.driver.AuthToken;
5151
import org.neo4j.driver.AuthTokens;
52-
import org.neo4j.driver.RevocationStrategy;
52+
import org.neo4j.driver.RevocationCheckingStrategy;
5353
import org.neo4j.driver.exceptions.AuthenticationException;
5454
import org.neo4j.driver.exceptions.ServiceUnavailableException;
5555
import org.neo4j.driver.internal.BoltServerAddress;
@@ -222,6 +222,6 @@ private ChannelConnectorImpl newConnector(
222222
}
223223

224224
private static SecurityPlan trustAllCertificates() throws GeneralSecurityException {
225-
return SecurityPlanImpl.forAllCertificates(false, RevocationStrategy.NO_CHECKS);
225+
return SecurityPlanImpl.forAllCertificates(false, RevocationCheckingStrategy.NO_CHECKS);
226226
}
227227
}

driver/src/test/java/org/neo4j/driver/internal/SecuritySettingsTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
import static org.junit.jupiter.api.Assertions.assertFalse;
2323
import static org.junit.jupiter.api.Assertions.assertThrows;
2424
import static org.junit.jupiter.api.Assertions.assertTrue;
25-
import static org.neo4j.driver.RevocationStrategy.NO_CHECKS;
26-
import static org.neo4j.driver.RevocationStrategy.STRICT;
27-
import static org.neo4j.driver.RevocationStrategy.VERIFY_IF_PRESENT;
25+
import static org.neo4j.driver.RevocationCheckingStrategy.NO_CHECKS;
26+
import static org.neo4j.driver.RevocationCheckingStrategy.STRICT;
27+
import static org.neo4j.driver.RevocationCheckingStrategy.VERIFY_IF_PRESENT;
2828

2929
import java.io.File;
3030
import java.io.IOException;
@@ -77,7 +77,7 @@ void testSystemCertCompatibleConfiguration(String scheme) throws Exception {
7777

7878
assertTrue(securityPlan.requiresEncryption());
7979
assertTrue(securityPlan.requiresHostnameVerification());
80-
assertEquals(NO_CHECKS, securityPlan.revocationStrategy());
80+
assertEquals(NO_CHECKS, securityPlan.revocationCheckingStrategy());
8181
}
8282

8383
@ParameterizedTest
@@ -178,7 +178,7 @@ void testConfigureStrictRevocationChecking(String scheme) {
178178

179179
SecurityPlan securityPlan = securitySettings.createSecurityPlan(scheme);
180180

181-
assertEquals(STRICT, securityPlan.revocationStrategy());
181+
assertEquals(STRICT, securityPlan.revocationCheckingStrategy());
182182
}
183183

184184
@ParameterizedTest
@@ -192,7 +192,7 @@ void testConfigureVerifyIfPresentRevocationChecking(String scheme) {
192192

193193
SecurityPlan securityPlan = securitySettings.createSecurityPlan(scheme);
194194

195-
assertEquals(VERIFY_IF_PRESENT, securityPlan.revocationStrategy());
195+
assertEquals(VERIFY_IF_PRESENT, securityPlan.revocationCheckingStrategy());
196196
}
197197

198198
@ParameterizedTest
@@ -205,7 +205,7 @@ void testRevocationCheckingDisabledByDefault(String scheme) {
205205

206206
SecurityPlan securityPlan = securitySettings.createSecurityPlan(scheme);
207207

208-
assertEquals(NO_CHECKS, securityPlan.revocationStrategy());
208+
assertEquals(NO_CHECKS, securityPlan.revocationCheckingStrategy());
209209
}
210210

211211
@Nested

0 commit comments

Comments
 (0)