This commit is contained in:
Clebert Suconic 2019-03-14 12:24:59 -04:00
commit 4bfeaf89c5
19 changed files with 3704 additions and 21 deletions

View File

@ -17,7 +17,7 @@
# Additional logger names to configure (root logger is always configured) # Additional logger names to configure (root logger is always configured)
# Root logger option # 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 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
# Root logger level # Root logger level
logger.level=INFO logger.level=INFO
@ -31,6 +31,15 @@ logger.org.eclipse.jetty.level=WARN
# Root logger handlers # Root logger handlers
logger.handlers=FILE,CONSOLE logger.handlers=FILE,CONSOLE
# to enable audit change the level to INFO
logger.org.apache.activemq.audit.base.level=ERROR
logger.org.apache.activemq.audit.base.handlers=AUDIT_FILE
logger.org.apache.activemq.audit.base.useParentHandlers=false
logger.org.apache.activemq.audit.message.level=ERROR
logger.org.apache.activemq.audit.message.handlers=AUDIT_FILE
logger.org.apache.activemq.audit.message.useParentHandlers=false
# Console handler configuration # Console handler configuration
handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
handler.CONSOLE.properties=autoFlush handler.CONSOLE.properties=autoFlush
@ -52,3 +61,17 @@ handler.FILE.formatter=PATTERN
formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.PATTERN.properties=pattern formatter.PATTERN.properties=pattern
formatter.PATTERN.pattern=%d %-5p [%c] %s%E%n formatter.PATTERN.pattern=%d %-5p [%c] %s%E%n
#Audit logger
handler.AUDIT_FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
handler.AUDIT_FILE.level=INFO
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=${artemis.instance}/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

File diff suppressed because it is too large Load Diff

View File

