ARTEMIS-3399 fix audit logging for AMQP

Due to the multi-threaded AMQP implementation the ThreadLocal variables
used by the AuditLogger to track the username and remote address don't
work properly. Changes include:

 - Passing the audit Subject (set during authentication) and the remote
   address explicitly for audit logging on the relevant ServerSession
   methods rather than relying on the AuditLogger's ThreadLocal
   variables
 - Audit logging core session creation *after* successful authentication
   so that we have the proper Subject; this is especially important for
   the SSL certificate authentication use-case
 - Renaming some methods and variables in AuditLogger to more accurately
   reflect their intended use
 - Adding JavaDoc and refactoring the getCaller methods on AuditLogger
 - Refactor audit log testing and add a new test
This commit is contained in:
Justin Bertram 2021-07-22 12:54:47 -05:00 committed by Clebert Suconic
parent 459d392444
commit 2954829e3e
36 changed files with 1175 additions and 925 deletions

View File

@ -107,7 +107,7 @@ public abstract class AbstractControl extends StandardMBean {
@Override
public MBeanInfo getMBeanInfo() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getMBeanInfo(this);
}
MBeanInfo info = super.getMBeanInfo();

View File

@ -53,7 +53,7 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
@Override
public String getFactoryClassName() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getFactoryClassName(this.acceptor);
}
clearIO();
@ -66,7 +66,7 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
@Override
public String getName() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getName(this.acceptor);
}
clearIO();
@ -79,7 +79,7 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
@Override
public Map<String, Object> getParameters() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getParameters(this.acceptor);
}
clearIO();
@ -98,7 +98,7 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
@Override
public void reload() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.reload(this.acceptor);
}
clearIO();
@ -111,7 +111,7 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
@Override
public boolean isStarted() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isStarted(this.acceptor);
}
clearIO();
@ -124,7 +124,7 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
@Override
public void start() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.startAcceptor(this.acceptor);
}
clearIO();
@ -137,7 +137,7 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
@Override
public void stop() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.stopAcceptor(this.acceptor);
}
clearIO();

View File

@ -99,7 +99,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public String[] getRoutingTypes() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getRoutingTypes(this.addressInfo);
}
EnumSet<RoutingType> routingTypes = addressInfo.getRoutingTypes();
@ -113,7 +113,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public String getRoutingTypesAsJSON() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getRoutingTypesAsJSON(this.addressInfo);
}
@ -151,7 +151,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
}
private String[] getQueueNames(SearchType searchType) throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getQueueNames(this.addressInfo, searchType);
}
clearIO();
@ -177,7 +177,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public String[] getBindingNames() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getBindingNames(this.addressInfo);
}
try {
@ -203,7 +203,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public Object[] getRoles() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getRoles(this.addressInfo);
}
clearIO();
@ -224,7 +224,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public String getRolesAsJSON() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getRolesAsJSON(this.addressInfo);
}
clearIO();
@ -243,7 +243,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public long getNumberOfBytesPerPage() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getNumberOfBytesPerPage(this.addressInfo);
}
clearIO();
@ -264,7 +264,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public long getAddressSize() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getAddressSize(this.addressInfo);
}
clearIO();
@ -284,7 +284,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public long getNumberOfMessages() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getNumberOfMessages(this.addressInfo);
}
clearIO();
@ -308,7 +308,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public boolean isPaging() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isPaging(this.addressInfo);
}
clearIO();
@ -325,7 +325,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public int getNumberOfPages() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getNumberOfPages(this.addressInfo);
}
clearIO();
@ -347,7 +347,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public long getMessageCount() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getMessageCount(this.addressInfo);
}
return getMessageCount(DurabilityType.ALL);
@ -355,7 +355,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public long getRoutedMessageCount() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getRoutedMessageCount(this.addressInfo);
}
return addressInfo.getRoutedMessageCount();
@ -363,7 +363,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public long getUnRoutedMessageCount() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getUnRoutedMessageCount(this.addressInfo);
}
return addressInfo.getUnRoutedMessageCount();
@ -377,8 +377,8 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
boolean durable,
final String user,
final String password) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.sendMessage(this, null, headers, type, body, durable, user, "****");
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.sendMessageThroughManagement(this, headers, type, body, durable, user, "****");
}
try {
return sendMessage(addressInfo.getName(), server, headers, type, body, durable, user, password);
@ -406,7 +406,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public void pause(boolean persist) {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.pause(addressInfo);
}
checkStarted();
@ -432,7 +432,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public void resume() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.resume(addressInfo);
}
checkStarted();
@ -457,7 +457,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public boolean isPaused() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isPaused(this.addressInfo);
}
return addressInfo.isPaused();
@ -465,7 +465,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public boolean isRetroactiveResource() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isRetroactiveResource(this.addressInfo);
}
return ResourceNames.isRetroactiveResource(server.getInternalNamingPrefix(), addressInfo.getName());
@ -473,7 +473,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public long getCurrentDuplicateIdCacheSize() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getCurrentDuplicateIdCacheSize(this.addressInfo);
}
DuplicateIDCache cache = ((PostOfficeImpl)server.getPostOffice()).getDuplicateIDCaches().get(addressInfo.getName());
@ -490,7 +490,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public boolean clearDuplicateIdCache() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.clearDuplicateIdCache(this.addressInfo);
}
DuplicateIDCache cache = ((PostOfficeImpl)server.getPostOffice()).getDuplicateIDCaches().get(addressInfo.getName());
@ -508,7 +508,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public boolean isAutoCreated() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isAutoCreated(this.addressInfo);
}
return addressInfo.isAutoCreated();
@ -516,7 +516,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public boolean isInternal() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isInternal(this.addressInfo);
}
return addressInfo.isInternal();
@ -524,7 +524,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override
public boolean isTemporary() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isTemporary(this.addressInfo);
}
return addressInfo.isTemporary();

View File

@ -62,7 +62,7 @@ public class BaseBroadcastGroupControlImpl extends AbstractControl implements Ba
@Override
public String getName() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getName(this.broadcastGroup);
}
clearIO();
@ -75,7 +75,7 @@ public class BaseBroadcastGroupControlImpl extends AbstractControl implements Ba
@Override
public long getBroadcastPeriod() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getBroadcastPeriod(this.broadcastGroup);
}
clearIO();
@ -88,7 +88,7 @@ public class BaseBroadcastGroupControlImpl extends AbstractControl implements Ba
@Override
public Object[] getConnectorPairs() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getConnectorPairs(this.broadcastGroup);
}
clearIO();
@ -107,7 +107,7 @@ public class BaseBroadcastGroupControlImpl extends AbstractControl implements Ba
@Override
public String getConnectorPairsAsJSON() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getConnectorPairsAsJSON(this.broadcastGroup);
}
clearIO();
@ -122,7 +122,7 @@ public class BaseBroadcastGroupControlImpl extends AbstractControl implements Ba
@Override
public boolean isStarted() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isStarted(this.broadcastGroup);
}
clearIO();
@ -135,7 +135,7 @@ public class BaseBroadcastGroupControlImpl extends AbstractControl implements Ba
@Override
public void start() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.startBroadcastGroup(this.broadcastGroup);
}
clearIO();
@ -148,7 +148,7 @@ public class BaseBroadcastGroupControlImpl extends AbstractControl implements Ba
@Override
public void stop() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.stopBroadcastGroup(this.broadcastGroup);
}
clearIO();

