This is an automated email from the ASF dual-hosted git repository.

martinzink pushed a commit to branch minifi_rust_pgp
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git

commit bba16042afe790335ce14e06450728f221d1f03c
Author: Martin Zink <[email protected]>
AuthorDate: Fri Aug 14 13:41:37 2026 +0200

    refactor
---
 .../src/controller_services/key_file_property.rs   | 124 ++++++++++++++
 .../src/controller_services/key_property.rs        |  49 ++++++
 .../minifi_pgp/src/controller_services/mod.rs      |   4 +-
 .../src/controller_services/private_key_service.rs | 181 +++++---------------
 .../controller_service_definition.rs               |   7 +-
 .../src/controller_services/public_key_service.rs  | 187 +++++----------------
 .../controller_service_definition.rs               |   7 +-
 .../minifi_pgp/src/processors/decrypt_content.rs   |   4 +-
 .../decrypt_content/output_attributes.rs           |   2 -
 .../src/processors/decrypt_content/properties.rs   |   4 -
 .../processors/decrypt_content/relationships.rs    |   2 -
 .../src/processors/decrypt_content/tests.rs        |   9 -
 .../minifi_pgp/src/processors/encrypt_content.rs   |   2 +-
 13 files changed, 276 insertions(+), 306 deletions(-)

diff --git 
a/minifi_rust/extensions/minifi_pgp/src/controller_services/key_file_property.rs
 
