001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.activemq.shiro.authz; 018 019import org.apache.activemq.broker.ConnectionContext; 020import org.apache.activemq.command.ActiveMQDestination; 021 022/** 023 * A {@code DestinationAction} represents behavior being taken on a particular {@link ActiveMQDestination}, such as 024 * creation, removal, and reading messages from it or writing messages to it. The exact behavior being taken on the 025 * specific {@link #getDestination() destination} is represented as a {@link #getVerb() verb} property, which is one of 026 * the following string tokens: 027 * <table> 028 * <tr> 029 * <th>Verb</th> 030 * <th>Description</th> 031 * </tr> 032 * <tr> 033 * <td>{@code create}</td> 034 * <td>Create a specific destination.</td> 035 * </tr> 036 * <tr> 037 * <td>{@code remove}</td> 038 * <td>Remove a specific destination.</td> 039 * </tr> 040 * <tr> 041 * <td>{@code read}</td> 042 * <td>Read (consume) messages from a specific destination.</td> 043 * </tr> 044 * <tr> 045 * <td>{@code write}</td> 046 * <td>Write messages to a specific destination.</td> 047 * </tr> 048 * </table> 049 * 050 * @since 5.10.0 051 */ 052public class DestinationAction implements Action { 053 054 private final ConnectionContext connectionContext; 055 private final ActiveMQDestination destination; 056 private final String verb; 057 058 public DestinationAction(ConnectionContext connectionContext, ActiveMQDestination destination, String verb) { 059 if (connectionContext == null) { 060 throw new IllegalArgumentException("ConnectionContext argument cannot be null."); 061 } 062 if (destination == null) { 063 throw new IllegalArgumentException("ActiveMQDestination argument cannot be null."); 064 } 065 if (verb == null) { 066 throw new IllegalArgumentException("verb argument cannot be null."); 067 } 068 069 this.connectionContext = connectionContext; 070 this.destination = destination; 071 this.verb = verb; 072 } 073 074 public ConnectionContext getConnectionContext() { 075 return connectionContext; 076 } 077 078 public ActiveMQDestination getDestination() { 079 return destination; 080 } 081 082 public String getVerb() { 083 return verb; 084 } 085 086 @Override 087 public String toString() { 088 return this.verb + " destination: " + destination; 089 } 090}