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
The
AuthorizationFilter asserts 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 a Subject associated with a connection attempts to perform an Action (such as creating a
destination, or reading from a queue, etc), one or more Permissions representing that action are
checked.
If the SubjectisPermitted to perform the
action, the action is allowed to execute and the broker filter chain executes uninterrupted.
However, if the Subject is not permitted to perform the action, an UnauthorizedException will be
thrown, preventing the filter chain from executing that action.
ActionPermissionResolver
The attemptedAction is guarded by one or more Permissions as indicated by a configurable
actionPermissionResolver. The
actionPermissionResolver indicates which permissions must be granted to the connection Subject in
order for the action to execute.
The default actionPermissionResolver instance is a
DestinationActionPermissionResolver, which indicates which permissions
are required to perform any action on a particular destination. Those familiar with Shiro's
WildcardPermission syntax will find the
DestinationActionPermissionResolver's
createPermissionString method
documentation valuable for understanding how destination actions are represented as permissions.- Since:
- 5.10.0
- See Also:
-
Field Summary
Fields inherited from class org.apache.activemq.broker.MutableBrokerFilter
next -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddConsumer(ConnectionContext context, org.apache.activemq.command.ConsumerInfo info) addDestination(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) 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.SubjectReturns 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, setEnvironmentMethods inherited from class org.apache.activemq.shiro.SecurityFilter
isEnabled, setEnabledMethods inherited from class org.apache.activemq.broker.MutableBrokerFilter
getAdaptor, getNext, setNextMethods 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
-
Constructor Details
-
AuthorizationFilter
public AuthorizationFilter()
-
-
Method Details
-
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
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
Returns theSubjectassociated with the specified connection using aConnectionSubjectResolver.- Parameters:
ctx- the connection context- Returns:
- the
Subjectassociated with the specified connection.
-
toString
-
assertAuthorized
-
isSystemBroker
-
assertAuthorized
-
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
-