Repository: karaf
Updated Branches:
  refs/heads/master 7eea1ff73 -> 040c805f4


[KARAF-4784] OsgiConfiguration for JAAS should fallback to default configuration

Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/040c805f
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/040c805f
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/040c805f

Branch: refs/heads/master
Commit: 040c805f47abe0f0a3fd18258e14bec5f4bca5a8
Parents: 7eea1ff
Author: Guillaume Nodet <gno...@apache.org>
Authored: Thu Dec 1 17:14:00 2016 +0100
Committer: Guillaume Nodet <gno...@apache.org>
Committed: Thu Dec 1 17:14:36 2016 +0100

----------------------------------------------------------------------
 .../karaf/jaas/config/impl/OsgiConfiguration.java       | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/040c805f/jaas/config/src/main/java/org/apache/karaf/jaas/config/impl/OsgiConfiguration.java
----------------------------------------------------------------------
diff --git 
a/jaas/config/src/main/java/org/apache/karaf/jaas/config/impl/OsgiConfiguration.java
 
b/jaas/config/src/main/java/org/apache/karaf/jaas/config/impl/OsgiConfiguration.java
index 6c995ba..522507d 100644
--- 
a/jaas/config/src/main/java/org/apache/karaf/jaas/config/impl/OsgiConfiguration.java
+++ 
b/jaas/config/src/main/java/org/apache/karaf/jaas/config/impl/OsgiConfiguration.java
@@ -23,18 +23,26 @@ import javax.security.auth.login.Configuration;
 
 import org.apache.karaf.jaas.config.JaasRealm;
 import org.apache.karaf.util.collections.CopyOnWriteArrayIdentityList;
+import org.slf4j.LoggerFactory;
 
 public class OsgiConfiguration extends Configuration {
 
     private final List<JaasRealm> realms = new 
CopyOnWriteArrayIdentityList<JaasRealm>();
+    private Configuration defaultConfiguration;
 
     public void init() {
+        try {
+            defaultConfiguration = Configuration.getConfiguration();
+        } catch (Throwable ex) {
+            // default configuration for fallback could not be retrieved
+            LoggerFactory.getLogger(OsgiConfiguration.class).warn("Unable to 
retrieve default configuration", ex);
+        }
         Configuration.setConfiguration(this);
     }
 
     public void close() {
         realms.clear();
-        Configuration.setConfiguration(null);
+        Configuration.setConfiguration(defaultConfiguration);
     }
 
     public void register(JaasRealm realm, Map<String,?> properties) {
@@ -60,6 +68,8 @@ public class OsgiConfiguration extends Configuration {
         }
         if (realm != null) {
             return realm.getEntries();
+        } else if (defaultConfiguration != null) {
+            return defaultConfiguration.getAppConfigurationEntry(name);
         }
         return null;
     }

Reply via email to