jbertram commented on code in PR #6100:
URL: https://github.com/apache/artemis/pull/6100#discussion_r2605139135
##########
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 feel like the literals in this method should probably be static final
class members somewhere.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]