Search in sources :

Example 16 with NamedAddressSpace

use of org.apache.qpid.server.model.NamedAddressSpace in project qpid-broker-j by apache.

the class ServerSessionDelegate method exchangeDeclare.

@Override
public void exchangeDeclare(ServerSession session, ExchangeDeclare method) {
    String exchangeName = method.getExchange();
    NamedAddressSpace addressSpace = getAddressSpace(session);
    // we must check for any unsupported arguments present and throw not-implemented
    if (method.hasArguments()) {
        Map<String, Object> args = method.getArguments();
        // QPID-3392: currently we don't support any!
        if (!args.isEmpty()) {
            exception(session, method, ExecutionErrorCode.NOT_IMPLEMENTED, "Unsupported exchange argument(s) found " + args.keySet().toString());
            return;
        }
    }
    String alternateExchangeName = method.getAlternateExchange();
    if (nameNullOrEmpty(method.getExchange())) {
        // special case handling to fake the existence of the default exchange for 0-10
        if (!ExchangeDefaults.DIRECT_EXCHANGE_CLASS.equals(method.getType())) {
            exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Attempt to redeclare default exchange " + " of type " + ExchangeDefaults.DIRECT_EXCHANGE_CLASS + " to " + method.getType() + ".");
        }
        if (!nameNullOrEmpty(alternateExchangeName)) {
            exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Attempt to set alternate exchange of the default exchange " + " to " + alternateExchangeName + ".");
        }
    } else {
        if (method.getPassive()) {
            Exchange<?> exchange = getExchange(session, exchangeName);
            if (exchange == null) {
                exception(session, method, ExecutionErrorCode.NOT_FOUND, "not-found: exchange-name '" + exchangeName + "'");
            } else {
                if (!exchange.getType().equals(method.getType()) && (method.getType() != null && method.getType().length() > 0)) {
                    exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Attempt to redeclare exchange: " + exchangeName + " of type " + exchange.getType() + " to " + method.getType() + ".");
                }
            }
        } else {
            try {
                Map<String, Object> attributes = new HashMap<String, Object>();
                attributes.put(org.apache.qpid.server.model.Exchange.NAME, method.getExchange());
                attributes.put(org.apache.qpid.server.model.Exchange.TYPE, method.getType());
                attributes.put(org.apache.qpid.server.model.Exchange.DURABLE, method.getDurable());
                attributes.put(org.apache.qpid.server.model.Exchange.LIFETIME_POLICY, method.getAutoDelete() ? LifetimePolicy.DELETE_ON_NO_LINKS : LifetimePolicy.PERMANENT);
                if (method.hasAlternateExchange() && !nameNullOrEmpty(alternateExchangeName)) {
                    validateAlternateExchangeIsNotQueue(addressSpace, alternateExchangeName);
                    attributes.put(org.apache.qpid.server.model.Exchange.ALTERNATE_BINDING, Collections.singletonMap(AlternateBinding.DESTINATION, alternateExchangeName));
                }
                addressSpace.createMessageDestination(Exchange.class, attributes);
                ;
            } catch (ReservedExchangeNameException e) {
                Exchange<?> existingExchange = getExchange(session, exchangeName);
                if (existingExchange == null || !existingExchange.getType().equals(method.getType()) || (method.hasAlternateExchange() && (existingExchange.getAlternateBinding() == null || !alternateExchangeName.equals(existingExchange.getAlternateBinding().getDestination())))) {
                    exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Attempt to declare exchange: " + exchangeName + " which begins with reserved name or prefix.");
                }
            } catch (UnknownAlternateBindingException e) {
                exception(session, method, ExecutionErrorCode.NOT_FOUND, String.format("Unknown alternate exchange '%s'", e.getAlternateBindingName()));
            } catch (NoFactoryForTypeException e) {
                exception(session, method, ExecutionErrorCode.NOT_FOUND, "Unknown Exchange Type: " + method.getType());
            } catch (AbstractConfiguredObject.DuplicateNameException e) {
                Exchange<?> exchange = (Exchange<?>) e.getExisting();
                if (!exchange.getType().equals(method.getType())) {
                    exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Attempt to redeclare exchange: " + exchangeName + " of type " + exchange.getType() + " to " + method.getType() + ".");
                } else if (method.hasAlternateExchange() && (exchange.getAlternateBinding() == null || !alternateExchangeName.equals(exchange.getAlternateBinding().getDestination()))) {
                    exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Attempt to change alternate exchange of: " + exchangeName + " from " + exchange.getAlternateBinding() + " to " + alternateExchangeName + ".");
                }
            } catch (AccessControlException e) {
                exception(session, method, ExecutionErrorCode.UNAUTHORIZED_ACCESS, e.getMessage());
            } catch (IllegalArgumentException | IllegalConfigurationException e) {
                exception(session, method, ExecutionErrorCode.ILLEGAL_ARGUMENT, e.getMessage());
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) AccessControlException(java.security.AccessControlException) Exchange(org.apache.qpid.server.model.Exchange) NoFactoryForTypeException(org.apache.qpid.server.model.NoFactoryForTypeException) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) ReservedExchangeNameException(org.apache.qpid.server.virtualhost.ReservedExchangeNameException) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) UnknownAlternateBindingException(org.apache.qpid.server.virtualhost.UnknownAlternateBindingException)

Example 17 with NamedAddressSpace

use of org.apache.qpid.server.model.NamedAddressSpace in project qpid-broker-j by apache.

the class AMQPConnection_1_0Impl method endpointClosed.

private void endpointClosed() {
    try {
        performDeleteTasks();
        closeReceived();
    } finally {
        NamedAddressSpace virtualHost = getAddressSpace();
        if (virtualHost != null) {
            virtualHost.deregisterConnection(this);
        }
    }
}
Also used : NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace)

