Repository: activemq Updated Branches: refs/heads/trunk 9c2471604 -> 167152307
https://issues.apache.org/jira/browse/AMQ-5096 Return proper error code for unathorized access. Project: http://git-wip-us.apache.org/repos/asf/activemq/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/16715230 Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/16715230 Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/16715230 Branch: refs/heads/trunk Commit: 1671523076327ba822caa5d1f1a2567e757999eb Parents: 9c24716 Author: Timothy Bish <[email protected]> Authored: Wed Mar 12 16:12:22 2014 -0400 Committer: Timothy Bish <[email protected]> Committed: Wed Mar 12 16:13:04 2014 -0400 ---------------------------------------------------------------------- .../transport/amqp/AmqpProtocolConverter.java | 22 ++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq/blob/16715230/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpProtocolConverter.java ---------------------------------------------------------------------- diff --git a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpProtocolConverter.java b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpProtocolConverter.java index 7c5764a..e83fdf4 100644 --- a/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpProtocolConverter.java +++ b/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpProtocolConverter.java @@ -743,7 +743,11 @@ class AmqpProtocolConverter implements IAmqpProtocolConverter { if (response.isException()) { receiver.setTarget(null); Throwable exception = ((ExceptionResponse) response).getException(); - receiver.setCondition(new ErrorCondition(AmqpError.INTERNAL_ERROR, exception.getMessage())); + if (exception instanceof SecurityException) { + receiver.setCondition(new ErrorCondition(AmqpError.UNAUTHORIZED_ACCESS, exception.getMessage())); + } else { + receiver.setCondition(new ErrorCondition(AmqpError.INTERNAL_ERROR, exception.getMessage())); + } receiver.close(); } else { receiver.open(); @@ -1151,7 +1155,11 @@ class AmqpProtocolConverter implements IAmqpProtocolConverter { if (response.isException()) { sender.setSource(null); Throwable exception = ((ExceptionResponse) response).getException(); - sender.setCondition(new ErrorCondition(AmqpError.INTERNAL_ERROR, exception.getMessage())); + if (exception instanceof SecurityException) { + sender.setCondition(new ErrorCondition(AmqpError.UNAUTHORIZED_ACCESS, exception.getMessage())); + } else { + sender.setCondition(new ErrorCondition(AmqpError.INTERNAL_ERROR, exception.getMessage())); + } } sender.open(); pumpProtonToSocket(); @@ -1203,11 +1211,13 @@ class AmqpProtocolConverter implements IAmqpProtocolConverter { if (response.isException()) { sender.setSource(null); Throwable exception = ((ExceptionResponse) response).getException(); - Symbol condition = AmqpError.INTERNAL_ERROR; - if (exception instanceof InvalidSelectorException) { - condition = AmqpError.INVALID_FIELD; + if (exception instanceof SecurityException) { + sender.setCondition(new ErrorCondition(AmqpError.UNAUTHORIZED_ACCESS, exception.getMessage())); + } else if (exception instanceof InvalidSelectorException) { + sender.setCondition(new ErrorCondition(AmqpError.INVALID_FIELD, exception.getMessage())); + } else { + sender.setCondition(new ErrorCondition(AmqpError.INTERNAL_ERROR, exception.getMessage())); } - sender.setCondition(new ErrorCondition(condition, exception.getMessage())); subscriptionsByConsumerId.remove(id); sender.close(); } else {