View File

@ -55,7 +55,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override
public String[] getStaticConnectors() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getStaticConnectors(this.bridge);
}
clearIO();
@ -69,7 +69,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override
public String getForwardingAddress() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getForwardingAddress(this.bridge);
}
clearIO();
@ -82,7 +82,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override
public String getQueueName() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getQueueName(this.bridge);
}
clearIO();
@ -95,7 +95,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override
public String getDiscoveryGroupName() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getDiscoveryGroupName(this.bridge);
}
clearIO();
@ -108,7 +108,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override
public String getFilterString() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getFilterString(this.bridge);
}
clearIO();
@ -121,7 +121,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override
public int getReconnectAttempts() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getReconnectAttempts(this.bridge);
}
clearIO();
@ -134,7 +134,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override
public String getName() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getName(this.bridge);
}
clearIO();
@ -147,7 +147,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override
public long getRetryInterval() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getRetryInterval(this.bridge);
}
clearIO();
@ -160,7 +160,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override
public double getRetryIntervalMultiplier() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getRetryIntervalMultiplier(this.bridge);
}
clearIO();
@ -173,7 +173,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override
public String getTransformerClassName() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getTransformerClassName(this.bridge);
}
clearIO();
@ -186,7 +186,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override
public String getTransformerPropertiesAsJSON() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getTransformerPropertiesAsJSON(this.bridge);
}
return JsonUtil.toJsonObject(getTransformerProperties()).toString();
@ -194,7 +194,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override
public Map<String, String> getTransformerProperties() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getTransformerProperties(this.bridge);
}
clearIO();
@ -207,7 +207,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override
public boolean isStarted() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isStartedBridge(this.bridge);
}
clearIO();
@ -220,7 +220,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override
public boolean isUseDuplicateDetection() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isUseDuplicateDetection(this.bridge);
}
clearIO();
@ -233,7 +233,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override
public boolean isHA() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isHA(this.bridge);
}
clearIO();
@ -246,7 +246,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override
public void start() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.startBridge(this.bridge);
}
clearIO();
@ -259,7 +259,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override
public void stop() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.stopBridge(this.bridge);
}
clearIO();
@ -283,7 +283,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override
public long getMessagesPendingAcknowledgement() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getMessagesPendingAcknowledgement(this.bridge);
}
clearIO();
@ -296,7 +296,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override
public long getMessagesAcknowledged() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getMessagesAcknowledged(this.bridge);
}
clearIO();
@ -309,7 +309,7 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override
public Map<String, Object> getMetrics() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getMetrics(this.bridge);
}
clearIO();

View File

@ -48,7 +48,7 @@ public class BroadcastGroupControlImpl extends BaseBroadcastGroupControlImpl imp
//todo ghoward we should deal with this properly
@Override
public String getGroupAddress() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getGroupAddress(this.getBroadcastGroup());
}
clearIO();
@ -61,7 +61,7 @@ public class BroadcastGroupControlImpl extends BaseBroadcastGroupControlImpl imp
@Override
public int getGroupPort() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getGroupPort(this.getBroadcastGroup());
}
clearIO();
@ -74,7 +74,7 @@ public class BroadcastGroupControlImpl extends BaseBroadcastGroupControlImpl imp
@Override
public int getLocalBindPort() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getLocalBindPort(this.getBroadcastGroup());
}
clearIO();

View File

@ -56,7 +56,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override
public String getAddress() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getAddress(this.clusterConnection);
}
clearIO();
@ -70,7 +70,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override
public String getDiscoveryGroupName() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getDiscoveryGroupName(this.clusterConnection);
}
clearIO();
@ -84,7 +84,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override
public int getMaxHops() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getMaxHops(this.clusterConnection);
}
clearIO();
@ -98,7 +98,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override
public String getName() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getName(this.clusterConnection);
}
clearIO();
@ -112,7 +112,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override
public long getRetryInterval() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getRetryInterval(this.clusterConnection);
}
clearIO();
@ -126,7 +126,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override
public String getNodeID() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getNodeID(this.clusterConnection);
}
clearIO();
@ -139,7 +139,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override
public String[] getStaticConnectors() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getStaticConnectors(this.clusterConnection);
}
clearIO();
@ -157,7 +157,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override
public String getStaticConnectorsAsJSON() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getStaticConnectorsAsJSON(this.clusterConnection);
}
clearIO();
@ -170,7 +170,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override
public boolean isDuplicateDetection() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isDuplicateDetection(this.clusterConnection);
}
clearIO();
@ -183,7 +183,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override
public String getMessageLoadBalancingType() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getMessageLoadBalancingType(this.clusterConnection);
}
clearIO();
@ -196,7 +196,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override
public String getTopology() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getTopology(this.clusterConnection);
}
clearIO();
@ -209,7 +209,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override
public Map<String, String> getNodes() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getNodes(this.clusterConnection);
}
clearIO();
@ -222,7 +222,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override
public boolean isStarted() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isStarted(this.clusterConnection);
}
clearIO();
@ -235,7 +235,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override
public void start() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.startClusterConnection(this.clusterConnection);
}
clearIO();
@ -249,7 +249,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override
public void stop() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.stopClusterConnection(this.clusterConnection);
}
clearIO();
@ -273,7 +273,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override
public long getMessagesPendingAcknowledgement() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getMessagesPendingAcknowledgement(this.clusterConnection);
}
clearIO();
@ -286,7 +286,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override
public long getMessagesAcknowledged() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getMessagesAcknowledged(this.clusterConnection);
}
clearIO();
@ -299,7 +299,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override
public Map<String, Object> getMetrics() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getMetrics(this.clusterConnection);
}
clearIO();
@ -312,7 +312,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override
public Map<String, Object> getBridgeMetrics(String nodeId) {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getBridgeMetrics(this.clusterConnection, nodeId);
}
clearIO();

View File

@ -58,7 +58,7 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
@Override
public String getAddress() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getAddress(this.divert);
}
clearIO();
@ -71,7 +71,7 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
@Override
public String getFilter() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getFilter(this.divert);
}
clearIO();
@ -85,7 +85,7 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
@Override
public String getForwardingAddress() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getForwardingAddress(this.divert);
}
clearIO();
@ -98,7 +98,7 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
@Override
public String getRoutingName() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getRoutingName(this.divert);
}
clearIO();
@ -111,7 +111,7 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
@Override
public String getTransformerClassName() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getTransformerClassName(this.divert);
}
clearIO();
@ -126,7 +126,7 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
@Override
public String getTransformerPropertiesAsJSON() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getTransformerPropertiesAsJSON(this.divert);
}
return JsonUtil.toJsonObject(getTransformerProperties()).toString();
@ -134,7 +134,7 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
@Override
public Map<String, String> getTransformerProperties() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getTransformerProperties(this.divert);
}
clearIO();
@ -149,7 +149,7 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
@Override
public String getRoutingType() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getRoutingType(this.divert);
}
clearIO();
@ -162,7 +162,7 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
@Override
public String getUniqueName() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getUniqueName(this.divert);
}
clearIO();
@ -175,7 +175,7 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
@Override
public boolean isExclusive() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isExclusive(this.divert);
}
clearIO();
@ -188,7 +188,7 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
@Override
public boolean isRetroactiveResource() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isRetroactiveResource(this.divert);
}
return ResourceNames.isRetroactiveResource(internalNamingPrefix, divert.getUniqueName());

