Search in sources :

Example 26 with EventLogger

use of org.apache.qpid.server.logging.EventLogger in project qpid-broker-j by apache.

the class MessagingACLTest method configureACL.

private void configureACL(String... rules) throws Exception {
    EventLoggerProvider eventLoggerProvider = mock(EventLoggerProvider.class);
    EventLogger eventLogger = mock(EventLogger.class);
    when(eventLoggerProvider.getEventLogger()).thenReturn(eventLogger);
    List<AclRule> aclRules = new ArrayList<>();
    try (StringReader stringReader = new StringReader(Arrays.stream(rules).collect(Collectors.joining(LINE_SEPARATOR)))) {
        RuleSet ruleSet = AclFileParser.parse(stringReader, eventLoggerProvider);
        final List<Rule> parsedRules = ruleSet.getAllRules();
        for (final Rule rule : parsedRules) {
            aclRules.add(new AclRule() {

                @Override
                public String getIdentity() {
                    return rule.getIdentity();
                }

                @Override
                public ObjectType getObjectType() {
                    return rule.getAction().getObjectType();
                }

                @Override
                public LegacyOperation getOperation() {
                    return rule.getAction().getOperation();
                }

                @Override
                public Map<ObjectProperties.Property, String> getAttributes() {
                    Map<ObjectProperties.Property, String> attributes = new HashMap<>(rule.getAction().getProperties().asPropertyMap());
                    FirewallRule firewallRule = rule.getAclAction().getFirewallRule();
                    if (firewallRule != null) {
                        if (firewallRule instanceof HostnameFirewallRule) {
                            attributes.put(ObjectProperties.Property.FROM_HOSTNAME, "127.0.0.1");
                        } else if (firewallRule instanceof NetworkFirewallRule) {
                            // tests use only 127.0.0.1 at the moment
                            attributes.put(ObjectProperties.Property.FROM_NETWORK, "127.0.0.1");
                        }
                    }
                    return attributes;
                }

                @Override
                public RuleOutcome getOutcome() {
                    return rule.getRuleOutcome();
                }
            });
        }
    }
    configureACL(aclRules.toArray(new AclRule[aclRules.size()]));
}
Also used : NetworkFirewallRule(org.apache.qpid.server.security.access.firewall.NetworkFirewallRule) RuleSet(org.apache.qpid.server.security.access.config.RuleSet) LegacyOperation(org.apache.qpid.server.security.access.config.LegacyOperation) EventLoggerProvider(org.apache.qpid.server.logging.EventLoggerProvider) EventLogger(org.apache.qpid.server.logging.EventLogger) ArrayList(java.util.ArrayList) ObjectProperties(org.apache.qpid.server.security.access.config.ObjectProperties) ObjectType(org.apache.qpid.server.security.access.config.ObjectType) HostnameFirewallRule(org.apache.qpid.server.security.access.firewall.HostnameFirewallRule) StringReader(java.io.StringReader) RuleOutcome(org.apache.qpid.server.security.access.plugins.RuleOutcome) AclRule(org.apache.qpid.server.security.access.plugins.AclRule) AclRule(org.apache.qpid.server.security.access.plugins.AclRule) NetworkFirewallRule(org.apache.qpid.server.security.access.firewall.NetworkFirewallRule) Rule(org.apache.qpid.server.security.access.config.Rule) FirewallRule(org.apache.qpid.server.security.access.firewall.FirewallRule) HostnameFirewallRule(org.apache.qpid.server.security.access.firewall.HostnameFirewallRule) Map(java.util.Map) HashMap(java.util.HashMap) NetworkFirewallRule(org.apache.qpid.server.security.access.firewall.NetworkFirewallRule) FirewallRule(org.apache.qpid.server.security.access.firewall.FirewallRule) HostnameFirewallRule(org.apache.qpid.server.security.access.firewall.HostnameFirewallRule)

Example 27 with EventLogger