b/minifi_rust/extensions/minifi_pgp/src/controller_services/key_file_property.rs
new file mode 100644
index 000000000..4e0c876f0
--- /dev/null
+++ 
b/minifi_rust/extensions/minifi_pgp/src/controller_services/key_file_property.rs
@@ -0,0 +1,124 @@
+use minifi_native::{MinifiError, PropertyConstraints, PropertySchema, 
PropertyType};
+use pgp::composed::{Deserializable, SignedPublicKey, SignedSecretKey};
+
+pub(crate) struct SecretKeyFile {}
+
+impl PropertySchema for SecretKeyFile {
+    const CONSTRAINT: Option<PropertyConstraints> = None;
+    const IS_REQUIRED: bool = false;
+}
+
+impl PropertyType for SecretKeyFile {
+    type Output = Vec<SignedSecretKey>;
+
+    fn parse(s: &str) -> Result<Self::Output, MinifiError> {
+        let mut result: Vec<SignedSecretKey> = Vec::new();
+        if let Ok((keys, _headers)) = SignedSecretKey::from_armor_file_many(s) 
{
+            result.extend(keys.filter_map(Result::ok));
+        } else if let Ok(keys) = SignedSecretKey::from_file_many(s) {
+            result.extend(keys.filter_map(Result::ok));
+        }
+        if result.is_empty() {
+            Err(MinifiError::validation(
+                "Couldnt load any valid secret keys",
+            ))
+        } else {
+            Ok(result)
+        }
+    }
+}
+
+pub(crate) struct PublicKeyFile {}
+impl PropertySchema for PublicKeyFile {
+    const CONSTRAINT: Option<PropertyConstraints> = None;
+    const IS_REQUIRED: bool = false;
+}
+
+impl PropertyType for PublicKeyFile {
+    type Output = Vec<SignedPublicKey>;
+
+    fn parse(s: &str) -> Result<Self::Output, MinifiError> {
+        let mut result: Vec<SignedPublicKey> = Vec::new();
+        if let Ok((keys, _headers)) = SignedPublicKey::from_armor_file_many(s) 
{
+            result.extend(keys.filter_map(Result::ok));
+        } else if let Ok(keys) = SignedPublicKey::from_file_many(s) {
+            result.extend(keys.filter_map(Result::ok));
+        }
+        if result.is_empty() {
+            Err(MinifiError::validation(
+                "Couldnt load any valid public keys",
+            ))
+        } else {
+            Ok(result)
+        }
+    }
+}
+
+#[cfg(test)]
+mod secret_key_file_tests {
+    use super::*;
+    use crate::test_utils::get_test_key_path;
+
+    fn assert_invalid_secret_key_file(file_name: &str) {
+        assert!(SecretKeyFile::parse(&get_test_key_path(file_name)).is_err())
+    }
+    fn assert_valid_secret_key_file(file_name: &str) {
+        assert!(
+            !SecretKeyFile::parse(&get_test_key_path(file_name))
+                .unwrap()
+                .is_empty()
+        )
+    }
+    #[test]
+    fn test_invalid_secret_keyfiles() {
+        assert_invalid_secret_key_file("alice.asc");
+        assert_invalid_secret_key_file("alice.gpg");
+        assert_invalid_secret_key_file("garbage.gpg");
+        assert_invalid_secret_key_file("truncated_private.asc");
+        assert_invalid_secret_key_file("non_existent.asc");
+    }
+
+    #[test]
+    fn test_valid_secret_keyfiles() {
+        assert_valid_secret_key_file("alice_private.asc");
+        assert_valid_secret_key_file("alice_private.gpg");
+        assert_valid_secret_key_file("bob_private.asc");
+        assert_valid_secret_key_file("bob_private.gpg");
+        assert_valid_secret_key_file("secret_keyring.asc");
+        assert_valid_secret_key_file("secret_keyring.gpg");
+    }
+}
+
+#[cfg(test)]
+mod public_key_file_tests {
+    use crate::controller_services::key_file_property::PublicKeyFile;
+    use crate::test_utils::get_test_key_path;
+    use minifi_native::PropertyType;
+
+    fn assert_invalid_public_key_file(file_name: &str) {
+        assert!(PublicKeyFile::parse(&get_test_key_path(file_name)).is_err())
+    }
+    fn assert_valid_public_key_file(file_name: &str) {
+        assert!(
+            !PublicKeyFile::parse(&get_test_key_path(file_name))
+                .unwrap()
+                .is_empty()
+        )
+    }
+    #[test]
+    fn test_invalid_public_keyfiles() {
+        assert_invalid_public_key_file("alice_private.asc");
+        assert_invalid_public_key_file("alice_private.gpg");
+        assert_invalid_public_key_file("garbage.gpg");
+        assert_invalid_public_key_file("truncated.asc");
+        assert_invalid_public_key_file("non_existent.asc");
+    }
+
+    #[test]
+    fn test_valid_public_keyfiles() {
+        assert_valid_public_key_file("alice.asc");
+        assert_valid_public_key_file("alice.gpg");
+        assert_valid_public_key_file("keyring.asc");
+        assert_valid_public_key_file("keyring.gpg");
+    }
+}
diff --git 
a/minifi_rust/extensions/minifi_pgp/src/controller_services/key_property.rs 
b/minifi_rust/extensions/minifi_pgp/src/controller_services/key_property.rs
new file mode 100644
index 000000000..b3d9aa07d
--- /dev/null
+++ b/minifi_rust/extensions/minifi_pgp/src/controller_services/key_property.rs
@@ -0,0 +1,49 @@
+use minifi_native::{MinifiError, PropertyConstraints, PropertySchema, 
PropertyType};
+use pgp::composed::{Deserializable, SignedPublicKey, SignedSecretKey};
+
+pub(crate) struct SecretKey {}
+
+impl PropertySchema for SecretKey {
+    const CONSTRAINT: Option<PropertyConstraints> = None;
+    const IS_REQUIRED: bool = false;
+}
+
+impl PropertyType for SecretKey {
+    type Output = Vec<SignedSecretKey>;
+
+    fn parse(s: &str) -> Result<Self::Output, MinifiError> {
+        let mut secret_keys: Vec<SignedSecretKey> = Vec::new();
+        if let Ok((keys, _headers)) = 
SignedSecretKey::from_armor_many(s.as_bytes()) {
+            secret_keys.extend(keys.filter_map(Result::ok));
+        }
+        if secret_keys.is_empty() {
+            return Err(MinifiError::validation(
+                "Couldnt load any valid secrey keys",
+            ));
+        }
+        Ok(secret_keys)
+    }
+}
+
+pub(crate) struct PublicKey {}
+impl PropertySchema for PublicKey {
+    const CONSTRAINT: Option<PropertyConstraints> = None;
+    const IS_REQUIRED: bool = false;
+}
+
+impl PropertyType for PublicKey {
+    type Output = Vec<SignedPublicKey>;
+
+    fn parse(s: &str) -> Result<Self::Output, MinifiError> {
+        let mut public_keys: Vec<SignedPublicKey> = Vec::new();
+        if let Ok((keys, _headers)) = 
SignedPublicKey::from_armor_many(s.as_bytes()) {
+            public_keys.extend(keys.filter_map(Result::ok));
+        }
+        if public_keys.is_empty() {
+            return Err(MinifiError::validation(
+                "Couldnt load any valid public keys",
+            ));
+        }
+        Ok(public_keys)
+    }
+}
diff --git a/minifi_rust/extensions/minifi_pgp/src/controller_services/mod.rs 
b/minifi_rust/extensions/minifi_pgp/src/controller_services/mod.rs
index d2c83be43..930207f53 100644
--- a/minifi_rust/extensions/minifi_pgp/src/controller_services/mod.rs
+++ b/minifi_rust/extensions/minifi_pgp/src/controller_services/mod.rs
@@ -1,3 +1,5 @@
-pub(crate) mod key_lookup;
+mod key_file_property;
+mod key_lookup;
+mod key_property;
 pub(crate) mod private_key_service;
 pub(crate) mod public_key_service;
diff --git 
a/minifi_rust/extensions/minifi_pgp/src/controller_services/private_key_service.rs
 
b/minifi_rust/extensions/minifi_pgp/src/controller_services/private_key_service.rs
index 0f8ca9eca..848fa5603 100644
--- 
a/minifi_rust/extensions/minifi_pgp/src/controller_services/private_key_service.rs
+++ 
b/minifi_rust/extensions/minifi_pgp/src/controller_services/private_key_service.rs
@@ -4,8 +4,8 @@ use controller_service_definition::*;
 #[cfg(test)]
 use crate::controller_services::key_lookup::key_matches;
 use minifi_native::macros::ComponentIdentifier;
-use minifi_native::{EnableControllerService, GetProperty, Logger, MinifiError, 
warn};
-use pgp::composed::{Deserializable, SignedSecretKey, TheRing};
+use minifi_native::{EnableControllerService, GetProperty, Logger, MinifiError};
+use pgp::composed::{SignedSecretKey, TheRing};
 #[cfg(test)]
 use pgp::types::KeyDetails;
 
