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
ADestinationActionPermissionResolverinspectsDestinationActions and returns one or moreWildcardPermissions that must be granted to aSubjectin order for thatSubjectto perform the action being taken on anActiveMQDestination. See thecreatePermissionString documentationto see what the resultingWildcardPermissioninstances 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.PermissioncreatePermission(String permissionString)protected Collection<org.apache.shiro.authz.Permission>createPermissions(ActiveMQDestination dest, String verb)protected StringcreatePermissionString(ActiveMQDestination dest, String verb)Inspects the specifieddestinationandverband returns aWildcardPermission-compatible String the represents the action.Collection<org.apache.shiro.authz.Permission>getPermissions(Action action)Returns allPermissions that must be granted to aSubjectin order for theSubjectto execute the action, or an empty collection if no permissions are required.protected Collection<org.apache.shiro.authz.Permission>getPermissions(DestinationAction da)StringgetPermissionStringPrefix()Returns the String prefix that should be automatically prepended to a permission String before the String is converted to aWildcardPermissioninstance.booleanisPermissionStringCaseSensitive()Returnstrueif returnedWildcardPermissioninstances should be considered case-sensitive,falseotherwise.voidsetPermissionStringCaseSensitive(boolean permissionStringCaseSensitive)Sets whether returnedWildcardPermissioninstances should be considered case-sensitive.voidsetPermissionStringPrefix(String permissionStringPrefix)Sets the String prefix that should be automatically prepended to a permission String before the String is converted to aWildcardPermissioninstance.
-
-
-
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 aWildcardPermissioninstance. 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 thepermissionStringPrefixwas 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
WildcardPermissioninstance. 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 aWildcardPermissioninstance. 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 thepermissionStringPrefixwas 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 aWildcardPermissioninstance. Useful for namespacing permissions.
-
isPermissionStringCaseSensitive
public boolean isPermissionStringCaseSensitive()
Returnstrueif returnedWildcardPermissioninstances should be considered case-sensitive,falseotherwise. The default value istrue, which is not the normalWildcardPermissiondefault setting. This default was chosen to reflect ActiveMQ's case-sensitive destination names.- Returns:
trueif returnedWildcardPermissioninstances should be considered case-sensitive,falseotherwise.
-
setPermissionStringCaseSensitive
public void setPermissionStringCaseSensitive(boolean permissionStringCaseSensitive)
Sets whether returnedWildcardPermissioninstances should be considered case-sensitive. The default value istrue, which is not the normalWildcardPermissiondefault setting. This default was chosen to accurately reflect ActiveMQ's case-sensitive destination names.- Parameters:
permissionStringCaseSensitive- whether returnedWildcardPermissioninstances should be considered case-sensitive.
-
getPermissions
public Collection<org.apache.shiro.authz.Permission> getPermissions(Action action)
Description copied from interface:ActionPermissionResolverReturns allPermissions that must be granted to aSubjectin order for theSubjectto 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:
getPermissionsin interfaceActionPermissionResolver- Parameters:
action- the action attempted- Returns:
- all
Permissions that must be granted to aSubjectin order for theSubjectto 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 specifieddestinationandverband returns aWildcardPermission-compatible String the represents the action.Format
This implementation returns WildcardPermission strings with the following format:optionalPermissionStringPrefix + destinationType + ':' + destinationPhysicalName + ':' + actionVerb
where:optionalPermissionStringPrefixis thepermissionStringPrefixfollowed by a colon delimiter (':'). This is only present if thepermissionStringPrefixhas been specified and is non-nulldestinationTypeis one of the following four string tokens:topictemp-topicqueuetemp-queue
destinationis a topic, temporary topic, queue, or temporary queue (respectively).-
destinationPhysicalNameisdestination.getPhysicalName() -
actionVerbisaction.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
IfpermissionStringPrefixwas 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 aWildcardPermissionstring.verb- the behavior taken on the destination- Returns:
- a
WildcardPermissionstring 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)
-
-