View File

@ -47,7 +47,7 @@ public class JGroupsChannelBroadcastGroupControlImpl extends BaseBroadcastGroupC
@Override
public String getChannelName() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getChannelName(this.endpointFactory.getChannelName());
}
return endpointFactory.getChannelName();

View File

@ -52,7 +52,7 @@ public class JGroupsFileBroadcastGroupControlImpl extends BaseBroadcastGroupCont
@Override
public String getFileContents() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getFileContents(this.getBroadcastGroup());
}
URL resource = this.getClass().getClassLoader().getResource(this.getFile());
@ -62,7 +62,7 @@ public class JGroupsFileBroadcastGroupControlImpl extends BaseBroadcastGroupCont
@Override
public String getChannelName() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getChannelName(this.getBroadcastGroup());
}
return endpointFactory.getChannelName();
@ -70,7 +70,7 @@ public class JGroupsFileBroadcastGroupControlImpl extends BaseBroadcastGroupCont
@Override
public String getFile() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getFile(this.getBroadcastGroup());
}
return endpointFactory.getFile();

View File

@ -47,7 +47,7 @@ public class JGroupsPropertiesBroadcastGroupControlImpl extends BaseBroadcastGro
@Override
public String getChannelName() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getChannelName(this.endpointFactory.getChannelName());
}
return endpointFactory.getChannelName();

View File

