Package org.apache.activemq.shiro.authz
Class DestinationActionPermissionResolver
java.lang.Object
org.apache.activemq.shiro.authz.DestinationActionPermissionResolver
- All Implemented Interfaces:
ActionPermissionResolver
A
DestinationActionPermissionResolver inspects DestinationActions and returns one or more
WildcardPermissions that must be granted to a Subject in order for that Subject to
perform the action being taken on an ActiveMQDestination.
See the createPermissionString documentation to see what the
resulting WildcardPermission instances would look like.- Since:
- 5.10.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.shiro.authz.PermissioncreatePermission(String permissionString) protected Collection<org.apache.shiro.authz.Permission>createPermissions(org.apache.activemq.command.ActiveMQDestination dest, String verb) protected StringcreatePermissionString(org.apache.activemq.command.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>Returns the String prefix that should be automatically prepended to a permission String before the String is converted to aWildcardPermissioninstance.booleanReturnstrueif 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.
-
Constructor Details
-
DestinationActionPermissionResolver
public DestinationActionPermissionResolver()
-
-
Method Details
-
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
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
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
-
createPermissions
protected Collection<org.apache.shiro.authz.Permission> createPermissions(org.apache.activemq.command.ActiveMQDestination dest, String verb) -
createPermissionString
protected String createPermissionString(org.apache.activemq.command.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:
-
createPermission
-