use of org.apache.qpid.server.logging.EventLogger in project qpid-broker-j by apache.

the class BDBHAVirtualHostNodeOperationalLoggingTest method resetEventLogger.

private EventLogger resetEventLogger() {
    EventLogger eventLogger = mock(EventLogger.class);
    SystemConfig<?> context = (SystemConfig<?>) _helper.getBroker().getParent();
    when(context.getEventLogger()).thenReturn(eventLogger);
    return eventLogger;
}
Also used : SystemConfig(org.apache.qpid.server.model.SystemConfig) EventLogger(org.apache.qpid.server.logging.EventLogger)

Example 28 with EventLogger

use of org.apache.qpid.server.logging.EventLogger in project qpid-broker-j by apache.

the class AbstractSystemConfig method initiateStartupLogging.

private EventLogger initiateStartupLogging() {
    final EventLogger eventLogger = _eventLogger;
    final EventLogger startupLogger;
    if (isStartupLoggedToSystemOut()) {
        // Create the composite (logging+SystemOut MessageLogger to be used during startup
        MessageLogger[] messageLoggers = { new SystemOutMessageLogger(), eventLogger.getMessageLogger() };
        CompositeStartupMessageLogger startupMessageLogger = new CompositeStartupMessageLogger(messageLoggers);
        startupLogger = new EventLogger(startupMessageLogger);
    } else {
        startupLogger = eventLogger;
    }
    return startupLogger;
}
Also used : EventLogger(org.apache.qpid.server.logging.EventLogger) CompositeStartupMessageLogger(org.apache.qpid.server.logging.CompositeStartupMessageLogger) SystemOutMessageLogger(org.apache.qpid.server.logging.SystemOutMessageLogger) MessageLogger(org.apache.qpid.server.logging.MessageLogger) SystemOutMessageLogger(org.apache.qpid.server.logging.SystemOutMessageLogger) CompositeStartupMessageLogger(org.apache.qpid.server.logging.CompositeStartupMessageLogger)

Example 29 with EventLogger

use of org.apache.qpid.server.logging.EventLogger in project qpid-broker-j by apache.

the class VirtualHostCreationTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    EventLogger eventLogger = mock(EventLogger.class);
    TaskExecutor executor = CurrentThreadTaskExecutor.newStartedInstance();
    SystemConfig systemConfig = mock(SystemConfig.class);
    ConfiguredObjectFactory objectFactory = new ConfiguredObjectFactoryImpl(BrokerModel.getInstance());
    when(systemConfig.getObjectFactory()).thenReturn(objectFactory);
    when(systemConfig.getModel()).thenReturn(objectFactory.getModel());
    when(systemConfig.getEventLogger()).thenReturn(eventLogger);
    when(systemConfig.getTaskExecutor()).thenReturn(executor);
    when(systemConfig.getChildExecutor()).thenReturn(executor);
    Broker broker = mock(Broker.class);
    when(broker.getObjectFactory()).thenReturn(objectFactory);
    when(broker.getModel()).thenReturn(objectFactory.getModel());
    when(broker.getCategoryClass()).thenReturn(Broker.class);
    when(broker.getParent()).thenReturn(systemConfig);
    when(broker.getTaskExecutor()).thenReturn(executor);
    when(broker.getChildExecutor()).thenReturn(executor);
    _virtualHostNode = BrokerTestHelper.mockWithSystemPrincipal(VirtualHostNode.class, mock(Principal.class));
    when(_virtualHostNode.getParent()).thenReturn(broker);
    when(_virtualHostNode.getObjectFactory()).thenReturn(objectFactory);
    when(_virtualHostNode.getConfigurationStore()).thenReturn(mock(DurableConfigurationStore.class));
    when(_virtualHostNode.getModel()).thenReturn(objectFactory.getModel());
    when(_virtualHostNode.getCategoryClass()).thenReturn(VirtualHostNode.class);
    when(_virtualHostNode.getTaskExecutor()).thenReturn(executor);
    when(_virtualHostNode.getChildExecutor()).thenReturn(executor);
}
Also used : CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) TaskExecutor(org.apache.qpid.server.configuration.updater.TaskExecutor) SystemConfig(org.apache.qpid.server.model.SystemConfig) Broker(org.apache.qpid.server.model.Broker) ConfiguredObjectFactory(org.apache.qpid.server.model.ConfiguredObjectFactory) DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) EventLogger(org.apache.qpid.server.logging.EventLogger) VirtualHostNode(org.apache.qpid.server.model.VirtualHostNode) ConfiguredObjectFactoryImpl(org.apache.qpid.server.model.ConfiguredObjectFactoryImpl)

