frankgh commented on code in PR #2652:
URL: https://github.com/apache/cassandra/pull/2652#discussion_r1430796979
##########
src/java/org/apache/cassandra/config/EncryptionOptions.java:
##########
@@ -67,6 +68,42 @@ public String description()
}
}
+ public enum ClientAuth
+ {
+ REQUIRED("true"),
+ NOT_REQUIRED("false"),
+ OPTIONAL("optional");
+ private final String value;
+ private static Map<String, ClientAuth> values = new HashMap<>();
+ static
+ {
+ for(final ClientAuth clientAuth: ClientAuth.values())
+ {
+ values.put(clientAuth.value, clientAuth);
+ values.put(clientAuth.name().toLowerCase(), clientAuth);
+ }
+ }
+
+ ClientAuth(String value)
+ {
+ this.value = value;
+ }
+
+ public static ClientAuth from(String value)
+ {
+ if(values.containsKey(value.toLowerCase()))
+ {
+ return values.get(value.toLowerCase());
+ };
Review Comment:
dangling semicolon
```suggestion
}
```
##########
src/java/org/apache/cassandra/config/EncryptionOptions.java:
##########
@@ -67,6 +68,42 @@ public String description()
}
}
+ public enum ClientAuth
+ {
+ REQUIRED("true"),
+ NOT_REQUIRED("false"),
+ OPTIONAL("optional");
+ private final String value;
+ private static Map<String, ClientAuth> values = new HashMap<>();
+ static
+ {
+ for(final ClientAuth clientAuth: ClientAuth.values())
+ {
+ values.put(clientAuth.value, clientAuth);
+ values.put(clientAuth.name().toLowerCase(), clientAuth);
+ }
+ }
+
+ ClientAuth(String value)
+ {
+ this.value = value;
+ }
+
+ public static ClientAuth from(String value)
+ {
+ if(values.containsKey(value.toLowerCase()))
Review Comment:
NIT spacing
```suggestion
if (values.containsKey(value.toLowerCase()))
```
##########
src/java/org/apache/cassandra/config/EncryptionOptions.java:
##########
@@ -67,6 +68,42 @@ public String description()
}
}
+ public enum ClientAuth
+ {
+ REQUIRED("true"),
+ NOT_REQUIRED("false"),
+ OPTIONAL("optional");
+ private final String value;
+ private static Map<String, ClientAuth> values = new HashMap<>();
+ static
+ {
+ for(final ClientAuth clientAuth: ClientAuth.values())
Review Comment:
NIT: Usage of final is discouraged in C* code style
```suggestion
for (ClientAuth clientAuth : ClientAuth.values())
```
##########
src/java/org/apache/cassandra/config/EncryptionOptions.java:
##########
@@ -67,6 +68,42 @@ public String description()
}
}
+ public enum ClientAuth
+ {
+ REQUIRED("true"),
+ NOT_REQUIRED("false"),
+ OPTIONAL("optional");
+ private final String value;
+ private static Map<String, ClientAuth> values = new HashMap<>();
Review Comment:
I would prefer a case insensitive treemap here, given that we are dealing
with user input, so both "Required" and "REQUIRED" would be valid configuration
options. Also, I think it is preferred to use final and I would uppercase this
field to denote it is a static final field
```suggestion
private static final Map<String, ClientAuth> VALUES = new
TreeMap<>(String.CASE_INSENSITIVE_ORDER);
```
##########
src/java/org/apache/cassandra/auth/MutualTlsWithPasswordFallbackAuthenticator.java:
##########
@@ -50,4 +55,15 @@ public SaslNegotiator newSaslNegotiator(InetAddress
clientAddress, Certificate[]
}
return mutualTlsAuthenticator.newSaslNegotiator(clientAddress,
certificates);
}
+
+ @Override
+ public void validateConfiguration() throws ConfigurationException
+ {
+ Config config = DatabaseDescriptor.getRawConfig();
+ if(config.client_encryption_options.getClientAuth() ==
EncryptionOptions.ClientAuth.NOT_REQUIRED)
Review Comment:
NIT:
```suggestion
if (config.client_encryption_options.getClientAuth() ==
EncryptionOptions.ClientAuth.NOT_REQUIRED)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]