001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019 package org.tynamo.security.services.impl;
020
021 import java.util.ArrayList;
022 import java.util.HashMap;
023 import java.util.List;
024 import java.util.Map;
025
026 import org.tynamo.shiro.extension.authz.aop.SecurityInterceptor;
027 import org.tynamo.security.services.ClassInterceptorsCache;
028
029 /**
030 * @see ClassInterceptorsCache
031 */
032 public class ClassInterceptorsCacheImpl implements ClassInterceptorsCache {
033
034 private final Map<String, List<SecurityInterceptor>> cache =
035 new HashMap<String, List<SecurityInterceptor>>();
036
037 @Override
038 public void add(String className, SecurityInterceptor interceptor) {
039 List<SecurityInterceptor> interceptors = cache.get(className);
040 if (interceptors == null) {
041 interceptors = new ArrayList<SecurityInterceptor>();
042 cache.put(className, interceptors);
043 }
044 interceptors.add(interceptor);
045 }
046
047 @Override
048 public List<SecurityInterceptor> get(String className) {
049 return cache.get(className);
050 }
051
052 @Override
053 public void put(String className, List<SecurityInterceptor> interceptors) {
054 cache.put(className, interceptors);
055 }
056 }