Example 18 with NamedAddressSpace

use of org.apache.qpid.server.model.NamedAddressSpace in project qpid-broker-j by apache.

the class AMQPConnection_1_0Impl method receiveOpen.

@Override
public void receiveOpen(final int channel, final Open open) {
    assertState(ConnectionState.AWAIT_OPEN);
    int channelMax = getPort().getSessionCountLimit() - 1;
    _channelMax = open.getChannelMax() == null ? channelMax : open.getChannelMax().intValue() < channelMax ? open.getChannelMax().intValue() : channelMax;
    if (_receivingSessions == null) {
        _receivingSessions = new Session_1_0[_channelMax + 1];
        _sendingSessions = new Session_1_0[_channelMax + 1];
    }
    _maxFrameSize = open.getMaxFrameSize() == null || open.getMaxFrameSize().longValue() > getBroker().getNetworkBufferSize() ? getBroker().getNetworkBufferSize() : open.getMaxFrameSize().intValue();
    _remoteContainerId = open.getContainerId();
    if (open.getHostname() != null && !"".equals(open.getHostname().trim())) {
        _localHostname = open.getHostname();
    }
    if (_localHostname == null || "".equals(_localHostname.trim()) && getNetwork().getSelectedHost() != null) {
        _localHostname = getNetwork().getSelectedHost();
    }
    if (open.getIdleTimeOut() != null) {
        _outgoingIdleTimeout = open.getIdleTimeOut().longValue();
    }
    final Map<Symbol, Object> remoteProperties = open.getProperties() == null ? Collections.emptyMap() : Collections.unmodifiableMap(new LinkedHashMap<>(open.getProperties()));
    _remoteDesiredCapabilities = open.getDesiredCapabilities() == null ? Collections.emptySet() : Sets.newHashSet(open.getDesiredCapabilities());
    if (remoteProperties.containsKey(Symbol.valueOf("product"))) {
        setClientProduct(remoteProperties.get(Symbol.valueOf("product")).toString());
    }
    if (remoteProperties.containsKey(Symbol.valueOf("version"))) {
        setClientVersion(remoteProperties.get(Symbol.valueOf("version")).toString());
    }
    setClientId(_remoteContainerId);
    if (_remoteDesiredCapabilities.contains(SoleConnectionConnectionProperties.SOLE_CONNECTION_FOR_CONTAINER)) {
        if (remoteProperties != null && remoteProperties.containsKey(SOLE_CONNECTION_ENFORCEMENT_POLICY)) {
            try {
                _soleConnectionEnforcementPolicy = SoleConnectionEnforcementPolicy.valueOf(remoteProperties.get(SOLE_CONNECTION_ENFORCEMENT_POLICY));
            } catch (IllegalArgumentException e) {
                closeConnection(AmqpError.INVALID_FIELD, e.getMessage());
                return;
            }
        } else {
            _soleConnectionEnforcementPolicy = SoleConnectionEnforcementPolicy.REFUSE_CONNECTION;
        }
    }
    if (_outgoingIdleTimeout != 0L && _outgoingIdleTimeout < MINIMUM_SUPPORTED_IDLE_TIMEOUT) {
        closeConnection(ConnectionError.CONNECTION_FORCED, "Requested idle timeout of " + _outgoingIdleTimeout + " is too low. The minimum supported timeout is" + MINIMUM_SUPPORTED_IDLE_TIMEOUT);
    } else {
        initialiseHeartbeating(_outgoingIdleTimeout / 2L, _incomingIdleTimeout);
        final NamedAddressSpace addressSpace = getPort().getAddressSpace(_localHostname);
        if (addressSpace == null) {
            closeConnection(AmqpError.NOT_FOUND, "Unknown hostname in connection open: '" + _localHostname + "'");
        } else {
            receiveOpenInternal(addressSpace);
        }
    }
}
Also used : Symbol(org.apache.qpid.server.protocol.v1_0.type.Symbol) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) LinkedHashMap(java.util.LinkedHashMap)

