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

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

                Author: ASF GitHub Bot
            Created on: 12/Mar/25 13:52
            Start Date: 12/Mar/25 13:52
    Worklog Time Spent: 10m 
      Work Description: jbertram commented on code in PR #5553:
URL: https://github.com/apache/activemq-artemis/pull/5553#discussion_r1991551612


##########
artemis-dto/src/test/java/org/apache/activemq/artemis/dto/XmlUtilTest.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.dto;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardOpenOption;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class XmlUtilTest {
+
+   @Test
+   public void testPropertySubstituion(@TempDir Path tempDir) throws Exception 
{
+      final String SYSTEM_PROP_NAME = "sysPropName";
+      final String SYSTEM_PROP_VALUE = "sysPropValue";
+      System.setProperty(SYSTEM_PROP_NAME, SYSTEM_PROP_VALUE);
+
+      // since System.getenv() returns an immutable Map we rely here on an 
environment variable that is likely to exist
+      final String ENV_VAR_NAME = "HOME";

Review Comment:
   I was actually doing that before, but I saw this pattern used in another 
test and thought it was cleaner.





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

    Worklog Id:     (was: 961441)
    Time Spent: 1h  (was: 50m)

> Support environment variable substitution in bootstrap.xml
> ----------------------------------------------------------
>
>                 Key: ARTEMIS-5347
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-5347
>             Project: ActiveMQ Artemis
>          Issue Type: New Feature
>          Components: Configuration
>    Affects Versions: 2.38.0
>            Reporter: Valeriy Ak
>            Assignee: Justin Bertram
>            Priority: Major
>              Labels: bootstrap, pull-request-available
>             Fix For: 2.40.0
>
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> {{bootstrap.xml}} supports TLS connections. For this option you should set 
> {{keyStorePath}} and {{{}keyStorePassword{}}}, e.g.:
> {code:xml}
> <binding uri="https://0.0.0.0:8161";
>          keyStorePath="keystore.jks"
>          keyStorePassword="ENC("@#$%UIO")"
>          
> passwordCodec="org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec">{code}
>  In this config you must set the encrypted password directly and placeholders 
> are not supported. Below code for reading password:
> {code:java}
> //BindingDTO
> private String getPassword(String password) throws Exception {
>     return PasswordMaskingUtil.resolveMask(password, this.passwordCodec);
> } 
> //PasswordMaskingUtil
> public static String resolveMask(String password, String codecClass) throws 
> Exception {
>    return resolveMask(null, password, codecClass);
> }
> public static String resolveMask(Boolean maskPassword, String password, 
> String codecClass) throws Exception {
>    String plainText = password;
>    if (maskPassword == null) {
>       if (isEncMasked(password)) {
>          //masked
>          String bareMaskedPassword = unwrap(password);
>          plainText = getCodec(codecClass).decode(bareMaskedPassword);
>       }
>    } else if (maskPassword) {
>       plainText = getCodec(codecClass).decode(password);
>    }
>    return plainText;
> }{code}
> There is no way to get values from properties/envs, like it is done in 
> {{{}broker.xml{}}}.
> In a cloud environment where credentials are passed by the pod environment 
> this is a problem. It's annoying that only this config does not support 
> values from env and requires additional actions to make it work. 
> Can you support this? I see two way for this:
>  # Add new sensitiveDataCode that will get vaule from env
>  # Read this config by XMLUtil as others, this reader support both props and 
> envs plaseholders



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to