@@ -16,29 +16,17 @@ pub(crate) struct PGPPrivateKeyService {
 }
 
 impl EnableControllerService for PGPPrivateKeyService {
-    fn enable<P: GetProperty, L: Logger>(context: &P, logger: &L) -> 
Result<Self, MinifiError>
+    fn enable<P: GetProperty, L: Logger>(context: &P, _logger: &L) -> 
Result<Self, MinifiError>
     where
         Self: Sized,
     {
-        let mut private_keys = vec![];
-        if let Some(keyring_file_path) = context.get_property(&KEY_FILE)? {
-            if let Ok((keys, _headers)) = 
SignedSecretKey::from_armor_file_many(&keyring_file_path)
-            {
-                collect_keys(keys, &mut private_keys, logger);
-            } else if let Ok(keys) = 
SignedSecretKey::from_file_many(keyring_file_path) {
-                collect_keys(keys, &mut private_keys, logger);
-            }
-        }
-        if let Some(keyring_ascii) = context.get_property(&KEY)?
-            && let Ok((keys, _headers)) = 
SignedSecretKey::from_armor_many(keyring_ascii.as_bytes())
-        {
-            collect_keys(keys, &mut private_keys, logger);
-        }
+        let mut private_keys = 
context.get_property(&KEY_FILE)?.unwrap_or_default();
+        private_keys.extend(context.get_property(&KEY)?.unwrap_or_default());
 
         let passphrase = 
context.get_property(&KEY_PASSPHRASE)?.unwrap_or_default();
 
         if private_keys.is_empty() {
-            return Err(MinifiError::custom("Could not load any valid keys"));
+            return Err(MinifiError::validation("Could not load any valid 
keys"));
         }
         Ok(Self {
             private_keys,
@@ -70,36 +58,12 @@ impl PGPPrivateKeyService {
     }
 }
 
-fn collect_keys<I, L>(keys: I, out: &mut Vec<SignedSecretKey>, logger: &L)
-where
-    I: Iterator<Item = pgp::errors::Result<SignedSecretKey>>,
-    L: Logger,
-{
-    for key in keys {
-        match key {
-            Ok(k) => out.push(k),
-            Err(e) => warn!(logger, "Skipping unparseable private key: {}", e),
-        }
-    }
-}
-
 #[cfg(test)]
 mod tests {
     use super::*;
     use crate::test_utils::get_test_key_path;
-    use minifi_native::MinifiError::CustomError;
     use minifi_native::{ComponentIdentifier, MockControllerServiceContext, 
MockLogger};
 
-    fn assert_private_key_service_enable_fails_with_no_valid_keys(
-        context: &MockControllerServiceContext,
-    ) {
-        if let Err(CustomError(error)) = PGPPrivateKeyService::enable(context, 
&MockLogger::new()) {
-            assert_eq!(error, "Could not load any valid keys");
-        } else {
-            panic!("Didnt fail with no_valid_keys");
-        }
-    }
-
     #[test]
     fn test_component_id() {
         assert_eq!(
@@ -107,56 +71,13 @@ mod tests {
             
"minifi_pgp::controller_services::private_key_service::PGPPrivateKeyService"
         );
         assert_eq!(PGPPrivateKeyService::GROUP_NAME, "minifi_pgp");
-        assert_eq!(PGPPrivateKeyService::VERSION, "0.1.0");
+        assert_eq!(PGPPrivateKeyService::VERSION, "1.0.0");
     }
 
     #[test]
     fn default_fails() {
         let context = MockControllerServiceContext::new();
-        assert_private_key_service_enable_fails_with_no_valid_keys(&context);
-    }
-
-    #[test]
-    fn corrupted_binary_keyring_file() {
-        let mut context = MockControllerServiceContext::new();
-        context
-            .properties
-            .insert("Key File".to_string(), get_test_key_path("garbage.gpg"));
-
-        assert_private_key_service_enable_fails_with_no_valid_keys(&context);
-    }
-
-    #[test]
-    fn armored_public_key_file() {
-        let mut context = MockControllerServiceContext::new();
-        context.properties.insert(
-            "Key File".to_string(),
-            get_test_key_path("private_mistake.asc"),
-        );
-
-        assert_private_key_service_enable_fails_with_no_valid_keys(&context);
-    }
-
-    #[test]
-    fn corrupted_armored_key_file() {
-        let mut context = MockControllerServiceContext::new();
-        context.properties.insert(
-            "Key File".to_string(),
-            get_test_key_path("truncated_private.asc"),
-        );
-
-        assert_private_key_service_enable_fails_with_no_valid_keys(&context);
-    }
-
-    #[test]
-    fn non_existent_keyfile() {
-        let mut context = MockControllerServiceContext::new();
-        context.properties.insert(
-            "Key File".to_string(),
-            get_test_key_path("non_existent.asc"),
-        );
-
-        assert_private_key_service_enable_fails_with_no_valid_keys(&context);
+        assert!(PGPPrivateKeyService::enable(&context, 
&MockLogger::new()).is_err());
     }
 
     #[test]
@@ -167,17 +88,13 @@ mod tests {
             get_test_key_path("alice_private.asc"),
         );
 
-        let controller_service =
+        let service =
             PGPPrivateKeyService::enable(&context, 
&MockLogger::new()).expect("should enable");
-        assert!(controller_service.get_secret_key("Alice").is_some());
-        assert!(
-            controller_service
-                .get_secret_key("[email protected]")
-                .is_some()
-        );
+        assert!(service.get_secret_key("Alice").is_some());
+        assert!(service.get_secret_key("[email protected]").is_some());
 
-        assert!(controller_service.get_secret_key("Bob").is_none());
-        assert!(controller_service.get_secret_key("Carol").is_none());
+        assert!(service.get_secret_key("Bob").is_none());
+        assert!(service.get_secret_key("Carol").is_none());
     }
 
     #[test]
@@ -188,20 +105,20 @@ mod tests {
             get_test_key_path("alice_private.gpg"),
         );
 
-        let controller_service =
+        let service =
             PGPPrivateKeyService::enable(&context, 
&MockLogger::new()).expect("should enable");
-        assert!(controller_service.get_secret_key("A").is_some());
-        assert!(controller_service.get_secret_key("Alice").is_some());
+        assert!(service.get_secret_key("A").is_some());
+        assert!(service.get_secret_key("Alice").is_some());
         assert!(
-            controller_service
+            service
                 .get_secret_key("Alice <[email protected]>")
                 .is_some()
         );
 
-        assert!(controller_service.get_secret_key("<Alice>").is_none());
+        assert!(service.get_secret_key("<Alice>").is_none());
 
-        assert!(controller_service.get_secret_key("Bob").is_none());
-        assert!(controller_service.get_secret_key("Carol").is_none());
+        assert!(service.get_secret_key("Bob").is_none());
+        assert!(service.get_secret_key("Carol").is_none());
     }
 
     #[test]
@@ -212,13 +129,13 @@ mod tests {
             get_test_key_path("secret_keyring.asc"),
         );
 
-        let controller_service =
+        let service =
             PGPPrivateKeyService::enable(&context, 
&MockLogger::new()).expect("should enable");
-        assert!(controller_service.get_secret_key("Alice").is_some());
-        assert!(controller_service.get_secret_key("Bob").is_some());
-        assert!(controller_service.get_secret_key("[email protected]").is_some());
-        assert!(controller_service.get_secret_key("[email protected]").is_some());
-        assert!(controller_service.get_secret_key("Carol").is_none());
+        assert!(service.get_secret_key("Alice").is_some());
+        assert!(service.get_secret_key("Bob").is_some());
+        assert!(service.get_secret_key("[email protected]").is_some());
+        assert!(service.get_secret_key("[email protected]").is_some());
+        assert!(service.get_secret_key("Carol").is_none());
     }
 
     #[test]
@@ -229,13 +146,13 @@ mod tests {
             get_test_key_path("secret_keyring.gpg"),
         );
 
-        let controller_service =
+        let service =
             PGPPrivateKeyService::enable(&context, 
&MockLogger::new()).expect("should enable");
-        assert!(controller_service.get_secret_key("Alice").is_some());
-        assert!(controller_service.get_secret_key("Bob").is_some());
-        assert!(controller_service.get_secret_key("[email protected]").is_some());
-        assert!(controller_service.get_secret_key("[email protected]").is_some());
-        assert!(controller_service.get_secret_key("Carol").is_none());
+        assert!(service.get_secret_key("Alice").is_some());
+        assert!(service.get_secret_key("Bob").is_some());
+        assert!(service.get_secret_key("[email protected]").is_some());
+        assert!(service.get_secret_key("[email protected]").is_some());
+        assert!(service.get_secret_key("Carol").is_none());
     }
 
     #[test]
@@ -247,13 +164,13 @@ mod tests {
 
         context.properties.insert("Key".to_string(), file_content);
 
-        let controller_service =
+        let service =
             PGPPrivateKeyService::enable(&context, 
&MockLogger::new()).expect("should enable");
-        assert!(controller_service.get_secret_key("Alice").is_some());
-        assert!(controller_service.get_secret_key("Bob").is_some());
-        assert!(controller_service.get_secret_key("[email protected]").is_some());
-        assert!(controller_service.get_secret_key("[email protected]").is_some());
-        assert!(controller_service.get_secret_key("Carol").is_none());
+        assert!(service.get_secret_key("Alice").is_some());
+        assert!(service.get_secret_key("Bob").is_some());
+        assert!(service.get_secret_key("[email protected]").is_some());
+        assert!(service.get_secret_key("[email protected]").is_some());
+        assert!(service.get_secret_key("Carol").is_none());
     }
 
     #[test]
@@ -265,23 +182,11 @@ mod tests {
 
         context.properties.insert("Key".to_string(), file_content);
 
-        let controller_service =
+        let service =
             PGPPrivateKeyService::enable(&context, 
&MockLogger::new()).expect("should enable");
-        assert!(controller_service.get_secret_key("Alice").is_some());
-        assert!(controller_service.get_secret_key("Bob").is_none());
-        assert!(controller_service.get_secret_key("Carol").is_none());
-    }
-
-    #[test]
-    fn corrupted_armored_key() {
-        let mut context = MockControllerServiceContext::new();
-
-        let file_content = 
std::fs::read_to_string(get_test_key_path("truncated_private.asc"))
-            .expect("required for test");
-
-        context.properties.insert("Key".to_string(), file_content);
-
-        assert_private_key_service_enable_fails_with_no_valid_keys(&context);
+        assert!(service.get_secret_key("Alice").is_some());
+        assert!(service.get_secret_key("Bob").is_none());
+        assert!(service.get_secret_key("Carol").is_none());
     }
 
     #[test]
@@ -293,6 +198,6 @@ mod tests {
 
         context.properties.insert("Key".to_string(), file_content);
 
-        assert_private_key_service_enable_fails_with_no_valid_keys(&context);
+        assert!(PGPPrivateKeyService::enable(&context, 
&MockLogger::new()).is_err());
     }
 }
diff --git 
a/minifi_rust/extensions/minifi_pgp/src/controller_services/private_key_service/controller_service_definition.rs
 
b/minifi_rust/extensions/minifi_pgp/src/controller_services/private_key_service/controller_service_definition.rs
index 585ad8214..fe421553a 100644
--- 
a/minifi_rust/extensions/minifi_pgp/src/controller_services/private_key_service/controller_service_definition.rs
+++ 
b/minifi_rust/extensions/minifi_pgp/src/controller_services/private_key_service/controller_service_definition.rs
@@ -1,18 +1,19 @@
 use super::PGPPrivateKeyService;
+use crate::controller_services::key_file_property::SecretKeyFile;
+use crate::controller_services::key_property::SecretKey;
 use crate::utils;
 use minifi_native::{
     ControllerServiceDefinition, Property, PropertyDefinition, 
ProvidedInterface,
     property_definitions,
 };
-use std::path::PathBuf;
 
-pub(super) const KEY_FILE: Property<Option<PathBuf>> = Property::new(
+pub(super) const KEY_FILE: Property<Option<SecretKeyFile>> = Property::new(
     "Key File",
     "File path to PGP Secret Key encoded in binary or ASCII Armor",
 )
 .supports_expression_language();
 
-pub(super) const KEY: Property<Option<String>> =
+pub(super) const KEY: Property<Option<SecretKey>> =
     Property::new("Key", "Secret Key encoded in ASCII Armor").sensitive();
 
 pub(super) const KEY_PASSPHRASE: Property<Option<utils::Password>> = 
Property::new(
diff --git 
a/minifi_rust/extensions/minifi_pgp/src/controller_services/public_key_service.rs
 
b/minifi_rust/extensions/minifi_pgp/src/controller_services/public_key_service.rs
index 007ca6f94..117abd119 100644
--- 
a/minifi_rust/extensions/minifi_pgp/src/controller_services/public_key_service.rs
+++ 
b/minifi_rust/extensions/minifi_pgp/src/controller_services/public_key_service.rs
@@ -3,8 +3,8 @@ use controller_service_definition::*;
 
 use crate::controller_services::key_lookup::key_matches;
 use minifi_native::macros::ComponentIdentifier;
-use minifi_native::{EnableControllerService, GetProperty, Logger, MinifiError, 
warn};
-use pgp::composed::{Deserializable, SignedPublicKey};
+use minifi_native::{EnableControllerService, GetProperty, Logger, MinifiError};
+use pgp::composed::SignedPublicKey;
 use pgp::types::KeyDetails;
 
 #[derive(Debug, ComponentIdentifier, PartialEq)]
@@ -13,45 +13,20 @@ pub(crate) struct PGPPublicKeyService {
 }
 
 impl EnableControllerService for PGPPublicKeyService {
-    fn enable<P: GetProperty, L: Logger>(context: &P, logger: &L) -> 
Result<Self, MinifiError>
+    fn enable<P: GetProperty, L: Logger>(context: &P, _logger: &L) -> 
Result<Self, MinifiError>
     where
         Self: Sized,
     {
-        let mut public_keys = vec![];
-        if let Some(keyring_file_path) = context.get_property(&KEYRING_FILE)? {
-            if let Ok((keys, _headers)) = 
SignedPublicKey::from_armor_file_many(&keyring_file_path)
-            {
-                collect_keys(keys, &mut public_keys, logger);
-            } else if let Ok(keys) = 
SignedPublicKey::from_file_many(keyring_file_path) {
-                collect_keys(keys, &mut public_keys, logger);
-            }
-        }
-        if let Some(keyring_ascii) = context.get_property(&KEYRING)?
-            && let Ok((keys, _headers)) = 
SignedPublicKey::from_armor_many(keyring_ascii.as_bytes())
-        {
-            collect_keys(keys, &mut public_keys, logger);
-        }
+        let mut public_keys = 
context.get_property(&KEYRING_FILE)?.unwrap_or_default();
+        
public_keys.extend(context.get_property(&KEYRING)?.unwrap_or_default());
 
         if public_keys.is_empty() {
-            return Err(MinifiError::custom("Could not load any valid keys"));
+            return Err(MinifiError::validation("Could not load any valid 
keys"));
         }
         Ok(Self { public_keys })
     }
 }
 
-fn collect_keys<I, L>(keys: I, out: &mut Vec<SignedPublicKey>, logger: &L)
-where
-    I: Iterator<Item = pgp::errors::Result<SignedPublicKey>>,
-    L: Logger,
-{
-    for key in keys {
-        match key {
-            Ok(k) => out.push(k),
-            Err(e) => warn!(logger, "Skipping unparseable public key: {}", e),
-        }
-    }
-}
-
 impl PGPPublicKeyService {
     pub fn get(&self, target_id: &str) -> Option<&SignedPublicKey> {
         self.public_keys.iter().find(|public_key| {
@@ -68,18 +43,8 @@ impl PGPPublicKeyService {
 mod tests {
     use super::*;
     use crate::test_utils::get_test_key_path;
-    use minifi_native::MinifiError::CustomError;
-    use minifi_native::{ComponentIdentifier, MockControllerServiceContext, 
MockLogger};
 
-    fn assert_public_key_service_enable_fails_with_no_valid_keys(
-        context: &MockControllerServiceContext,
-    ) {
-        if let Err(CustomError(error)) = PGPPublicKeyService::enable(context, 
&MockLogger::new()) {
-            assert_eq!(error, "Could not load any valid keys");
-        } else {
-            panic!("Didnt fail with no_valid_keys");
-        }
-    }
+    use minifi_native::{ComponentIdentifier, MockControllerServiceContext, 
MockLogger};
 
     #[test]
     fn test_component_id() {
@@ -88,24 +53,13 @@ mod tests {
             
"minifi_pgp::controller_services::public_key_service::PGPPublicKeyService"
         );
         assert_eq!(PGPPublicKeyService::GROUP_NAME, "minifi_pgp");
-        assert_eq!(PGPPublicKeyService::VERSION, "0.1.0");
+        assert_eq!(PGPPublicKeyService::VERSION, "1.0.0");
     }
 
     #[test]
     fn default_fails() {
         let context = MockControllerServiceContext::new();
-
-        assert_public_key_service_enable_fails_with_no_valid_keys(&context);
-    }
-
-    #[test]
-    fn corrupted_binary_keyring_file() {
-        let mut context = MockControllerServiceContext::new();
-        context
-            .properties
-            .insert("Keyring File".to_string(), 
get_test_key_path("garbage.gpg"));
-
-        assert_public_key_service_enable_fails_with_no_valid_keys(&context);
+        assert!(PGPPublicKeyService::enable(&context, 
&MockLogger::new()).is_err());
     }
 
     #[test]
@@ -116,29 +70,7 @@ mod tests {
             get_test_key_path("alice_private.asc"),
         );
 
-        assert_public_key_service_enable_fails_with_no_valid_keys(&context);
-    }
-
-    #[test]
-    fn corrupted_armored_key_file() {
-        let mut context = MockControllerServiceContext::new();
-        context.properties.insert(
-            "Keyring File".to_string(),
-            get_test_key_path("truncated.asc"),
-        );
-
-        assert_public_key_service_enable_fails_with_no_valid_keys(&context);
-    }
-
-    #[test]
-    fn non_existent_keyfile() {
-        let mut context = MockControllerServiceContext::new();
-        context.properties.insert(
-            "Keyring File".to_string(),
-            get_test_key_path("non_existent.asc"),
-        );
-
-        assert_public_key_service_enable_fails_with_no_valid_keys(&context);
+        assert!(PGPPublicKeyService::enable(&context, 
&MockLogger::new()).is_err());
     }
 
     #[test]
@@ -165,20 +97,16 @@ mod tests {
             .properties
             .insert("Keyring File".to_string(), 
get_test_key_path("alice.gpg"));
 
-        let controller_service = PGPPublicKeyService::enable(&context, 
&MockLogger::new())
+        let service = PGPPublicKeyService::enable(&context, &MockLogger::new())
             .expect("enable should succeed");
-        assert!(controller_service.get("A").is_some());
-        assert!(controller_service.get("Alice").is_some());
-        assert!(
-            controller_service
-                .get("Alice <[email protected]>")
-                .is_some()
-        );
+        assert!(service.get("A").is_some());
+        assert!(service.get("Alice").is_some());
+        assert!(service.get("Alice <[email protected]>").is_some());
 
-        assert!(controller_service.get("<Alice>").is_none());
+        assert!(service.get("<Alice>").is_none());
 
-        assert!(controller_service.get("Bob").is_none());
-        assert!(controller_service.get("Carol").is_none());
+        assert!(service.get("Bob").is_none());
+        assert!(service.get("Carol").is_none());
     }
 
     #[test]
@@ -188,13 +116,13 @@ mod tests {
             .properties
             .insert("Keyring File".to_string(), 
get_test_key_path("keyring.asc"));
 
-        let controller_service = PGPPublicKeyService::enable(&context, 
&MockLogger::new())
+        let service = PGPPublicKeyService::enable(&context, &MockLogger::new())
             .expect("enable should succeed");
-        assert!(controller_service.get("Alice").is_some());
-        assert!(controller_service.get("Bob").is_some());
-        assert!(controller_service.get("[email protected]").is_some());
-        assert!(controller_service.get("[email protected]").is_some());
-        assert!(controller_service.get("Carol").is_none());
+        assert!(service.get("Alice").is_some());
+        assert!(service.get("Bob").is_some());
+        assert!(service.get("[email protected]").is_some());
+        assert!(service.get("[email protected]").is_some());
+        assert!(service.get("Carol").is_none());
     }
 
     #[test]
@@ -204,13 +132,13 @@ mod tests {
             .properties
             .insert("Keyring File".to_string(), 
get_test_key_path("keyring.gpg"));
 
-        let controller_service = PGPPublicKeyService::enable(&context, 
&MockLogger::new())
+        let service = PGPPublicKeyService::enable(&context, &MockLogger::new())
             .expect("enable should succeed");
-        assert!(controller_service.get("Alice").is_some());
-        assert!(controller_service.get("Bob").is_some());
-        assert!(controller_service.get("[email protected]").is_some());
-        assert!(controller_service.get("[email protected]").is_some());
-        assert!(controller_service.get("Carol").is_none());
+        assert!(service.get("Alice").is_some());
+        assert!(service.get("Bob").is_some());
+        assert!(service.get("[email protected]").is_some());
+        assert!(service.get("[email protected]").is_some());
+        assert!(service.get("Carol").is_none());
     }
 
     #[test]
@@ -224,13 +152,13 @@ mod tests {
             .properties
             .insert("Keyring".to_string(), file_content);
 
-        let controller_service = PGPPublicKeyService::enable(&context, 
&MockLogger::new())
+        let service = PGPPublicKeyService::enable(&context, &MockLogger::new())
             .expect("enable should succeed");
-        assert!(controller_service.get("Alice").is_some());
-        assert!(controller_service.get("Bob").is_some());
-        assert!(controller_service.get("[email protected]").is_some());
-        assert!(controller_service.get("[email protected]").is_some());
-        assert!(controller_service.get("Carol").is_none());
+        assert!(service.get("Alice").is_some());
+        assert!(service.get("Bob").is_some());
+        assert!(service.get("[email protected]").is_some());
+        assert!(service.get("[email protected]").is_some());
+        assert!(service.get("Carol").is_none());
     }
 
     #[test]
@@ -244,25 +172,11 @@ mod tests {
             .properties
             .insert("Keyring".to_string(), file_content);
 
-        let controller_service = PGPPublicKeyService::enable(&context, 
&MockLogger::new())
+        let service = PGPPublicKeyService::enable(&context, &MockLogger::new())
             .expect("enable should succeed");
-        assert!(controller_service.get("Alice").is_some());
-        assert!(controller_service.get("Bob").is_none());
-        assert!(controller_service.get("Carol").is_none());
-    }
-
-    #[test]
-    fn corrupted_armored_key() {
-        let mut context = MockControllerServiceContext::new();
-
-        let file_content =
-            
std::fs::read_to_string(get_test_key_path("truncated.asc")).expect("required 
for test");
-
-        context
-            .properties
-            .insert("Keyring".to_string(), file_content);
-
-        assert_public_key_service_enable_fails_with_no_valid_keys(&context);
+        assert!(service.get("Alice").is_some());
+        assert!(service.get("Bob").is_none());
+        assert!(service.get("Carol").is_none());
     }
 
     #[test]
@@ -276,7 +190,7 @@ mod tests {
             .properties
             .insert("Keyring".to_string(), file_content);
 
-        assert_public_key_service_enable_fails_with_no_valid_keys(&context);
+        assert!(PGPPublicKeyService::enable(&context, 
&MockLogger::new()).is_err());
     }
 
     #[test]
@@ -286,24 +200,15 @@ mod tests {
             .properties
             .insert("Keyring File".to_string(), 
get_test_key_path("alice.asc"));
 
-        let controller_service = PGPPublicKeyService::enable(&context, 
&MockLogger::new())
+        let service = PGPPublicKeyService::enable(&context, &MockLogger::new())
             .expect("enable should succeed");
 
-        // Get Alice's Key ID from the loaded key so the test doesn't 
hard-code hex bytes.
-        let alice = controller_service.get("Alice").expect("Alice should 
exist");
+        let alice = service.get("Alice").expect("Alice should exist");
         let key_id_hex = alice.primary_key.legacy_key_id().to_string();
         assert_eq!(key_id_hex.len(), 16);
-
-        // Full 16-char hex, both cases, should match.
-        assert!(controller_service.get(&key_id_hex).is_some());
-        assert!(
-            controller_service
-                .get(&key_id_hex.to_ascii_uppercase())
-                .is_some()
-        );
-
-        // A partial or unrelated hex string should not.
-        assert!(controller_service.get(&key_id_hex[..8]).is_none());
-        assert!(controller_service.get("0123456789abcdef").is_none());
+        assert!(service.get(&key_id_hex).is_some());
+        assert!(service.get(&key_id_hex.to_ascii_uppercase()).is_some());
+        assert!(service.get(&key_id_hex[..8]).is_none());
+        assert!(service.get("0123456789abcdef").is_none());
     }
 }
diff --git 
a/minifi_rust/extensions/minifi_pgp/src/controller_services/public_key_service/controller_service_definition.rs
 
b/minifi_rust/extensions/minifi_pgp/src/controller_services/public_key_service/controller_service_definition.rs
index 580b3e007..099cd5fc1 100644
--- 
a/minifi_rust/extensions/minifi_pgp/src/controller_services/public_key_service/controller_service_definition.rs
+++ 
b/minifi_rust/extensions/minifi_pgp/src/controller_services/public_key_service/controller_service_definition.rs
@@ -1,17 +1,18 @@
 use super::PGPPublicKeyService;
+use crate::controller_services::key_file_property::PublicKeyFile;
+use crate::controller_services::key_property::PublicKey;
 use minifi_native::{
     ControllerServiceDefinition, Property, PropertyDefinition, 
ProvidedInterface,
     property_definitions,
 };
-use std::path::PathBuf;
 
-pub(crate) const KEYRING_FILE: Property<Option<PathBuf>> = Property::new(
+pub(crate) const KEYRING_FILE: Property<Option<PublicKeyFile>> = Property::new(
     "Keyring File",
     "File path to PGP Keyring or Secret Key encoded in binary or ASCII Armor",
 )
 .supports_expression_language();
 
-pub(crate) const KEYRING: Property<Option<String>> = Property::new(
+pub(crate) const KEYRING: Property<Option<PublicKey>> = Property::new(
     "Keyring",
     "PGP Keyring or Secret Key encoded in ASCII Armor",
 )
diff --git 
a/minifi_rust/extensions/minifi_pgp/src/processors/decrypt_content.rs 
b/minifi_rust/extensions/minifi_pgp/src/processors/decrypt_content.rs
index 7ea0dc78b..506bc24ba 100644
--- a/minifi_rust/extensions/minifi_pgp/src/processors/decrypt_content.rs
+++ b/minifi_rust/extensions/minifi_pgp/src/processors/decrypt_content.rs
@@ -39,7 +39,7 @@ impl Schedule for DecryptContentPGP {
         let symmetric_password = context.get_property(&SYMMETRIC_PASSWORD)?;
         let has_context_service = 
context.get_raw_property(&PRIVATE_KEY_SERVICE)?.is_some();
         if !has_context_service && symmetric_password.is_none() {
-            Err(MinifiError::custom(
+            Err(MinifiError::validation(
                 "Either Symmetric Password or Private Key Service must be set",
             ))
         } else {
@@ -139,7 +139,7 @@ mod tests {
             "minifi_pgp::processors::decrypt_content::DecryptContentPGP"
         );
         assert_eq!(DecryptContentPGP::GROUP_NAME, "minifi_pgp");
-        assert_eq!(DecryptContentPGP::VERSION, "0.1.0");
+        assert_eq!(DecryptContentPGP::VERSION, "1.0.0");
     }
 
     #[test]
diff --git 
a/minifi_rust/extensions/minifi_pgp/src/processors/decrypt_content/output_attributes.rs
 
b/minifi_rust/extensions/minifi_pgp/src/processors/decrypt_content/output_attributes.rs
deleted file mode 100644
index 5511193e8..000000000
--- 
a/minifi_rust/extensions/minifi_pgp/src/processors/decrypt_content/output_attributes.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-use minifi_native::OutputAttribute;
-
diff --git 
a/minifi_rust/extensions/minifi_pgp/src/processors/decrypt_content/properties.rs
 
b/minifi_rust/extensions/minifi_pgp/src/processors/decrypt_content/properties.rs
deleted file mode 100644
index d2c0be786..000000000
--- 
a/minifi_rust/extensions/minifi_pgp/src/processors/decrypt_content/properties.rs
+++ /dev/null
@@ -1,4 +0,0 @@
-use crate::controller_services::private_key_service::PGPPrivateKeyService;
-use crate::processors::decrypt_content::DecryptionStrategy;
-use crate::utils;
-use minifi_native::Property;
diff --git 
a/minifi_rust/extensions/minifi_pgp/src/processors/decrypt_content/relationships.rs
 
b/minifi_rust/extensions/minifi_pgp/src/processors/decrypt_content/relationships.rs
deleted file mode 100644
index ed61a1165..000000000
--- 
a/minifi_rust/extensions/minifi_pgp/src/processors/decrypt_content/relationships.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-use minifi_native::Relationship;
-
diff --git 
a/minifi_rust/extensions/minifi_pgp/src/processors/decrypt_content/tests.rs 
b/minifi_rust/extensions/minifi_pgp/src/processors/decrypt_content/tests.rs
deleted file mode 100644
index 87b6179d0..000000000
--- a/minifi_rust/extensions/minifi_pgp/src/processors/decrypt_content/tests.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-use crate::controller_services::private_key_service::PGPPrivateKeyService;
-use crate::processors::decrypt_content::{DecryptContentPGP, output_attributes};
-use crate::test_utils;
-use crate::test_utils::get_test_message;
-use minifi_native::{
-    ComponentIdentifier, EnableControllerService, FlowFileStreamTransform, 
IoState,
-    MockControllerServiceContext, MockLogger, MockProcessContext, Schedule,
-};
-
diff --git 
a/minifi_rust/extensions/minifi_pgp/src/processors/encrypt_content.rs 
b/minifi_rust/extensions/minifi_pgp/src/processors/encrypt_content.rs
index 6d2352136..07b7b70dc 100644
--- a/minifi_rust/extensions/minifi_pgp/src/processors/encrypt_content.rs
+++ b/minifi_rust/extensions/minifi_pgp/src/processors/encrypt_content.rs
@@ -164,7 +164,7 @@ mod tests {
             "minifi_pgp::processors::encrypt_content::EncryptContentPGP"
         );
         assert_eq!(EncryptContentPGP::GROUP_NAME, "minifi_pgp");
-        assert_eq!(EncryptContentPGP::VERSION, "0.1.0");
+        assert_eq!(EncryptContentPGP::VERSION, "1.0.0");
     }
 
     #[test]

Reply via email to