18
18
*/
19
19
package org .neo4j .driver .internal .security ;
20
20
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 ;
23
23
import static org .neo4j .driver .internal .util .CertificateTool .loadX509Cert ;
24
24
25
25
import java .io .File ;
41
41
import javax .net .ssl .TrustManager ;
42
42
import javax .net .ssl .TrustManagerFactory ;
43
43
import javax .net .ssl .X509TrustManager ;
44
- import org .neo4j .driver .RevocationStrategy ;
44
+ import org .neo4j .driver .RevocationCheckingStrategy ;
45
45
46
46
/**
47
47
* A SecurityPlan consists of encryption and trust details.
48
48
*/
49
49
public class SecurityPlanImpl implements SecurityPlan {
50
50
public static SecurityPlan forAllCertificates (
51
- boolean requiresHostnameVerification , RevocationStrategy revocationStrategy )
51
+ boolean requiresHostnameVerification , RevocationCheckingStrategy revocationCheckingStrategy )
52
52
throws GeneralSecurityException {
53
53
SSLContext sslContext = SSLContext .getInstance ("TLS" );
54
54
sslContext .init (new KeyManager [0 ], new TrustManager [] {new TrustAllTrustManager ()}, null );
55
55
56
- return new SecurityPlanImpl (true , sslContext , requiresHostnameVerification , revocationStrategy );
56
+ return new SecurityPlanImpl (true , sslContext , requiresHostnameVerification , revocationCheckingStrategy );
57
57
}
58
58
59
59
public static SecurityPlan forCustomCASignedCertificates (
60
- List <File > certFiles , boolean requiresHostnameVerification , RevocationStrategy revocationStrategy )
60
+ List <File > certFiles ,
61
+ boolean requiresHostnameVerification ,
62
+ RevocationCheckingStrategy revocationCheckingStrategy )
61
63
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 );
64
66
}
65
67
66
68
public static SecurityPlan forSystemCASignedCertificates (
67
- boolean requiresHostnameVerification , RevocationStrategy revocationStrategy )
69
+ boolean requiresHostnameVerification , RevocationCheckingStrategy revocationCheckingStrategy )
68
70
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 );
71
73
}
72
74
73
- private static SSLContext configureSSLContext (List <File > customCertFiles , RevocationStrategy revocationStrategy )
75
+ private static SSLContext configureSSLContext (
76
+ List <File > customCertFiles , RevocationCheckingStrategy revocationCheckingStrategy )
74
77
throws GeneralSecurityException , IOException {
75
78
KeyStore trustedKeyStore = KeyStore .getInstance (KeyStore .getDefaultType ());
76
79
trustedKeyStore .load (null , null );
@@ -83,7 +86,7 @@ private static SSLContext configureSSLContext(List<File> customCertFiles, Revoca
83
86
}
84
87
85
88
PKIXBuilderParameters pkixBuilderParameters =
86
- configurePKIXBuilderParameters (trustedKeyStore , revocationStrategy );
89
+ configurePKIXBuilderParameters (trustedKeyStore , revocationCheckingStrategy );
87
90
88
91
SSLContext sslContext = SSLContext .getInstance ("TLS" );
89
92
TrustManagerFactory trustManagerFactory =
@@ -101,11 +104,11 @@ private static SSLContext configureSSLContext(List<File> customCertFiles, Revoca
101
104
}
102
105
103
106
private static PKIXBuilderParameters configurePKIXBuilderParameters (
104
- KeyStore trustedKeyStore , RevocationStrategy revocationStrategy )
107
+ KeyStore trustedKeyStore , RevocationCheckingStrategy revocationCheckingStrategy )
105
108
throws InvalidAlgorithmParameterException , KeyStoreException {
106
109
PKIXBuilderParameters pkixBuilderParameters = null ;
107
110
108
- if (requiresRevocationChecking (revocationStrategy )) {
111
+ if (requiresRevocationChecking (revocationCheckingStrategy )) {
109
112
// Configure certificate revocation checking (X509CertSelector() selects all certificates)
110
113
pkixBuilderParameters = new PKIXBuilderParameters (trustedKeyStore , new X509CertSelector ());
111
114
@@ -115,7 +118,7 @@ private static PKIXBuilderParameters configurePKIXBuilderParameters(
115
118
// enables status_request extension in client hello
116
119
System .setProperty ("jdk.tls.client.enableStatusRequestExtension" , "true" );
117
120
118
- if (revocationStrategy .equals (VERIFY_IF_PRESENT )) {
121
+ if (revocationCheckingStrategy .equals (VERIFY_IF_PRESENT )) {
119
122
// enables soft-fail behaviour if no stapled response found.
120
123
Security .setProperty ("ocsp.enable" , "true" );
121
124
}
@@ -146,23 +149,23 @@ private static void loadSystemCertificates(KeyStore trustedKeyStore) throws Gene
146
149
}
147
150
148
151
public static SecurityPlan insecure () {
149
- return new SecurityPlanImpl (false , null , false , RevocationStrategy .NO_CHECKS );
152
+ return new SecurityPlanImpl (false , null , false , RevocationCheckingStrategy .NO_CHECKS );
150
153
}
151
154
152
155
private final boolean requiresEncryption ;
153
156
private final SSLContext sslContext ;
154
157
private final boolean requiresHostnameVerification ;
155
- private final RevocationStrategy revocationStrategy ;
158
+ private final RevocationCheckingStrategy revocationCheckingStrategy ;
156
159
157
160
private SecurityPlanImpl (
158
161
boolean requiresEncryption ,
159
162
SSLContext sslContext ,
160
163
boolean requiresHostnameVerification ,
161
- RevocationStrategy revocationStrategy ) {
164
+ RevocationCheckingStrategy revocationCheckingStrategy ) {
162
165
this .requiresEncryption = requiresEncryption ;
163
166
this .sslContext = sslContext ;
164
167
this .requiresHostnameVerification = requiresHostnameVerification ;
165
- this .revocationStrategy = revocationStrategy ;
168
+ this .revocationCheckingStrategy = revocationCheckingStrategy ;
166
169
}
167
170
168
171
@ Override
@@ -181,8 +184,8 @@ public boolean requiresHostnameVerification() {
181
184
}
182
185
183
186
@ Override
184
- public RevocationStrategy revocationStrategy () {
185
- return revocationStrategy ;
187
+ public RevocationCheckingStrategy revocationCheckingStrategy () {
188
+ return revocationCheckingStrategy ;
186
189
}
187
190
188
191
private static class TrustAllTrustManager implements X509TrustManager {
0 commit comments