Search in sources :

Example 11 with ConnectionLimitException

use of org.apache.qpid.server.security.limit.ConnectionLimitException in project qpid-broker-j by apache.

the class RuleSetTest method testBlocked.

private void testBlocked(RuleSet ruleSet) {
    assertNotNull(ruleSet);
    ConnectionSlot connection = null;
    try {
        connection = ruleSet.register(newConnection());
        fail("An exception is expected");
    } catch (ConnectionLimitException e) {
        assertEquals("User user is blocked on port amqp", e.getMessage());
    }
    assertNull(connection);
}
Also used : ConnectionSlot(org.apache.qpid.server.security.limit.ConnectionSlot) ConnectionLimitException(org.apache.qpid.server.security.limit.ConnectionLimitException)

Example 12 with ConnectionLimitException

use of org.apache.qpid.server.security.limit.ConnectionLimitException in project qpid-broker-j by apache.

the class RuleSetTest method testRegisterNullUser.

private void testRegisterNullUser(Duration duration) {
    final Builder builder = RuleSet.newBuilder(LIMITER_NAME, duration);
    builder.addRule(Rule.newBlockingRule(RulePredicates.ALL_PORTS, RulePredicates.ALL_USERS));
    final RuleSet ruleSet = builder.build();
    assertNotNull(ruleSet);
    final AMQPConnection<?> connection = Mockito.mock(AMQPConnection.class);
    Mockito.doReturn(_port).when(connection).getPort();
    Mockito.doReturn(_subject).when(connection).getSubject();
    Mockito.doReturn(_eventLogger).when(connection).getEventLogger();
    try {
        ruleSet.register(connection);
        fail("An exception is expected");
    } catch (ConnectionLimitException e) {
        assertEquals("Unauthorized connection is forbidden", e.getMessage());
    }
}
Also used : ConnectionLimitException(org.apache.qpid.server.security.limit.ConnectionLimitException) Builder(org.apache.qpid.server.user.connection.limits.config.RuleSet.Builder)

Aggregations

ConnectionLimitException (org.apache.qpid.server.security.limit.ConnectionLimitException)12 ConnectionSlot (org.apache.qpid.server.security.limit.ConnectionSlot)4 Builder (org.apache.qpid.server.user.connection.limits.config.RuleSet.Builder)4 AccessControlException (java.security.AccessControlException)3 VirtualHostUnavailableException (org.apache.qpid.server.virtualhost.VirtualHostUnavailableException)3 Principal (java.security.Principal)2 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)2 AmqpPort (org.apache.qpid.server.model.port.AmqpPort)2 Duration (java.time.Duration)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 SoleConnectionEnforcementPolicyException (org.apache.qpid.server.protocol.v1_0.type.extensions.soleconn.SoleConnectionEnforcementPolicyException)1 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)1 ConnectionError (org.apache.qpid.server.protocol.v1_0.type.transport.ConnectionError)1 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)1 AuthenticatedPrincipal (org.apache.qpid.server.security.auth.AuthenticatedPrincipal)1 GroupPrincipal (org.apache.qpid.server.security.group.GroupPrincipal)1 ConnectionScopedRuntimeException (org.apache.qpid.server.util.ConnectionScopedRuntimeException)1 Test (org.junit.Test)1