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);
}
}
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);
}
}
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);
}
}
}
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);
}
}
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.");
}
}
Aggregations