[ 
https://issues.apache.org/jira/browse/ARTEMIS-5795?focusedWorklogId=995523&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-995523
 ]

ASF GitHub Bot logged work on ARTEMIS-5795:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 10/Dec/25 10:08
            Start Date: 10/Dec/25 10:08
    Worklog Time Spent: 10m 
      Work Description: brusdev commented on code in PR #6100:
URL: https://github.com/apache/artemis/pull/6100#discussion_r2606004238


##########
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/BrokerFactory.java:
##########
@@ -44,7 +52,42 @@ private static BrokerDTO createBrokerConfiguration(URI 
configURI,
       } catch (IOException ioe) {
          throw new ConfigurationException("Invalid configuration URI, can't 
find configuration scheme: " + configURI.getScheme());
       }
-      return factory.createBroker(configURI, artemisHome, artemisInstance, 
artemisURIInstance);
+      BrokerDTO broker = factory.createBroker(configURI, artemisHome, 
artemisInstance, artemisURIInstance);
+
+      populateSecurityWithSystemProperties(broker);
+
+      return broker;
+   }
+
+   private static void populateSecurityWithSystemProperties(BrokerDTO broker) {
+      Properties systemProperties = System.getProperties();
+      String systemSecurityJaasPropertyPrefix = 
ActiveMQDefaultConfiguration.getDefaultSystemSecurityJaasPropertyPrefix();
+      String systemSecurityManagerPropertyPrefix = 
ActiveMQDefaultConfiguration.getDefaultSystemSecurityManagerPropertyPrefix();
+
+      if (systemProperties.containsKey(systemSecurityJaasPropertyPrefix + 
"domain")) {
+         broker.security = broker.security instanceof JaasSecurityDTO ?
+            (JaasSecurityDTO) broker.security : new JaasSecurityDTO();
+      } else if 
(systemProperties.containsKey(systemSecurityManagerPropertyPrefix + 
"className")) {
+         broker.security = broker.security instanceof SecurityManagerDTO ?
+            (SecurityManagerDTO) broker.security : new SecurityManagerDTO();
+      }
+
+      if (broker.security instanceof JaasSecurityDTO security) {
+         security.domain = Optional.ofNullable((String)systemProperties.get(
+            systemSecurityJaasPropertyPrefix + 
"domain")).orElse(security.domain);
+         security.certificateDomain = 
Optional.ofNullable((String)systemProperties.get(
+            systemSecurityJaasPropertyPrefix + 
"certificateDomain")).orElse(security.certificateDomain);
+      } else if (broker.security instanceof SecurityManagerDTO security) {
+         security.className = Optional.ofNullable((String)systemProperties.get(
+            systemSecurityManagerPropertyPrefix + 
"className")).orElse(security.className);
+         security.properties = Objects.requireNonNullElse(security.properties, 
new ArrayList<>());
+         systemProperties.forEach((key, value) -> {
+            if (((String)key).startsWith(systemSecurityManagerPropertyPrefix + 
"properties.")) {
+               security.properties.add(new PropertyDTO(((String)key).substring(
+                  systemSecurityManagerPropertyPrefix.length() + 11), 
(String)value));
+            }
+         });
+      }
    }

Review Comment:
   I added them to BrokerFactory because it's the only class that uses them for 
now.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 995523)
    Time Spent: 0.5h  (was: 20m)

> Set security config using system properties
> -------------------------------------------
>
>                 Key: ARTEMIS-5795
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-5795
>             Project: Artemis
>          Issue Type: Improvement
>            Reporter: Domenico Francesco Bruscino
>            Assignee: Domenico Francesco Bruscino
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Set security config using system properties as users can set broker config, 
> i.e. starting the broker JVM with the option 
> `-Dsecurityconfig.jaas.domain=MyDomain` sets the default JAAS domain to 
> `MyDomain`. This is useful for containerized deployments or scenarios where 
> configuration needs to be injected without modifying configuration files.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to