diff options
| author | Robert Godfrey <rgodfrey@apache.org> | 2014-02-13 19:41:22 +0000 |
|---|---|---|
| committer | Robert Godfrey <rgodfrey@apache.org> | 2014-02-13 19:41:22 +0000 |
| commit | 08b64b592cb844cbd746b33e5f17c94b2158a115 (patch) | |
| tree | a46a4a554c3b04bb9109f02a203df370ac5ee6f6 /qpid/java/broker-plugins | |
| parent | e800236056d84261ca34a849d8767405724de298 (diff) | |
| download | qpid-python-08b64b592cb844cbd746b33e5f17c94b2158a115.tar.gz | |
QPID-5551 : replace AMQSecurityException with QpidSecurityException in the broker
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1568015 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-plugins')
21 files changed, 189 insertions, 51 deletions
diff --git a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java index d3d53504be..3d50da6ed5 100644 --- a/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java +++ b/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerSessionDelegate.java @@ -42,6 +42,7 @@ import org.apache.qpid.server.model.UUIDGenerator; import org.apache.qpid.server.plugin.ExchangeType; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.QueueArgumentsConverter; +import org.apache.qpid.server.security.QpidSecurityException; import org.apache.qpid.server.security.SecurityManager; import org.apache.qpid.server.store.DurableConfigurationStore; import org.apache.qpid.server.store.MessageStore; @@ -301,6 +302,10 @@ public class ServerSessionDelegate extends SessionDelegate { exception(session, method, e, "Cannot subscribe to queue '" + queueName + "' with destination '" + destination); } + catch (QpidSecurityException e) + { + exception(session, method, ExecutionErrorCode.UNAUTHORIZED_ACCESS, e.getMessage()); + } } } } @@ -786,6 +791,10 @@ public class ServerSessionDelegate extends SessionDelegate { exception(session, method, e, "Cannot declare exchange '" + exchangeName); } + catch (QpidSecurityException e) + { + exception(session, method, ExecutionErrorCode.UNAUTHORIZED_ACCESS, e.getMessage()); + } } @@ -898,6 +907,10 @@ public class ServerSessionDelegate extends SessionDelegate { exception(session, method, e, "Cannot delete exchange '" + method.getExchange() ); } + catch (QpidSecurityException e) + { + exception(session, method, ExecutionErrorCode.UNAUTHORIZED_ACCESS, e.getMessage()); + } } private boolean nameNullOrEmpty(String name) @@ -992,6 +1005,10 @@ public class ServerSessionDelegate extends SessionDelegate { exception(session, method, e, "Cannot add binding '" + method.getBindingKey()); } + catch (QpidSecurityException e) + { + exception(session, method, ExecutionErrorCode.UNAUTHORIZED_ACCESS, e.getMessage()); + } } else { @@ -1045,6 +1062,10 @@ public class ServerSessionDelegate extends SessionDelegate { exception(session, method, e, "Cannot remove binding '" + method.getBindingKey()); } + catch (QpidSecurityException e) + { + exception(session, method, ExecutionErrorCode.UNAUTHORIZED_ACCESS, e.getMessage()); + } } } } @@ -1272,6 +1293,10 @@ public class ServerSessionDelegate extends SessionDelegate { exception(session, method, e, "Cannot delete '" + method.getQueue()); } + catch (QpidSecurityException e) + { + exception(session, method, ExecutionErrorCode.UNAUTHORIZED_ACCESS, e.getMessage()); + } } }; final ServerSession s = (ServerSession) session; @@ -1324,6 +1349,10 @@ public class ServerSessionDelegate extends SessionDelegate { exception(session, method, e, "Cannot declare queue '" + queueName); } + catch (QpidSecurityException e) + { + exception(session, method, ExecutionErrorCode.UNAUTHORIZED_ACCESS, e.getMessage()); + } } } @@ -1401,6 +1430,10 @@ public class ServerSessionDelegate extends SessionDelegate { exception(session, method, e, "Cannot delete queue '" + queueName); } + catch (QpidSecurityException e) + { + exception(session, method, ExecutionErrorCode.UNAUTHORIZED_ACCESS, e.getMessage()); + } } } } @@ -1432,6 +1465,10 @@ public class ServerSessionDelegate extends SessionDelegate { exception(session, method, e, "Cannot purge queue '" + queueName); } + catch (QpidSecurityException e) + { + exception(session, method, ExecutionErrorCode.UNAUTHORIZED_ACCESS, e.getMessage()); + } } } } diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java index 5afb2069c1..4eeb9d8fb2 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java @@ -29,7 +29,7 @@ import java.util.concurrent.locks.Lock; import org.apache.log4j.Logger; import org.apache.qpid.AMQConnectionException; import org.apache.qpid.AMQException; -import org.apache.qpid.AMQSecurityException; +import org.apache.qpid.server.security.QpidSecurityException; import org.apache.qpid.common.AMQPFilterTypes; import org.apache.qpid.framing.AMQMethodBody; import org.apache.qpid.framing.AMQShortString; @@ -262,13 +262,13 @@ public class AMQChannel implements AMQSessionModel, AsyncAutoCommitTransaction.F return _channelId; } - public void setPublishFrame(MessagePublishInfo info, final MessageDestination e) throws AMQSecurityException + public void setPublishFrame(MessagePublishInfo info, final MessageDestination e) throws QpidSecurityException { String routingKey = info.getRoutingKey() == null ? null : info.getRoutingKey().asString(); SecurityManager securityManager = getVirtualHost().getSecurityManager(); if (!securityManager.authorisePublish(info.isImmediate(), routingKey, e.getName())) { - throw new AMQSecurityException("Permission denied: " + e.getName()); + throw new QpidSecurityException("Permission denied: " + e.getName()); } _currentMessage = new IncomingMessage(info); _currentMessage.setMessageDestination(e); @@ -515,7 +515,8 @@ public class AMQChannel implements AMQSessionModel, AsyncAutoCommitTransaction.F * @throws AMQException if something goes wrong */ public AMQShortString consumeFromSource(AMQShortString tag, MessageSource source, boolean acks, - FieldTable filters, boolean exclusive, boolean noLocal) throws AMQException + FieldTable filters, boolean exclusive, boolean noLocal) + throws AMQException, QpidSecurityException { if (tag == null) { @@ -588,6 +589,11 @@ public class AMQChannel implements AMQSessionModel, AsyncAutoCommitTransaction.F _tag2SubscriptionTargetMap.remove(tag); throw e; } + catch (QpidSecurityException e) + { + _tag2SubscriptionTargetMap.remove(tag); + throw e; + } return tag; } diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java index ba61afc376..329aa396b0 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQProtocolEngine.java @@ -46,7 +46,7 @@ import org.apache.log4j.Logger; import org.apache.qpid.AMQChannelException; import org.apache.qpid.AMQConnectionException; import org.apache.qpid.AMQException; -import org.apache.qpid.AMQSecurityException; +import org.apache.qpid.server.security.QpidSecurityException; import org.apache.qpid.codec.AMQCodecFactory; import org.apache.qpid.common.QpidProperties; import org.apache.qpid.common.ServerPropertyNames; @@ -628,12 +628,6 @@ public class AMQProtocolEngine implements ServerProtocolEngine, AMQProtocolSessi _logger.info(e.getMessage() + " whilst processing:" + methodBody); closeConnection(channelId, e); } - catch (AMQSecurityException e) - { - AMQConnectionException ce = evt.getMethod().getConnectionException(AMQConstant.ACCESS_REFUSED, e.getMessage()); - _logger.info(e.getMessage() + " whilst processing:" + methodBody); - closeConnection(channelId, ce); - } } catch (Exception e) { diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicConsumeMethodHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicConsumeMethodHandler.java index b28bb5a0ad..ad4235b786 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicConsumeMethodHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicConsumeMethodHandler.java @@ -35,6 +35,7 @@ import org.apache.qpid.server.protocol.AMQSessionModel; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; +import org.apache.qpid.server.security.QpidSecurityException; import org.apache.qpid.server.virtualhost.VirtualHost; public class BasicConsumeMethodHandler implements StateAwareMethodListener<BasicConsumeBody> @@ -175,6 +176,13 @@ public class BasicConsumeMethodHandler implements StateAwareMethodListener<Basic + queue.getName() + " exclusively as it already has a consumer"); } + catch (QpidSecurityException e) + { + throw body.getChannelException(AMQConstant.ACCESS_REFUSED, + "Cannot subscribe to queue " + + queue.getName() + + " permission denied"); + } } } diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicGetMethodHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicGetMethodHandler.java index fd4324cee0..f55a120a2d 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicGetMethodHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicGetMethodHandler.java @@ -45,6 +45,7 @@ import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; import org.apache.qpid.server.protocol.v0_8.ClientDeliveryMethod; import org.apache.qpid.server.protocol.v0_8.RecordDeliveryMethod; import org.apache.qpid.server.consumer.Consumer; +import org.apache.qpid.server.security.QpidSecurityException; import org.apache.qpid.server.virtualhost.VirtualHost; import java.util.EnumSet; @@ -106,14 +107,22 @@ public class BasicGetMethodHandler implements StateAwareMethodListener<BasicGetB } } - if (!performGet(queue,protocolConnection, channel, !body.getNoAck())) + try { - MethodRegistry methodRegistry = protocolConnection.getMethodRegistry(); - // TODO - set clusterId - BasicGetEmptyBody responseBody = methodRegistry.createBasicGetEmptyBody(null); + if (!performGet(queue,protocolConnection, channel, !body.getNoAck())) + { + MethodRegistry methodRegistry = protocolConnection.getMethodRegistry(); + // TODO - set clusterId + BasicGetEmptyBody responseBody = methodRegistry.createBasicGetEmptyBody(null); - protocolConnection.writeFrame(responseBody.generateFrame(channelId)); + protocolConnection.writeFrame(responseBody.generateFrame(channelId)); + } + } + catch (QpidSecurityException e) + { + throw body.getConnectionException(AMQConstant.ACCESS_REFUSED, + e.getMessage()); } } } @@ -123,7 +132,7 @@ public class BasicGetMethodHandler implements StateAwareMethodListener<BasicGetB final AMQProtocolSession session, final AMQChannel channel, final boolean acks) - throws AMQException + throws AMQException, QpidSecurityException { final FlowCreditManager singleMessageCredit = new MessageOnlyCreditManager(1L); diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicPublishMethodHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicPublishMethodHandler.java index f8a7722447..318efdd125 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicPublishMethodHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/BasicPublishMethodHandler.java @@ -34,6 +34,7 @@ import org.apache.qpid.server.exchange.Exchange; import org.apache.qpid.server.protocol.v0_8.AMQProtocolSession; import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; +import org.apache.qpid.server.security.QpidSecurityException; import org.apache.qpid.server.virtualhost.VirtualHost; public class BasicPublishMethodHandler implements StateAwareMethodListener<BasicPublishBody> @@ -88,7 +89,14 @@ public class BasicPublishMethodHandler implements StateAwareMethodListener<Basic MessagePublishInfo info = session.getMethodRegistry().getProtocolVersionMethodConverter().convertToInfo(body); info.setExchange(exchangeName); - channel.setPublishFrame(info, exch); + try + { + channel.setPublishFrame(info, exch); + } + catch (QpidSecurityException e) + { + throw body.getConnectionException(AMQConstant.ACCESS_REFUSED, e.getMessage()); + } } } diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java index 154c38a4bf..fa513486a4 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java @@ -35,6 +35,7 @@ import org.apache.qpid.server.exchange.Exchange; import org.apache.qpid.server.protocol.v0_8.AMQProtocolSession; import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; +import org.apache.qpid.server.security.QpidSecurityException; import org.apache.qpid.server.virtualhost.ExchangeExistsException; import org.apache.qpid.server.virtualhost.ReservedExchangeNameException; import org.apache.qpid.server.virtualhost.VirtualHost; @@ -124,6 +125,10 @@ public class ExchangeDeclareHandler implements StateAwareMethodListener<Exchange { throw body.getConnectionException(AMQConstant.COMMAND_INVALID, "Unknown exchange: " + exchangeName,e); } + catch (QpidSecurityException e) + { + throw body.getConnectionException(AMQConstant.ACCESS_REFUSED, e.getMessage()); + } } diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeleteHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeleteHandler.java index ce377eee78..ea3d7ded4d 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeleteHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeleteHandler.java @@ -29,6 +29,7 @@ import org.apache.qpid.server.exchange.Exchange; import org.apache.qpid.server.protocol.v0_8.AMQProtocolSession; import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; +import org.apache.qpid.server.security.QpidSecurityException; import org.apache.qpid.server.virtualhost.ExchangeIsAlternateException; import org.apache.qpid.server.virtualhost.RequiredExchangeException; import org.apache.qpid.server.virtualhost.VirtualHost; @@ -82,5 +83,9 @@ public class ExchangeDeleteHandler implements StateAwareMethodListener<ExchangeD { throw body.getChannelException(AMQConstant.NOT_ALLOWED, "Exchange '"+body.getExchange()+"' cannot be deleted"); } + catch (QpidSecurityException e) + { + throw body.getConnectionException(AMQConstant.ACCESS_REFUSED, e.getMessage()); + } } } diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueBindHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueBindHandler.java index d95d59f75f..401718db88 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueBindHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueBindHandler.java @@ -41,6 +41,7 @@ import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.QueueRegistry; import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; +import org.apache.qpid.server.security.QpidSecurityException; import org.apache.qpid.server.virtualhost.VirtualHost; import java.util.Map; @@ -147,6 +148,10 @@ public class QueueBindHandler implements StateAwareMethodListener<QueueBindBody> { throw body.getChannelException(AMQConstant.CHANNEL_ERROR, e.toString()); } + catch (QpidSecurityException e) + { + throw body.getConnectionException(AMQConstant.ACCESS_REFUSED, e.getMessage()); + } if (_log.isInfoEnabled()) { diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeclareHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeclareHandler.java index 263175d590..1286a20970 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeclareHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeclareHandler.java @@ -39,9 +39,11 @@ import org.apache.qpid.server.queue.QueueArgumentsConverter; import org.apache.qpid.server.queue.QueueRegistry; import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; +import org.apache.qpid.server.security.QpidSecurityException; import org.apache.qpid.server.store.DurableConfigurationStoreHelper; import org.apache.qpid.server.store.DurableConfigurationStore; import org.apache.qpid.server.util.Action; +import org.apache.qpid.server.util.ConnectionScopedRuntimeException; import org.apache.qpid.server.virtualhost.VirtualHost; import java.util.Map; @@ -185,6 +187,10 @@ public class QueueDeclareHandler implements StateAwareMethodListener<QueueDeclar } } + catch (QpidSecurityException e) + { + throw body.getConnectionException(AMQConstant.ACCESS_REFUSED, e.getMessage()); + } //set this as the default queue on the channel: channel.setDefaultQueue(queue); @@ -213,7 +219,7 @@ public class QueueDeclareHandler implements StateAwareMethodListener<QueueDeclar QueueDeclareBody body, final VirtualHost virtualHost, final AMQProtocolSession session) - throws AMQException + throws AMQException, QpidSecurityException { final boolean durable = body.getDurable(); @@ -239,7 +245,14 @@ public class QueueDeclareHandler implements StateAwareMethodListener<QueueDeclar { if (virtualHost.getQueue(queueName.toString()) == queue) { - virtualHost.removeQueue(queue); + try + { + virtualHost.removeQueue(queue); + } + catch (QpidSecurityException e) + { + throw new ConnectionScopedRuntimeException("Permission exception: Unable to remove a temporary queue created by a session which has now removed itself", e); + } } } }; diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeleteHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeleteHandler.java index d3c196a789..3a9a6dc44e 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeleteHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueDeleteHandler.java @@ -32,6 +32,7 @@ import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.QueueRegistry; import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; +import org.apache.qpid.server.security.QpidSecurityException; import org.apache.qpid.server.store.DurableConfigurationStore; import org.apache.qpid.server.store.DurableConfigurationStoreHelper; import org.apache.qpid.server.virtualhost.VirtualHost; @@ -111,7 +112,15 @@ public class QueueDeleteHandler implements StateAwareMethodListener<QueueDeleteB "Queue " + queue.getName() + " is exclusive, but not created on this Connection."); } - int purged = virtualHost.removeQueue(queue); + int purged = 0; + try + { + purged = virtualHost.removeQueue(queue); + } + catch (QpidSecurityException e) + { + throw body.getConnectionException(AMQConstant.ACCESS_REFUSED, e.getMessage()); + } MethodRegistry methodRegistry = protocolConnection.getMethodRegistry(); QueueDeleteOkBody responseBody = methodRegistry.createQueueDeleteOkBody(purged); diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueuePurgeHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueuePurgeHandler.java index ff845d3c16..6d8f8e64fc 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueuePurgeHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueuePurgeHandler.java @@ -33,6 +33,7 @@ import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.QueueRegistry; import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; +import org.apache.qpid.server.security.QpidSecurityException; import org.apache.qpid.server.virtualhost.VirtualHost; public class QueuePurgeHandler implements StateAwareMethodListener<QueuePurgeBody> @@ -103,10 +104,18 @@ public class QueuePurgeHandler implements StateAwareMethodListener<QueuePurgeBod "Queue is exclusive, but not created on this Connection."); } - long purged = queue.clearQueue(); + long purged = 0; + try + { + purged = queue.clearQueue(); + } + catch (QpidSecurityException e) + { + throw body.getConnectionException(AMQConstant.ACCESS_REFUSED, e.getMessage()); + } - if(!body.getNowait()) + if(!body.getNowait()) { channel.sync(); MethodRegistry methodRegistry = protocolConnection.getMethodRegistry(); diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueUnbindHandler.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueUnbindHandler.java index d568e0f581..91025dacf2 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueUnbindHandler.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/QueueUnbindHandler.java @@ -38,6 +38,7 @@ import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.QueueRegistry; import org.apache.qpid.server.protocol.v0_8.state.AMQStateManager; import org.apache.qpid.server.protocol.v0_8.state.StateAwareMethodListener; +import org.apache.qpid.server.security.QpidSecurityException; import org.apache.qpid.server.virtualhost.VirtualHost; public class QueueUnbindHandler implements StateAwareMethodListener<QueueUnbindBody> @@ -105,7 +106,14 @@ public class QueueUnbindHandler implements StateAwareMethodListener<QueueUnbindB } else { - exch.removeBinding(String.valueOf(routingKey), queue, FieldTable.convertToMap(body.getArguments())); + try + { + exch.removeBinding(String.valueOf(routingKey), queue, FieldTable.convertToMap(body.getArguments())); + } + catch (QpidSecurityException e) + { + throw body.getConnectionException(AMQConstant.ACCESS_REFUSED, e.getMessage()); + } } diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AckTest.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AckTest.java index c805956b83..23c32f988d 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AckTest.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AckTest.java @@ -177,7 +177,7 @@ public class AckTest extends QpidTestCase * Tests that the acknowledgements are correctly associated with a channel and * order is preserved when acks are enabled */ - public void testAckChannelAssociationTest() throws AMQException + public void testAckChannelAssociationTest() throws Exception { _subscriptionTarget = ConsumerTarget_0_8.createAckTarget(_channel, DEFAULT_CONSUMER_TAG, @@ -206,7 +206,7 @@ public class AckTest extends QpidTestCase /** * Tests that in no-ack mode no messages are retained */ - public void testNoAckMode() throws AMQException + public void testNoAckMode() throws Exception { // false arg means no acks expected _subscriptionTarget = ConsumerTarget_0_8.createNoAckTarget(_channel, @@ -231,7 +231,7 @@ public class AckTest extends QpidTestCase /** * Tests that in no-ack mode no messages are retained */ - public void testPersistentNoAckMode() throws AMQException + public void testPersistentNoAckMode() throws Exception { // false arg means no acks expected @@ -255,7 +255,7 @@ public class AckTest extends QpidTestCase * Tests that a single acknowledgement is handled correctly (i.e multiple flag not * set case) */ - public void testSingleAckReceivedTest() throws AMQException + public void testSingleAckReceivedTest() throws Exception { _subscriptionTarget = ConsumerTarget_0_8.createAckTarget(_channel, @@ -292,7 +292,7 @@ public class AckTest extends QpidTestCase * Tests that a single acknowledgement is handled correctly (i.e multiple flag not * set case) */ - public void testMultiAckReceivedTest() throws AMQException + public void testMultiAckReceivedTest() throws Exception { _subscriptionTarget = ConsumerTarget_0_8.createAckTarget(_channel, @@ -326,7 +326,7 @@ public class AckTest extends QpidTestCase /** * Tests that a multiple acknowledgement is handled correctly. When ack'ing all pending msgs. */ - public void testMultiAckAllReceivedTest() throws AMQException + public void testMultiAckAllReceivedTest() throws Exception { _subscriptionTarget = ConsumerTarget_0_8.createAckTarget(_channel, diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AcknowledgeTest.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AcknowledgeTest.java index f47525097e..9e551c9c01 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AcknowledgeTest.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/AcknowledgeTest.java @@ -84,40 +84,40 @@ public class AcknowledgeTest extends QpidTestCase return _queue; } - public void testTransactionalSingleAck() throws AMQException + public void testTransactionalSingleAck() throws Exception { getChannel().setLocalTransactional(); runMessageAck(1, 1, 1, false, 0); } - public void testTransactionalMultiAck() throws AMQException + public void testTransactionalMultiAck() throws Exception { getChannel().setLocalTransactional(); runMessageAck(10, 1, 5, true, 5); } - public void testTransactionalAckAll() throws AMQException + public void testTransactionalAckAll() throws Exception { getChannel().setLocalTransactional(); runMessageAck(10, 1, 0, true, 0); } - public void testNonTransactionalSingleAck() throws AMQException + public void testNonTransactionalSingleAck() throws Exception { runMessageAck(1, 1, 1, false, 0); } - public void testNonTransactionalMultiAck() throws AMQException + public void testNonTransactionalMultiAck() throws Exception { runMessageAck(10, 1, 5, true, 5); } - public void testNonTransactionalAckAll() throws AMQException + public void testNonTransactionalAckAll() throws Exception { runMessageAck(10, 1, 0, true, 0); } - protected void runMessageAck(int sendMessageCount, long firstDeliveryTag, long acknowledgeDeliveryTag, boolean acknowledgeMultiple, int remainingUnackedMessages) throws AMQException + protected void runMessageAck(int sendMessageCount, long firstDeliveryTag, long acknowledgeDeliveryTag, boolean acknowledgeMultiple, int remainingUnackedMessages) throws Exception { //Check store is empty checkStoreContents(0); diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/BrokerTestHelper_0_8.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/BrokerTestHelper_0_8.java index 991a0272d4..845c1d55b4 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/BrokerTestHelper_0_8.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/BrokerTestHelper_0_8.java @@ -26,6 +26,7 @@ import org.apache.qpid.framing.BasicContentHeaderProperties; import org.apache.qpid.framing.ContentHeaderBody; import org.apache.qpid.framing.abstraction.MessagePublishInfo; import org.apache.qpid.server.exchange.Exchange; +import org.apache.qpid.server.security.QpidSecurityException; import org.apache.qpid.server.util.BrokerTestHelper; import org.apache.qpid.server.virtualhost.VirtualHost; @@ -64,7 +65,8 @@ public class BrokerTestHelper_0_8 extends BrokerTestHelper return new InternalTestProtocolSession(virtualHost, createBrokerMock()); } - public static void publishMessages(AMQChannel channel, int numberOfMessages, String queueName, String exchangeName) throws AMQException + public static void publishMessages(AMQChannel channel, int numberOfMessages, String queueName, String exchangeName) + throws AMQException, QpidSecurityException { AMQShortString routingKey = new AMQShortString(queueName); AMQShortString exchangeNameAsShortString = new AMQShortString(exchangeName); diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/QueueBrowserUsesNoAckTest.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/QueueBrowserUsesNoAckTest.java index dc687e1075..e213aa8a20 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/QueueBrowserUsesNoAckTest.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/test/java/org/apache/qpid/server/protocol/v0_8/QueueBrowserUsesNoAckTest.java @@ -85,7 +85,7 @@ public class QueueBrowserUsesNoAckTest extends QpidTestCase return _queue; } - public void testQueueBrowserUsesNoAck() throws AMQException + public void testQueueBrowserUsesNoAck() throws Exception { int sendMessageCount = 2; int prefetch = 1; @@ -136,7 +136,7 @@ public class QueueBrowserUsesNoAckTest extends QpidTestCase assertEquals("Message header count incorrect in the MetaDataMap", messageCount, ((TestableMemoryMessageStore) _messageStore).getMessageCount()); } - private AMQShortString browse(AMQChannel channel, AMQQueue queue) throws AMQException + private AMQShortString browse(AMQChannel channel, AMQQueue queue) throws Exception { FieldTable filters = new FieldTable(); filters.put(AMQPFilterTypes.NO_CONSUME.getValue(), true); diff --git a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java index f796a4b2e3..56b574685f 100644 --- a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java +++ b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java @@ -32,7 +32,7 @@ import java.util.concurrent.ConcurrentHashMap; import org.apache.log4j.Logger; import org.apache.qpid.AMQException; import org.apache.qpid.AMQInternalException; -import org.apache.qpid.AMQSecurityException; +import org.apache.qpid.server.security.QpidSecurityException; import org.apache.qpid.amqp_1_0.transport.DeliveryStateHandler; import org.apache.qpid.amqp_1_0.transport.LinkEndpoint; import org.apache.qpid.amqp_1_0.transport.SendingLinkEndpoint; @@ -329,6 +329,11 @@ public class SendingLink_1_0 implements SendingLinkListener, Link_1_0, DeliveryS //TODO _logger.error("Error removing queue", e); } + catch (QpidSecurityException e) + { + //TODO + _logger.error("Error removing queue", e); + } } } }; @@ -348,7 +353,7 @@ public class SendingLink_1_0 implements SendingLinkListener, Link_1_0, DeliveryS qd = new QueueDestination(queue); } - catch (AMQSecurityException e) + catch (QpidSecurityException e) { _logger.error("Security error", e); throw new RuntimeException(e); @@ -403,6 +408,11 @@ public class SendingLink_1_0 implements SendingLinkListener, Link_1_0, DeliveryS //TODO _logger.error("Error registering subscription", e); } + catch (QpidSecurityException e) + { + //TODO + _logger.error("Error registering subscription", e); + } } } @@ -455,7 +465,12 @@ public class SendingLink_1_0 implements SendingLinkListener, Link_1_0, DeliveryS catch(AMQException e) { //TODO - _logger.error("Error removing queue", e); + _logger.error("Error registering subscription", e); + } + catch (QpidSecurityException e) + { + //TODO + _logger.error("Error registering subscription", e); } } diff --git a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java index beed6be84b..a0b2fc5289 100644 --- a/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java +++ b/qpid/java/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java @@ -37,7 +37,7 @@ import org.apache.qpid.amqp_1_0.type.transport.*; import org.apache.qpid.amqp_1_0.type.transport.Error; import org.apache.qpid.AMQException; -import org.apache.qpid.AMQSecurityException; +import org.apache.qpid.server.security.QpidSecurityException; import org.apache.qpid.protocol.AMQConstant; import org.apache.qpid.server.exchange.Exchange; import org.apache.qpid.server.logging.LogSubject; @@ -362,6 +362,11 @@ public class Session_1_0 implements SessionEventListener, AMQSessionModel, LogSu //TODO _logger.error("Error removing queue from vhost", e); } + catch (QpidSecurityException e) + { + //TODO + _logger.error("Error removing queue from vhost", e); + } } } }; @@ -391,7 +396,7 @@ public class Session_1_0 implements SessionEventListener, AMQSessionModel, LogSu } } - catch (AMQSecurityException e) + catch (QpidSecurityException e) { //TODO _logger.error("Security error", e); diff --git a/qpid/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNode.java b/qpid/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNode.java index 2cb4e50415..4921db5c07 100644 --- a/qpid/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNode.java +++ b/qpid/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNode.java @@ -21,7 +21,7 @@ package org.apache.qpid.server.management.amqp; import org.apache.qpid.AMQException; -import org.apache.qpid.AMQSecurityException; +import org.apache.qpid.server.security.QpidSecurityException; import org.apache.qpid.server.consumer.Consumer; import org.apache.qpid.server.consumer.ConsumerTarget; import org.apache.qpid.server.filter.FilterManager; @@ -373,7 +373,7 @@ class ManagementNode implements MessageSource<ManagementNodeConsumer,ManagementN } catch(RuntimeException e) { - if (e instanceof AccessControlException || e.getCause() instanceof AMQSecurityException) + if (e instanceof AccessControlException || e.getCause() instanceof QpidSecurityException) { response = createFailureResponse(message, STATUS_CODE_FORBIDDEN, e.getMessage()); } @@ -478,7 +478,7 @@ class ManagementNode implements MessageSource<ManagementNodeConsumer,ManagementN } catch(RuntimeException e) { - if (e instanceof AccessControlException || e.getCause() instanceof AMQSecurityException) + if (e instanceof AccessControlException || e.getCause() instanceof QpidSecurityException) { responseHeader.setHeader(STATUS_CODE_HEADER, STATUS_CODE_FORBIDDEN); } @@ -516,7 +516,7 @@ class ManagementNode implements MessageSource<ManagementNodeConsumer,ManagementN } catch(RuntimeException e) { - if (e instanceof AccessControlException || e.getCause() instanceof AMQSecurityException) + if (e instanceof AccessControlException || e.getCause() instanceof QpidSecurityException) { return createFailureResponse(requestMessage, STATUS_CODE_FORBIDDEN, e.getMessage()); } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java index ca11bd9465..45e0c2dab8 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java @@ -27,7 +27,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; -import org.apache.qpid.AMQSecurityException; +import org.apache.qpid.server.security.QpidSecurityException; import org.apache.qpid.server.model.*; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.SerializationConfig; @@ -498,7 +498,7 @@ public class RestServlet extends AbstractServlet private void setResponseStatus(HttpServletResponse response, RuntimeException e) throws IOException { - if (e instanceof AccessControlException || e.getCause() instanceof AMQSecurityException) + if (e instanceof AccessControlException || e.getCause() instanceof QpidSecurityException) { if (LOGGER.isDebugEnabled()) { |
