Meant to add that there are Groovy unit tests for those classes so you may be able to copy the code directly from [1] and [2].
[1] https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-properties-loader/src/test/groovy/org/apache/nifi/properties/ProtectedNiFiPropertiesGroovyTest.groovy <https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-properties-loader/src/test/groovy/org/apache/nifi/properties/ProtectedNiFiPropertiesGroovyTest.groovy> [2] https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-properties-loader/src/test/groovy/org/apache/nifi/properties/NiFiPropertiesLoaderGroovyTest.groovy <https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-properties-loader/src/test/groovy/org/apache/nifi/properties/NiFiPropertiesLoaderGroovyTest.groovy> Andy LoPresto [email protected] [email protected] PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4 BACE 3C6E F65B 2F7D EF69 > On Sep 23, 2016, at 7:45 PM, Andy LoPresto <[email protected]> wrote: > > Tom, > > You’ll want to take a look at ProtectedNiFiProperties [1] and > NiFiPropertiesLoader [2]. ProtectedNiFiProperties provides a decorator on a > normal NiFiProperties class which allows access to various values via key > access or through named getters. It “unprotects” the values and can return a > regular NiFiProperties instance with direct access to the plain values. The > NiFiPropertiesLoader can be instantiated with the decryption key (currently > the only supported protection scheme is AES/GCM encryption) and can load > multiple instances of the NiFiProperties directly from any nifi.properties > file simultaneously. > > If you wanted to do this with a non-native file (i.e. a source that NiFi does > not have an internal mechanism for reading), you’d probably use a GetFile -> > ExtractText -> EncryptContent processor chain, or the ExecuteScript processor > (Groovy and other scripting languages have extensive tooling provided to > easily read from files, parse text, etc.). > > [1] > https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-properties-loader/src/main/java/org/apache/nifi/properties/ProtectedNiFiProperties.java > > <https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-properties-loader/src/main/java/org/apache/nifi/properties/ProtectedNiFiProperties.java> > [2] > https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-properties-loader/src/main/java/org/apache/nifi/properties/NiFiPropertiesLoader.java > > <https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-properties-loader/src/main/java/org/apache/nifi/properties/NiFiPropertiesLoader.java> > > > Andy LoPresto > [email protected] <mailto:[email protected]> > [email protected] <mailto:[email protected]> > PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4 BACE 3C6E F65B 2F7D EF69 > >> On Sep 23, 2016, at 3:28 PM, Tom Gullo <[email protected] >> <mailto:[email protected]>> wrote: >> >> I'm using v1.0. I want to access some values that are in the >> nifi.properties file. And I would like to just use the nifi.properties file >> because I'll be encrypting some of these values and I want to use the built >> in encryption feature. >> >> Thanks >> >> On Fri, Sep 23, 2016 at 6:05 PM, Andrew Grande <[email protected] >> <mailto:[email protected]>> wrote: >> Which NiFi version? With 1.0 there are some bits for variable registry >> available, basically one can reference values from external config files via >> regular EL expressions. >> >> Andrew >> >> >> On Fri, Sep 23, 2016, 6:00 PM Tom Gullo <[email protected] >> <mailto:[email protected]>> wrote: >> I want to read in values from nifi.properties in a Groovy ExecuteScript >> processor. What's the best way to do that? >> >> Thanks >> -Tom >> >
signature.asc
Description: Message signed with OpenPGP using GPGMail