Example 19 with NamedAddressSpace

use of org.apache.qpid.server.model.NamedAddressSpace in project qpid-broker-j by apache.

the class AMQPConnection_1_0Impl method receiveOpenInternal.

private void receiveOpenInternal(final NamedAddressSpace addressSpace) {
    if (!addressSpace.isActive()) {
        final Error err = new Error();
        err.setCondition(AmqpError.NOT_FOUND);
        populateConnectionRedirect(addressSpace, err);
        closeConnection(err);
    } else {
        if (AuthenticatedPrincipal.getOptionalAuthenticatedPrincipalFromSubject(getSubject()) == null) {
            closeConnection(AmqpError.NOT_ALLOWED, "Connection has not been authenticated");
        } else {
            try {
                boolean registerSucceeded = addressSpace.registerConnection(this, (existingConnections, newConnection) -> {
                    boolean proceedWithRegistration = true;
                    if (newConnection instanceof AMQPConnection_1_0Impl && !newConnection.isClosing()) {
                        List<ListenableFuture<Void>> rescheduleFutures = new ArrayList<>();
                        for (AMQPConnection<?> existingConnection : StreamSupport.stream(existingConnections.spliterator(), false).filter(con -> con instanceof AMQPConnection_1_0).filter(con -> !con.isClosing()).filter(con -> con.getRemoteContainerName().equals(newConnection.getRemoteContainerName())).collect(Collectors.toList())) {
                            SoleConnectionEnforcementPolicy soleConnectionEnforcementPolicy = null;
                            if (((AMQPConnection_1_0Impl) existingConnection)._soleConnectionEnforcementPolicy != null) {
                                soleConnectionEnforcementPolicy = ((AMQPConnection_1_0Impl) existingConnection)._soleConnectionEnforcementPolicy;
                            } else if (((AMQPConnection_1_0Impl) newConnection)._soleConnectionEnforcementPolicy != null) {
                                soleConnectionEnforcementPolicy = ((AMQPConnection_1_0Impl) newConnection)._soleConnectionEnforcementPolicy;
                            }
                            if (SoleConnectionEnforcementPolicy.REFUSE_CONNECTION.equals(soleConnectionEnforcementPolicy)) {
                                _properties.put(Symbol.valueOf("amqp:connection-establishment-failed"), true);
                                Error error = new Error(AmqpError.INVALID_FIELD, String.format("Connection closed due to sole-connection-enforcement-policy '%s'", soleConnectionEnforcementPolicy.toString()));
                                error.setInfo(Collections.singletonMap(Symbol.valueOf("invalid-field"), Symbol.valueOf("container-id")));
                                newConnection.doOnIOThreadAsync(() -> ((AMQPConnection_1_0Impl) newConnection).closeConnection(error));
                                proceedWithRegistration = false;
                                break;
                            } else if (SoleConnectionEnforcementPolicy.CLOSE_EXISTING.equals(soleConnectionEnforcementPolicy)) {
                                final Error error = new Error(AmqpError.RESOURCE_LOCKED, String.format("Connection closed due to sole-connection-enforcement-policy '%s'", soleConnectionEnforcementPolicy.toString()));
                                error.setInfo(Collections.singletonMap(Symbol.valueOf("sole-connection-enforcement"), true));
                                rescheduleFutures.add(existingConnection.doOnIOThreadAsync(() -> ((AMQPConnection_1_0Impl) existingConnection).closeConnection(error)));
                                proceedWithRegistration = false;
                            }
                        }
                        if (!rescheduleFutures.isEmpty()) {
                            doAfter(allAsList(rescheduleFutures), () -> newConnection.doOnIOThreadAsync(() -> receiveOpenInternal(addressSpace)));
                        }
                    }
                    return proceedWithRegistration;
                });
                if (registerSucceeded) {
                    setAddressSpace(addressSpace);
                    if (!addressSpace.authoriseCreateConnection(this)) {
                        closeConnection(AmqpError.NOT_ALLOWED, "Connection refused");
                    } else {
                        switch(_connectionState) {
                            case AWAIT_OPEN:
                                sendOpen(_channelMax, _maxFrameSize);
                                _connectionState = ConnectionState.OPENED;
                                break;
                            case CLOSE_SENT:
                            case CLOSED:
                                // already sent our close - probably due to an error
                                break;
                            default:
                                throw new ConnectionScopedRuntimeException(String.format("Unexpected state %s during connection open.", _connectionState));
                        }
                    }
                }
            } catch (VirtualHostUnavailableException | AccessControlException e) {
                closeConnection(AmqpError.NOT_ALLOWED, e.getMessage());
            }
        }
    }
}
Also used : AccessControlContext(java.security.AccessControlContext) Arrays(java.util.Arrays) SoleConnectionDetectionPolicy(org.apache.qpid.server.protocol.v1_0.type.extensions.soleconn.SoleConnectionDetectionPolicy) PeekingIterator(com.google.common.collect.PeekingIterator) AuthenticationResult(org.apache.qpid.server.security.auth.AuthenticationResult) ExternalAuthenticationManagerImpl(org.apache.qpid.server.security.auth.manager.ExternalAuthenticationManagerImpl) Map(java.util.Map) Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) ProtocolHandler(org.apache.qpid.server.protocol.v1_0.codec.ProtocolHandler) ConnectionError(org.apache.qpid.server.protocol.v1_0.type.transport.ConnectionError) End(org.apache.qpid.server.protocol.v1_0.type.transport.End) Futures.allAsList(com.google.common.util.concurrent.Futures.allAsList) Set(java.util.Set) DescribedTypeConstructorRegistry(org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry) AMQPConnection(org.apache.qpid.server.transport.AMQPConnection) SaslCode(org.apache.qpid.server.protocol.v1_0.type.security.SaslCode) VirtualHostUnavailableException(org.apache.qpid.server.virtualhost.VirtualHostUnavailableException) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) Transport(org.apache.qpid.server.model.Transport) SASLFrame(org.apache.qpid.server.protocol.v1_0.framing.SASLFrame) OversizeFrameException(org.apache.qpid.server.protocol.v1_0.framing.OversizeFrameException) AggregateTicker(org.apache.qpid.server.transport.AggregateTicker) ByteBufferSender(org.apache.qpid.server.transport.ByteBufferSender) ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) AccessController(java.security.AccessController) ValueWriter(org.apache.qpid.server.protocol.v1_0.codec.ValueWriter) ProtocolEngine(org.apache.qpid.server.transport.ProtocolEngine) FrameBody(org.apache.qpid.server.protocol.v1_0.type.FrameBody) FrameWriter(org.apache.qpid.server.protocol.v1_0.codec.FrameWriter) SOLE_CONNECTION_ENFORCEMENT_POLICY(org.apache.qpid.server.protocol.v1_0.type.extensions.soleconn.SoleConnectionConnectionProperties.SOLE_CONNECTION_ENFORCEMENT_POLICY) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Close(org.apache.qpid.server.protocol.v1_0.type.transport.Close) ChannelFrameBody(org.apache.qpid.server.protocol.v1_0.type.transport.ChannelFrameBody) SoleConnectionEnforcementPolicy(org.apache.qpid.server.protocol.v1_0.type.extensions.soleconn.SoleConnectionEnforcementPolicy) AmqpError(org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError) StreamSupport(java.util.stream.StreamSupport) Flow(org.apache.qpid.server.protocol.v1_0.type.transport.Flow) ConnectionPropertyEnricher(org.apache.qpid.server.plugin.ConnectionPropertyEnricher) SaslFrameBody(org.apache.qpid.server.protocol.v1_0.type.SaslFrameBody) SoleConnectionConnectionProperties(org.apache.qpid.server.protocol.v1_0.type.extensions.soleconn.SoleConnectionConnectionProperties) Connection(org.apache.qpid.server.model.Connection) ServerNetworkConnection(org.apache.qpid.server.transport.ServerNetworkConnection) UnsignedShort(org.apache.qpid.server.protocol.v1_0.type.UnsignedShort) AMQFrame(org.apache.qpid.server.protocol.v1_0.framing.AMQFrame) SaslChallenge(org.apache.qpid.server.protocol.v1_0.type.security.SaslChallenge) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) TransportFrame(org.apache.qpid.server.protocol.v1_0.framing.TransportFrame) AMQPDescribedTypeRegistry(org.apache.qpid.server.protocol.v1_0.type.codec.AMQPDescribedTypeRegistry) SocketAddress(java.net.SocketAddress) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) LoggerFactory(org.slf4j.LoggerFactory) ByteBuffer(java.nio.ByteBuffer) ConnectionMessages(org.apache.qpid.server.logging.messages.ConnectionMessages) ErrorCondition(org.apache.qpid.server.protocol.v1_0.type.ErrorCondition) Transfer(org.apache.qpid.server.protocol.v1_0.type.transport.Transfer) AmqpPort(org.apache.qpid.server.model.port.AmqpPort) ValueHandler(org.apache.qpid.server.protocol.v1_0.codec.ValueHandler) SectionDecoderRegistry(org.apache.qpid.server.protocol.v1_0.codec.SectionDecoderRegistry) Symbol(org.apache.qpid.server.protocol.v1_0.type.Symbol) StoreException(org.apache.qpid.server.store.StoreException) LocalTransaction(org.apache.qpid.server.txn.LocalTransaction) Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach) Collection(java.util.Collection) AnonymousAuthenticationManager(org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManager) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SaslOutcome(org.apache.qpid.server.protocol.v1_0.type.security.SaslOutcome) UUID(java.util.UUID) PrivilegedAction(java.security.PrivilegedAction) Collectors(java.util.stream.Collectors) Functions(org.apache.qpid.server.transport.util.Functions) Sets(com.google.common.collect.Sets) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) List(java.util.List) Principal(java.security.Principal) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) AccessControlException(java.security.AccessControlException) FrameHandler(org.apache.qpid.server.protocol.v1_0.framing.FrameHandler) Queue(java.util.Queue) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) AuthenticationProvider(org.apache.qpid.server.model.AuthenticationProvider) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) AtomicReference(java.util.concurrent.atomic.AtomicReference) SaslMechanisms(org.apache.qpid.server.protocol.v1_0.type.security.SaslMechanisms) Iterators(com.google.common.collect.Iterators) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) SaslNegotiator(org.apache.qpid.server.security.auth.sasl.SaslNegotiator) SaslInit(org.apache.qpid.server.protocol.v1_0.type.security.SaslInit) AuthenticatedPrincipal(org.apache.qpid.server.security.auth.AuthenticatedPrincipal) AbstractAMQPConnection(org.apache.qpid.server.transport.AbstractAMQPConnection) ServerScopedRuntimeException(org.apache.qpid.server.util.ServerScopedRuntimeException) SaslResponse(org.apache.qpid.server.protocol.v1_0.type.security.SaslResponse) NoSuchElementException(java.util.NoSuchElementException) SubjectAuthenticationResult(org.apache.qpid.server.security.auth.SubjectAuthenticationResult) ServerTransaction(org.apache.qpid.server.txn.ServerTransaction) Logger(org.slf4j.Logger) Action(org.apache.qpid.server.util.Action) Iterator(java.util.Iterator) Broker(org.apache.qpid.server.model.Broker) Protocol(org.apache.qpid.server.model.Protocol) SubjectCreator(org.apache.qpid.server.security.SubjectCreator) ConnectionClosingTicker(org.apache.qpid.server.protocol.ConnectionClosingTicker) AMQPSession(org.apache.qpid.server.session.AMQPSession) Collections(java.util.Collections) ArrayList(java.util.ArrayList) ConnectionError(org.apache.qpid.server.protocol.v1_0.type.transport.ConnectionError) AmqpError(org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) AccessControlException(java.security.AccessControlException) VirtualHostUnavailableException(org.apache.qpid.server.virtualhost.VirtualHostUnavailableException) SoleConnectionEnforcementPolicy(org.apache.qpid.server.protocol.v1_0.type.extensions.soleconn.SoleConnectionEnforcementPolicy) ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Example 20 with NamedAddressSpace

