Principal principal = SecurityManager.getThreadPrincipal();
if (principal == null)
{
return getDefault(); // Default if there is no user associated with the thread
}
PrincipalPermissions principalPermissions = _users.get(principal.getName());
if (principalPermissions == null)
{
return Result.DENIED;
}
// Authorise operation
switch (operation)
{
case CONSUME:
return principalPermissions.authorise(Permission.CONSUME, properties.get(NAME), properties.get(AUTO_DELETE), properties.get(OWNER));
case PUBLISH:
return principalPermissions.authorise(Permission.PUBLISH, properties.get(NAME), properties.get(ROUTING_KEY));
case CREATE:
if (objectType == ObjectType.EXCHANGE)
{
return principalPermissions.authorise(Permission.CREATEEXCHANGE, properties.get(NAME));
}
else if (objectType == ObjectType.QUEUE)
{
return principalPermissions.authorise(Permission.CREATEQUEUE, properties.get(AUTO_DELETE), properties.get(NAME));
}
case ACCESS:
return principalPermissions.authorise(Permission.ACCESS);
case BIND:
return principalPermissions.authorise(Permission.BIND, null, properties.get(NAME), properties.get(QUEUE_NAME), properties.get(ROUTING_KEY));
case UNBIND:
return principalPermissions.authorise(Permission.UNBIND);
case DELETE:
return principalPermissions.authorise(Permission.DELETE);
case PURGE:
return principalPermissions.authorise(Permission.PURGE);
}
// Default
return getDefault();
}