Skip to content

Commit

Permalink
ARTEMIS-2087 support masked passwords in management.xml
Browse files Browse the repository at this point in the history
(cherry picked from commit 07e14c1)
  • Loading branch information
jbertram authored and clebertsuconic committed Sep 21, 2018
1 parent f90afad commit 1fd1c79
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 7 deletions.
Expand Up @@ -60,7 +60,7 @@ public static ManagementContextDTO createJmxAclConfiguration(String configuratio
return createJmxAclConfiguration(new URI(configuration), artemisHome, artemisInstance, artemisURIInstance);
}

public static ManagementContext create(ManagementContextDTO config) {
public static ManagementContext create(ManagementContextDTO config) throws Exception {
ManagementContext context = new ManagementContext();

if (config.getAuthorisation() != null) {
Expand Down
Expand Up @@ -22,6 +22,8 @@
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

import org.apache.activemq.artemis.utils.PasswordMaskingUtil;

@XmlRootElement(name = "connector")
@XmlAccessorType(XmlAccessType.FIELD)
public class JMXConnectorDTO {
Expand Down Expand Up @@ -62,6 +64,9 @@ public class JMXConnectorDTO {
@XmlAttribute (name = "trust-store-password")
String trustStorePassword;

@XmlAttribute (name = "password-codec")
String passwordCodec;

public String getConnectorHost() {
return connectorHost;
}
Expand Down Expand Up @@ -94,8 +99,8 @@ public String getKeyStorePath() {
return keyStorePath;
}

public String getKeyStorePassword() {
return keyStorePassword;
public String getKeyStorePassword() throws Exception {
return getPassword(keyStorePassword);
}

public String getTrustStoreProvider() {
Expand All @@ -106,7 +111,11 @@ public String getTrustStorePath() {
return trustStorePath;
}

public String getTrustStorePassword() {
return trustStorePassword;
public String getTrustStorePassword() throws Exception {
return getPassword(trustStorePassword);
}

private String getPassword(String password) throws Exception {
return PasswordMaskingUtil.resolveMask(null, password, this.passwordCodec);
}
}
10 changes: 8 additions & 2 deletions docs/user-manual/en/management.md
Expand Up @@ -444,7 +444,7 @@ You can also configure the connector using the following:

- `key-store-password`

The keystore password.
The keystore password. This can be [masked](masking-passwords.md).

- `key-store-provider`

Expand All @@ -456,12 +456,18 @@ You can also configure the connector using the following:

- `trust-store-password`

The trustore password.
The trustore password. This can be [masked](masking-passwords.md).

- `trust-store-provider`

The provider; `JKS` by default.

- `password-codec`

The fully qualified class name of the password codec to use. See the
[password masking](masking-passwords.md) documentation for more details on
how this works.

> **Note:**
>
> It is important to note that the rmi registry will pick an ip address to bind
Expand Down
23 changes: 23 additions & 0 deletions docs/user-manual/en/masking-passwords.md
Expand Up @@ -155,6 +155,29 @@ codec other than the default one. For example
</web>
```

#### Passwords in management.xml

The broker embeds a JMX connector which is used for management. The connector can
be secured using SSL and it can be configured with a keystore password and/or
truststore password which by default are specified in plain text forms.

To mask these passwords you need to use `ENC()` syntax. The `mask-password`
boolean is not supported here.

You can also set the `password-codec` attribute if you want to use a password
codec other than the default one. For example

```xml
<connector
connector-port="1099"
connector-host="localhost"
secured="true"
key-store-path="myKeystore.jks"
key-store-password="ENC(3a34fd21b82bf2a822fa49a8d8fa115d"
trust-store-path="myTruststore.jks"
trust-store-password="ENC(3a34fd21b82bf2a822fa49a8d8fa115d)"/>
```

### Passwords for the JCA Resource Adapter

Both ra.xml and MDB activation configuration have a `password` property that
Expand Down

0 comments on commit 1fd1c79

Please sign in to comment.