shiro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdem...@apache.org
Subject [17/20] shiro git commit: SHIRO-593 - Moved 'defaultBeans' to IniFactorySupport
Date Fri, 14 Oct 2016 19:36:20 GMT
SHIRO-593 - Moved 'defaultBeans' to IniFactorySupport


Project: http://git-wip-us.apache.org/repos/asf/shiro/repo
Commit: http://git-wip-us.apache.org/repos/asf/shiro/commit/48887a59
Tree: http://git-wip-us.apache.org/repos/asf/shiro/tree/48887a59
Diff: http://git-wip-us.apache.org/repos/asf/shiro/diff/48887a59

Branch: refs/heads/1.4.x
Commit: 48887a595eb524d3b7fdf7f72472d511615d467c
Parents: f48a8de
Author: Brian Demers <bdemers@apache.org>
Authored: Mon Sep 26 21:30:52 2016 -0400
Committer: Brian Demers <bdemers@apache.org>
Committed: Fri Oct 14 15:15:51 2016 -0400

----------------------------------------------------------------------
 .../apache/shiro/config/IniFactorySupport.java  | 25 ++++++++++++++++++++
 .../shiro/config/IniSecurityManagerFactory.java |  6 +++++
 .../config/IniFilterChainResolverFactory.java   |  9 ++++---
 3 files changed, 35 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/shiro/blob/48887a59/core/src/main/java/org/apache/shiro/config/IniFactorySupport.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/shiro/config/IniFactorySupport.java b/core/src/main/java/org/apache/shiro/config/IniFactorySupport.java
index ad91ee7..959996d 100644
--- a/core/src/main/java/org/apache/shiro/config/IniFactorySupport.java
+++ b/core/src/main/java/org/apache/shiro/config/IniFactorySupport.java
@@ -25,6 +25,9 @@ import org.apache.shiro.util.Factory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * Base support class for {@link Factory} implementations that generate their instance(s)
based on
  * {@link Ini} configuration.
@@ -39,6 +42,8 @@ public abstract class IniFactorySupport<T> extends AbstractFactory<T>
{
 
     private Ini ini;
 
+    private Map<String, ?> defaultBeans;
+
     protected IniFactorySupport() {
     }
 
@@ -55,6 +60,26 @@ public abstract class IniFactorySupport<T> extends AbstractFactory<T>
{
     }
 
     /**
+     * Returns a mapping of String to bean representing the default set of object used by
the factory.
+     * These beans can be used by this factory in conjunction with objects parsed from the
INI configuration.
+     * @return A Map of default objects, or <code>null</code>.
+     * @since 1.4
+     */
+    protected Map<String, ?> getDefaults() {
+        return defaultBeans;
+    }
+
+    /**
+     * Sets the default objects used by this factory. These defaults may be used in conjunction
with the INI
+     * configuration.
+     * @param defaultBeans String to object mapping used for default configuration in this
factory.
+     * @since 1.4
+     */
+    public void setDefaults(Map<String, ?> defaultBeans) {
+        this.defaultBeans = defaultBeans;
+    }
+
+    /**
      * Returns a new Ini instance created from the default {@code classpath:shiro.ini} file,
or {@code null} if
      * the file does not exist.
      *

http://git-wip-us.apache.org/repos/asf/shiro/blob/48887a59/core/src/main/java/org/apache/shiro/config/IniSecurityManagerFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/shiro/config/IniSecurityManagerFactory.java b/core/src/main/java/org/apache/shiro/config/IniSecurityManagerFactory.java
index 6a30f0a..6ff6e64 100644
--- a/core/src/main/java/org/apache/shiro/config/IniSecurityManagerFactory.java
+++ b/core/src/main/java/org/apache/shiro/config/IniSecurityManagerFactory.java
@@ -159,6 +159,12 @@ public class IniSecurityManagerFactory extends IniFactorySupport<SecurityManager
             }
         }
 
+        // The values from 'getDefaults()' will override the above.
+        Map<String, ?> defaultBeans = getDefaults();
+        if (!CollectionUtils.isEmpty(defaultBeans)) {
+            defaults.putAll(defaultBeans);
+        }
+
         return defaults;
     }
 

http://git-wip-us.apache.org/repos/asf/shiro/blob/48887a59/web/src/main/java/org/apache/shiro/web/config/IniFilterChainResolverFactory.java
----------------------------------------------------------------------
diff --git a/web/src/main/java/org/apache/shiro/web/config/IniFilterChainResolverFactory.java
b/web/src/main/java/org/apache/shiro/web/config/IniFilterChainResolverFactory.java
index ad7e7f0..fb9f822 100644
--- a/web/src/main/java/org/apache/shiro/web/config/IniFilterChainResolverFactory.java
+++ b/web/src/main/java/org/apache/shiro/web/config/IniFilterChainResolverFactory.java
@@ -49,8 +49,6 @@ public class IniFilterChainResolverFactory extends IniFactorySupport<FilterChain
 
     private FilterConfig filterConfig;
 
-    private Map<String, ?> defaultBeans;
-
     public IniFilterChainResolverFactory() {
         super();
     }
@@ -61,7 +59,7 @@ public class IniFilterChainResolverFactory extends IniFactorySupport<FilterChain
 
     public IniFilterChainResolverFactory(Ini ini, Map<String, ?> defaultBeans) {
         this(ini);
-        this.defaultBeans = defaultBeans;
+        this.setDefaults(defaultBeans);
     }
 
     public FilterConfig getFilterConfig() {
@@ -113,8 +111,9 @@ public class IniFilterChainResolverFactory extends IniFactorySupport<FilterChain
         }
         //User-provided objects must come _after_ the default filters - to allow the user-provided
         //ones to override the default filters if necessary.
-        if (!CollectionUtils.isEmpty(this.defaultBeans)) {
-            defaults.putAll(this.defaultBeans);
+        Map<String, ?> defaultBeans = getDefaults();
+        if (!CollectionUtils.isEmpty(defaultBeans)) {
+            defaults.putAll(defaultBeans);
         }
 
         Map<String, Filter> filters = getFilters(section, defaults);


Mime
View raw message