bbende commented on a change in pull request #4427:
URL: https://github.com/apache/nifi/pull/4427#discussion_r460290036



##########
File path: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/encrypt/StringEncryptor.java
##########
@@ -267,6 +296,16 @@ private boolean paramsAreValid() {
         return algorithmAndProviderValid && secretIsValid;
     }
 
+    private boolean customSecretIsValid(PBEKeySpec password, SecretKeySpec 
key, String algorithm) {
+        // Currently, the only custom algorithms use AES-G/CM with a password 
via Argon2
+        String rawPassword = new String(password.getPassword());
+        final boolean secretIsValid = StringUtils.isNotBlank(rawPassword) && 
rawPassword.trim().length() >= 12;
+        if (!secretIsValid) {
+            logger.error("The nifi.sensitive.props.key password provided is 
invalid for algorithm {}; must be >= 12 characters", algorithm);

Review comment:
       This message is really helpful for the user to know the problem. One 
minor issue is that the exception that prints to the log doesn't end up 
including this, it just ends with:
   ```
   
   Caused by: org.apache.nifi.encrypt.EncryptionException: Cannot initialize 
the StringEncryptor because some configuration values are invalid
        at 
org.apache.nifi.encrypt.StringEncryptor.initialize(StringEncryptor.java:270)
        at 
org.apache.nifi.encrypt.StringEncryptor.<init>(StringEncryptor.java:137)
        at 
org.apache.nifi.encrypt.StringEncryptor.createEncryptor(StringEncryptor.java:236)
        at 
org.apache.nifi.encrypt.StringEncryptor.createEncryptor(StringEncryptor.java:209)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at 
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
        ... 58 common frames omitted
   ```
   
   Was wondering if we could get that same message into the exception so its 
not missed and is clear what needs to be fixed. 




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