}
String username = session.getAuthorizedID().getName();
//Get the Users Permissions
PrincipalPermissions permissions = _users.get(username);
if (permissions != null)
{
switch (permission)
{
case ACCESS:
return GRANTED;
case BIND: // Body QueueDeclareBody - Parameters : Exchange, Queue, QueueName
// Body QueueBindBody - Paramters : Exchange, Queue, QueueName
if (parameters.length == 3)
{
// Parameters : Exchange, Queue, RoutingKey
if (permissions.authorise(Permission.BIND, body, parameters[0], parameters[1], parameters[2]))
{
return GRANTED;
}
}
break;
case CONSUME: // Parameters : none
if (parameters.length == 1 && permissions.authorise(Permission.CONSUME, parameters[0]))
{
return GRANTED;
}
break;
case CREATE: // Body : QueueDeclareBody | ExchangeDeclareBody - Parameters : none
if (permissions.authorise(Permission.CREATE, body))
{
return GRANTED;
}
break;
case PUBLISH: // Body : BasicPublishBody Parameters : exchange
if (parameters.length == 1 && parameters[0] instanceof Exchange)
{
if (permissions.authorise(Permission.PUBLISH, ((Exchange) parameters[0]).getName(),
((BasicPublishBody) body).getRoutingKey()))
{
return GRANTED;
}
}