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 */ 019package org.apache.shiro.web.config; 020 021import org.apache.shiro.config.Ini; 022import org.apache.shiro.config.IniSecurityManagerFactory; 023import org.apache.shiro.mgt.SecurityManager; 024import org.apache.shiro.web.filter.mgt.DefaultFilter; 025import org.apache.shiro.web.mgt.DefaultWebSecurityManager; 026 027import javax.servlet.Filter; 028import java.util.Map; 029 030/** 031 * Differs from the parent class only in the {@link #createDefaultInstance()} method, to 032 * ensure a web-capable {@code SecurityManager} instance is created by default. 033 * 034 * @since 1.0 035 * @deprecated use Shiro's {@code Environment} mechanisms instead. 036 */ 037@Deprecated 038public class WebIniSecurityManagerFactory extends IniSecurityManagerFactory { 039 040 /** 041 * Creates a new {@code WebIniSecurityManagerFactory} instance which will construct web-capable 042 * {@code SecurityManager} instances. 043 */ 044 public WebIniSecurityManagerFactory() { 045 super(); 046 } 047 048 /** 049 * Creates a new {@code WebIniSecurityManagerFactory} instance which will construct web-capable 050 * {@code SecurityManager} instances. Uses the given {@link Ini} instance to construct the instance. 051 * 052 * @param config the Ini configuration that will be used to construct new web-capable {@code SecurityManager} 053 * instances. 054 */ 055 public WebIniSecurityManagerFactory(Ini config) { 056 super(config); 057 } 058 059 /** 060 * Simply returns <code>new {@link DefaultWebSecurityManager}();</code> to ensure a web-capable 061 * {@code SecurityManager} is available by default. 062 * 063 * @return a new web-capable {@code SecurityManager} instance. 064 */ 065 @Override 066 protected SecurityManager createDefaultInstance() { 067 return new DefaultWebSecurityManager(); 068 } 069 070 @SuppressWarnings({"unchecked"}) 071 @Override 072 protected Map<String, ?> createDefaults(Ini ini, Ini.Section mainSection) { 073 Map defaults = super.createDefaults(ini, mainSection); 074 //add the default filters: 075 Map<String, Filter> defaultFilters = DefaultFilter.createInstanceMap(null); 076 defaults.putAll(defaultFilters); 077 return defaults; 078 } 079}