@ -136,7 +136,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public String getName() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getName(queue);
}
clearIO();
@ -149,7 +149,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public String getAddress() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getAddress(queue);
}
@ -160,7 +160,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public String getFilter() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getFilter(queue);
}
@ -179,7 +179,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public boolean isDurable() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isDurable(queue);
}
checkStarted();
@ -194,7 +194,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public String getUser() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getUser(queue);
}
checkStarted();
@ -211,7 +211,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public String getRoutingType() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getRoutingType(queue);
}
checkStarted();
@ -227,7 +227,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public boolean isTemporary() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isTemporary(queue);
}
checkStarted();
@ -242,7 +242,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public boolean isRetroactiveResource() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isRetroactiveResource(queue);
}
checkStarted();
@ -257,7 +257,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public long getMessageCount() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getMessageCount(queue);
}
checkStarted();
@ -272,7 +272,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public long getPersistentSize() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getPersistentSize(queue);
}
@ -288,7 +288,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public long getDurableMessageCount() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getDurableMessageCount(queue);
}
checkStarted();
@ -303,7 +303,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public long getDurablePersistentSize() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getDurablePersistSize(queue);
}
checkStarted();
@ -318,7 +318,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public int getConsumerCount() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getConsumerCount(queue);
}
checkStarted();
@ -333,7 +333,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public int getDeliveringCount() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getDeliveringCount(queue);
}
checkStarted();
@ -348,7 +348,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public long getDeliveringSize() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getDeliveringSize(queue);
}
checkStarted();
@ -363,7 +363,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public int getDurableDeliveringCount() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getDurableDeliveringCount(queue);
}
checkStarted();
@ -378,7 +378,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public long getDurableDeliveringSize() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getDurableDeliveringSize(queue);
}
checkStarted();
@ -393,7 +393,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public long getMessagesAdded() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getMessagesAdded(queue);
}
checkStarted();
@ -408,7 +408,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public long getMessagesAcknowledged() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getMessagesAcknowledged(queue);
}
checkStarted();
@ -423,7 +423,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public long getAcknowledgeAttempts() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getMessagesAcknowledged(queue);
}
checkStarted();
@ -438,7 +438,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public long getMessagesExpired() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getMessagesExpired(queue);
}
checkStarted();
@ -453,7 +453,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public long getMessagesKilled() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getMessagesKilled(queue);
}
checkStarted();
@ -468,7 +468,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public long getID() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getID(queue);
}
checkStarted();
@ -483,7 +483,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public long getScheduledCount() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getScheduledCount(queue);
}
checkStarted();
@ -498,7 +498,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public long getScheduledSize() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getScheduledSize(queue);
}
checkStarted();
@ -513,7 +513,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public long getDurableScheduledCount() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getDurableScheduledCount(queue);
}
checkStarted();
@ -528,7 +528,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public long getDurableScheduledSize() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getDurableScheduledSize(queue);
}
checkStarted();
@ -543,7 +543,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public String getDeadLetterAddress() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getDeadLetterAddress(queue);
}
checkStarted();
@ -563,7 +563,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public String getExpiryAddress() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getExpiryAddress(queue);
}
checkStarted();
@ -584,7 +584,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public int getMaxConsumers() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getMaxConsumers(queue);
}
checkStarted();
@ -599,7 +599,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public boolean isPurgeOnNoConsumers() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isPurgeOnNoConsumers(queue);
}
checkStarted();
@ -614,7 +614,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public void disable() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.disable(queue);
}
checkStarted();
@ -629,7 +629,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public void enable() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.enable(queue);
}
checkStarted();
@ -644,7 +644,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public boolean isEnabled() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isEnabled(queue);
}
checkStarted();
@ -660,7 +660,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public boolean isConfigurationManaged() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isConfigurationManaged(queue);
}
checkStarted();
@ -675,7 +675,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public boolean isExclusive() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isExclusive(queue);
}
checkStarted();
@ -690,7 +690,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public boolean isLastValue() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isLastValue(queue);
}
checkStarted();
@ -705,7 +705,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public String getLastValueKey() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.lastValueKey(queue);
}
checkStarted();
@ -724,7 +724,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public int getConsumersBeforeDispatch() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.consumersBeforeDispatch(queue);
}
checkStarted();
@ -739,7 +739,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public long getDelayBeforeDispatch() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.delayBeforeDispatch(queue);
}
checkStarted();
@ -754,7 +754,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public Map<String, Object>[] listScheduledMessages() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.listScheduledMessages(queue);
}
checkStarted();
@ -770,7 +770,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public String listScheduledMessagesAsJSON() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.listScheduledMessagesAsJSON(queue);
}
checkStarted();
@ -800,7 +800,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public Map<String, Map<String, Object>[]> listDeliveringMessages() throws ActiveMQException {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.listDeliveringMessages(queue);
}
checkStarted();
@ -823,7 +823,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public String listDeliveringMessagesAsJSON() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.listDeliveringMessagesAsJSON(queue);
}
checkStarted();
@ -838,7 +838,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public Map<String, Object>[] listMessages(final String filterStr) throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.listMessages(queue, filterStr);
}
checkStarted();
@ -875,7 +875,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public String listMessagesAsJSON(final String filter) throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.listMessagesAsJSON(queue);
}
checkStarted();
@ -889,7 +889,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
}
protected Map<String, Object>[] getFirstMessage() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getFirstMessage(queue);
}
checkStarted();
@ -916,7 +916,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public String getFirstMessageAsJSON() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getFirstMessageAsJSON(queue);
}
return toJSON(getFirstMessage());
@ -924,7 +924,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public Long getFirstMessageTimestamp() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getFirstMessageTimestamp(queue);
}
@ -941,7 +941,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public Long getFirstMessageAge() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getFirstMessageAge(queue);
}
@ -960,7 +960,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public long countMessages(final String filterStr) throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.countMessages(queue, filterStr);
}
@ -970,7 +970,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public String countMessages(final String filterStr, final String groupByProperty) throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.countMessages(queue, filterStr, groupByProperty);
}
@ -1010,7 +1010,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public long countDeliveringMessages(final String filterStr) throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.countDeliveringMessages(queue, filterStr);
}
@ -1020,7 +1020,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public String countDeliveringMessages(final String filterStr, final String groupByProperty) throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.countDeliveringMessages(queue, filterStr, groupByProperty);
}
@ -1066,7 +1066,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public boolean removeMessage(final long messageID) throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.removeMessage(queue, messageID);
}
checkStarted();
@ -1088,7 +1088,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public int removeMessages(final int flushLimit, final String filterStr) throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.removeMessages(queue, flushLimit, filterStr);
}
checkStarted();
@ -1122,7 +1122,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public boolean expireMessage(final long messageID) throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.expireMessage(queue, messageID);
}
checkStarted();
@ -1137,7 +1137,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public int expireMessages(final String filterStr) throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.expireMessages(queue, filterStr);
}
checkStarted();
@ -1155,7 +1155,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public boolean retryMessage(final long messageID) throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.retryMessage(queue, messageID);
}
@ -1193,7 +1193,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public int retryMessages() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.retryMessages(queue);
}
checkStarted();
@ -1215,7 +1215,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
public boolean moveMessage(final long messageID,
final String otherQueueName,
final boolean rejectDuplicates) throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.moveMessage(queue, messageID, otherQueueName, rejectDuplicates);
}
checkStarted();
@ -1254,7 +1254,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
final String otherQueueName,
final boolean rejectDuplicates,
final int messageCount) throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.moveMessages(queue, flushLimit, filterStr, otherQueueName, rejectDuplicates, messageCount);
}
checkStarted();
@ -1286,7 +1286,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public int sendMessagesToDeadLetterAddress(final String filterStr) throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.sendMessagesToDeadLetterAddress(queue, filterStr);
}
checkStarted();
@ -1308,8 +1308,8 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
boolean durable,
final String user,
final String password) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.sendMessage(queue, null, headers, type, body, durable, user, "****");
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.sendMessageThroughManagement(queue, headers, type, body, durable, user, "****");
}
try {
String s = sendMessage(queue.getAddress(), server, headers, type, body, durable, user, password, queue.getID());
@ -1327,7 +1327,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public boolean sendMessageToDeadLetterAddress(final long messageID) throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.sendMessageToDeadLetterAddress(queue, messageID);
}
checkStarted();
@ -1342,7 +1342,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public int changeMessagesPriority(final String filterStr, final int newPriority) throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.changeMessagesPriority(queue, filterStr, newPriority);
}
checkStarted();
@ -1362,7 +1362,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public boolean changeMessagePriority(final long messageID, final int newPriority) throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.changeMessagePriority(queue, messageID, newPriority);
}
checkStarted();
@ -1380,7 +1380,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public String listMessageCounter() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.listMessageCounter(queue);
}
checkStarted();
@ -1397,7 +1397,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public void resetMessageCounter() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.resetMessageCounter(queue);
}
checkStarted();
@ -1412,7 +1412,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public String listMessageCounterAsHTML() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.listMessageCounterAsHTML(queue);
}
checkStarted();
@ -1427,7 +1427,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public String listMessageCounterHistory() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.listMessageCounterHistory(queue);
}
checkStarted();
@ -1442,7 +1442,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public String listMessageCounterHistoryAsHTML() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.listMessageCounterHistoryAsHTML(queue);
}
checkStarted();
@ -1457,7 +1457,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public void pause() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.pause(queue);
}
checkStarted();
@ -1482,7 +1482,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public void pause(boolean persist) {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.pause(queue, persist);
}
checkStarted();
@ -1505,7 +1505,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
}
@Override
public void resume() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.resume(queue);
}
checkStarted();
@ -1530,7 +1530,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public boolean isPaused() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isPaused(queue);
}
checkStarted();
@ -1550,7 +1550,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public CompositeData[] browse(int page, int pageSize, String filter) throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.browse(queue, page, pageSize);
}
checkStarted();
@ -1605,7 +1605,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
}
@Override
public CompositeData[] browse(String filter) throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.browse(queue, filter);
}
checkStarted();
@ -1651,7 +1651,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public void flushExecutor() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.flushExecutor(queue);
}
checkStarted();
@ -1666,7 +1666,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public void resetAllGroups() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.resetAllGroups(queue);
}
checkStarted();
@ -1681,7 +1681,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public void resetGroup(String groupID) {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.resetGroup(queue, groupID);
}
checkStarted();
@ -1696,7 +1696,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public int getGroupCount() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getGroupCount(queue);
}
checkStarted();
@ -1711,7 +1711,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public String listGroupsAsJSON() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.listGroupsAsJSON(queue);
}
checkStarted();
@ -1742,7 +1742,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public long getRingSize() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getRingSize(queue);
}
checkStarted();
@ -1757,7 +1757,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public String listConsumersAsJSON() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.listConsumersAsJSON(queue);
}
checkStarted();
@ -1798,7 +1798,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public void resetMessagesAdded() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.resetMessagesAdded(queue);
}
checkStarted();
@ -1814,7 +1814,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public void resetMessagesAcknowledged() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.resetMessagesAcknowledged(queue);
}
checkStarted();
@ -1830,7 +1830,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public void resetMessagesExpired() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.resetMessagesExpired(queue);
}
checkStarted();
@ -1846,7 +1846,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public void resetMessagesKilled() throws Exception {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.resetMessagesKilled(queue);
}
checkStarted();
@ -1862,7 +1862,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public boolean isGroupRebalance() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isGroupRebalance(queue);
}
checkStarted();
@ -1877,7 +1877,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public boolean isGroupRebalancePauseDispatch() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.isGroupRebalancePauseDispatch(queue);
}
checkStarted();
@ -1892,7 +1892,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public int getGroupBuckets() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getGroupBuckets(queue);
}
checkStarted();
@ -1907,7 +1907,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public String getGroupFirstKey() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getGroupFirstKey(queue);
}
checkStarted();
@ -1924,7 +1924,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override
public int getPreparedTransactionMessageCount() {
if (AuditLogger.isEnabled()) {
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.getPreparedTransactionMessageCount(queue);
}
checkStarted();

View File

@ -195,7 +195,7 @@ public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryC
connection.setAuditSubject(subject);
}
if (AuditLogger.isResourceLoggingEnabled()) {
AuditLogger.userSuccesfullyLoggedInAudit(subject);
AuditLogger.userSuccesfullyAuthenticatedInAudit(subject, connection.getRemoteAddress());
}
return validatedUser;
@ -375,7 +375,7 @@ public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryC
ActiveMQServerLogger.LOGGER.securityProblemWhileAuthenticating(e.getMessage());
if (AuditLogger.isResourceLoggingEnabled()) {
AuditLogger.userFailedLoggedInAudit(null, e.getMessage());
AuditLogger.userFailedAuthenticationInAudit(null, e.getMessage());
}
throw e;

