Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Nifi Add Custom Sensitive Field To Processor?

Solved Go to solution

Nifi Add Custom Sensitive Field To Processor?

Expert Contributor

I'm trying to add in a password field to an execute script processor, how do I make this field "sensitive"?

13862-nifi-question1.png

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Nifi Add Custom Sensitive Field To Processor?

With the ExecuteScript processor, you are likely just adding Dynamic Properties (also known as User-Defined Properties), which are not sensitive. To add your own sensitive properties to a scripted processor, you would need to use InvokeScriptedProcessor. There's an example from the NiFi mailing list (though not with sensitive properties, you'd just need to add .sensitive(true) to your PropertyDescriptor.Builder, and I have another example (with no added properties) on my blog.

7 REPLIES 7

Re: Nifi Add Custom Sensitive Field To Processor?

With the ExecuteScript processor, you are likely just adding Dynamic Properties (also known as User-Defined Properties), which are not sensitive. To add your own sensitive properties to a scripted processor, you would need to use InvokeScriptedProcessor. There's an example from the NiFi mailing list (though not with sensitive properties, you'd just need to add .sensitive(true) to your PropertyDescriptor.Builder, and I have another example (with no added properties) on my blog.

Re: Nifi Add Custom Sensitive Field To Processor?

Expert Contributor

Hi thanks for the response, I'm Trying to use this inside the custom processor script, but it is not showing up as a required parameter in InvokeScriptedProcessor. I currently have this in "script body", along with the rest of the class.

	def password = new PropertyDescriptor.Builder()
                                .name('Password')
                                .description("Password used to connect")
                                .required(true)				
				.sensitive(true)
                                .build()

Re: Nifi Add Custom Sensitive Field To Processor?

Check the getPropertyDescriptor() and getPropertyDescriptors() methods from the example in the mailing list (link above). You have to look up the descriptor by name in the former, and return a List of the PropertyDescriptors in the latter.

Re: Nifi Add Custom Sensitive Field To Processor?

Expert Contributor

Hi,

Your example is showing an error: "Unable to resolve class ProcessorLog"

I did a direct import of your template.

Re: Nifi Add Custom Sensitive Field To Processor?

That example was written against NiFi 0.x. In NiFi 1.x you can use ComponentLog rather than ProcessorLog.

Re: Nifi Add Custom Sensitive Field To Processor?

Expert Contributor

@Matt Burgess Is there anyway of not using the password in your examples if I had already setup password-less SSH. The groovy script is throwing an error if I try to not use the password.

Re: Nifi Add Custom Sensitive Field To Processor?

You can set .required(false) on your password property. Later on when the script would try to use the value (if it is set), you can call context.getProperty(password).isSet() to see if anything has been entered.

Don't have an account?
Coming from Hortonworks? Activate your account here