keith-turner commented on a change in pull request #345: ACCUMULO-4769 Sanity 
check for valid CryptoModule and KeyEncryptionStrategy in config
URL: https://github.com/apache/accumulo/pull/345#discussion_r173194554
 
 

 ##########
 File path: 
core/src/main/java/org/apache/accumulo/core/security/crypto/CryptoModuleFactory.java
 ##########
 @@ -146,49 +136,40 @@ public static SecretKeyEncryptionStrategy 
getSecretKeyEncryptionStrategy(String
     return strategy;
   }
 
-  @SuppressWarnings("rawtypes")
   private static SecretKeyEncryptionStrategy 
instantiateSecreteKeyEncryptionStrategy(String className) {
 
     log.debug("About to instantiate secret key encryption strategy {}", 
className);
 
     SecretKeyEncryptionStrategy strategy = null;
-    Class keyEncryptionStrategyClazz = null;
+    Class<?> keyEncryptionStrategyClazz = null;
     try {
       keyEncryptionStrategyClazz = AccumuloVFSClassLoader.loadClass(className);
     } catch (ClassNotFoundException e1) {
-      log.warn("Could not find configured secret key encryption strategy 
\"{}\".  No encryption will be used.", className);
-      return new NullSecretKeyEncryptionStrategy();
+      throw new IllegalArgumentException("Could not find configured secret key 
encryption strategy: " + className);
     }
 
     // Check if the given class implements the CryptoModule interface
-    Class[] interfaces = keyEncryptionStrategyClazz.getInterfaces();
+    Class<?>[] interfaces = keyEncryptionStrategyClazz.getInterfaces();
     boolean implementsSecretKeyStrategy = false;
 
-    for (Class clazz : interfaces) {
+    for (Class<?> clazz : interfaces) {
       if (clazz.equals(SecretKeyEncryptionStrategy.class)) {
         implementsSecretKeyStrategy = true;
         break;
       }
     }
 
     if (!implementsSecretKeyStrategy) {
-      log.warn("Configured Accumulo secret key encryption strategy \"%s\" does 
not implement the SecretKeyEncryptionStrategy interface. No encryption will be 
used.");
-      return new NullSecretKeyEncryptionStrategy();
+      throw new IllegalArgumentException(
+          "Configured Accumulo secret key encryption strategy \"%s\" does not 
implement the SecretKeyEncryptionStrategy interface.");
     } else {
       try {
         strategy = (SecretKeyEncryptionStrategy) 
keyEncryptionStrategyClazz.newInstance();
 
 Review comment:
   Should be able to drop this cast when class type is `Class<? extends 
SecretKeyEncryptionStrategy>`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to