use of org.apache.qpid.server.connection.AmqpConnectionMetaData in project qpid-broker-j by apache.
the class ManagementNode method performConfiguredObjectOperation.
private InternalMessage performConfiguredObjectOperation(final ConfiguredObject<?> object, final InternalMessage message, final ConfiguredObjectOperation<ConfiguredObject<?>> method) {
final InternalMessageHeader requestHeader = message.getMessageHeader();
final Map<String, Object> headers = requestHeader.getHeaderMap();
try {
Map<String, Object> parameters = new HashMap<>(headers);
parameters.remove(KEY_ATTRIBUTE);
parameters.remove(IDENTITY_ATTRIBUTE);
parameters.remove(TYPE_ATTRIBUTE);
parameters.remove(INDEX_ATTRIBUTE);
parameters.remove(OPERATION_HEADER);
parameters.keySet().removeIf(paramName -> paramName.startsWith("JMS_QPID"));
AmqpConnectionMetaData callerConnectionMetaData = getCallerConnectionMetaData();
if (method.isSecure(object, parameters) && !(callerConnectionMetaData.getTransport().isSecure() || callerConnectionMetaData.getPort().isAllowConfidentialOperationsOnInsecureChannels())) {
return createFailureResponse(message, STATUS_CODE_FORBIDDEN, "Operation '" + method.getName() + "' can only be performed over a secure (AMQPS) connection");
}
final MutableMessageHeader responseHeader = new MutableMessageHeader();
responseHeader.setCorrelationId(requestHeader.getCorrelationId() == null ? requestHeader.getMessageId() : requestHeader.getCorrelationId());
responseHeader.setMessageId(UUID.randomUUID().toString());
responseHeader.setHeader(STATUS_CODE_HEADER, STATUS_CODE_OK);
final Object result = method.perform(object, parameters);
return createManagedOperationResponse(method, responseHeader, result);
} catch (IllegalArgumentException | IllegalStateException | IllegalConfigurationException e) {
return createFailureResponse(message, STATUS_CODE_BAD_REQUEST, e.getMessage());
} catch (AccessControlException e) {
return createFailureResponse(message, STATUS_CODE_FORBIDDEN, "Forbidden");
}
}
Aggregations