Search in sources :

Example 21 with ConnectionScopedRuntimeException

use of org.apache.qpid.server.util.ConnectionScopedRuntimeException in project qpid-broker-j by apache.

the class Session_1_0 method createDynamicDestination.

private MessageDestination createDynamicDestination(final Link_1_0<?, ?> link, Map properties, final Symbol[] capabilities) throws AmqpErrorException {
    final Set<Symbol> capabilitySet = capabilities == null ? Collections.emptySet() : Sets.newHashSet(capabilities);
    boolean isTopic = capabilitySet.contains(Symbol.valueOf("temporary-topic")) || capabilitySet.contains(Symbol.valueOf("topic"));
    final String destName = (isTopic ? "TempTopic" : "TempQueue") + UUID.randomUUID().toString();
    try {
        Map<String, Object> attributes = convertDynamicNodePropertiesToAttributes(link, properties, destName);
        Class<? extends MessageDestination> clazz = isTopic ? Exchange.class : MessageDestination.class;
        if (isTopic) {
            attributes.put(Exchange.TYPE, ExchangeDefaults.FANOUT_EXCHANGE_CLASS);
        }
        return Subject.doAs(getSubjectWithAddedSystemRights(), (PrivilegedAction<MessageDestination>) () -> getAddressSpace().createMessageDestination(clazz, attributes));
    } catch (AccessControlException e) {
        throw new AmqpErrorException(AmqpError.UNAUTHORIZED_ACCESS, e.getMessage());
    } catch (AbstractConfiguredObject.DuplicateNameException e) {
        LOGGER.error("A temporary destination was created with a name which collided with an existing destination name '{}'", destName);
        throw new ConnectionScopedRuntimeException(e);
    }
}
Also used : MessageDestination(org.apache.qpid.server.message.MessageDestination) Symbol(org.apache.qpid.server.protocol.v1_0.type.Symbol) AccessControlException(java.security.AccessControlException) AmqpErrorException(org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject)

Example 22 with ConnectionScopedRuntimeException

use of org.apache.qpid.server.util.ConnectionScopedRuntimeException in project qpid-broker-j by apache.

the class Session_1_0 method sendTransfer.

void sendTransfer(final Transfer xfr, final SendingLinkEndpoint endpoint) {
    _nextOutgoingId.incr();
    final boolean settled = Boolean.TRUE.equals(xfr.getSettled());
    UnsignedInteger deliveryId = UnsignedInteger.valueOf(_nextOutgoingDeliveryId++);
    xfr.setDeliveryId(deliveryId);
    if (!settled) {
        final UnsettledDelivery delivery = new UnsettledDelivery(xfr.getDeliveryTag(), endpoint);
        _outgoingDeliveryRegistry.addDelivery(deliveryId, delivery);
    }
    _remoteIncomingWindow--;
    try (QpidByteBuffer payload = xfr.getPayload()) {
        long remaining = payload == null ? 0 : (long) payload.remaining();
        int payloadSent = _connection.sendFrame(_sendingChannel, xfr, payload);
        if (payload != null) {
            while (payloadSent < remaining && payloadSent >= 0) {
                Transfer continuationTransfer = new Transfer();
                continuationTransfer.setHandle(xfr.getHandle());
                continuationTransfer.setRcvSettleMode(xfr.getRcvSettleMode());
                continuationTransfer.setState(xfr.getState());
                continuationTransfer.setPayload(payload);
                _nextOutgoingId.incr();
                _remoteIncomingWindow--;
                remaining = (long) payload.remaining();
                payloadSent = _connection.sendFrame(_sendingChannel, continuationTransfer, payload);
                continuationTransfer.dispose();
            }
        }
    } catch (OversizeFrameException e) {
        throw new ConnectionScopedRuntimeException(e);
    }
}
Also used : OversizeFrameException(org.apache.qpid.server.protocol.v1_0.framing.OversizeFrameException) ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) UnsettledDelivery(org.apache.qpid.server.protocol.v1_0.delivery.UnsettledDelivery) Transfer(org.apache.qpid.server.protocol.v1_0.type.transport.Transfer) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)

Example 23 with ConnectionScopedRuntimeException

