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 */ 017 package org.apache.activemq.security; 018 019 import java.util.Set; 020 021 import org.apache.activemq.command.ActiveMQDestination; 022 import org.apache.activemq.filter.DestinationMap; 023 024 /** 025 * An AuthorizationMap which is configured with individual DestinationMaps for 026 * each operation. 027 * 028 * @org.apache.xbean.XBean 029 * 030 * @version $Revision: 564814 $ 031 */ 032 public class SimpleAuthorizationMap implements AuthorizationMap { 033 034 private DestinationMap writeACLs; 035 private DestinationMap readACLs; 036 private DestinationMap adminACLs; 037 038 private TempDestinationAuthorizationEntry tempDestinationAuthorizationEntry; 039 040 public SimpleAuthorizationMap() { 041 } 042 043 public SimpleAuthorizationMap(DestinationMap writeACLs, DestinationMap readACLs, DestinationMap adminACLs) { 044 this.writeACLs = writeACLs; 045 this.readACLs = readACLs; 046 this.adminACLs = adminACLs; 047 } 048 049 /* 050 * Need to think how to retrieve the ACLs for temporary destinations since 051 * they are not map to a specific destination. For now we'll just retrieve 052 * it from a TempDestinationAuthorizationEntry same way as the 053 * DefaultAuthorizationMap. The ACLs retrieved here will be map to all temp 054 * destinations 055 */ 056 057 public void setTempDestinationAuthorizationEntry( 058 TempDestinationAuthorizationEntry tempDestinationAuthorizationEntry) { 059 this.tempDestinationAuthorizationEntry = tempDestinationAuthorizationEntry; 060 } 061 062 public TempDestinationAuthorizationEntry getTempDestinationAuthorizationEntry() { 063 return this.tempDestinationAuthorizationEntry; 064 } 065 066 public Set<Object> getTempDestinationAdminACLs() { 067 if (tempDestinationAuthorizationEntry != null) { 068 return tempDestinationAuthorizationEntry.getAdminACLs(); 069 } else { 070 return null; 071 } 072 } 073 074 public Set<Object> getTempDestinationReadACLs() { 075 if (tempDestinationAuthorizationEntry != null) { 076 return tempDestinationAuthorizationEntry.getReadACLs(); 077 } else { 078 return null; 079 } 080 } 081 082 public Set<Object> getTempDestinationWriteACLs() { 083 if (tempDestinationAuthorizationEntry != null) { 084 return tempDestinationAuthorizationEntry.getWriteACLs(); 085 } else { 086 return null; 087 } 088 } 089 090 @SuppressWarnings("unchecked") 091 public Set<Object> getAdminACLs(ActiveMQDestination destination) { 092 return adminACLs.get(destination); 093 } 094 095 @SuppressWarnings("unchecked") 096 public Set<Object> getReadACLs(ActiveMQDestination destination) { 097 return readACLs.get(destination); 098 } 099 100 @SuppressWarnings("unchecked") 101 public Set<Object> getWriteACLs(ActiveMQDestination destination) { 102 return writeACLs.get(destination); 103 } 104 105 public DestinationMap getAdminACLs() { 106 return adminACLs; 107 } 108 109 public void setAdminACLs(DestinationMap adminACLs) { 110 this.adminACLs = adminACLs; 111 } 112 113 public DestinationMap getReadACLs() { 114 return readACLs; 115 } 116 117 public void setReadACLs(DestinationMap readACLs) { 118 this.readACLs = readACLs; 119 } 120 121 public DestinationMap getWriteACLs() { 122 return writeACLs; 123 } 124 125 public void setWriteACLs(DestinationMap writeACLs) { 126 this.writeACLs = writeACLs; 127 } 128 129 }