Package org.apache.activemq.shiro.authz
Class AuthorizationFilter
- java.lang.Object
-
- org.apache.activemq.broker.BrokerFilter
-
- org.apache.activemq.broker.MutableBrokerFilter
-
- org.apache.activemq.shiro.SecurityFilter
-
- org.apache.activemq.shiro.env.EnvironmentFilter
-
- org.apache.activemq.shiro.authz.AuthorizationFilter
-
public class AuthorizationFilter extends EnvironmentFilter
TheAuthorizationFilterasserts that actions are allowed to execute first before they are actually executed. Such actions include creating, removing, reading from and writing to destinations. This implementation is strictly permission-based, allowing for the finest-grained security policies possible. Whenever aSubjectassociated with a connection attempts to perform anAction(such as creating a destination, or reading from a queue, etc), one or morePermissions representing thatactionare checked. If theSubjectisPermittedto perform theaction, the action is allowed to execute and the broker filter chain executes uninterrupted. However, if theSubjectis not permitted to perform the action, anUnauthorizedExceptionwill be thrown, preventing the filter chain from executing that action.ActionPermissionResolver
The attemptedActionis guarded by one or morePermissions as indicated by a configurableactionPermissionResolver. TheactionPermissionResolverindicates which permissions must be granted to the connectionSubjectin order for the action to execute. The defaultactionPermissionResolverinstance is aDestinationActionPermissionResolver, which indicates which permissions are required to perform any action on a particular destination. Those familiar with Shiro'sWildcardPermissionsyntax will find theDestinationActionPermissionResolver'screatePermissionStringmethod documentation valuable for understanding how destination actions are represented as permissions.- Since:
- 5.10.0
- See Also:
ActionPermissionResolver,DestinationActionPermissionResolver
-
-
Field Summary
-
Fields inherited from class org.apache.activemq.broker.MutableBrokerFilter
next
-
-
Constructor Summary
Constructors Constructor Description AuthorizationFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SubscriptionaddConsumer(ConnectionContext context, org.apache.activemq.command.ConsumerInfo info)DestinationaddDestination(ConnectionContext context, org.apache.activemq.command.ActiveMQDestination destination, boolean create)voidaddDestinationInfo(ConnectionContext context, org.apache.activemq.command.DestinationInfo info)voidaddProducer(ConnectionContext context, org.apache.activemq.command.ProducerInfo info)protected voidassertAuthorized(DestinationAction action)protected voidassertAuthorized(DestinationAction action, String verbText)protected StringcreateUnauthorizedMessage(org.apache.shiro.subject.Subject subject, DestinationAction action, String verbDisplayText)ActionPermissionResolvergetActionPermissionResolver()Returns theActionPermissionResolverused to indicate which permissions are required to be granted to aSubjectto perform a particular destinationAction, (such as creating a destination, or reading from a queue, etc).protected org.apache.shiro.subject.SubjectgetSubject(ConnectionContext ctx)Returns theSubjectassociated with the specified connection using aConnectionSubjectResolver.protected booleanisSystemBroker(DestinationAction action)voidremoveDestination(ConnectionContext context, org.apache.activemq.command.ActiveMQDestination destination, long timeout)voidremoveDestinationInfo(ConnectionContext context, org.apache.activemq.command.DestinationInfo info)voidsend(ProducerBrokerExchange exchange, org.apache.activemq.command.Message message)voidsetActionPermissionResolver(ActionPermissionResolver actionPermissionResolver)Sets theActionPermissionResolverused to indicate which permissions are required to be granted to aSubjectto perform a particular destinationAction, (such as creating a destination, or reading from a queue, etc).protected StringtoString(org.apache.shiro.subject.Subject subject)-
Methods inherited from class org.apache.activemq.shiro.env.EnvironmentFilter
getEnvironment, setEnvironment
-
Methods inherited from class org.apache.activemq.shiro.SecurityFilter
isEnabled, setEnabled
-
Methods inherited from class org.apache.activemq.broker.MutableBrokerFilter
getAdaptor, getNext, setNext
-
Methods inherited from class org.apache.activemq.broker.BrokerFilter
acknowledge, addBroker, addConnection, addSession, beginTransaction, brokerServiceStarted, commitTransaction, fastProducer, forgetTransaction, gc, getAdminConnectionContext, getBrokerId, getBrokerName, getBrokerSequenceId, getBrokerService, getClients, getDestinationMap, getDestinationMap, getDestinations, getDestinations, getDurableDestinations, getExecutor, getPeerBrokerInfos, getPreparedTransactions, getRoot, getScheduler, getTempDataStore, getVmConnectorURI, isExpired, isFaultTolerantConfiguration, isFull, isStopped, messageConsumed, messageDelivered, messageDiscarded, messageDispatched, messageExpired, messagePull, networkBridgeStarted, networkBridgeStopped, nowMasterBroker, postProcessDispatch, prepareTransaction, preProcessDispatch, processConsumerControl, processDispatchNotification, reapplyInterceptor, removeBroker, removeConnection, removeConsumer, removeProducer, removeSession, removeSubscription, rollbackTransaction, sendToDeadLetterQueue, setAdminConnectionContext, slowConsumer, start, stop, virtualDestinationAdded, virtualDestinationRemoved
-
-
-
-
Method Detail
-
getActionPermissionResolver
public ActionPermissionResolver getActionPermissionResolver()
Returns theActionPermissionResolverused to indicate which permissions are required to be granted to aSubjectto perform a particular destinationAction, (such as creating a destination, or reading from a queue, etc). The default instance is aDestinationActionPermissionResolver.- Returns:
- the
ActionPermissionResolverused to indicate which permissions are required to be granted to aSubjectto perform a particular destinationAction, (such as creating a destination, or reading from a queue, etc).
-
setActionPermissionResolver
public void setActionPermissionResolver(ActionPermissionResolver actionPermissionResolver)
Sets theActionPermissionResolverused to indicate which permissions are required to be granted to aSubjectto perform a particular destinationAction, (such as creating a destination, or reading from a queue, etc). Unless overridden by this method, the default instance is aDestinationActionPermissionResolver.- Parameters:
actionPermissionResolver- theActionPermissionResolverused to indicate which permissions are required to be granted to aSubjectto perform a particular destinationAction, (such as creating a destination, or reading from a queue, etc).
-
getSubject
protected org.apache.shiro.subject.Subject getSubject(ConnectionContext ctx)
Returns theSubjectassociated with the specified connection using aConnectionSubjectResolver.- Parameters:
ctx- the connection context- Returns:
- the
Subjectassociated with the specified connection.
-
toString
protected String toString(org.apache.shiro.subject.Subject subject)
-
assertAuthorized
protected void assertAuthorized(DestinationAction action)
-
isSystemBroker
protected boolean isSystemBroker(DestinationAction action)
-
assertAuthorized
protected void assertAuthorized(DestinationAction action, String verbText)
-
createUnauthorizedMessage
protected String createUnauthorizedMessage(org.apache.shiro.subject.Subject subject, DestinationAction action, String verbDisplayText)
-
addDestinationInfo
public void addDestinationInfo(ConnectionContext context, org.apache.activemq.command.DestinationInfo info) throws Exception
- Specified by:
addDestinationInfoin interfaceBroker- Overrides:
addDestinationInfoin classBrokerFilter- Throws:
Exception
-
addDestination
public Destination addDestination(ConnectionContext context, org.apache.activemq.command.ActiveMQDestination destination, boolean create) throws Exception
- Specified by:
addDestinationin interfaceRegion- Overrides:
addDestinationin classBrokerFilter- Throws:
Exception
-
removeDestination
public void removeDestination(ConnectionContext context, org.apache.activemq.command.ActiveMQDestination destination, long timeout) throws Exception
- Specified by:
removeDestinationin interfaceRegion- Overrides:
removeDestinationin classBrokerFilter- Throws:
Exception
-
removeDestinationInfo
public void removeDestinationInfo(ConnectionContext context, org.apache.activemq.command.DestinationInfo info) throws Exception
- Specified by:
removeDestinationInfoin interfaceBroker- Overrides:
removeDestinationInfoin classBrokerFilter- Throws:
Exception
-
addConsumer
public Subscription addConsumer(ConnectionContext context, org.apache.activemq.command.ConsumerInfo info) throws Exception
- Specified by:
addConsumerin interfaceRegion- Overrides:
addConsumerin classBrokerFilter- Throws:
Exception
-
addProducer
public void addProducer(ConnectionContext context, org.apache.activemq.command.ProducerInfo info) throws Exception
- Specified by:
addProducerin interfaceBroker- Specified by:
addProducerin interfaceRegion- Overrides:
addProducerin classBrokerFilter- Throws:
Exception
-
send
public void send(ProducerBrokerExchange exchange, org.apache.activemq.command.Message message) throws Exception
- Specified by:
sendin interfaceRegion- Overrides:
sendin classBrokerFilter- Throws:
Exception
-
-