Example 30 with EventLogger

use of org.apache.qpid.server.logging.EventLogger in project qpid-broker-j by apache.

the class HeadersBindingTest method setUp.

@Override
protected void setUp() {
    _count++;
    _queue = mock(Queue.class);
    TaskExecutor executor = new CurrentThreadTaskExecutor();
    executor.start();
    QueueManagingVirtualHost vhost = mock(QueueManagingVirtualHost.class);
    when(_queue.getVirtualHost()).thenReturn(vhost);
    when(_queue.getModel()).thenReturn(BrokerModel.getInstance());
    when(_queue.getTaskExecutor()).thenReturn(executor);
    when(_queue.getChildExecutor()).thenReturn(executor);
    final EventLogger eventLogger = new EventLogger();
    when(vhost.getEventLogger()).thenReturn(eventLogger);
    when(vhost.getTaskExecutor()).thenReturn(executor);
    when(vhost.getChildExecutor()).thenReturn(executor);
    _exchange = mock(Exchange.class);
    when(_exchange.getType()).thenReturn(ExchangeDefaults.HEADERS_EXCHANGE_CLASS);
    when(_exchange.getEventLogger()).thenReturn(eventLogger);
    when(_exchange.getModel()).thenReturn(BrokerModel.getInstance());
    when(_exchange.getTaskExecutor()).thenReturn(executor);
    when(_exchange.getChildExecutor()).thenReturn(executor);
}
Also used : Exchange(org.apache.qpid.server.model.Exchange) CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) TaskExecutor(org.apache.qpid.server.configuration.updater.TaskExecutor) QueueManagingVirtualHost(org.apache.qpid.server.virtualhost.QueueManagingVirtualHost) EventLogger(org.apache.qpid.server.logging.EventLogger) CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) Queue(org.apache.qpid.server.model.Queue)

Aggregations

EventLogger (org.apache.qpid.server.logging.EventLogger)40 Broker (org.apache.qpid.server.model.Broker)15 SystemConfig (org.apache.qpid.server.model.SystemConfig)10 TaskExecutor (org.apache.qpid.server.configuration.updater.TaskExecutor)8 HashMap (java.util.HashMap)7 CurrentThreadTaskExecutor (org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor)7 Principal (java.security.Principal)6 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)6 ConfiguredObjectFactoryImpl (org.apache.qpid.server.model.ConfiguredObjectFactoryImpl)6 TaskExecutorImpl (org.apache.qpid.server.configuration.updater.TaskExecutorImpl)5 InetSocketAddress (java.net.InetSocketAddress)4 BrokerModel (org.apache.qpid.server.model.BrokerModel)4 Model (org.apache.qpid.server.model.Model)4 VirtualHostNode (org.apache.qpid.server.model.VirtualHostNode)4 AuthenticatedPrincipal (org.apache.qpid.server.security.auth.AuthenticatedPrincipal)4 IOException (java.io.IOException)3 Map (java.util.Map)3 Subject (javax.security.auth.Subject)3 UnitTestMessageLogger (org.apache.qpid.server.logging.UnitTestMessageLogger)3 AmqpPort (org.apache.qpid.server.model.port.AmqpPort)3