View File

@ -1673,11 +1673,6 @@ public class ActiveMQServerImpl implements ActiveMQServer {
final OperationContext context,
final Map<SimpleString, RoutingType> prefixes,
final String securityDomain) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.createCoreSession(this, name, username, "****", minLargeMessageSize, connection, autoCommitSends,
autoCommitAcks, preAcknowledge, xa, defaultAddress, callback, autoCreateQueues, context, prefixes);
}
String validatedUser = "";
if (securityStore != null) {
@ -1686,6 +1681,11 @@ public class ActiveMQServerImpl implements ActiveMQServer {
checkSessionLimit(validatedUser);
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.createCoreSession(this, connection.getAuditSubject(), connection.getRemoteAddress(), name, username, "****", minLargeMessageSize, connection, autoCommitSends,
autoCommitAcks, preAcknowledge, xa, defaultAddress, callback, autoCreateQueues, context, prefixes);
}
final ServerSessionImpl session = internalCreateSession(name, username, password, validatedUser, minLargeMessageSize, connection, autoCommitSends, autoCommitAcks, preAcknowledge, xa, defaultAddress, callback, context, autoCreateQueues, prefixes, securityDomain);
return session;

View File

@ -493,8 +493,8 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
try {
Message message = reference.getMessage();
if (AuditLogger.isMessageEnabled()) {
AuditLogger.coreConsumeMessage(session.getRemotingConnection().getAuditSubject(), getQueueName().toString(), reference.toString());
if (AuditLogger.isMessageLoggingEnabled()) {
AuditLogger.coreConsumeMessage(session.getRemotingConnection().getAuditSubject(), session.getRemotingConnection().getRemoteAddress(), getQueueName().toString(), reference.toString());
}
if (server.hasBrokerMessagePlugins()) {
server.callBrokerMessagePlugins(plugin -> plugin.beforeDeliver(this, reference));

View File

@ -524,8 +524,8 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
final boolean browseOnly,
final boolean supportLargeMessage,
final Integer credits) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.createCoreConsumer(this, getUsername(), consumerID, queueName, filterString, priority, browseOnly, supportLargeMessage, credits);
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.createCoreConsumer(this, remotingConnection.getAuditSubject(), remotingConnection.getRemoteAddress(), consumerID, queueName, filterString, priority, browseOnly, supportLargeMessage, credits);
}
final SimpleString unPrefixedQueueName = removePrefix(queueName);
@ -714,8 +714,8 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
@Override
public Queue createQueue(QueueConfiguration queueConfiguration) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.createQueue(this, getUsername(), queueConfiguration);
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.createQueue(this, remotingConnection.getAuditSubject(), remotingConnection.getRemoteAddress(), queueConfiguration);
}
queueConfiguration
@ -924,8 +924,8 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
public AddressInfo createAddress(final SimpleString address,
EnumSet<RoutingType> routingTypes,
final boolean autoCreated) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.serverSessionCreateAddress(this.getName(), getUsername(), address, routingTypes, autoCreated);
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.serverSessionCreateAddress(this.getName(), remotingConnection.getAuditSubject(), remotingConnection.getRemoteAddress(), address, routingTypes, autoCreated);
}
SimpleString realAddress = CompositeAddress.extractAddressName(address);
@ -944,8 +944,8 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
@Override
public AddressInfo createAddress(AddressInfo addressInfo, boolean autoCreated) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.serverSessionCreateAddress(this.getName(), getUsername(), addressInfo, autoCreated);
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.serverSessionCreateAddress(this.getName(), remotingConnection.getAuditSubject(), remotingConnection.getRemoteAddress(), addressInfo, autoCreated);
}
AddressInfo art = getAddressAndRoutingType(addressInfo);
@ -1034,8 +1034,8 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
@Override
public void createSharedQueue(QueueConfiguration queueConfiguration) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.createSharedQueue(this, getUsername(), queueConfiguration);
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.createSharedQueue(this, remotingConnection.getAuditSubject(), remotingConnection.getRemoteAddress(), queueConfiguration);
}
queueConfiguration.setAddress(removePrefix(queueConfiguration.getAddress()));
@ -1161,8 +1161,8 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
@Override
public void deleteQueue(final SimpleString queueToDelete) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.destroyQueue(this, getUsername(), queueToDelete);
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.destroyQueue(this, remotingConnection.getAuditSubject(), remotingConnection.getRemoteAddress(), queueToDelete);
}
final SimpleString unPrefixedQueueName = removePrefix(queueToDelete);
@ -1802,8 +1802,8 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
message.setMessageID(id);
}
if (AuditLogger.isMessageEnabled()) {
AuditLogger.coreSendMessage(getUsername(), message.toString(), routingContext);
if (AuditLogger.isMessageLoggingEnabled()) {
AuditLogger.coreSendMessage(remotingConnection.getAuditSubject(), remotingConnection.getRemoteAddress(), message.toString(), routingContext);
}
SimpleString address = message.getAddressSimpleString();
@ -2048,8 +2048,8 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
private RoutingStatus handleManagementMessage(final Transaction tx,
final Message message,
final boolean direct) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.handleManagementMessage(this.getName(), getUsername(), tx, message, direct);
if (AuditLogger.isBaseLoggingEnabled()) {
AuditLogger.handleManagementMessage(this.getName(), remotingConnection.getAuditSubject(), remotingConnection.getRemoteAddress(), tx, message, direct);
}
try {
securityCheck(removePrefix(message.getAddressSimpleString()), CheckType.MANAGE, this);

View File

@ -43,12 +43,12 @@ public class BasicAuthenticator implements JMXAuthenticator {
result = securityManager.authenticate(params[0], params[1], null, null);
if (result != null) {
if (AuditLogger.isResourceLoggingEnabled()) {
AuditLogger.userSuccesfullyLoggedInAudit(result);
AuditLogger.userSuccesfullyAuthenticatedInAudit(result);
}
return result;
} else {
if (AuditLogger.isResourceLoggingEnabled()) {
AuditLogger.userFailedLoggedInAudit(result, null);
AuditLogger.userFailedAuthenticationInAudit(result, null);
}
throw new SecurityException("Authentication failed");
}

View File

@ -74,12 +74,12 @@ public class JaasAuthenticator implements JMXAuthenticator {
});
loginContext.login();
if (AuditLogger.isResourceLoggingEnabled()) {
AuditLogger.userSuccesfullyLoggedInAudit(subject);
AuditLogger.userSuccesfullyAuthenticatedInAudit(subject);
}
return subject;
} catch (LoginException e) {
if (AuditLogger.isResourceLoggingEnabled()) {
AuditLogger.userFailedLoggedInAudit(subject, e.getMessage());
AuditLogger.userFailedAuthenticationInAudit(subject, e.getMessage());
}
throw new SecurityException("Authentication failed", e);
}

View File

@ -46,9 +46,9 @@ public class AuthenticationFilter implements Filter {
//status 200 means that the user has been authenticated, anything else must be a failure
if (status == 200) {
HttpSession session = ((Request) servletRequest).getSession();
AuditLogger.userSuccesfullyLoggedInAudit(session != null ? (Subject) session.getAttribute("subject") : null);
AuditLogger.userSuccesfullyAuthenticatedInAudit(session != null ? (Subject) session.getAttribute("subject") : null);
} else {
AuditLogger.userFailedLoggedInAudit("" + status);
AuditLogger.userFailedAuthenticationInAudit("" + status);
}
}
}

