179.7. 隐藏敏感信息
可作为 Camel 2.12 提供
默认情况下,Camel enlists MBeans in JMX (如使用 URI 配置的端点)在此配置中,可能会存在密码等敏感信息。
可通过启用 mask
选项隐藏这些信息,如下所示:
使用 Java DSL,您可以通过以下方式实现:
// only enable routes when Camel starts context.getManagementStrategy().getManagementAgent().setMask(true);
// only enable routes when Camel starts
context.getManagementStrategy().getManagementAgent().setMask(true);
在 Spring DSL 中,您可以:
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> <jmxAgent id="agent" mask="true"/> ... </camelContext>
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<jmxAgent id="agent" mask="true"/>
...
</camelContext>
这将屏蔽具有密码和密码短语等选项的 URI,并使用 xxxxxx
作为替换值。
179.7.1. 声明要屏蔽的 JMX 属性和操作 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
在 org.apache.camel.api.management.ManagedAttribute
和 org.apache.camel.api.management.ManagedOperation
中,属性 掩码
可以设为 true
,以指示应屏蔽 JMX 属性/operation 结果(如果在 JMX 代理上启用)。
例如,在来自 camel-core org.apache.camel.api.mbean.ManagedEndpointMBean
的默认受管端点上,我们宣布 EndpointUri
JMX 属性被屏蔽:
@ManagedAttribute(description = "Endpoint URI", mask = true) String getEndpointUri();
@ManagedAttribute(description = "Endpoint URI", mask = true)
String getEndpointUri();