@ -33,6 +33,7 @@ import org.apache.activemq.artemis.core.persistence.StorageManager;
import org.apache.activemq.artemis.core.persistence.impl.journal.DummyOperationContext; import org.apache.activemq.artemis.core.persistence.impl.journal.DummyOperationContext;
import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ServerSession; import org.apache.activemq.artemis.core.server.ServerSession;
import org.apache.activemq.artemis.logs.AuditLogger;
import org.apache.activemq.artemis.utils.Base64; import org.apache.activemq.artemis.utils.Base64;
import org.apache.activemq.artemis.utils.RunnableEx; import org.apache.activemq.artemis.utils.RunnableEx;
import org.apache.activemq.artemis.utils.UUIDGenerator; import org.apache.activemq.artemis.utils.UUIDGenerator;
@ -106,6 +107,9 @@ public abstract class AbstractControl extends StandardMBean {
@Override @Override
public MBeanInfo getMBeanInfo() { public MBeanInfo getMBeanInfo() {
if (AuditLogger.isEnabled()) {
AuditLogger.getMBeanInfo(this);
}
MBeanInfo info = super.getMBeanInfo(); MBeanInfo info = super.getMBeanInfo();
return new MBeanInfo(info.getClassName(), info.getDescription(), fillMBeanAttributeInfo(), info.getConstructors(), fillMBeanOperationInfo(), info.getNotifications()); return new MBeanInfo(info.getClassName(), info.getDescription(), fillMBeanAttributeInfo(), info.getConstructors(), fillMBeanOperationInfo(), info.getNotifications());
} }

View File

@ -24,6 +24,7 @@ import java.util.Map;
import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.api.core.management.AcceptorControl; import org.apache.activemq.artemis.api.core.management.AcceptorControl;
import org.apache.activemq.artemis.core.persistence.StorageManager; import org.apache.activemq.artemis.core.persistence.StorageManager;
import org.apache.activemq.artemis.logs.AuditLogger;
import org.apache.activemq.artemis.spi.core.remoting.Acceptor; import org.apache.activemq.artemis.spi.core.remoting.Acceptor;
public class AcceptorControlImpl extends AbstractControl implements AcceptorControl { public class AcceptorControlImpl extends AbstractControl implements AcceptorControl {
@ -52,6 +53,9 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
@Override @Override
public String getFactoryClassName() { public String getFactoryClassName() {
if (AuditLogger.isEnabled()) {
AuditLogger.getFactoryClassName(this.acceptor);
}
clearIO(); clearIO();
try { try {
return configuration.getFactoryClassName(); return configuration.getFactoryClassName();
@ -62,6 +66,9 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
@Override @Override
public String getName() { public String getName() {
if (AuditLogger.isEnabled()) {
AuditLogger.getName(this.acceptor);
}
clearIO(); clearIO();
try { try {
return configuration.getName(); return configuration.getName();
@ -72,6 +79,9 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
@Override @Override
public Map<String, Object> getParameters() { public Map<String, Object> getParameters() {
if (AuditLogger.isEnabled()) {
AuditLogger.getParameters(this.acceptor);
}
clearIO(); clearIO();
try { try {
Map<String, Object> clone = new HashMap(configuration.getParams()); Map<String, Object> clone = new HashMap(configuration.getParams());
@ -88,6 +98,9 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
@Override @Override
public void reload() { public void reload() {
if (AuditLogger.isEnabled()) {
AuditLogger.reload(this.acceptor);
}
clearIO(); clearIO();
try { try {
acceptor.reload(); acceptor.reload();
@ -98,6 +111,9 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
@Override @Override
public boolean isStarted() { public boolean isStarted() {
if (AuditLogger.isEnabled()) {
AuditLogger.isStarted(this.acceptor);
}
clearIO(); clearIO();
try { try {
return acceptor.isStarted(); return acceptor.isStarted();
@ -108,6 +124,9 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
@Override @Override
public void start() throws Exception { public void start() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.startAcceptor(this.acceptor);
}
clearIO(); clearIO();
try { try {
acceptor.start(); acceptor.start();
@ -118,6 +137,9 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
@Override @Override
public void stop() throws Exception { public void stop() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.stopAcceptor(this.acceptor);
}
clearIO(); clearIO();
try { try {
acceptor.stop(); acceptor.stop();

View File

@ -43,6 +43,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.impl.AddressInfo; import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.core.server.management.ManagementService; import org.apache.activemq.artemis.core.server.management.ManagementService;
import org.apache.activemq.artemis.core.settings.HierarchicalRepository; import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
import org.apache.activemq.artemis.logs.AuditLogger;
import org.apache.activemq.artemis.utils.JsonLoader; import org.apache.activemq.artemis.utils.JsonLoader;
public class AddressControlImpl extends AbstractControl implements AddressControl { public class AddressControlImpl extends AbstractControl implements AddressControl {
@ -94,6 +95,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override @Override
public String[] getRoutingTypes() { public String[] getRoutingTypes() {
if (AuditLogger.isEnabled()) {
AuditLogger.getRoutingTypes(this.addressInfo);
}
EnumSet<RoutingType> routingTypes = addressInfo.getRoutingTypes(); EnumSet<RoutingType> routingTypes = addressInfo.getRoutingTypes();
String[] result = new String[routingTypes.size()]; String[] result = new String[routingTypes.size()];
int i = 0; int i = 0;
@ -105,6 +109,10 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override @Override
public String getRoutingTypesAsJSON() throws Exception { public String getRoutingTypesAsJSON() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.getRoutingTypesAsJSON(this.addressInfo);
}
clearIO(); clearIO();
try { try {
JsonArrayBuilder json = JsonLoader.createArrayBuilder(); JsonArrayBuilder json = JsonLoader.createArrayBuilder();
@ -121,6 +129,11 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override @Override
public String[] getQueueNames() throws Exception { public String[] getQueueNames() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.getQueueNames(this.addressInfo);
}
String[] result;
clearIO(); clearIO();
try { try {
Bindings bindings = server.getPostOffice().lookupBindingsForAddress(addressInfo.getName()); Bindings bindings = server.getPostOffice().lookupBindingsForAddress(addressInfo.getName());
@ -144,8 +157,12 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override @Override
public String[] getBindingNames() throws Exception { public String[] getBindingNames() throws Exception {
clearIO(); if (AuditLogger.isEnabled()) {
AuditLogger.getBindingNames(this.addressInfo);
}
try { try {
clearIO();
Bindings bindings = server.getPostOffice().lookupBindingsForAddress(addressInfo.getName()); Bindings bindings = server.getPostOffice().lookupBindingsForAddress(addressInfo.getName());
if (bindings != null) { if (bindings != null) {
String[] bindingNames = new String[bindings.getBindings().size()]; String[] bindingNames = new String[bindings.getBindings().size()];
@ -166,6 +183,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override @Override
public Object[] getRoles() throws Exception { public Object[] getRoles() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.getRoles(this.addressInfo);
}
clearIO(); clearIO();
try { try {
Set<Role> roles = securityRepository.getMatch(addressInfo.getName().toString()); Set<Role> roles = securityRepository.getMatch(addressInfo.getName().toString());
@ -184,6 +204,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override @Override
public String getRolesAsJSON() throws Exception { public String getRolesAsJSON() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.getRolesAsJSON(this.addressInfo);
}
clearIO(); clearIO();
try { try {
JsonArrayBuilder json = JsonLoader.createArrayBuilder(); JsonArrayBuilder json = JsonLoader.createArrayBuilder();
@ -200,6 +223,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override @Override
public long getNumberOfBytesPerPage() throws Exception { public long getNumberOfBytesPerPage() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.getNumberOfBytesPerPage(this.addressInfo);
}
clearIO(); clearIO();
try { try {
final PagingStore pagingStore = getPagingStore(); final PagingStore pagingStore = getPagingStore();
@ -218,6 +244,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override @Override
public long getAddressSize() throws Exception { public long getAddressSize() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.getAddressSize(this.addressInfo);
}
clearIO(); clearIO();
try { try {
final PagingStore pagingStore = getPagingStore(); final PagingStore pagingStore = getPagingStore();
@ -232,6 +261,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override @Override
public long getNumberOfMessages() throws Exception { public long getNumberOfMessages() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.getNumberOfMessages(this.addressInfo);
}
clearIO(); clearIO();
long totalMsgs = 0; long totalMsgs = 0;
try { try {
@ -253,6 +285,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override @Override
public boolean isPaging() throws Exception { public boolean isPaging() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.isPaging(this.addressInfo);
}
clearIO(); clearIO();
try { try {
final PagingStore pagingStore = getPagingStore(); final PagingStore pagingStore = getPagingStore();
@ -267,6 +302,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override @Override
public int getNumberOfPages() throws Exception { public int getNumberOfPages() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.getNumberOfPages(this.addressInfo);
}
clearIO(); clearIO();
try { try {
final PagingStore pageStore = getPagingStore(); final PagingStore pageStore = getPagingStore();
@ -283,16 +321,25 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
@Override @Override
public long getMessageCount() { public long getMessageCount() {
if (AuditLogger.isEnabled()) {
AuditLogger.getMessageCount(this.addressInfo);
}
return getMessageCount(DurabilityType.ALL); return getMessageCount(DurabilityType.ALL);
} }
@Override @Override
public long getRoutedMessageCount() { public long getRoutedMessageCount() {
if (AuditLogger.isEnabled()) {
AuditLogger.getRoutedMessageCount(this.addressInfo);
}
return addressInfo.getRoutedMessageCount(); return addressInfo.getRoutedMessageCount();
} }
@Override @Override
public long getUnRoutedMessageCount() { public long getUnRoutedMessageCount() {
if (AuditLogger.isEnabled()) {
AuditLogger.getUnRoutedMessageCount(this.addressInfo);
}
return addressInfo.getUnRoutedMessageCount(); return addressInfo.getUnRoutedMessageCount();
} }
@ -304,6 +351,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
boolean durable, boolean durable,
final String user, final String user,
final String password) throws Exception { final String password) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.sendMessage(this, null, headers, type, body, durable, user, "****");
}
try { try {
return sendMessage(addressInfo.getName(), server, headers, type, body, durable, user, password); return sendMessage(addressInfo.getName(), server, headers, type, body, durable, user, password);
} catch (Exception e) { } catch (Exception e) {

View File

@ -27,6 +27,7 @@ import org.apache.activemq.artemis.api.core.management.BridgeControl;
import org.apache.activemq.artemis.core.config.BridgeConfiguration; import org.apache.activemq.artemis.core.config.BridgeConfiguration;
import org.apache.activemq.artemis.core.persistence.StorageManager; import org.apache.activemq.artemis.core.persistence.StorageManager;
import org.apache.activemq.artemis.core.server.cluster.Bridge; import org.apache.activemq.artemis.core.server.cluster.Bridge;
import org.apache.activemq.artemis.logs.AuditLogger;
public class BridgeControlImpl extends AbstractControl implements BridgeControl { public class BridgeControlImpl extends AbstractControl implements BridgeControl {
@ -54,6 +55,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override @Override
public String[] getStaticConnectors() throws Exception { public String[] getStaticConnectors() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.getStaticConnectors(this.bridge);
}
clearIO(); clearIO();
try { try {
List<String> staticConnectors = configuration.getStaticConnectors(); List<String> staticConnectors = configuration.getStaticConnectors();
@ -65,6 +69,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override @Override
public String getForwardingAddress() { public String getForwardingAddress() {
if (AuditLogger.isEnabled()) {
AuditLogger.getForwardingAddress(this.bridge);
}
clearIO(); clearIO();
try { try {
return configuration.getForwardingAddress(); return configuration.getForwardingAddress();
@ -75,6 +82,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override @Override
public String getQueueName() { public String getQueueName() {
if (AuditLogger.isEnabled()) {
AuditLogger.getQueueName(this.bridge);
}
clearIO(); clearIO();
try { try {
return configuration.getQueueName(); return configuration.getQueueName();
@ -85,6 +95,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override @Override
public String getDiscoveryGroupName() { public String getDiscoveryGroupName() {
if (AuditLogger.isEnabled()) {
AuditLogger.getDiscoveryGroupName(this.bridge);
}
clearIO(); clearIO();
try { try {
return configuration.getDiscoveryGroupName(); return configuration.getDiscoveryGroupName();
@ -95,6 +108,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override @Override
public String getFilterString() { public String getFilterString() {
if (AuditLogger.isEnabled()) {
AuditLogger.getFilterString(this.bridge);
}
clearIO(); clearIO();
try { try {
return configuration.getFilterString(); return configuration.getFilterString();
@ -105,6 +121,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override @Override
public int getReconnectAttempts() { public int getReconnectAttempts() {
if (AuditLogger.isEnabled()) {
AuditLogger.getReconnectAttempts(this.bridge);
}
clearIO(); clearIO();
try { try {
return configuration.getReconnectAttempts(); return configuration.getReconnectAttempts();
@ -115,6 +134,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override @Override
public String getName() { public String getName() {
if (AuditLogger.isEnabled()) {
AuditLogger.getName(this.bridge);
}
clearIO(); clearIO();
try { try {
return configuration.getName(); return configuration.getName();
@ -125,6 +147,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override @Override
public long getRetryInterval() { public long getRetryInterval() {
if (AuditLogger.isEnabled()) {
AuditLogger.getRetryInterval(this.bridge);
}
clearIO(); clearIO();
try { try {
return configuration.getRetryInterval(); return configuration.getRetryInterval();
@ -135,6 +160,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override @Override
public double getRetryIntervalMultiplier() { public double getRetryIntervalMultiplier() {
if (AuditLogger.isEnabled()) {
AuditLogger.getRetryIntervalMultiplier(this.bridge);
}
clearIO(); clearIO();
try { try {
return configuration.getRetryIntervalMultiplier(); return configuration.getRetryIntervalMultiplier();
@ -145,6 +173,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override @Override
public String getTransformerClassName() { public String getTransformerClassName() {
if (AuditLogger.isEnabled()) {
AuditLogger.getTransformerClassName(this.bridge);
}
clearIO(); clearIO();
try { try {
return configuration.getTransformerConfiguration() == null ? null : configuration.getTransformerConfiguration().getClassName(); return configuration.getTransformerConfiguration() == null ? null : configuration.getTransformerConfiguration().getClassName();
@ -155,11 +186,17 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override @Override
public String getTransformerPropertiesAsJSON() { public String getTransformerPropertiesAsJSON() {
if (AuditLogger.isEnabled()) {
AuditLogger.getTransformerPropertiesAsJSON(this.bridge);
}
return JsonUtil.toJsonObject(getTransformerProperties()).toString(); return JsonUtil.toJsonObject(getTransformerProperties()).toString();
} }
@Override @Override
public Map<String, String> getTransformerProperties() { public Map<String, String> getTransformerProperties() {
if (AuditLogger.isEnabled()) {
AuditLogger.getTransformerProperties(this.bridge);
}
clearIO(); clearIO();
try { try {
return configuration.getTransformerConfiguration() == null ? null : configuration.getTransformerConfiguration().getProperties(); return configuration.getTransformerConfiguration() == null ? null : configuration.getTransformerConfiguration().getProperties();
@ -170,6 +207,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override @Override
public boolean isStarted() { public boolean isStarted() {
if (AuditLogger.isEnabled()) {
AuditLogger.isStartedBridge(this.bridge);
}
clearIO(); clearIO();
try { try {
return bridge.isStarted(); return bridge.isStarted();
@ -180,6 +220,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override @Override
public boolean isUseDuplicateDetection() { public boolean isUseDuplicateDetection() {
if (AuditLogger.isEnabled()) {
AuditLogger.isUseDuplicateDetection(this.bridge);
}
clearIO(); clearIO();
try { try {
return configuration.isUseDuplicateDetection(); return configuration.isUseDuplicateDetection();
@ -190,6 +233,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override @Override
public boolean isHA() { public boolean isHA() {
if (AuditLogger.isEnabled()) {
AuditLogger.isHA(this.bridge);
}
clearIO(); clearIO();
try { try {
return configuration.isHA(); return configuration.isHA();
@ -200,6 +246,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override @Override
public void start() throws Exception { public void start() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.startBridge(this.bridge);
}
clearIO(); clearIO();
try { try {
bridge.start(); bridge.start();
@ -210,6 +259,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override @Override
public void stop() throws Exception { public void stop() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.stopBridge(this.bridge);
}
clearIO(); clearIO();
try { try {
bridge.stop(); bridge.stop();
@ -231,6 +283,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override @Override
public long getMessagesPendingAcknowledgement() { public long getMessagesPendingAcknowledgement() {
if (AuditLogger.isEnabled()) {
AuditLogger.getMessagesPendingAcknowledgement(this.bridge);
}
clearIO(); clearIO();
try { try {
return bridge.getMetrics().getMessagesPendingAcknowledgement(); return bridge.getMetrics().getMessagesPendingAcknowledgement();
@ -241,6 +296,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override @Override
public long getMessagesAcknowledged() { public long getMessagesAcknowledged() {
if (AuditLogger.isEnabled()) {
AuditLogger.getMessagesAcknowledged(this.bridge);
}
clearIO(); clearIO();
try { try {
return bridge.getMetrics().getMessagesAcknowledged(); return bridge.getMetrics().getMessagesAcknowledged();
@ -251,6 +309,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
@Override @Override
public Map<String, Object> getMetrics() { public Map<String, Object> getMetrics() {
if (AuditLogger.isEnabled()) {
AuditLogger.getMetrics(this.bridge);
}
clearIO(); clearIO();
try { try {
return bridge.getMetrics().convertToMap(); return bridge.getMetrics().convertToMap();

View File

@ -25,6 +25,7 @@ import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory;
import org.apache.activemq.artemis.api.core.management.BroadcastGroupControl; import org.apache.activemq.artemis.api.core.management.BroadcastGroupControl;
import org.apache.activemq.artemis.core.persistence.StorageManager; import org.apache.activemq.artemis.core.persistence.StorageManager;
import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup; import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup;
import org.apache.activemq.artemis.logs.AuditLogger;
public class BroadcastGroupControlImpl extends AbstractControl implements BroadcastGroupControl { public class BroadcastGroupControlImpl extends AbstractControl implements BroadcastGroupControl {
@ -52,6 +53,9 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
@Override @Override
public String getName() { public String getName() {
if (AuditLogger.isEnabled()) {
AuditLogger.getName(this.broadcastGroup);
}
clearIO(); clearIO();
try { try {
return configuration.getName(); return configuration.getName();
@ -62,6 +66,9 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
@Override @Override
public long getBroadcastPeriod() { public long getBroadcastPeriod() {
if (AuditLogger.isEnabled()) {
AuditLogger.getBroadcastPeriod(this.broadcastGroup);
}
clearIO(); clearIO();
try { try {
return configuration.getBroadcastPeriod(); return configuration.getBroadcastPeriod();
@ -72,6 +79,9 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
@Override @Override
public Object[] getConnectorPairs() { public Object[] getConnectorPairs() {
if (AuditLogger.isEnabled()) {
AuditLogger.getConnectorPairs(this.broadcastGroup);
}
clearIO(); clearIO();
try { try {
Object[] ret = new Object[configuration.getConnectorInfos().size()]; Object[] ret = new Object[configuration.getConnectorInfos().size()];
@ -80,7 +90,6 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
for (String connector : configuration.getConnectorInfos()) { for (String connector : configuration.getConnectorInfos()) {
ret[i++] = connector; ret[i++] = connector;
} }
return ret; return ret;
} finally { } finally {
blockOnIO(); blockOnIO();
@ -89,6 +98,9 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
@Override @Override
public String getConnectorPairsAsJSON() throws Exception { public String getConnectorPairsAsJSON() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.getConnectorPairsAsJSON(this.broadcastGroup);
}
clearIO(); clearIO();
try { try {
return JsonUtil.toJsonArray(configuration.getConnectorInfos()).toString(); return JsonUtil.toJsonArray(configuration.getConnectorInfos()).toString();
@ -100,6 +112,9 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
//todo ghoward we should deal with this properly //todo ghoward we should deal with this properly
@Override @Override
public String getGroupAddress() throws Exception { public String getGroupAddress() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.getGroupAddress(this.broadcastGroup);
}
clearIO(); clearIO();
try { try {
if (configuration.getEndpointFactory() instanceof UDPBroadcastEndpointFactory) { if (configuration.getEndpointFactory() instanceof UDPBroadcastEndpointFactory) {
@ -113,6 +128,9 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
@Override @Override
public int getGroupPort() throws Exception { public int getGroupPort() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.getGroupPort(this.broadcastGroup);
}
clearIO(); clearIO();
try { try {
if (configuration.getEndpointFactory() instanceof UDPBroadcastEndpointFactory) { if (configuration.getEndpointFactory() instanceof UDPBroadcastEndpointFactory) {
@ -126,6 +144,9 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
@Override @Override
public int getLocalBindPort() throws Exception { public int getLocalBindPort() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.getLocalBindPort(this.broadcastGroup);
}
clearIO(); clearIO();
try { try {
if (configuration.getEndpointFactory() instanceof UDPBroadcastEndpointFactory) { if (configuration.getEndpointFactory() instanceof UDPBroadcastEndpointFactory) {
@ -141,6 +162,9 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
@Override @Override
public boolean isStarted() { public boolean isStarted() {
if (AuditLogger.isEnabled()) {
AuditLogger.isStarted(this.broadcastGroup);
}
clearIO(); clearIO();
try { try {
return broadcastGroup.isStarted(); return broadcastGroup.isStarted();
@ -151,6 +175,9 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
@Override @Override
public void start() throws Exception { public void start() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.startBroadcastGroup(this.broadcastGroup);
}
clearIO(); clearIO();
try { try {
broadcastGroup.start(); broadcastGroup.start();
@ -161,6 +188,9 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
@Override @Override
public void stop() throws Exception { public void stop() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.stopBroadcastGroup(this.broadcastGroup);
}
clearIO(); clearIO();
try { try {
broadcastGroup.stop(); broadcastGroup.stop();

View File

@ -28,6 +28,7 @@ import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
import org.apache.activemq.artemis.core.persistence.StorageManager; import org.apache.activemq.artemis.core.persistence.StorageManager;
import org.apache.activemq.artemis.core.server.cluster.ClusterConnection; import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
import org.apache.activemq.artemis.core.server.cluster.impl.BridgeMetrics; import org.apache.activemq.artemis.core.server.cluster.impl.BridgeMetrics;
import org.apache.activemq.artemis.logs.AuditLogger;
public class ClusterConnectionControlImpl extends AbstractControl implements ClusterConnectionControl { public class ClusterConnectionControlImpl extends AbstractControl implements ClusterConnectionControl {
@ -55,6 +56,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override @Override
public String getAddress() { public String getAddress() {
if (AuditLogger.isEnabled()) {
AuditLogger.getAddress(this.clusterConnection);
}
clearIO(); clearIO();
try { try {
return configuration.getAddress(); return configuration.getAddress();
@ -66,6 +70,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override @Override
public String getDiscoveryGroupName() { public String getDiscoveryGroupName() {
if (AuditLogger.isEnabled()) {
AuditLogger.getDiscoveryGroupName(this.clusterConnection);
}
clearIO(); clearIO();
try { try {
return configuration.getDiscoveryGroupName(); return configuration.getDiscoveryGroupName();
@ -77,6 +84,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override @Override
public int getMaxHops() { public int getMaxHops() {
if (AuditLogger.isEnabled()) {
AuditLogger.getMaxHops(this.clusterConnection);
}
clearIO(); clearIO();
try { try {
return configuration.getMaxHops(); return configuration.getMaxHops();
@ -88,6 +98,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override @Override
public String getName() { public String getName() {
if (AuditLogger.isEnabled()) {
AuditLogger.getName(this.clusterConnection);
}
clearIO(); clearIO();
try { try {
return configuration.getName(); return configuration.getName();
@ -99,6 +112,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override @Override
public long getRetryInterval() { public long getRetryInterval() {
if (AuditLogger.isEnabled()) {
AuditLogger.getRetryInterval(this.clusterConnection);
}
clearIO(); clearIO();
try { try {
return configuration.getRetryInterval(); return configuration.getRetryInterval();
@ -110,6 +126,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override @Override
public String getNodeID() { public String getNodeID() {
if (AuditLogger.isEnabled()) {
AuditLogger.getNodeID(this.clusterConnection);
}
clearIO(); clearIO();
try { try {
return clusterConnection.getNodeID(); return clusterConnection.getNodeID();
@ -120,6 +139,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override @Override
public String[] getStaticConnectors() { public String[] getStaticConnectors() {
if (AuditLogger.isEnabled()) {
AuditLogger.getStaticConnectors(this.clusterConnection);
}
clearIO(); clearIO();
try { try {
List<String> staticConnectors = configuration.getStaticConnectors(); List<String> staticConnectors = configuration.getStaticConnectors();
@ -135,6 +157,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override @Override
public String getStaticConnectorsAsJSON() throws Exception { public String getStaticConnectorsAsJSON() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.getStaticConnectorsAsJSON(this.clusterConnection);
}
clearIO(); clearIO();
try { try {
return JsonUtil.toJsonArray(configuration.getStaticConnectors()).toString(); return JsonUtil.toJsonArray(configuration.getStaticConnectors()).toString();
@ -145,6 +170,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override @Override
public boolean isDuplicateDetection() { public boolean isDuplicateDetection() {
if (AuditLogger.isEnabled()) {
AuditLogger.isDuplicateDetection(this.clusterConnection);
}
clearIO(); clearIO();
try { try {
return configuration.isDuplicateDetection(); return configuration.isDuplicateDetection();
@ -155,6 +183,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override @Override
public String getMessageLoadBalancingType() { public String getMessageLoadBalancingType() {
if (AuditLogger.isEnabled()) {
AuditLogger.getMessageLoadBalancingType(this.clusterConnection);
}
clearIO(); clearIO();
try { try {
return configuration.getMessageLoadBalancingType().getType(); return configuration.getMessageLoadBalancingType().getType();
@ -165,6 +196,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override @Override
public String getTopology() { public String getTopology() {
if (AuditLogger.isEnabled()) {
AuditLogger.getTopology(this.clusterConnection);
}
clearIO(); clearIO();
try { try {
return clusterConnection.getTopology().describe(); return clusterConnection.getTopology().describe();
@ -175,6 +209,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override @Override
public Map<String, String> getNodes() throws Exception { public Map<String, String> getNodes() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.getNodes(this.clusterConnection);
}
clearIO(); clearIO();
try { try {
return clusterConnection.getNodes(); return clusterConnection.getNodes();
@ -185,6 +222,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override @Override
public boolean isStarted() { public boolean isStarted() {
if (AuditLogger.isEnabled()) {
AuditLogger.isStarted(this.clusterConnection);
}
clearIO(); clearIO();
try { try {
return clusterConnection.isStarted(); return clusterConnection.isStarted();
@ -195,6 +235,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override @Override
public void start() throws Exception { public void start() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.startClusterConnection(this.clusterConnection);
}
clearIO(); clearIO();
try { try {
clusterConnection.start(); clusterConnection.start();
@ -206,6 +249,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override @Override
public void stop() throws Exception { public void stop() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.stopClusterConnection(this.clusterConnection);
}
clearIO(); clearIO();
try { try {
clusterConnection.stop(); clusterConnection.stop();
@ -227,6 +273,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override @Override
public long getMessagesPendingAcknowledgement() { public long getMessagesPendingAcknowledgement() {
if (AuditLogger.isEnabled()) {
AuditLogger.getMessagesPendingAcknowledgement(this.clusterConnection);
}
clearIO(); clearIO();
try { try {
return clusterConnection.getMetrics().getMessagesPendingAcknowledgement(); return clusterConnection.getMetrics().getMessagesPendingAcknowledgement();
@ -237,6 +286,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override @Override
public long getMessagesAcknowledged() { public long getMessagesAcknowledged() {
if (AuditLogger.isEnabled()) {
AuditLogger.getMessagesAcknowledged(this.clusterConnection);
}
clearIO(); clearIO();
try { try {
return clusterConnection.getMetrics().getMessagesAcknowledged(); return clusterConnection.getMetrics().getMessagesAcknowledged();
@ -247,6 +299,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override @Override
public Map<String, Object> getMetrics() { public Map<String, Object> getMetrics() {
if (AuditLogger.isEnabled()) {
AuditLogger.getMetrics(this.clusterConnection);
}
clearIO(); clearIO();
try { try {
return clusterConnection.getMetrics().convertToMap(); return clusterConnection.getMetrics().convertToMap();
@ -257,6 +312,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
@Override @Override
public Map<String, Object> getBridgeMetrics(String nodeId) { public Map<String, Object> getBridgeMetrics(String nodeId) {
if (AuditLogger.isEnabled()) {
AuditLogger.getBridgeMetrics(this.clusterConnection, nodeId);
}
clearIO(); clearIO();
try { try {
final BridgeMetrics bridgeMetrics = clusterConnection.getBridgeMetrics(nodeId); final BridgeMetrics bridgeMetrics = clusterConnection.getBridgeMetrics(nodeId);

View File

@ -26,6 +26,7 @@ import org.apache.activemq.artemis.api.core.management.DivertControl;
import org.apache.activemq.artemis.core.config.DivertConfiguration; import org.apache.activemq.artemis.core.config.DivertConfiguration;
import org.apache.activemq.artemis.core.persistence.StorageManager; import org.apache.activemq.artemis.core.persistence.StorageManager;
import org.apache.activemq.artemis.core.server.Divert; import org.apache.activemq.artemis.core.server.Divert;
import org.apache.activemq.artemis.logs.AuditLogger;
public class DivertControlImpl extends AbstractControl implements DivertControl { public class DivertControlImpl extends AbstractControl implements DivertControl {
@ -53,6 +54,9 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
@Override @Override
public String getAddress() { public String getAddress() {
if (AuditLogger.isEnabled()) {
AuditLogger.getAddress(this.divert);
}
clearIO(); clearIO();
try { try {
return configuration.getAddress(); return configuration.getAddress();
@ -63,6 +67,9 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
@Override @Override
public String getFilter() { public String getFilter() {
if (AuditLogger.isEnabled()) {
AuditLogger.getFilter(this.divert);
}
clearIO(); clearIO();
try { try {
return configuration.getFilterString(); return configuration.getFilterString();
@ -73,6 +80,9 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
@Override @Override
public String getForwardingAddress() { public String getForwardingAddress() {
if (AuditLogger.isEnabled()) {
AuditLogger.getForwardingAddress(this.divert);
}
clearIO(); clearIO();
try { try {
return configuration.getForwardingAddress(); return configuration.getForwardingAddress();
@ -83,6 +93,9 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
@Override @Override
public String getRoutingName() { public String getRoutingName() {
if (AuditLogger.isEnabled()) {
AuditLogger.getRoutingName(this.divert);
}
clearIO(); clearIO();
try { try {
return divert.getRoutingName().toString(); return divert.getRoutingName().toString();
@ -93,6 +106,9 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
@Override @Override
public String getTransformerClassName() { public String getTransformerClassName() {
if (AuditLogger.isEnabled()) {
AuditLogger.getTransformerClassName(this.divert);
}
clearIO(); clearIO();
try { try {
return configuration.getTransformerConfiguration() == null ? null : configuration.getTransformerConfiguration().getClassName(); return configuration.getTransformerConfiguration() == null ? null : configuration.getTransformerConfiguration().getClassName();
@ -103,11 +119,17 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
@Override @Override
public String getTransformerPropertiesAsJSON() { public String getTransformerPropertiesAsJSON() {
if (AuditLogger.isEnabled()) {
AuditLogger.getTransformerPropertiesAsJSON(this.divert);
}
return JsonUtil.toJsonObject(getTransformerProperties()).toString(); return JsonUtil.toJsonObject(getTransformerProperties()).toString();
} }
@Override @Override
public Map<String, String> getTransformerProperties() { public Map<String, String> getTransformerProperties() {
if (AuditLogger.isEnabled()) {
AuditLogger.getTransformerProperties(this.divert);
}
clearIO(); clearIO();
try { try {
return configuration.getTransformerConfiguration() == null ? null : configuration.getTransformerConfiguration().getProperties(); return configuration.getTransformerConfiguration() == null ? null : configuration.getTransformerConfiguration().getProperties();
@ -118,6 +140,9 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
@Override @Override
public String getRoutingType() { public String getRoutingType() {
if (AuditLogger.isEnabled()) {
AuditLogger.getRoutingType(this.divert);
}
clearIO(); clearIO();
try { try {
return configuration.getRoutingType().toString(); return configuration.getRoutingType().toString();
@ -128,6 +153,9 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
@Override @Override
public String getUniqueName() { public String getUniqueName() {
if (AuditLogger.isEnabled()) {
AuditLogger.getUniqueName(this.divert);
}
clearIO(); clearIO();
try { try {
return divert.getUniqueName().toString(); return divert.getUniqueName().toString();
@ -138,6 +166,9 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
@Override @Override
public boolean isExclusive() { public boolean isExclusive() {
if (AuditLogger.isEnabled()) {
AuditLogger.isExclusive(this.divert);
}
clearIO(); clearIO();
try { try {
return divert.isExclusive(); return divert.isExclusive();

View File

@ -52,6 +52,7 @@ import org.apache.activemq.artemis.core.server.ServerConsumer;
import org.apache.activemq.artemis.core.settings.HierarchicalRepository; import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.selector.filter.Filterable; import org.apache.activemq.artemis.selector.filter.Filterable;
import org.apache.activemq.artemis.logs.AuditLogger;
import org.apache.activemq.artemis.utils.JsonLoader; import org.apache.activemq.artemis.utils.JsonLoader;
import org.apache.activemq.artemis.utils.collections.LinkedListIterator; import org.apache.activemq.artemis.utils.collections.LinkedListIterator;
@ -129,6 +130,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public String getName() { public String getName() {
if (AuditLogger.isEnabled()) {
AuditLogger.getName(queue);
}
clearIO(); clearIO();
try { try {
return queue.getName().toString(); return queue.getName().toString();
@ -139,6 +143,10 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public String getAddress() { public String getAddress() {
if (AuditLogger.isEnabled()) {
AuditLogger.getAddress(queue);
}
checkStarted(); checkStarted();
return address; return address;
@ -146,6 +154,10 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public String getFilter() { public String getFilter() {
if (AuditLogger.isEnabled()) {
AuditLogger.getFilter(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -160,6 +172,10 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public boolean isDurable() { public boolean isDurable() {
if (AuditLogger.isEnabled()) {
AuditLogger.isDurable(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -172,6 +188,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public String getUser() { public String getUser() {
if (AuditLogger.isEnabled()) {
AuditLogger.getUser(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -186,6 +205,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public String getRoutingType() { public String getRoutingType() {
if (AuditLogger.isEnabled()) {
AuditLogger.getRoutingType(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -199,6 +221,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public boolean isTemporary() { public boolean isTemporary() {
if (AuditLogger.isEnabled()) {
AuditLogger.isTemporary(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -211,6 +236,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public long getMessageCount() { public long getMessageCount() {
if (AuditLogger.isEnabled()) {
AuditLogger.getMessageCount(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -223,6 +251,10 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public long getPersistentSize() { public long getPersistentSize() {
if (AuditLogger.isEnabled()) {
AuditLogger.getPersistentSize(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -235,6 +267,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public long getDurableMessageCount() { public long getDurableMessageCount() {
if (AuditLogger.isEnabled()) {
AuditLogger.getDurableMessageCount(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -247,6 +282,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public long getDurablePersistentSize() { public long getDurablePersistentSize() {
if (AuditLogger.isEnabled()) {
AuditLogger.getDurablePersistSize(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -259,6 +297,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public int getConsumerCount() { public int getConsumerCount() {
if (AuditLogger.isEnabled()) {
AuditLogger.getConsumerCount(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -271,6 +312,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public int getDeliveringCount() { public int getDeliveringCount() {
if (AuditLogger.isEnabled()) {
AuditLogger.getDeliveringCount(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -283,6 +327,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public long getDeliveringSize() { public long getDeliveringSize() {
if (AuditLogger.isEnabled()) {
AuditLogger.getDeliveringSize(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -295,6 +342,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public int getDurableDeliveringCount() { public int getDurableDeliveringCount() {
if (AuditLogger.isEnabled()) {
AuditLogger.getDurableDeliveringCount(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -307,6 +357,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public long getDurableDeliveringSize() { public long getDurableDeliveringSize() {
if (AuditLogger.isEnabled()) {
AuditLogger.getDurableDeliveringSize(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -319,6 +372,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public long getMessagesAdded() { public long getMessagesAdded() {
if (AuditLogger.isEnabled()) {
AuditLogger.getMessagesAdded(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -331,6 +387,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public long getMessagesAcknowledged() { public long getMessagesAcknowledged() {
if (AuditLogger.isEnabled()) {
AuditLogger.getMessagesAcknowledged(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -343,6 +402,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public long getMessagesExpired() { public long getMessagesExpired() {
if (AuditLogger.isEnabled()) {
AuditLogger.getMessagesExpired(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -355,6 +417,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public long getMessagesKilled() { public long getMessagesKilled() {
if (AuditLogger.isEnabled()) {
AuditLogger.getMessagesKilled(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -367,6 +432,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public long getID() { public long getID() {
if (AuditLogger.isEnabled()) {
AuditLogger.getID(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -379,6 +447,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public long getScheduledCount() { public long getScheduledCount() {
if (AuditLogger.isEnabled()) {
AuditLogger.getScheduledCount(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -391,6 +462,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public long getScheduledSize() { public long getScheduledSize() {
if (AuditLogger.isEnabled()) {
AuditLogger.getScheduledSize(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -403,6 +477,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public long getDurableScheduledCount() { public long getDurableScheduledCount() {
if (AuditLogger.isEnabled()) {
AuditLogger.getDurableScheduledCount(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -415,6 +492,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public long getDurableScheduledSize() { public long getDurableScheduledSize() {
if (AuditLogger.isEnabled()) {
AuditLogger.getDurableScheduledSize(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -427,6 +507,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public String getDeadLetterAddress() { public String getDeadLetterAddress() {
if (AuditLogger.isEnabled()) {
AuditLogger.getDeadLetterAddress(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -444,6 +527,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public String getExpiryAddress() { public String getExpiryAddress() {
if (AuditLogger.isEnabled()) {
AuditLogger.getExpiryAddress(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -462,6 +548,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public int getMaxConsumers() { public int getMaxConsumers() {
if (AuditLogger.isEnabled()) {
AuditLogger.getMaxConsumers(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -474,6 +563,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public boolean isPurgeOnNoConsumers() { public boolean isPurgeOnNoConsumers() {
if (AuditLogger.isEnabled()) {
AuditLogger.isPurgeOnNoConsumers(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -486,6 +578,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public boolean isConfigurationManaged() { public boolean isConfigurationManaged() {
if (AuditLogger.isEnabled()) {
AuditLogger.isConfigurationManaged(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -498,6 +593,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public boolean isExclusive() { public boolean isExclusive() {
if (AuditLogger.isEnabled()) {
AuditLogger.isExclusive(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -510,6 +608,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public boolean isLastValue() { public boolean isLastValue() {
if (AuditLogger.isEnabled()) {
AuditLogger.isLastValue(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -522,6 +623,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public Map<String, Object>[] listScheduledMessages() throws Exception { public Map<String, Object>[] listScheduledMessages() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.listScheduledMessages(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -535,6 +639,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public String listScheduledMessagesAsJSON() throws Exception { public String listScheduledMessagesAsJSON() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.listScheduledMessagesAsJSON(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -561,6 +668,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public Map<String, Map<String, Object>[]> listDeliveringMessages() throws ActiveMQException { public Map<String, Map<String, Object>[]> listDeliveringMessages() throws ActiveMQException {
if (AuditLogger.isEnabled()) {
AuditLogger.listDeliveringMessages(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -572,15 +682,18 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
for (Map.Entry<String, List<MessageReference>> entry : msgs.entrySet()) { for (Map.Entry<String, List<MessageReference>> entry : msgs.entrySet()) {
msgRet.put(entry.getKey(), convertMessagesToMaps(entry.getValue())); msgRet.put(entry.getKey(), convertMessagesToMaps(entry.getValue()));
} }
return msgRet; return msgRet;
} finally { } finally {
blockOnIO(); blockOnIO();
} }
} }
@Override @Override
public String listDeliveringMessagesAsJSON() throws Exception { public String listDeliveringMessagesAsJSON() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.listDeliveringMessagesAsJSON(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -593,6 +706,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public Map<String, Object>[] listMessages(final String filterStr) throws Exception { public Map<String, Object>[] listMessages(final String filterStr) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.listMessages(queue, filterStr);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -623,6 +739,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public String listMessagesAsJSON(final String filter) throws Exception { public String listMessagesAsJSON(final String filter) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.listMessagesAsJSON(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -634,6 +753,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
} }
protected Map<String, Object>[] getFirstMessage() throws Exception { protected Map<String, Object>[] getFirstMessage() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.getFirstMessage(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -657,11 +779,18 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public String getFirstMessageAsJSON() throws Exception { public String getFirstMessageAsJSON() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.getFirstMessageAsJSON(queue);
}
return toJSON(getFirstMessage()); return toJSON(getFirstMessage());
} }
@Override @Override
public Long getFirstMessageTimestamp() throws Exception { public Long getFirstMessageTimestamp() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.getFirstMessageTimestamp(queue);
}
Map<String, Object>[] _message = getFirstMessage(); Map<String, Object>[] _message = getFirstMessage();
if (_message == null || _message.length == 0 || _message[0] == null) { if (_message == null || _message.length == 0 || _message[0] == null) {
return null; return null;
@ -675,6 +804,10 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public Long getFirstMessageAge() throws Exception { public Long getFirstMessageAge() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.getFirstMessageAge(queue);
}
Long firstMessageTimestamp = getFirstMessageTimestamp(); Long firstMessageTimestamp = getFirstMessageTimestamp();
if (firstMessageTimestamp == null) { if (firstMessageTimestamp == null) {
return null; return null;
@ -690,12 +823,20 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public long countMessages(final String filterStr) throws Exception { public long countMessages(final String filterStr) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.countMessages(queue, filterStr);
}
Long value = intenalCountMessages(filterStr, null).get(null); Long value = intenalCountMessages(filterStr, null).get(null);
return value == null ? 0 : value; return value == null ? 0 : value;
} }
@Override @Override
public String countMessages(final String filterStr, final String groupByProperty) throws Exception { public String countMessages(final String filterStr, final String groupByProperty) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.countMessages(queue, filterStr, groupByProperty);
}
return JsonUtil.toJsonObject(intenalCountMessages(filterStr, groupByProperty)).toString(); return JsonUtil.toJsonObject(intenalCountMessages(filterStr, groupByProperty)).toString();
} }
@ -730,12 +871,20 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public long countDeliveringMessages(final String filterStr) throws Exception { public long countDeliveringMessages(final String filterStr) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.countDeliveringMessages(queue, filterStr);
}
Long value = intenalCountDeliveryMessages(filterStr, null).get(null); Long value = intenalCountDeliveryMessages(filterStr, null).get(null);
return value == null ? 0 : value; return value == null ? 0 : value;
} }
@Override @Override
public String countDeliveringMessages(final String filterStr, final String groupByProperty) throws Exception { public String countDeliveringMessages(final String filterStr, final String groupByProperty) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.countDeliveringMessages(queue, filterStr, groupByProperty);
}
return JsonUtil.toJsonObject(intenalCountDeliveryMessages(filterStr, groupByProperty)).toString(); return JsonUtil.toJsonObject(intenalCountDeliveryMessages(filterStr, groupByProperty)).toString();
} }
@ -778,6 +927,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public boolean removeMessage(final long messageID) throws Exception { public boolean removeMessage(final long messageID) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.removeMessage(queue, messageID);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -797,6 +949,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public int removeMessages(final int flushLimit, final String filterStr) throws Exception { public int removeMessages(final int flushLimit, final String filterStr) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.removeMessages(queue, flushLimit, filterStr);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -816,6 +971,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public boolean expireMessage(final long messageID) throws Exception { public boolean expireMessage(final long messageID) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.expireMessage(queue, messageID);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -828,6 +986,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public int expireMessages(final String filterStr) throws Exception { public int expireMessages(final String filterStr) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.expireMessages(queue, filterStr);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -843,6 +1004,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public boolean retryMessage(final long messageID) throws Exception { public boolean retryMessage(final long messageID) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.retryMessage(queue, messageID);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -878,6 +1042,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public int retryMessages() throws Exception { public int retryMessages() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.retryMessages(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -897,6 +1064,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
public boolean moveMessage(final long messageID, public boolean moveMessage(final long messageID,
final String otherQueueName, final String otherQueueName,
final boolean rejectDuplicates) throws Exception { final boolean rejectDuplicates) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.moveMessage(queue, messageID, otherQueueName, rejectDuplicates);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -924,6 +1094,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
final String filterStr, final String filterStr,
final String otherQueueName, final String otherQueueName,
final boolean rejectDuplicates) throws Exception { final boolean rejectDuplicates) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.moveMessages(queue, flushLimit, filterStr, otherQueueName, rejectDuplicates);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -937,7 +1110,6 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
} }
int retValue = queue.moveReferences(flushLimit, filter, binding.getAddress(), rejectDuplicates, binding); int retValue = queue.moveReferences(flushLimit, filter, binding.getAddress(), rejectDuplicates, binding);
return retValue; return retValue;
} finally { } finally {
blockOnIO(); blockOnIO();
@ -954,6 +1126,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public int sendMessagesToDeadLetterAddress(final String filterStr) throws Exception { public int sendMessagesToDeadLetterAddress(final String filterStr) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.sendMessagesToDeadLetterAddress(queue, filterStr);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -973,6 +1148,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
boolean durable, boolean durable,
final String user, final String user,
final String password) throws Exception { final String password) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.sendMessage(queue, null, headers, type, body, durable, user, "****");
}
try { try {
return sendMessage(queue.getAddress(), server, headers, type, body, durable, user, password, queue.getID()); return sendMessage(queue.getAddress(), server, headers, type, body, durable, user, password, queue.getID());
} catch (Exception e) { } catch (Exception e) {
@ -982,6 +1160,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public boolean sendMessageToDeadLetterAddress(final long messageID) throws Exception { public boolean sendMessageToDeadLetterAddress(final long messageID) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.sendMessageToDeadLetterAddress(queue, messageID);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -994,6 +1175,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public int changeMessagesPriority(final String filterStr, final int newPriority) throws Exception { public int changeMessagesPriority(final String filterStr, final int newPriority) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.changeMessagesPriority(queue, filterStr, newPriority);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -1011,6 +1195,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public boolean changeMessagePriority(final long messageID, final int newPriority) throws Exception { public boolean changeMessagePriority(final long messageID, final int newPriority) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.changeMessagePriority(queue, messageID, newPriority);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -1026,6 +1213,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public String listMessageCounter() { public String listMessageCounter() {
if (AuditLogger.isEnabled()) {
AuditLogger.listMessageCounter(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -1040,6 +1230,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public void resetMessageCounter() { public void resetMessageCounter() {
if (AuditLogger.isEnabled()) {
AuditLogger.resetMessageCounter(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -1052,6 +1245,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public String listMessageCounterAsHTML() { public String listMessageCounterAsHTML() {
if (AuditLogger.isEnabled()) {
AuditLogger.listMessageCounterAsHTML(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -1064,6 +1260,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public String listMessageCounterHistory() throws Exception { public String listMessageCounterHistory() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.listMessageCounterHistory(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -1076,6 +1275,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public String listMessageCounterHistoryAsHTML() { public String listMessageCounterHistoryAsHTML() {
if (AuditLogger.isEnabled()) {
AuditLogger.listMessageCounterHistoryAsHTML(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -1088,6 +1290,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public void pause() { public void pause() {
if (AuditLogger.isEnabled()) {
AuditLogger.pause(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -1101,6 +1306,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public void pause(boolean persist) { public void pause(boolean persist) {
if (AuditLogger.isEnabled()) {
AuditLogger.pause(queue, persist);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -1112,6 +1320,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
} }
@Override @Override
public void resume() { public void resume() {
if (AuditLogger.isEnabled()) {
AuditLogger.resume(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -1124,6 +1335,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public boolean isPaused() throws Exception { public boolean isPaused() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.isPaused(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -1136,6 +1350,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public CompositeData[] browse(int page, int pageSize) throws Exception { public CompositeData[] browse(int page, int pageSize) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.browse(queue, page, pageSize);
}
String filter = null; String filter = null;
checkStarted(); checkStarted();
@ -1181,6 +1398,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
} }
@Override @Override
public CompositeData[] browse(String filter) throws Exception { public CompositeData[] browse(String filter) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.browse(queue, filter);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -1216,6 +1436,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public void flushExecutor() { public void flushExecutor() {
if (AuditLogger.isEnabled()) {
AuditLogger.flushExecutor(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -1228,6 +1451,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public void resetAllGroups() { public void resetAllGroups() {
if (AuditLogger.isEnabled()) {
AuditLogger.resetAllGroups(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -1240,6 +1466,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public void resetGroup(String groupID) { public void resetGroup(String groupID) {
if (AuditLogger.isEnabled()) {
AuditLogger.resetGroup(queue, groupID);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -1252,6 +1481,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public int getGroupCount() { public int getGroupCount() {
if (AuditLogger.isEnabled()) {
AuditLogger.getGroupCount(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -1264,6 +1496,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public String listGroupsAsJSON() throws Exception { public String listGroupsAsJSON() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.listGroupsAsJSON(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -1292,6 +1527,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public String listConsumersAsJSON() throws Exception { public String listConsumersAsJSON() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.listConsumersAsJSON(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -1330,6 +1568,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public void resetMessagesAdded() throws Exception { public void resetMessagesAdded() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.resetMessagesAdded(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -1343,6 +1584,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public void resetMessagesAcknowledged() throws Exception { public void resetMessagesAcknowledged() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.resetMessagesAcknowledged(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -1356,6 +1600,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public void resetMessagesExpired() throws Exception { public void resetMessagesExpired() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.resetMessagesExpired(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();
@ -1369,6 +1616,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
@Override @Override
public void resetMessagesKilled() throws Exception { public void resetMessagesKilled() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.resetMessagesKilled(queue);
}
checkStarted(); checkStarted();
clearIO(); clearIO();

View File

@ -35,6 +35,7 @@ import org.apache.activemq.artemis.core.server.management.Notification;
import org.apache.activemq.artemis.core.server.management.NotificationService; import org.apache.activemq.artemis.core.server.management.NotificationService;
import org.apache.activemq.artemis.core.settings.HierarchicalRepository; import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
import org.apache.activemq.artemis.core.settings.HierarchicalRepositoryChangeListener; import org.apache.activemq.artemis.core.settings.HierarchicalRepositoryChangeListener;
import org.apache.activemq.artemis.logs.AuditLogger;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager; import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager2; import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager2;
@ -227,11 +228,14 @@ public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryC
notificationService.sendNotification(notification); notificationService.sendNotification(notification);
} }
Exception ex;
if (queue == null) { if (queue == null) {
throw ActiveMQMessageBundle.BUNDLE.userNoPermissions(session.getUsername(), checkType, saddress); ex = ActiveMQMessageBundle.BUNDLE.userNoPermissions(session.getUsername(), checkType, saddress);
} else { } else {
throw ActiveMQMessageBundle.BUNDLE.userNoPermissionsQueue(session.getUsername(), checkType, queue.toString(), saddress); ex = ActiveMQMessageBundle.BUNDLE.userNoPermissionsQueue(session.getUsername(), checkType, queue.toString(), saddress);
} }
AuditLogger.securityFailure(ex);
throw ex;
} }
// if we get here we're granted, add to the cache // if we get here we're granted, add to the cache
ConcurrentHashSet<SimpleString> set = new ConcurrentHashSet<>(); ConcurrentHashSet<SimpleString> set = new ConcurrentHashSet<>();

View File

@ -177,6 +177,7 @@ import org.apache.activemq.artemis.core.settings.impl.ResourceLimitSettings;
import org.apache.activemq.artemis.core.transaction.ResourceManager; import org.apache.activemq.artemis.core.transaction.ResourceManager;
import org.apache.activemq.artemis.core.transaction.impl.ResourceManagerImpl; import org.apache.activemq.artemis.core.transaction.impl.ResourceManagerImpl;
import org.apache.activemq.artemis.core.version.Version; import org.apache.activemq.artemis.core.version.Version;
import org.apache.activemq.artemis.logs.AuditLogger;
import org.apache.activemq.artemis.spi.core.protocol.ProtocolManagerFactory; import org.apache.activemq.artemis.spi.core.protocol.ProtocolManagerFactory;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.spi.core.protocol.SessionCallback; import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
@ -1448,6 +1449,11 @@ public class ActiveMQServerImpl implements ActiveMQServer {
final boolean autoCreateQueues, final boolean autoCreateQueues,
final OperationContext context, final OperationContext context,
final Map<SimpleString, RoutingType> prefixes) throws Exception { final Map<SimpleString, RoutingType> prefixes) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.createCoreSession(this, name, username, "****", minLargeMessageSize, connection, autoCommitSends,
autoCommitAcks, preAcknowledge, xa, defaultAddress, callback, autoCreateQueues, context, prefixes);
}
String validatedUser = ""; String validatedUser = "";
if (securityStore != null) { if (securityStore != null) {

View File

@ -88,6 +88,7 @@ import org.apache.activemq.artemis.core.transaction.Transaction.State;
import org.apache.activemq.artemis.core.transaction.TransactionOperationAbstract; import org.apache.activemq.artemis.core.transaction.TransactionOperationAbstract;
import org.apache.activemq.artemis.core.transaction.TransactionPropertyIndexes; import org.apache.activemq.artemis.core.transaction.TransactionPropertyIndexes;
import org.apache.activemq.artemis.core.transaction.impl.TransactionImpl; import org.apache.activemq.artemis.core.transaction.impl.TransactionImpl;
import org.apache.activemq.artemis.logs.AuditLogger;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.spi.core.protocol.SessionCallback; import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
import org.apache.activemq.artemis.utils.CompositeAddress; import org.apache.activemq.artemis.utils.CompositeAddress;
@ -486,6 +487,9 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
final boolean browseOnly, final boolean browseOnly,
final boolean supportLargeMessage, final boolean supportLargeMessage,
final Integer credits) throws Exception { final Integer credits) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.createCoreConsumer(this, getUsername(), consumerID, queueName, filterString, priority, browseOnly, supportLargeMessage, credits);
}
final SimpleString unPrefixedQueueName = removePrefix(queueName); final SimpleString unPrefixedQueueName = removePrefix(queueName);
Binding binding = postOffice.getBinding(unPrefixedQueueName); Binding binding = postOffice.getBinding(unPrefixedQueueName);
@ -632,6 +636,11 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
final long autoDeleteDelay, final long autoDeleteDelay,
final long autoDeleteMessageCount, final long autoDeleteMessageCount,
final boolean autoCreated) throws Exception { final boolean autoCreated) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.createQueue(this, getUsername(), addressInfo, name, filterString, temporary, durable, maxConsumers, purgeOnNoConsumers,
exclusive, groupRebalance, groupBuckets, lastValue, lastValueKey, nonDestructive, consumersBeforeDispatch,
delayBeforeDispatch, autoDelete, autoDeleteDelay, autoDeleteMessageCount, autoCreated);
}
final SimpleString unPrefixedName = removePrefix(name); final SimpleString unPrefixedName = removePrefix(name);
AddressInfo art = getAddressAndRoutingType(addressInfo); AddressInfo art = getAddressAndRoutingType(addressInfo);
@ -780,6 +789,10 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
public AddressInfo createAddress(final SimpleString address, public AddressInfo createAddress(final SimpleString address,
EnumSet<RoutingType> routingTypes, EnumSet<RoutingType> routingTypes,
final boolean autoCreated) throws Exception { final boolean autoCreated) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.serverSessionCreateAddress(this.getName(), getUsername(), address, routingTypes, autoCreated);
}
SimpleString realAddress = CompositeAddress.extractAddressName(address); SimpleString realAddress = CompositeAddress.extractAddressName(address);
Pair<SimpleString, EnumSet<RoutingType>> art = getAddressAndRoutingTypes(realAddress, routingTypes); Pair<SimpleString, EnumSet<RoutingType>> art = getAddressAndRoutingTypes(realAddress, routingTypes);
securityCheck(art.getA(), CheckType.CREATE_ADDRESS, this); securityCheck(art.getA(), CheckType.CREATE_ADDRESS, this);
@ -796,6 +809,10 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
@Override @Override
public AddressInfo createAddress(AddressInfo addressInfo, boolean autoCreated) throws Exception { public AddressInfo createAddress(AddressInfo addressInfo, boolean autoCreated) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.serverSessionCreateAddress(this.getName(), getUsername(), addressInfo, autoCreated);
}
AddressInfo art = getAddressAndRoutingType(addressInfo); AddressInfo art = getAddressAndRoutingType(addressInfo);
securityCheck(art.getName(), CheckType.CREATE_ADDRESS, this); securityCheck(art.getName(), CheckType.CREATE_ADDRESS, this);
server.addOrUpdateAddressInfo(art.setAutoCreated(autoCreated)); server.addOrUpdateAddressInfo(art.setAutoCreated(autoCreated));
@ -834,6 +851,11 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
Boolean autoDelete, Boolean autoDelete,
Long autoDeleteDelay, Long autoDeleteDelay,
Long autoDeleteMessageCount) throws Exception { Long autoDeleteMessageCount) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.createSharedQueue(this, getUsername(), address, name, routingType, filterString, durable, maxConsumers, purgeOnNoConsumers,
exclusive, groupRebalance, groupBuckets, lastValue, lastValueKey, nonDestructive, consumersBeforeDispatch,
delayBeforeDispatch, autoDelete, autoDeleteDelay, autoDeleteMessageCount);
}
address = removePrefix(address); address = removePrefix(address);
securityCheck(address, name, durable ? CheckType.CREATE_DURABLE_QUEUE : CheckType.CREATE_NON_DURABLE_QUEUE, this); securityCheck(address, name, durable ? CheckType.CREATE_DURABLE_QUEUE : CheckType.CREATE_NON_DURABLE_QUEUE, this);
@ -942,6 +964,9 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
@Override @Override
public void deleteQueue(final SimpleString queueToDelete) throws Exception { public void deleteQueue(final SimpleString queueToDelete) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.destroyQueue(this, getUsername(), queueToDelete);
}
final SimpleString unPrefixedQueueName = removePrefix(queueToDelete); final SimpleString unPrefixedQueueName = removePrefix(queueToDelete);
Binding binding = postOffice.getBinding(unPrefixedQueueName); Binding binding = postOffice.getBinding(unPrefixedQueueName);
@ -1535,6 +1560,9 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
final boolean direct, final boolean direct,
boolean noAutoCreateQueue, boolean noAutoCreateQueue,
RoutingContext routingContext) throws Exception { RoutingContext routingContext) throws Exception {
if (AuditLogger.isMessageEnabled()) {
AuditLogger.coreSendMessage(this, getUsername(), tx, messageParameter, direct, noAutoCreateQueue, routingContext);
}
final Message message = LargeServerMessageImpl.checkLargeMessage(messageParameter, storageManager); final Message message = LargeServerMessageImpl.checkLargeMessage(messageParameter, storageManager);
@ -1801,6 +1829,9 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
private RoutingStatus handleManagementMessage(final Transaction tx, private RoutingStatus handleManagementMessage(final Transaction tx,
final Message message, final Message message,
final boolean direct) throws Exception { final boolean direct) throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.handleManagementMessage(this.getName(), getUsername(), tx, message, direct);
}
try { try {
securityCheck(removePrefix(message.getAddressSimpleString()), CheckType.MANAGE, this); securityCheck(removePrefix(message.getAddressSimpleString()), CheckType.MANAGE, this);
} catch (ActiveMQException e) { } catch (ActiveMQException e) {
@ -1825,7 +1856,6 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
doSend(tx, reply, null, direct, false, routingContext); doSend(tx, reply, null, direct, false, routingContext);
} }
return RoutingStatus.OK; return RoutingStatus.OK;
} }
@ -2052,4 +2082,4 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
AddressSettings as = server.getAddressSettingsRepository().getMatch(address.toString()); AddressSettings as = server.getAddressSettingsRepository().getMatch(address.toString());
return as.getDefaultConsumerWindowSize(); return as.getDefaultConsumerWindowSize();
} }
} }

View File

@ -5,7 +5,7 @@ configurable via the `logging.properties` file found in the
configuration directories. This is configured by Default to log to both configuration directories. This is configured by Default to log to both
the console and to a file. the console and to a file.
There are 6 loggers available which are as follows: There are 8 loggers available which are as follows:
Logger | Description Logger | Description
---|--- ---|---
@ -15,6 +15,8 @@ org.apache.activemq.artemis.utils|Logs utility calls
org.apache.activemq.artemis.journal|Logs Journal calls org.apache.activemq.artemis.journal|Logs Journal calls
org.apache.activemq.artemis.jms|Logs JMS calls org.apache.activemq.artemis.jms|Logs JMS calls
org.apache.activemq.artemis.integration.bootstrap|Logs bootstrap calls org.apache.activemq.artemis.integration.bootstrap|Logs bootstrap calls
org.apache.activemq.audit.base|audit log. Disabled by default
org.apache.activemq.audit.message|message audit log. Disabled by default
## Logging in a client or with an Embedded server ## Logging in a client or with an Embedded server
@ -84,4 +86,43 @@ handler.FILE.formatter=PATTERN
formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.PATTERN.properties=pattern formatter.PATTERN.properties=pattern
formatter.PATTERN.pattern=%d{HH:mm:ss,SSS} %-5p [%c] %s%E%n formatter.PATTERN.pattern=%d{HH:mm:ss,SSS} %-5p [%c] %s%E%n
``` ```
## Configuring Audit Log
The 2 audit loggers can be enabled to record some important operations like
create/delete queues. By default this logger is disabled. The configuration
(logging.properties) for audit log is like this by default:
```$xslt
logger.org.apache.activemq.audit.base.level=ERROR
logger.org.apache.activemq.audit.base.handlers=AUDIT_FILE
logger.org.apache.activemq.audit.base.useParentHandlers=false
logger.org.apache.activemq.audit.message.level=ERROR
logger.org.apache.activemq.audit.message.handlers=AUDIT_FILE
logger.org.apache.activemq.audit.message.useParentHandlers=false
...
```
To enable the audit log change the above level to INFO, like this:
```$xslt
logger.org.apache.activemq.audit.base.level=INFO
logger.org.apache.activemq.audit.base.handlers=AUDIT_FILE
logger.org.apache.activemq.audit.base.useParentHandlers=false
logger.org.apache.activemq.audit.message.level=INFO
logger.org.apache.activemq.audit.message.handlers=AUDIT_FILE
logger.org.apache.activemq.audit.message.useParentHandlers=false
...
```
The 2 audit loggers can be disable/enable separately. The second logger
(org.apache.activemq.audit.message) audits messages in 'hot path'
(code path that is very sensitive to performance, e.g. sending messages).
Turn on this audit logger may affect the performance.
Once enabled, all audit records are written into a separate log
file (by default audit.log).

View File

@ -17,7 +17,7 @@
# Additional logger names to configure (root logger is always configured) # Additional logger names to configure (root logger is always configured)
# Root logger option # Root logger option
loggers=org.jboss.logging,org.apache.activemq.artemis.core.server,org.apache.activemq.artemis.utils,org.apache.activemq.artemis.journal,org.apache.activemq.artemis.jms,org.apache.activemq.artemis.ra,org.apache.activemq.artemis.tests.unit,org.apache.activemq.artemis.tests.integration,org.apache.activemq.artemis.jms.tests loggers=org.jboss.logging,org.apache.activemq.artemis.core.server,org.apache.activemq.artemis.utils,org.apache.activemq.artemis.journal,org.apache.activemq.artemis.jms,org.apache.activemq.artemis.ra,org.apache.activemq.artemis.tests.unit,org.apache.activemq.artemis.tests.integration,org.apache.activemq.artemis.jms.tests,org.apache.activemq.audit
# Root logger level # Root logger level
logger.level=INFO logger.level=INFO
@ -35,6 +35,11 @@ logger.org.apache.activemq.artemis.jms.tests.level=INFO
logger.handlers=CONSOLE,TEST logger.handlers=CONSOLE,TEST
#logger.handlers=CONSOLE,FILE #logger.handlers=CONSOLE,FILE
# to enable audit change the level to INFO
logger.org.apache.activemq.audit.level=ERROR
logger.org.apache.activemq.audit.handlers=AUDIT_FILE
logger.org.apache.activemq.audit.useParentHandlers=false
# Console handler configuration # Console handler configuration
handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
handler.CONSOLE.properties=autoFlush handler.CONSOLE.properties=autoFlush
@ -59,3 +64,17 @@ handler.TEST.formatter=PATTERN
formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.PATTERN.properties=pattern formatter.PATTERN.properties=pattern
formatter.PATTERN.pattern=[%t] %d{HH:mm:ss,SSS} %-5p [%c] %s%E%n formatter.PATTERN.pattern=[%t] %d{HH:mm:ss,SSS} %-5p [%c] %s%E%n
#Audit logger
handler.AUDIT_FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
handler.AUDIT_FILE.level=INFO
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=target/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,213 @@
/*
* 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.integration.management;
import org.apache.activemq.artemis.api.core.Message;
import org.apache.activemq.artemis.api.core.RoutingType;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.api.core.client.ClientSession;
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.core.config.Configuration;
import org.apache.activemq.artemis.core.config.impl.SecurityConfiguration;
import org.apache.activemq.artemis.core.security.Role;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServers;
import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
import org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule;
import org.apache.activemq.artemis.tests.util.Wait;
import org.apache.activemq.artemis.utils.Base64;
import org.apache.activemq.artemis.utils.RandomUtil;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.UUID;
import java.util.logging.LogManager;
public class AuditLoggerTest extends ManagementTestBase {
private static final File auditLog = new File("target/audit.log");
private ActiveMQServer server;
private Configuration conf;
protected ClientSession session;
private ServerLocator locator;
private ClientSessionFactory sf;
@Override
@Before
public void setUp() throws Exception {
super.setUp();
emptyLogFile();
TransportConfiguration connectorConfig = new TransportConfiguration(INVM_CONNECTOR_FACTORY);
conf = createDefaultNettyConfig().setJMXManagementEnabled(true).addConnectorConfiguration(connectorConfig.getName(), connectorConfig);
conf.setSecurityEnabled(true);
SecurityConfiguration securityConfiguration = new SecurityConfiguration();
securityConfiguration.addUser("guest", "guest");
securityConfiguration.addUser("myUser", "myPass");
securityConfiguration.addRole("guest", "guest");
securityConfiguration.addRole("myUser", "guest");
securityConfiguration.setDefaultUser("guest");
ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), securityConfiguration);
server = addServer(ActiveMQServers.newActiveMQServer(conf, mbeanServer, securityManager, true));
server.start();
HashSet<Role> role = new HashSet<>();
//role guest cannot delete queues
role.add(new Role("guest", true, true, true, false, true, false, true, true, true, true));
server.getSecurityRepository().addMatch("#", role);
locator = createInVMNonHALocator().setBlockOnNonDurableSend(true);
sf = createSessionFactory(locator);
session = sf.createSession("guest", "guest", false, true, false, false, 100);
session.start();
addClientSession(session);
}
@After
@Override
public void tearDown() throws Exception {
super.tearDown();
}
private void emptyLogFile() throws Exception {
if (auditLog.exists()) {
try (PrintWriter writer = new PrintWriter(new FileWriter(auditLog))) {
writer.print("");
}
}
}
@Test
public void testAuditLog() throws Exception {
reloadLoggingConfig("audit.logging.properties");
SimpleString address = RandomUtil.randomSimpleString();
session.createAddress(address, RoutingType.ANYCAST, false);
final AddressControl addressControl = ManagementControlHelper.createAddressControl(address, mbeanServer);
Assert.assertEquals(0, addressControl.getQueueNames().length);
session.createQueue(address, RoutingType.ANYCAST, address);
Assert.assertEquals(1, addressControl.getQueueNames().length);
String uniqueStr = Base64.encodeBytes(UUID.randomUUID().toString().getBytes());
addressControl.sendMessage(null, Message.BYTES_TYPE, uniqueStr, false, null, null);
Wait.waitFor(() -> addressControl.getMessageCount() == 1);
Assert.assertEquals(1, addressControl.getMessageCount());
checkAuditLogRecord(true, "sending a message", uniqueStr);
//failure log
address = RandomUtil.randomSimpleString();
session.createAddress(address, RoutingType.ANYCAST, false);
final AddressControl addressControl2 = ManagementControlHelper.createAddressControl(address, mbeanServer);
Assert.assertEquals(1, addressControl.getQueueNames().length);
session.createQueue(address, RoutingType.ANYCAST, address);
Wait.waitFor(() -> addressControl2.getQueueNames().length == 1);
try {
session.deleteQueue(address);
fail("Deleting queue should get exception");
} catch (Exception e) {
//ignore
}
checkAuditLogRecord(true, "gets security check failure:", "guest does not have permission='DELETE_NON_DURABLE_QUEUE'");
//hot patch not in log
checkAuditLogRecord(false, "is sending a core message");
}
private void reloadLoggingConfig(String logFile) {
ClassLoader cl = AuditLoggerTest.class.getClassLoader();
InputStream inputStream = cl.getResourceAsStream(logFile);
LogManager logManager = LogManager.getLogManager();
try {
logManager.readConfiguration(inputStream);
} catch (IOException e) {
System.out.println("error loading logging conifg");
e.printStackTrace();
}
}
@Test
public void testAuditHotLog() throws Exception {
reloadLoggingConfig("audit.logging.hot.properties");
SimpleString address = RandomUtil.randomSimpleString();
session.createAddress(address, RoutingType.ANYCAST, false);
final AddressControl addressControl = ManagementControlHelper.createAddressControl(address, mbeanServer);
Assert.assertEquals(0, addressControl.getQueueNames().length);
session.createQueue(address, RoutingType.ANYCAST, address);
Assert.assertEquals(1, addressControl.getQueueNames().length);
String uniqueStr = Base64.encodeBytes(UUID.randomUUID().toString().getBytes());
addressControl.sendMessage(null, Message.BYTES_TYPE, uniqueStr, false, null, null);
Wait.waitFor(() -> addressControl.getMessageCount() == 1);
Assert.assertEquals(1, addressControl.getMessageCount());
checkAuditLogRecord(true, "sending a core message");
}
//check the audit log has a line that contains all the values
private void checkAuditLogRecord(boolean exist, String... values) throws Exception {
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) {
assertTrue(hasRecord);
} else {
assertFalse(hasRecord);
}
}
}
}

View File

@ -0,0 +1,76 @@
#
# 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
# 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=INFO
logger.org.apache.activemq.audit.base.handlers=AUDIT_FILE
logger.org.apache.activemq.audit.base.useParentHandlers=false
logger.org.apache.activemq.audit.message.level=INFO
logger.org.apache.activemq.audit.message.handlers=AUDIT_FILE
logger.org.apache.activemq.audit.message.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=target/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=target/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,76 @@
#
# 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
# 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=INFO
logger.org.apache.activemq.audit.base.handlers=AUDIT_FILE
logger.org.apache.activemq.audit.base.useParentHandlers=false
logger.org.apache.activemq.audit.message.level=ERROR
logger.org.apache.activemq.audit.message.handlers=AUDIT_FILE
logger.org.apache.activemq.audit.message.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=target/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=INFO
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=target/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