use of org.apache.qpid.server.model.NamedAddressSpace in project qpid-broker-j by apache.

the class AMQChannel method receiveQueuePurge.

@Override
public void receiveQueuePurge(final AMQShortString queueName, final boolean nowait) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("RECV[" + _channelId + "] QueuePurge[" + " queue: " + queueName + " nowait: " + nowait + " ]");
    }
    NamedAddressSpace virtualHost = _connection.getAddressSpace();
    Queue<?> queue = null;
    if (queueName == null && (queue = getDefaultQueue()) == null) {
        _connection.sendConnectionClose(ErrorCodes.NOT_ALLOWED, "No queue specified.", getChannelId());
    } else if ((queueName != null) && (queue = getQueue(queueName.toString())) == null) {
        closeChannel(ErrorCodes.NOT_FOUND, "Queue '" + queueName + "' does not exist.");
    } else if (!queue.verifySessionAccess(this)) {
        _connection.sendConnectionClose(ErrorCodes.NOT_ALLOWED, "Queue is exclusive, but not created on this Connection.", getChannelId());
    } else {
        try {
            long purged = queue.clearQueue();
            if (!nowait) {
                sync();
                MethodRegistry methodRegistry = _connection.getMethodRegistry();
                AMQMethodBody responseBody = methodRegistry.createQueuePurgeOkBody(purged);
                _connection.writeFrame(responseBody.generateFrame(getChannelId()));
            }
        } catch (AccessControlException e) {
            _connection.sendConnectionClose(ErrorCodes.ACCESS_REFUSED, e.getMessage(), getChannelId());
        }
    }
}
Also used : NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) AccessControlException(java.security.AccessControlException)

Aggregations

NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)42 AccessControlException (java.security.AccessControlException)22 HashMap (java.util.HashMap)12 MessageSource (org.apache.qpid.server.message.MessageSource)8 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)8 Queue (org.apache.qpid.server.model.Queue)6 Collection (java.util.Collection)5 LinkedHashMap (java.util.LinkedHashMap)5 Map (java.util.Map)5 Symbol (org.apache.qpid.server.protocol.v1_0.type.Symbol)5 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)4 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)4 MessageDestination (org.apache.qpid.server.message.MessageDestination)4 AmqpPort (org.apache.qpid.server.model.port.AmqpPort)4 ArrayList (java.util.ArrayList)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 Exchange (org.apache.qpid.server.model.Exchange)3 BaseSource (org.apache.qpid.server.protocol.v1_0.type.BaseSource)3 Source (org.apache.qpid.server.protocol.v1_0.type.messaging.Source)3 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)3