szaszm commented on code in PR #2166:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2166#discussion_r3196377812


##########
libminifi/src/minifi-c.cpp:
##########
@@ -578,5 +604,40 @@ MinifiStatus MinifiProcessContextGetControllerService(
   return MINIFI_STATUS_VALIDATION_FAILED;
 }
 
+void MinifiProcessContextGetDynamicProperties(MinifiProcessContext* context, 
MinifiFlowFile* minifi_flow_file,
+    void (*cb)(void* user_ctx, MinifiStringView dynamic_property_name, 
MinifiStringView dynamic_property_value), void* user_ctx) {
+  gsl_Assert(context != MINIFI_NULL);
+  auto flow_file = minifi_flow_file != MINIFI_NULL ? 
reinterpret_cast<std::shared_ptr<minifi::core::FlowFile>*>(minifi_flow_file)->get()
 : nullptr;
+  for (auto& [key, value] : 
reinterpret_cast<minifi::core::ProcessContext*>(context)->getDynamicProperties(flow_file))
 {
+    cb(user_ctx, minifiStringView(key), minifiStringView(value));
+  }
+}
+
+MinifiStatus MinifiProcessContextGetSslData(MinifiProcessContext* 
process_context, MinifiStringView controller_service_name,
+    void (*cb)(void* user_ctx, const MinifiSslData* ssl_data), void* user_ctx) 
{
+  gsl_Assert(process_context != MINIFI_NULL);
+  const auto context = 
reinterpret_cast<minifi::core::ProcessContext*>(process_context);
+  const auto name_str = std::string{toStringView(controller_service_name)};
+  const auto service_shared_ptr = context->getControllerService(name_str, 
context->getProcessorInfo().getUUID());
+  if (!service_shared_ptr) { return MINIFI_STATUS_VALIDATION_FAILED; }
+  if (const auto ssl_context_service = 
dynamic_cast<minifi::controllers::SSLContextServiceInterface*>(service_shared_ptr.get()))
 {
+    const std::string ca_cert_file = 
ssl_context_service->getCACertificate().string();
+    const std::string passphrase = ssl_context_service->getPassphrase();
+    const std::string cert_file = 
ssl_context_service->getCertificateFile().string();
+    const std::string private_key_file = 
ssl_context_service->getPrivateKeyFile().string();

Review Comment:
   We need to handle exceptions here, so that no C++ exceptions cross the C API 
boundary. And ideally we should handle string allocation errors too.



##########
minifi-api/include/minifi-c/minifi-c.h:
##########
@@ -41,6 +41,9 @@ extern "C" {
 #define MINIFI_REGISTER_EXTENSION_FN MinifiRegisterExtension
 #endif
 
+/// To allow the proper usage of SSLContextServices set the 
MinifiPropertyDefinition::type to MINIFI_SSL_CONTEXT_SERVICE_PROPERTY_TYPE

Review Comment:
   This doesn't really describe what proper usage means, so I would rephrase it 
to something like: "To declare a processor property that expects an 
SSLContextService, use MINIFI_SSL_CONTEXT_SERVICE_PROPERTY_TYPE in the type 
field of the property definition (MinifiPropertyDefinition::type)"



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to