Package org.apache.activemq.shiro.authz
Class DestinationActionPermissionResolver
- java.lang.Object
-
- org.apache.activemq.shiro.authz.DestinationActionPermissionResolver
-
- All Implemented Interfaces:
ActionPermissionResolver
public class DestinationActionPermissionResolver extends Object implements ActionPermissionResolver
ADestinationActionPermissionResolver
inspectsDestinationAction
s and returns one or moreWildcardPermission
s that must be granted to aSubject
in order for thatSubject
to perform the action being taken on anActiveMQDestination
. See thecreatePermissionString documentation
to see what the resultingWildcardPermission
instances would look like.- Since:
- 5.10.0
- See Also:
)
,setPermissionStringPrefix(String)
-
-
Constructor Summary
Constructors Constructor Description DestinationActionPermissionResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.apache.shiro.authz.Permission
createPermission(String permissionString)
protected Collection<org.apache.shiro.authz.Permission>
createPermissions(ActiveMQDestination dest, String verb)
protected String
createPermissionString(ActiveMQDestination dest, String verb)
Inspects the specifieddestination
andverb
and returns aWildcardPermission
-compatible String the represents the action.Collection<org.apache.shiro.authz.Permission>
getPermissions(Action action)
Returns allPermission
s that must be granted to aSubject
in order for theSubject
to execute the action, or an empty collection if no permissions are required.protected Collection<org.apache.shiro.authz.Permission>
getPermissions(DestinationAction da)
String
getPermissionStringPrefix()
Returns the String prefix that should be automatically prepended to a permission String before the String is converted to aWildcardPermission
instance.boolean
isPermissionStringCaseSensitive()
Returnstrue
if returnedWildcardPermission
instances should be considered case-sensitive,false
otherwise.void
setPermissionStringCaseSensitive(boolean permissionStringCaseSensitive)
Sets whether returnedWildcardPermission
instances should be considered case-sensitive.void
setPermissionStringPrefix(String permissionStringPrefix)
Sets the String prefix that should be automatically prepended to a permission String before the String is converted to aWildcardPermission
instance.
-
-
-
Method Detail
-
getPermissionStringPrefix
public String getPermissionStringPrefix()
Returns the String prefix that should be automatically prepended to a permission String before the String is converted to aWildcardPermission
instance. This is convenient if you want to provide a 'scope' or 'namespace' for ActiveMQ Destinations to clearly distinguish ActiveMQ-specific permissions from any others you might assign to user accounts. The default value isnull
, indicating no prefix will be set by default. For example, the default settings might result in permissions Strings that look like this:topic:TEST:create temp-queue:MyQueue:remove topic:ActiveMQ.Advisory.*:read
However, if your application has any application-specific permissions that start with the tokenstopic
,temp-topic
,queue
, ortemp-queue
, you wouldn't be able to distinguish between application-specific permissions and those specific to ActiveMQ. In this case you might set thepermissionStringPrefix
. For example, if you set:resolver.setPermissionStringPrefix("jms");
, the above permission strings would look like this:jms:topic:TEST:create jms:temp-queue:MyQueue:remove jms:topic:ActiveMQ.Advisory.*:read
Similarly, if thepermissionStringPrefix
was equal toactiveMQ
:activeMQ:topic:TEST:create activeMQ:temp-queue:MyQueue:remove activeMQ:topic:ActiveMQ.Advisory.*:read
- Returns:
- any String prefix that should be automatically prepended to a permission String before the
String is converted to a
WildcardPermission
instance. Useful for namespacing permissions.
-
setPermissionStringPrefix
public void setPermissionStringPrefix(String permissionStringPrefix)
Sets the String prefix that should be automatically prepended to a permission String before the String is converted to aWildcardPermission
instance. This is convenient if you want to provide a 'scope' or 'namespace' for ActiveMQ Destinations to clearly distinguish ActiveMQ-specific permissions from any others you might assign to user accounts. The default value isnull
, indicating no prefix will be set by default. For example, the default settings might result in permissions Strings that look like this:topic:TEST:create temp-queue:MyQueue:remove topic:ActiveMQ.Advisory.*:read
However, if your application has any application-specific permissions that start with the tokenstopic
,temp-topic
,queue
, ortemp-queue
, you wouldn't be able to distinguish between application-specific permissions and those specific to ActiveMQ. In this case you might set thepermissionStringPrefix
. For example, if you set:resolver.setPermissionStringPrefix("jms");
, the above permission strings would look like this:jms:topic:TEST:create jms:temp-queue:MyQueue:remove jms:topic:ActiveMQ.Advisory.*:read
Similarly, if thepermissionStringPrefix
was equal toactiveMQ
:activeMQ:topic:TEST:create activeMQ:temp-queue:MyQueue:remove activeMQ:topic:ActiveMQ.Advisory.*:read
- Parameters:
permissionStringPrefix
- any String prefix that should be automatically prepended to a permission String before the String is converted to aWildcardPermission
instance. Useful for namespacing permissions.
-
isPermissionStringCaseSensitive
public boolean isPermissionStringCaseSensitive()
Returnstrue
if returnedWildcardPermission
instances should be considered case-sensitive,false
otherwise. The default value istrue
, which is not the normalWildcardPermission
default setting. This default was chosen to reflect ActiveMQ's case-sensitive destination names.- Returns:
true
if returnedWildcardPermission
instances should be considered case-sensitive,false
otherwise.
-
setPermissionStringCaseSensitive
public void setPermissionStringCaseSensitive(boolean permissionStringCaseSensitive)
Sets whether returnedWildcardPermission
instances should be considered case-sensitive. The default value istrue
, which is not the normalWildcardPermission
default setting. This default was chosen to accurately reflect ActiveMQ's case-sensitive destination names.- Parameters:
permissionStringCaseSensitive
- whether returnedWildcardPermission
instances should be considered case-sensitive.
-
getPermissions
public Collection<org.apache.shiro.authz.Permission> getPermissions(Action action)
Description copied from interface:ActionPermissionResolver
Returns allPermission
s that must be granted to aSubject
in order for theSubject
to execute the action, or an empty collection if no permissions are required. Most implementations will probably return a single Permission, but multiple permissions are possible, especially if the Action represents behavior attempted on a Composite Destination.- Specified by:
getPermissions
in interfaceActionPermissionResolver
- Parameters:
action
- the action attempted- Returns:
- all
Permission
s that must be granted to aSubject
in order for theSubject
to execute the action, or an empty collection if no permissions are required.
-
getPermissions
protected Collection<org.apache.shiro.authz.Permission> getPermissions(DestinationAction da)
-
createPermissions
protected Collection<org.apache.shiro.authz.Permission> createPermissions(ActiveMQDestination dest, String verb)
-
createPermissionString
protected String createPermissionString(ActiveMQDestination dest, String verb)
Inspects the specifieddestination
andverb
and returns aWildcardPermission
-compatible String the represents the action.Format
This implementation returns WildcardPermission strings with the following format:optionalPermissionStringPrefix + destinationType + ':' + destinationPhysicalName + ':' + actionVerb
where:optionalPermissionStringPrefix
is thepermissionStringPrefix
followed by a colon delimiter (':'). This is only present if thepermissionStringPrefix
has been specified and is non-nulldestinationType
is one of the following four string tokens:topic
temp-topic
queue
temp-queue
destination
is a topic, temporary topic, queue, or temporary queue (respectively).-
destinationPhysicalName
isdestination.getPhysicalName()
-
actionVerb
isaction.getVerb()
Examples
With the default settings (nopermissionStringPrefix
), this might produce strings that look like the following:topic:TEST:create temp-queue:MyTempQueue:remove queue:ActiveMQ.Advisory.*:read
IfpermissionStringPrefix
was set tojms
, the above examples would look like this:jms:topic:TEST:create jms:temp-queue:MyTempQueue:remove jms:queue:ActiveMQ.Advisory.*:read
- Parameters:
dest
- the destination to inspect and convert to aWildcardPermission
string.verb
- the behavior taken on the destination- Returns:
- a
WildcardPermission
string that represents the specifiedaction
. - See Also:
getPermissionStringPrefix() for more on why you might want to set this value
-
createPermission
protected org.apache.shiro.authz.Permission createPermission(String permissionString)
-
-