View File

@ -537,6 +537,27 @@
</args>
</configuration>
</execution>
<execution>
<phase>test-compile</phase>
<id>create-createAuditLoggingAMQPMutualSSL</id>
<goals>
<goal>create</goal>
</goals>
<configuration>
<configuration>${basedir}/target/classes/servers/audit-logging-amqp-mutual-ssl</configuration>
<noWeb>false</noWeb>
<allowAnonymous>true</allowAnonymous>
<user>admin</user>
<password>admin</password>
<instance>${basedir}/target/audit-logging-amqp-mutual-ssl</instance>
<args>
<!-- this is needed to run the server remotely -->
<arg>--java-options</arg>
<arg>-Djava.rmi.server.hostname=localhost</arg>
<!--<arg>-Djava.rmi.server.hostname=localhost -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005</arg>-->
</args>
</configuration>
</execution>
<execution>
<phase>test-compile</phase>
<id>create-jmx-failback</id>

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
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.
-->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core">
<bindings-directory>./data/messaging/bindings</bindings-directory>
<journal-directory>./data/messaging/journal</journal-directory>
<large-messages-directory>./data/messaging/largemessages</large-messages-directory>
<paging-directory>./data/messaging/paging</paging-directory>
<acceptors>
<acceptor name="artemis">tcp://localhost:61616?securityDomain=guest</acceptor> <!-- this is only for the smoke test health-check -->
<acceptor name="netty-ssl-acceptor">tcp://localhost:5500?sslEnabled=true;needClientAuth=true;keyStorePath=server-side-keystore.jks;keyStorePassword=secureexample;trustStorePath=server-side-truststore.jks;trustStorePassword=secureexample</acceptor>
</acceptors>
<security-settings>
<security-setting match="exampleQueue">
<permission roles="consumers" type="consume"/>
<permission roles="producers" type="send"/>
</security-setting>
</security-settings>
<addresses>
<address name="exampleQueue">
<anycast>
<queue name="exampleQueue"/>
</anycast>
</address>
</addresses>
</core>
</configuration>

View File

@ -0,0 +1,19 @@
#
# 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.
#
producers=myUser
consumers=myUser

View File

@ -0,0 +1,18 @@
#
# 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.
#
myUser=CN=ActiveMQ Artemis Client, OU=Artemis, O=ActiveMQ, L=AMQ, ST=AMQ, C=AMQ

View File

@ -0,0 +1,80 @@
#
# 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.
#
# Additional logger names to configure (root logger is always configured)
# Root logger option
loggers=org.eclipse.jetty,org.jboss.logging,org.apache.activemq.artemis.core.server,org.apache.activemq.artemis.utils,org.apache.activemq.artemis.journal,org.apache.activemq.artemis.jms.server,org.apache.activemq.artemis.integration.bootstrap,org.apache.activemq.audit.base,org.apache.activemq.audit.message,org.apache.activemq.audit.resource
# Root logger level
logger.level=INFO
# ActiveMQ Artemis logger levels
logger.org.apache.activemq.artemis.core.server.level=INFO
logger.org.apache.activemq.artemis.journal.level=INFO
logger.org.apache.activemq.artemis.utils.level=INFO
logger.org.apache.activemq.artemis.jms.level=INFO
logger.org.apache.activemq.artemis.integration.bootstrap.level=INFO
logger.org.eclipse.jetty.level=WARN
# Root logger handlers
logger.handlers=FILE,CONSOLE
logger.org.apache.activemq.audit.base.level=DEBUG
logger.org.apache.activemq.audit.base.handlers=AUDIT_FILE
logger.org.apache.activemq.audit.base.useParentHandlers=false
logger.org.apache.activemq.audit.message.level=DEBUG
logger.org.apache.activemq.audit.message.handlers=AUDIT_FILE
logger.org.apache.activemq.audit.message.useParentHandlers=
logger.org.apache.activemq.audit.resource.level=DEBUG
logger.org.apache.activemq.audit.resource.handlers=AUDIT_FILE
logger.org.apache.activemq.audit.resource.useParentHandlers=false
# Console handler configuration
handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
handler.CONSOLE.properties=autoFlush
handler.CONSOLE.level=DEBUG
handler.CONSOLE.autoFlush=true
handler.CONSOLE.formatter=PATTERN
# File handler configuration
handler.FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
handler.FILE.level=DEBUG
handler.FILE.properties=suffix,append,autoFlush,fileName
handler.FILE.suffix=.yyyy-MM-dd
handler.FILE.append=true
handler.FILE.autoFlush=true
handler.FILE.fileName=../log/artemis.log
handler.FILE.formatter=PATTERN
# Formatter pattern configuration
formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.PATTERN.properties=pattern
formatter.PATTERN.pattern=%d %-5p [%c] %s%E%n
#Audit logger
handler.AUDIT_FILE.level=DEBUG
handler.AUDIT_FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
handler.AUDIT_FILE.properties=suffix,append,autoFlush,fileName
handler.AUDIT_FILE.suffix=.yyyy-MM-dd
handler.AUDIT_FILE.append=true
handler.AUDIT_FILE.autoFlush=true
handler.AUDIT_FILE.fileName=../log/audit.log
handler.AUDIT_FILE.formatter=AUDIT_PATTERN
formatter.AUDIT_PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.AUDIT_PATTERN.properties=pattern
formatter.AUDIT_PATTERN.pattern=%d [AUDIT](%t) %s%E%n

View File

@ -0,0 +1,30 @@
/*
* 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.
*/
activemq {
org.apache.activemq.artemis.spi.core.security.jaas.TextFileCertificateLoginModule required
debug=true
org.apache.activemq.jaas.textfiledn.user="cert-users.properties"
org.apache.activemq.jaas.textfiledn.role="cert-roles.properties";
};
guest {
org.apache.activemq.artemis.spi.core.security.jaas.GuestLoginModule sufficient
debug=false
org.apache.activemq.jaas.guest.user="guest"
org.apache.activemq.jaas.guest.role="guest";
};

View File

