milleruntime commented on a change in pull request #1968:
URL: https://github.com/apache/accumulo/pull/1968#discussion_r597790646



##########
File path: core/src/main/java/org/apache/accumulo/core/crypto/CryptoUtils.java
##########
@@ -84,4 +84,65 @@ public static void writeParams(byte[] decryptionParams, 
DataOutputStream out) th
     out.write(decryptionParams);
   }
 
+  public static Property getPropPerScope(CryptoService.Scope scope) {
+    return (scope == RFILE ? TABLE_CRYPTO_ENCRYPT_SERVICE : 
TSERV_WALOG_CRYPTO_ENCRYPT_SERVICE);
+  }
+
+  public static Property getPrefixPerScope(CryptoService.Scope scope) {
+    return (scope == RFILE ? TABLE_CRYPTO_PREFIX : TSERV_WALOG_CRYPTO_PREFIX);
+  }
+
+  /**
+   * Read the crypto service name from decryptionParams and if it matches one 
of the provided
+   * decrypters, call the init method and return the FileDecrypter. The crypto 
service name is
+   * required to be the first bytes written to the decryptionParams.
+   */
+  public static FileDecrypter getDecrypterInitialized(CryptoService.Scope 
scope,
+      List<CryptoService> decrypters, byte[] decryptionParams) {
+    if (decryptionParams == null || checkNoCrypto(decryptionParams))
+      return NoCryptoService.NO_DECRYPT;
+
+    String nameInFile = getCryptoServiceName(decryptionParams);
+    CryptoService cs = null;
+    // check if service in file matches what was loaded from config
+    for (CryptoService d : decrypters) {
+      if (d.getClass().getName().equals(nameInFile)) {
+        cs = d;
+        break;
+      }
+    }
+    if (cs == null)
+      throw new CryptoException("Unknown crypto class found in " + scope + " 
file: " + nameInFile);

Review comment:
       I am not sure but I thought we still need a way to tell the 
CryptoService which type of file, since a user can still implement one to be 
used for both.




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to