This is an automated email from the ASF dual-hosted git repository.
pvillard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new d60f541d7e NIFI-11098 Deprecated ProcessContext encrypt and decrypt
methods
d60f541d7e is described below
commit d60f541d7edc89b968a932109be3c088b3d1bcf8
Author: exceptionfactory <[email protected]>
AuthorDate: Wed Jan 25 20:19:32 2023 -0600
NIFI-11098 Deprecated ProcessContext encrypt and decrypt methods
Signed-off-by: Pierre Villard <[email protected]>
This closes #6891.
---
.../src/main/java/org/apache/nifi/processor/ProcessContext.java | 4 ++++
.../repository/scheduling/ConnectableProcessContext.java | 7 +++++++
.../java/org/apache/nifi/processor/StandardProcessContext.java | 8 ++++++++
3 files changed, 19 insertions(+)
diff --git
a/nifi-api/src/main/java/org/apache/nifi/processor/ProcessContext.java
b/nifi-api/src/main/java/org/apache/nifi/processor/ProcessContext.java
index 9db1289a07..cbb67574c7 100644
--- a/nifi-api/src/main/java/org/apache/nifi/processor/ProcessContext.java
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/ProcessContext.java
@@ -99,18 +99,22 @@ public interface ProcessContext extends PropertyContext,
ClusterContext {
* Encrypts the given value using the password provided in the NiFi
* Properties
*
+ * @deprecated Processors should not depend on framework encryption
operations
* @param unencrypted plaintext value
* @return encrypted value
*/
+ @Deprecated
String encrypt(String unencrypted);
/**
* Decrypts the given value using the password provided in the NiFi
* Properties
*
+ * @deprecated Processors should not depend on framework encryption
operations
* @param encrypted the encrypted value
* @return the plaintext value
*/
+ @Deprecated
String decrypt(String encrypted);
/**
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/repository/scheduling/ConnectableProcessContext.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/repository/scheduling/ConnectableProcessContext.java
index c2a0879b35..40cf69d522 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/repository/scheduling/ConnectableProcessContext.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/repository/scheduling/ConnectableProcessContext.java
@@ -25,6 +25,8 @@ import org.apache.nifi.connectable.Connectable;
import org.apache.nifi.connectable.Connection;
import org.apache.nifi.controller.ControllerService;
import org.apache.nifi.controller.ControllerServiceLookup;
+import org.apache.nifi.deprecation.log.DeprecationLogger;
+import org.apache.nifi.deprecation.log.DeprecationLoggerFactory;
import org.apache.nifi.encrypt.PropertyEncryptor;
import org.apache.nifi.expression.AttributeValueDecorator;
import org.apache.nifi.flowfile.FlowFile;
@@ -52,10 +54,13 @@ public class ConnectableProcessContext implements
ProcessContext {
private final PropertyEncryptor propertyEncryptor;
private final StateManager stateManager;
+ private final DeprecationLogger deprecationLogger;
+
public ConnectableProcessContext(final Connectable connectable, final
PropertyEncryptor propertyEncryptor, final StateManager stateManager) {
this.connectable = connectable;
this.propertyEncryptor = propertyEncryptor;
this.stateManager = stateManager;
+ this.deprecationLogger =
DeprecationLoggerFactory.getLogger(connectable.getClass());
}
@Override
@@ -224,11 +229,13 @@ public class ConnectableProcessContext implements
ProcessContext {
@Override
public String decrypt(String encrypted) {
+ deprecationLogger.warn("ProcessContext.decrypt() should be replaced an
alternative implementation");
return propertyEncryptor.decrypt(encrypted);
}
@Override
public String encrypt(String unencrypted) {
+ deprecationLogger.warn("ProcessContext.encrypt() should be replaced an
alternative implementation");
return propertyEncryptor.encrypt(unencrypted);
}
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/processor/StandardProcessContext.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/processor/StandardProcessContext.java
index 795db39b1c..3a4f793a8f 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/processor/StandardProcessContext.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/processor/StandardProcessContext.java
@@ -36,6 +36,8 @@ import org.apache.nifi.controller.PropertyConfiguration;
import org.apache.nifi.controller.PropertyConfigurationMapper;
import org.apache.nifi.controller.lifecycle.TaskTermination;
import org.apache.nifi.controller.service.ControllerServiceProvider;
+import org.apache.nifi.deprecation.log.DeprecationLogger;
+import org.apache.nifi.deprecation.log.DeprecationLoggerFactory;
import org.apache.nifi.encrypt.PropertyEncryptor;
import org.apache.nifi.parameter.ParameterLookup;
import org.apache.nifi.processor.exception.TerminatedTaskException;
@@ -62,6 +64,7 @@ public class StandardProcessContext implements
ProcessContext, ControllerService
private final NodeTypeProvider nodeTypeProvider;
private final Map<PropertyDescriptor, String> properties;
private final String annotationData;
+ private final DeprecationLogger deprecationLogger;
public StandardProcessContext(final ProcessorNode processorNode, final
ControllerServiceProvider controllerServiceProvider, final PropertyEncryptor
propertyEncryptor,
@@ -89,6 +92,9 @@ public class StandardProcessContext implements
ProcessContext, ControllerService
this.taskTermination = taskTermination;
this.nodeTypeProvider = nodeTypeProvider;
this.annotationData = annotationData;
+ final Class<?> componentClass = processorNode.getComponentClass();
+ final Class<?> loggerClass = componentClass == null ? getClass() :
componentClass;
+ this.deprecationLogger =
DeprecationLoggerFactory.getLogger(loggerClass);
properties = Collections.unmodifiableMap(propertyValues);
@@ -227,12 +233,14 @@ public class StandardProcessContext implements
ProcessContext, ControllerService
@Override
public String encrypt(final String unencrypted) {
verifyTaskActive();
+ deprecationLogger.warn("ProcessContext.encrypt() should be replaced an
alternative implementation");
return propertyEncryptor.encrypt(unencrypted);
}
@Override
public String decrypt(final String encrypted) {
verifyTaskActive();
+ deprecationLogger.warn("ProcessContext.decrypt() should be replaced an
alternative implementation");
return propertyEncryptor.decrypt(encrypted);
}