@ -22,6 +22,7 @@ import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.HashSet;
import java.util.Set;
@ -35,6 +36,8 @@ import org.junit.Assert;
public class SmokeTestBase extends ActiveMQTestBase {
Set<Process> processes = new HashSet<>();
private static final String JMX_SERVER_HOSTNAME = "localhost";
private static final int JMX_SERVER_PORT = 10099;
public static final String basedir = System.getProperty("basedir");
@ -92,7 +95,11 @@ public class SmokeTestBase extends ActiveMQTestBase {
return process;
}
protected static JMXConnector getJmxConnector(String hostname, int port) throws Exception {
protected JMXConnector getJmxConnector() throws MalformedURLException {
return getJmxConnector(JMX_SERVER_HOSTNAME, JMX_SERVER_PORT);
}
protected static JMXConnector getJmxConnector(String hostname, int port) throws MalformedURLException {
// Without this, the RMI server would bind to the default interface IP (the user's local IP mostly)
System.setProperty("java.rmi.server.hostname", hostname);

View File

@ -0,0 +1,89 @@
/*
* 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.tests.smoke.logging;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import org.apache.qpid.jms.JmsConnectionFactory;
import org.junit.Test;
/**
* The various keystore files used for this test were generated using the following commands:
*
* keytool -genkey -keystore server-side-keystore.jks -storepass secureexample -keypass secureexample -dname "CN=ActiveMQ Artemis Server, OU=Artemis, O=ActiveMQ, L=AMQ, S=AMQ, C=AMQ" -keyalg RSA
* keytool -export -keystore server-side-keystore.jks -file server-side-cert.cer -storepass secureexample
* keytool -import -keystore client-side-truststore.jks -file server-side-cert.cer -storepass secureexample -keypass secureexample -noprompt
* keytool -genkey -keystore client-side-keystore.jks -storepass secureexample -keypass secureexample -dname "CN=ActiveMQ Artemis Client, OU=Artemis, O=ActiveMQ, L=AMQ, S=AMQ, C=AMQ" -keyalg RSA
* keytool -export -keystore client-side-keystore.jks -file client-side-cert.cer -storepass secureexample
* keytool -import -keystore server-side-truststore.jks -file client-side-cert.cer -storepass secureexample -keypass secureexample -noprompt
*/
public class AuditLoggerAMQPMutualSSLTest extends AuditLoggerTestBase {
@Override
protected String getServerName() {
return "audit-logging-amqp-mutual-ssl";
}
@Test
public void testAuditForProducerAndConsumer() throws Exception {
String sslhost = "amqps://localhost:5500";
int maxInactivityDurationInitialDelay = 30000;
int idleTimeout = 120000;
boolean verifyHost = false;
String keyStoreLocation = "target/" + getServerName() + "/etc/client-side-keystore.jks";
String keyStorePassword = "secureexample";
String trustStoreLocation = "target/" + getServerName() + "/etc/client-side-truststore.jks";
String trustStorePassword = "secureexample";
String remoteUri = sslhost +
"?maxInactivityDurationInitialDelay=" + maxInactivityDurationInitialDelay +
"&amqp.idleTimeout=" + idleTimeout +
"&transport.verifyHost=" + verifyHost +
"&transport.keyStoreLocation=" + keyStoreLocation +
"&transport.keyStorePassword=" + keyStorePassword +
"&transport.trustStoreLocation=" + trustStoreLocation +
"&transport.trustStorePassword=" + trustStorePassword;
ConnectionFactory connectionFactory = new JmsConnectionFactory(remoteUri);
try (Connection connection = connectionFactory.createConnection()) {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue("exampleQueue");
MessageProducer sender = session.createProducer(queue);
TextMessage stm = session.createTextMessage("Hello world ");
stm.setStringProperty("foo", "bar");
sender.send(stm);
MessageConsumer consumer = session.createConsumer(queue);
connection.start();
Message m = consumer.receive(500);
assertNotNull(m);
}
checkAuditLogRecord(true, "AMQ601715: User myUser(producers)@", "successfully authenticated");
checkAuditLogRecord(true, "AMQ601267: User myUser(producers)@", "is creating a core session");
checkAuditLogRecord(true, "AMQ601500: User myUser(producers)@", "is sending a message AMQPStandardMessage");
checkAuditLogRecord(true, "AMQ601265: User myUser(producers)@", "is creating a core consumer");
checkAuditLogRecord(true, "AMQ601501: User myUser(producers)@", "is consuming a message from exampleQueue");
}
}

View File

@ -16,6 +16,12 @@
*/
package org.apache.activemq.artemis.tests.smoke.logging;
import javax.management.MBeanServerConnection;
import javax.management.MBeanServerInvocationHandler;
import javax.management.openmbean.CompositeData;
import javax.management.remote.JMXConnector;
import java.util.HashMap;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.api.core.RoutingType;
import org.apache.activemq.artemis.api.core.SimpleString;
@ -26,71 +32,18 @@ import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl;
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
import org.apache.activemq.artemis.api.core.management.QueueControl;
import org.apache.activemq.artemis.tests.smoke.common.SmokeTestBase;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import javax.management.MBeanServerConnection;
import javax.management.MBeanServerInvocationHandler;
import javax.management.openmbean.CompositeData;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.HashMap;
public class AuditLoggerResourceTest extends AuditLoggerTestBase {
public class AuditLoggerResourceTest extends SmokeTestBase {
private static final File auditLog = new File("target/audit-logging/log/audit.log");
private static final String JMX_SERVER_HOSTNAME = "localhost";
private static final int JMX_SERVER_PORT = 10099;
public static final String SERVER_NAME = "audit-logging";
@Before
public void before() throws Exception {
cleanupData(SERVER_NAME);
disableCheckThread();
startServer(SERVER_NAME, 0, 30000);
emptyLogFile();
}
private void emptyLogFile() throws Exception {
if (auditLog.exists()) {
try (PrintWriter writer = new PrintWriter(new FileWriter(auditLog))) {
writer.print("");
}
}
@Override
protected String getServerName() {
return "audit-logging";
}
@Test
public void testAuditResourceLog() throws Exception {
HashMap environment = new HashMap();
String[] credentials = new String[] {"admin", "admin"};
environment.put(JMXConnector.CREDENTIALS, credentials);
// Without this, the RMI server would bind to the default interface IP (the user's local IP mostly)
System.setProperty("java.rmi.server.hostname", JMX_SERVER_HOSTNAME);
// I don't specify both ports here manually on purpose. See actual RMI registry connection port extraction below.
String urlString = "service:jmx:rmi:///jndi/rmi://" + JMX_SERVER_HOSTNAME + ":" + JMX_SERVER_PORT + "/jmxrmi";
JMXServiceURL url = new JMXServiceURL(urlString);
JMXConnector jmxConnector = null;
try {
jmxConnector = JMXConnectorFactory.connect(url, environment);
System.out.println("Successfully connected to: " + urlString);
} catch (Exception e) {
jmxConnector = null;
e.printStackTrace();
Assert.fail(e.getMessage());
}
JMXConnector jmxConnector = getJmxConnector();
try {
MBeanServerConnection mBeanServerConnection = jmxConnector.getMBeanServerConnection();
@ -132,35 +85,4 @@ public class AuditLoggerResourceTest extends SmokeTestBase {
jmxConnector.close();
}
}
//check the audit log has a line that contains all the values
private void checkAuditLogRecord(boolean exist, String... values) throws Exception {
Assert.assertTrue(auditLog.exists());
boolean hasRecord = false;
try (BufferedReader reader = new BufferedReader(new FileReader(auditLog))) {
String line = reader.readLine();
while (line != null) {
if (line.contains(values[0])) {
boolean hasAll = true;
for (int i = 1; i < values.length; i++) {
if (!line.contains(values[i])) {
hasAll = false;
break;
}
}
if (hasAll) {
hasRecord = true;
System.out.println("audit has it: " + line);
break;
}
}
line = reader.readLine();
}
if (exist) {
Assert.assertTrue(hasRecord);
} else {
Assert.assertFalse(hasRecord);
}
}
}
}

View File

@ -16,6 +16,17 @@
*/
package org.apache.activemq.artemis.tests.smoke.logging;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.management.MBeanServerConnection;
import javax.management.MBeanServerInvocationHandler;
import javax.management.remote.JMXConnector;
import java.util.UUID;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.api.core.Message;
import org.apache.activemq.artemis.api.core.QueueConfiguration;
@ -27,54 +38,23 @@ import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.api.core.management.AddressControl;
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
import org.apache.activemq.artemis.tests.smoke.common.SmokeTestBase;
import org.apache.activemq.artemis.utils.Base64;
import org.apache.activemq.artemis.utils.RandomUtil;
import org.apache.activemq.artemis.utils.Wait;
import org.apache.qpid.jms.JmsConnectionFactory;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.management.MBeanServerConnection;
import javax.management.MBeanServerInvocationHandler;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.UUID;
public class AuditLoggerTest extends SmokeTestBase {
private static final File auditLog = new File("target/audit-logging2/log/audit.log");
private static final String JMX_SERVER_HOSTNAME = "localhost";
private static final int JMX_SERVER_PORT = 10099;
public static final String SERVER_NAME = "audit-logging2";
public class AuditLoggerTest extends AuditLoggerTestBase {
protected ClientSession session;
private ServerLocator locator;
private ClientSessionFactory sf;
@Before
@Override
public void before() throws Exception {
cleanupData(SERVER_NAME);
disableCheckThread();
startServer(SERVER_NAME, 0, 30000);
emptyLogFile();
super.before();
locator = createNonHALocator(true).setBlockOnNonDurableSend(true);
sf = createSessionFactory(locator);
session = sf.createSession("guest", "guest", false, true, false, false, 100);
@ -82,12 +62,9 @@ public class AuditLoggerTest extends SmokeTestBase {
addClientSession(session);
}
private void emptyLogFile() throws Exception {
if (auditLog.exists()) {
try (PrintWriter writer = new PrintWriter(new FileWriter(auditLog))) {
writer.print("");
}
}
@Override
protected String getServerName() {
return "audit-logging2";
}
@Test
@ -139,30 +116,6 @@ public class AuditLoggerTest extends SmokeTestBase {
checkAuditLogRecord(true, "is sending a message");
}
protected JMXConnector getJmxConnector() throws MalformedURLException {
HashMap environment = new HashMap();
String[] credentials = new String[] {"admin", "admin"};
environment.put(JMXConnector.CREDENTIALS, credentials);
// Without this, the RMI server would bind to the default interface IP (the user's local IP mostly)
System.setProperty("java.rmi.server.hostname", JMX_SERVER_HOSTNAME);
// I don't specify both ports here manually on purpose. See actual RMI registry connection port extraction below.
String urlString = "service:jmx:rmi:///jndi/rmi://" + JMX_SERVER_HOSTNAME + ":" + JMX_SERVER_PORT + "/jmxrmi";
JMXServiceURL url = new JMXServiceURL(urlString);
JMXConnector jmxConnector = null;
try {
jmxConnector = JMXConnectorFactory.connect(url, environment);
System.out.println("Successfully connected to: " + urlString);
} catch (Exception e) {
jmxConnector = null;
e.printStackTrace();
Assert.fail(e.getMessage());
}
return jmxConnector;
}
@Test
public void testAuditHotLogCore() throws Exception {
internalSend("CORE");
@ -223,52 +176,4 @@ public class AuditLoggerTest extends SmokeTestBase {
connection.close();
}
}
//check the audit log has a line that contains all the values
private void checkAuditLogRecord(boolean exist, String... values) throws Exception {
Assert.assertTrue(auditLog.exists());
boolean hasRecord = false;
try (BufferedReader reader = new BufferedReader(new FileReader(auditLog))) {
String line = reader.readLine();
while (line != null) {
if (line.contains(values[0])) {
boolean hasAll = true;
for (int i = 1; i < values.length; i++) {
if (!line.contains(values[i])) {
hasAll = false;
break;
}
}
if (hasAll) {
hasRecord = true;
System.out.println("audit has it: " + line);
break;
}
}
line = reader.readLine();
}
if (exist) {
Assert.assertTrue(hasRecord);
} else {
Assert.assertFalse(hasRecord);
}
}
}
public static ConnectionFactory createConnectionFactory(String protocol, String uri) {
if (protocol.toUpperCase().equals("OPENWIRE")) {
return new org.apache.activemq.ActiveMQConnectionFactory(uri);
} else if (protocol.toUpperCase().equals("AMQP")) {
if (uri.startsWith("tcp://")) {
// replacing tcp:// by amqp://
uri = "amqp" + uri.substring(3);
}
return new JmsConnectionFactory(uri);
} else if (protocol.toUpperCase().equals("CORE") || protocol.toUpperCase().equals("ARTEMIS")) {
return new org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory(uri);
} else {
throw new IllegalStateException("Unkown:" + protocol);
}
}
}

View File

@ -0,0 +1,107 @@
/*
* 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.tests.smoke.logging;
import javax.jms.ConnectionFactory;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintWriter;
import org.apache.activemq.artemis.tests.smoke.common.SmokeTestBase;
import org.apache.qpid.jms.JmsConnectionFactory;
import org.junit.Assert;
import org.junit.Before;
public abstract class AuditLoggerTestBase extends SmokeTestBase {
private File auditLog = null;
@Before
public void before() throws Exception {
cleanupData(getServerName());
disableCheckThread();
startServer(getServerName(), 0, 30000);
emptyLogFile();
}
private void emptyLogFile() throws Exception {
if (getAuditLog().exists()) {
try (PrintWriter writer = new PrintWriter(new FileWriter(getAuditLog()))) {
writer.print("");
}
}
}
protected File getAuditLog() {
if (auditLog == null) {
auditLog = new File("target/" + getServerName() + "/log/audit.log");
}
return auditLog;
}
abstract String getServerName();
//check the audit log has a line that contains all the values
protected void checkAuditLogRecord(boolean exist, String... values) throws Exception {
Assert.assertTrue(getAuditLog().exists());
boolean hasRecord = false;
try (BufferedReader reader = new BufferedReader(new FileReader(getAuditLog()))) {
String line = reader.readLine();
while (line != null) {
if (line.contains(values[0])) {
boolean hasAll = true;
for (int i = 1; i < values.length; i++) {
if (!line.contains(values[i])) {
hasAll = false;
break;
}
}
if (hasAll) {
hasRecord = true;
System.out.println("audit has it: " + line);
break;
}
}
line = reader.readLine();
}
if (exist) {
Assert.assertTrue(hasRecord);
} else {
Assert.assertFalse(hasRecord);
}
}
}
public static ConnectionFactory createConnectionFactory(String protocol, String uri) {
if (protocol.toUpperCase().equals("OPENWIRE")) {
return new org.apache.activemq.ActiveMQConnectionFactory(uri);
} else if (protocol.toUpperCase().equals("AMQP")) {
if (uri.startsWith("tcp://")) {
// replacing tcp:// by amqp://
uri = "amqp" + uri.substring(3);
}
return new JmsConnectionFactory(uri);
} else if (protocol.toUpperCase().equals("CORE") || protocol.toUpperCase().equals("ARTEMIS")) {
return new org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory(uri);
} else {
throw new IllegalStateException("Unkown:" + protocol);
}
}
}