001 /**
002 *
003 * Copyright 2004 Protique Ltd
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * 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 *
017 **/
018 package org.activemq.security;
019
020 import org.activemq.broker.BrokerClient;
021 import org.activemq.message.ActiveMQMessage;
022 import org.activemq.message.ConnectionInfo;
023 import org.activemq.message.ConsumerInfo;
024 import org.activemq.message.ProducerInfo;
025
026 import javax.jms.JMSException;
027
028 /**
029 * A pluggable strategy to authenticate new connections and authorize
030 * the connection and producer and consumer on destinations
031 *
032 * @version $Revision: 1.1.1.1 $
033 */
034 public interface SecurityAdapter {
035
036 /**
037 * Authenticates the connection and authorizes it for use with this
038 * Message Broker
039 *
040 * @throws JMSException if the connection is not allowed for any reason
041 */
042 public void authorizeConnection(BrokerClient client, ConnectionInfo info) throws JMSException;
043
044 /**
045 * Authorizes that the consumer can start with the given consumer information
046 *
047 * @throws JMSException if the connection is not allowed for any reason
048 */
049 public void authorizeConsumer(BrokerClient client, ConsumerInfo info) throws JMSException;
050
051 /**
052 * Authorizes that the prodcuer can start with the given producer information.
053 * Note that the destination information may not be present at the start of the producer.
054 *
055 * @throws JMSException if the connection is not allowed for any reason
056 */
057 public void authorizeProducer(BrokerClient client, ProducerInfo info) throws JMSException;
058
059 /**
060 * Authorizes on a per message basis whether or not the client is allowed to send the given
061 * message. The client may not have been authorized yet for this destination as a destination
062 * may not have been specified on the previous call to
063 * {@link #authorizeProducer(org.activemq.broker.BrokerClient, org.activemq.message.ProducerInfo)}
064 */
065 public void authorizeSendMessage(BrokerClient client, ActiveMQMessage message) throws JMSException;
066
067 /**
068 * Returns true if the given client is authorized to receive the given message.
069 *
070 * @param client the client
071 * @param message the message to be delivered
072 * @return true if the client can receive the given message
073 */
074 public boolean authorizeReceive(BrokerClient client, ActiveMQMessage message);
075 }