View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.shiro.web.config;
20  
21  import org.apache.shiro.config.Ini;
22  import org.apache.shiro.config.IniSecurityManagerFactory;
23  import org.apache.shiro.mgt.SecurityManager;
24  import org.apache.shiro.web.filter.mgt.DefaultFilter;
25  import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
26  
27  import javax.servlet.Filter;
28  import java.util.Map;
29  
30  /**
31   * Differs from the parent class only in the {@link #createDefaultInstance()} method, to
32   * ensure a web-capable {@code SecurityManager} instance is created by default.
33   *
34   * @since 1.0
35   * @deprecated use Shiro's {@code Environment} mechanisms instead.
36   */
37  @Deprecated
38  public class WebIniSecurityManagerFactory extends IniSecurityManagerFactory {
39  
40      /**
41       * Creates a new {@code WebIniSecurityManagerFactory} instance which will construct web-capable
42       * {@code SecurityManager} instances.
43       */
44      public WebIniSecurityManagerFactory() {
45          super();
46      }
47  
48      /**
49       * Creates a new {@code WebIniSecurityManagerFactory} instance which will construct web-capable
50       * {@code SecurityManager} instances.  Uses the given {@link Ini} instance to construct the instance.
51       *
52       * @param config the Ini configuration that will be used to construct new web-capable {@code SecurityManager}
53       *               instances.
54       */
55      public WebIniSecurityManagerFactory(Ini config) {
56          super(config);
57      }
58  
59      /**
60       * Simply returns <code>new {@link DefaultWebSecurityManager}();</code> to ensure a web-capable
61       * {@code SecurityManager} is available by default.
62       *
63       * @return a new web-capable {@code SecurityManager} instance.
64       */
65      @Override
66      protected SecurityManager createDefaultInstance() {
67          return new DefaultWebSecurityManager();
68      }
69  
70      @SuppressWarnings({"unchecked"})
71      @Override
72      protected Map<String, ?> createDefaults(Ini ini, Ini.Section mainSection) {
73          Map defaults = super.createDefaults(ini, mainSection);
74          //add the default filters:
75          Map<String, Filter> defaultFilters = DefaultFilter.createInstanceMap(null);
76          defaults.putAll(defaultFilters);
77          return defaults;
78      }
79  }