use of org.apache.qpid.server.util.ConnectionScopedRuntimeException in project qpid-broker-j by apache.

the class AbstractSection method decode.

private S decode(DescribedTypeConstructor<S> constructor) {
    try (QpidByteBuffer input = getEncodedForm()) {
        int originalPosition = input.position();
        int describedByte = input.get();
        if (describedByte != ValueHandler.DESCRIBED_TYPE) {
            throw new ConnectionScopedRuntimeException("Cannot decode section", new AmqpErrorException(AmqpError.DECODE_ERROR, "Not a described type."));
        }
        ValueHandler handler = new ValueHandler(TYPE_REGISTRY);
        try {
            Object descriptor = handler.parse(input);
            return constructor.construct(descriptor, input, originalPosition, handler).construct(input, handler);
        } catch (AmqpErrorException e) {
            throw new ConnectionScopedRuntimeException("Cannot decode section", e);
        }
    }
}
Also used : ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) AmqpErrorException(org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) ValueHandler(org.apache.qpid.server.protocol.v1_0.codec.ValueHandler)

Example 24 with ConnectionScopedRuntimeException

use of org.apache.qpid.server.util.ConnectionScopedRuntimeException in project qpid-broker-j by apache.

the class ServerSessionDelegate method command.

@Override
public void command(ServerSession session, Method method) {
    try {
        if (!session.isClosing()) {
            Object asyncCommandMark = session.getAsyncCommandMark();
            command(session, method, false);
            Object newOutstanding = session.getAsyncCommandMark();
            if (newOutstanding == null || newOutstanding == asyncCommandMark) {
                session.processed(method);
            }
            if (newOutstanding != null) {
                session.completeAsyncCommands();
            }
            if (method.isSync()) {
                session.awaitCommandCompletion();
                session.flushProcessed();
            }
        }
    } catch (ServerScopedRuntimeException | ConnectionScopedRuntimeException e) {
        throw e;
    } catch (RuntimeException e) {
        LOGGER.error("Exception processing command", e);
        exception(session, method, ExecutionErrorCode.INTERNAL_ERROR, "Exception processing command: " + e);
    }
}
Also used : ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) ServerScopedRuntimeException(org.apache.qpid.server.util.ServerScopedRuntimeException) ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) ServerScopedRuntimeException(org.apache.qpid.server.util.ServerScopedRuntimeException)

Example 25 with ConnectionScopedRuntimeException

use of org.apache.qpid.server.util.ConnectionScopedRuntimeException in project qpid-broker-j by apache.

the class SaslServlet method checkSaslAuthEnabled.

private void checkSaslAuthEnabled(HttpServletRequest request) {
    boolean saslAuthEnabled = false;
    HttpManagementConfiguration management = getManagementConfiguration();
    if (request.isSecure()) {
        saslAuthEnabled = management.isHttpsSaslAuthenticationEnabled();
    } else {
        saslAuthEnabled = management.isHttpSaslAuthenticationEnabled();
    }
    if (!saslAuthEnabled) {
        throw new ConnectionScopedRuntimeException("Sasl authentication disabled.");
    }
}
Also used : HttpManagementConfiguration(org.apache.qpid.server.management.plugin.HttpManagementConfiguration) ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException)

Aggregations

ConnectionScopedRuntimeException (org.apache.qpid.server.util.ConnectionScopedRuntimeException)32 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)9 ServerScopedRuntimeException (org.apache.qpid.server.util.ServerScopedRuntimeException)7 AmqpErrorException (org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException)6 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)5 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 Symbol (org.apache.qpid.server.protocol.v1_0.type.Symbol)4 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)4 AmqpValueSection (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValueSection)4 EncodingRetainingSection (org.apache.qpid.server.protocol.v1_0.type.messaging.EncodingRetainingSection)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)3 AmqpSequenceSection (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpSequenceSection)3 DataSection (org.apache.qpid.server.protocol.v1_0.type.messaging.DataSection)3 Close (org.apache.qpid.server.protocol.v1_0.type.transport.Close)3 Futures.allAsList (com.google.common.util.concurrent.Futures.allAsList)2 ObjectOutputStream (java.io.ObjectOutputStream)2 BufferUnderflowException (java.nio.BufferUnderflowException)2