Search in sources :

Example 1 with EventLoggerProvider

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

the class RuleBasedAccessControlTest method createGroupRuleSet.

private RuleSet createGroupRuleSet() {
    final EventLoggerProvider provider = mock(EventLoggerProvider.class);
    when(provider.getEventLogger()).thenReturn(_eventLogger);
    RuleCollector rsc = new RuleCollector();
    // Rule expressed with username
    rsc.addRule(0, new Rule.Builder().withIdentity("user1").withOutcome(RuleOutcome.ALLOW).withOperation(LegacyOperation.ACCESS).withObject(ObjectType.VIRTUALHOST).build());
    // Rules expressed with groups
    rsc.addRule(1, new Rule.Builder().withIdentity(ALLOWED_GROUP).withOutcome(RuleOutcome.ALLOW).withOperation(LegacyOperation.ACCESS).withObject(ObjectType.VIRTUALHOST).build());
    rsc.addRule(2, new Rule.Builder().withIdentity(DENIED_GROUP).withOutcome(RuleOutcome.DENY).withOperation(LegacyOperation.ACCESS).withObject(ObjectType.VIRTUALHOST).build());
    // Catch all rule
    rsc.addRule(3, new Rule.Builder().withIdentity(Rule.ALL).withOutcome(RuleOutcome.DENY_LOG).withOperation(LegacyOperation.ACCESS).withObject(ObjectType.VIRTUALHOST).build());
    return rsc.createRuleSet(provider);
}
Also used : EventLoggerProvider(org.apache.qpid.server.logging.EventLoggerProvider)

Example 2 with EventLoggerProvider

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

the class RuleSetTest method testGetDefault.

@Test
public void testGetDefault() {
    final Rule rule = new Builder().withIdentity(TEST_USER).withOperation(LegacyOperation.ACCESS).withObject(ObjectType.VIRTUALHOST).withOutcome(RuleOutcome.ALLOW).build();
    final EventLoggerProvider logger = mock(EventLoggerProvider.class);
    final RuleSet ruleSet = RuleSet.newInstance(logger, Collections.singletonList(rule), Result.ALLOWED);
    assertNotNull(ruleSet);
    assertEquals(Result.ALLOWED, ruleSet.getDefault());
}
Also used : EventLoggerProvider(org.apache.qpid.server.logging.EventLoggerProvider) Builder(org.apache.qpid.server.security.access.config.Rule.Builder) Test(org.junit.Test)

Example 3 with EventLoggerProvider

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

the class AcceptRegistrationTest method setUp.

@Before
public void setUp() {
    _eventLogger = Mockito.mock(org.apache.qpid.server.logging.EventLogger.class);
    final EventLoggerProvider provider = () -> _eventLogger;
    _logger = new FullConnectionLimitEventLogger("AllLogger", provider);
    _rejectLogger = new ConnectionLimitEventLogger("RejectLogger", provider);
    _slot = Mockito.mock(ConnectionSlot.class);
}
Also used : ConnectionSlot(org.apache.qpid.server.security.limit.ConnectionSlot) EventLoggerProvider(org.apache.qpid.server.logging.EventLoggerProvider) FullConnectionLimitEventLogger(org.apache.qpid.server.user.connection.limits.logging.FullConnectionLimitEventLogger) ConnectionLimitEventLogger(org.apache.qpid.server.user.connection.limits.logging.ConnectionLimitEventLogger) FullConnectionLimitEventLogger(org.apache.qpid.server.user.connection.limits.logging.FullConnectionLimitEventLogger) FullConnectionLimitEventLogger(org.apache.qpid.server.user.connection.limits.logging.FullConnectionLimitEventLogger) ConnectionLimitEventLogger(org.apache.qpid.server.user.connection.limits.logging.ConnectionLimitEventLogger) Before(org.junit.Before)

Example 4 with EventLoggerProvider

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

the class LoginLogoutReporterTest method setUp.

@Before
public void setUp() throws Exception {
    _subject.getPrincipals().add(new AuthenticatedPrincipal(new UsernamePrincipal("mockusername", null)));
    when(_logger.isEnabled()).thenReturn(true);
    when(_logger.isMessageEnabled(anyString())).thenReturn(true);
    EventLogger eventLogger = new EventLogger(_logger);
    EventLoggerProvider provider = mock(EventLoggerProvider.class);
    when(provider.getEventLogger()).thenReturn(eventLogger);
    _loginLogoutReport = new LoginLogoutReporter(_subject, provider);
}
Also used : UsernamePrincipal(org.apache.qpid.server.security.auth.UsernamePrincipal) EventLoggerProvider(org.apache.qpid.server.logging.EventLoggerProvider) EventLogger(org.apache.qpid.server.logging.EventLogger) AuthenticatedPrincipal(org.apache.qpid.server.security.auth.AuthenticatedPrincipal) Before(org.junit.Before)

Example 5 with EventLoggerProvider

use of org.apache.qpid.server.logging.EventLoggerProvider 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);
        for (final Rule rule : ruleSet) {
            aclRules.add(rule.asAclRule());
        }
    }
    configureACL(aclRules.toArray(new AclRule[aclRules.size()]));
}
Also used : RuleSet(org.apache.qpid.server.security.access.config.RuleSet) EventLoggerProvider(org.apache.qpid.server.logging.EventLoggerProvider) EventLogger(org.apache.qpid.server.logging.EventLogger) ArrayList(java.util.ArrayList) StringReader(java.io.StringReader) AclRule(org.apache.qpid.server.security.access.plugins.AclRule) AclRule(org.apache.qpid.server.security.access.plugins.AclRule) Rule(org.apache.qpid.server.security.access.config.Rule)

Aggregations

EventLoggerProvider (org.apache.qpid.server.logging.EventLoggerProvider)5 EventLogger (org.apache.qpid.server.logging.EventLogger)2 Before (org.junit.Before)2 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 Rule (org.apache.qpid.server.security.access.config.Rule)1 Builder (org.apache.qpid.server.security.access.config.Rule.Builder)1 RuleSet (org.apache.qpid.server.security.access.config.RuleSet)1 AclRule (org.apache.qpid.server.security.access.plugins.AclRule)1 AuthenticatedPrincipal (org.apache.qpid.server.security.auth.AuthenticatedPrincipal)1 UsernamePrincipal (org.apache.qpid.server.security.auth.UsernamePrincipal)1 ConnectionSlot (org.apache.qpid.server.security.limit.ConnectionSlot)1 ConnectionLimitEventLogger (org.apache.qpid.server.user.connection.limits.logging.ConnectionLimitEventLogger)1 FullConnectionLimitEventLogger (org.apache.qpid.server.user.connection.limits.logging.FullConnectionLimitEventLogger)1 Test (org.junit.Test)1