You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ma...@apache.org on 2021/12/23 13:49:57 UTC
[activemq] 01/03: [AMQ-8413] Add remoteUserName and remotePassword config fields to network connector (#725)
This is an automated email from the ASF dual-hosted git repository.
mattrpav pushed a commit to branch activemq-5.16.x
in repository https://gitbox.apache.org/repos/asf/activemq.git
commit c58e531584955419d5f388ab2e398d4edcada3e0
Author: Matt Pavlovich <ma...@hyte.io>
AuthorDate: Mon Dec 20 08:36:56 2021 -0600
[AMQ-8413] Add remoteUserName and remotePassword config fields to network connector (#725)
---
.../activemq/broker/jmx/NetworkConnectorView.java | 31 +++++++++++++++++-----
.../broker/jmx/NetworkConnectorViewMBean.java | 8 ++++++
.../network/DemandForwardingBridgeSupport.java | 10 +++++--
.../network/NetworkBridgeConfiguration.java | 30 +++++++++++++++++++++
4 files changed, 71 insertions(+), 8 deletions(-)
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkConnectorView.java b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkConnectorView.java
index b3d0762..18e00e6 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkConnectorView.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkConnectorView.java
@@ -20,6 +20,7 @@ import org.apache.activemq.network.NetworkConnector;
public class NetworkConnectorView implements NetworkConnectorViewMBean {
+ private static final String PASSWORD_MASK = "****";
private final NetworkConnector connector;
public NetworkConnectorView(NetworkConnector connector) {
@@ -158,12 +159,8 @@ public class NetworkConnectorView implements NetworkConnectorViewMBean {
@Override
public String getPassword() {
- String pw = connector.getPassword();
- // Hide the password for security reasons.
- if (pw != null) {
- pw = pw.replaceAll(".", "*");
- }
- return pw;
+ // Hide the password for security reasons
+ return PASSWORD_MASK;
}
@Override
@@ -180,4 +177,26 @@ public class NetworkConnectorView implements NetworkConnectorViewMBean {
public void setSuppressDuplicateTopicSubscriptions(boolean val) {
connector.setSuppressDuplicateTopicSubscriptions(val);
}
+
+ @Override
+ public String getRemotePassword() {
+ // Hide the password for security reasons.
+ return PASSWORD_MASK;
+ }
+
+ @Override
+ public void setRemotePassword(String remotePassword) {
+ connector.setRemotePassword(remotePassword);
+ }
+
+ @Override
+ public String getRemoteUserName() {
+ return connector.getRemoteUserName();
+ }
+
+ @Override
+ public void setRemoteUserName(String remoteUserName) {
+ connector.setRemoteUserName(remoteUserName);
+ }
+
}
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkConnectorViewMBean.java b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkConnectorViewMBean.java
index 99974ce..3dac547 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkConnectorViewMBean.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkConnectorViewMBean.java
@@ -81,4 +81,12 @@ public interface NetworkConnectorViewMBean extends Service {
void setSuppressDuplicateTopicSubscriptions(boolean val);
+ String getRemoteUserName();
+
+ void setRemoteUserName(String remoteUserName);
+
+ String getRemotePassword();
+
+ void setRemotePassword(String remotePassword);
+
}
diff --git a/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java b/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
index 2ee198b..578a05f 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
@@ -608,8 +608,14 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
remoteConnectionInfo = new ConnectionInfo();
remoteConnectionInfo.setConnectionId(new ConnectionId(idGenerator.generateId()));
remoteConnectionInfo.setClientId(configuration.getName() + configuration.getClientIdToken() + configuration.getBrokerName() + configuration.getClientIdToken() + "outbound");
- remoteConnectionInfo.setUserName(configuration.getUserName());
- remoteConnectionInfo.setPassword(configuration.getPassword());
+
+ if(configuration.getRemoteUserName() != null) {
+ remoteConnectionInfo.setUserName(configuration.getRemoteUserName());
+ remoteConnectionInfo.setPassword(configuration.getRemotePassword());
+ } else {
+ remoteConnectionInfo.setUserName(configuration.getUserName());
+ remoteConnectionInfo.setPassword(configuration.getPassword());
+ }
remoteBroker.oneway(remoteConnectionInfo);
SessionInfo remoteSessionInfo = new SessionInfo(remoteConnectionInfo, 1);
diff --git a/activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridgeConfiguration.java b/activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridgeConfiguration.java
index a564f57..018355c 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridgeConfiguration.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridgeConfiguration.java
@@ -58,6 +58,8 @@ public class NetworkBridgeConfiguration {
private String brokerURL = "";
private String userName;
private String password;
+ private String remoteUserName;
+ private String remotePassword;
private String destinationFilter = null;
private String name = "NC";
private String clientIdToken = "_";
@@ -301,6 +303,34 @@ public class NetworkBridgeConfiguration {
}
/**
+ * @return the remoteUserName
+ */
+ public String getRemoteUserName() {
+ return this.remoteUserName;
+ }
+
+ /**
+ * @param remoteUserName the remoteUserName to set
+ */
+ public void setRemoteUserName(String remoteUserName) {
+ this.remoteUserName = remoteUserName;
+ }
+
+ /**
+ * @return the remotePassword
+ */
+ public String getRemotePassword() {
+ return this.remotePassword;
+ }
+
+ /**
+ * @param userName the userName to set
+ */
+ public void setRemotePassword(String remotePassword) {
+ this.remotePassword = remotePassword;
+ }
+
+ /**
* @return the destinationFilter
*/
public String getDestinationFilter() {