diff options
author | Jan Bartel | 2013-08-01 01:56:13 +0000 |
---|---|---|
committer | Jan Bartel | 2013-08-01 01:56:13 +0000 |
commit | e87eee1b4605249acda549c583ade23f7ca2654b (patch) | |
tree | 746ddd953ac230d1f1bb369d7f5d35e3d4408e66 | |
parent | b706f541ecb795403171b0d33e24674212aa89a3 (diff) | |
download | org.eclipse.jetty.project-e87eee1b4605249acda549c583ade23f7ca2654b.tar.gz org.eclipse.jetty.project-e87eee1b4605249acda549c583ade23f7ca2654b.tar.xz org.eclipse.jetty.project-e87eee1b4605249acda549c583ade23f7ca2654b.zip |
412629 PropertyFileLoginModule doesn't cache user configuration file even for refreshInterval=0
-rw-r--r-- | jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/PropertyFileLoginModule.java | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/PropertyFileLoginModule.java b/jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/PropertyFileLoginModule.java index 5ecf5256bd..ab5ee46aa7 100644 --- a/jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/PropertyFileLoginModule.java +++ b/jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/PropertyFileLoginModule.java @@ -20,11 +20,10 @@ package org.eclipse.jetty.plus.jaas.spi; import java.security.Principal; import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import javax.security.auth.Subject; import javax.security.auth.callback.CallbackHandler; @@ -46,7 +45,7 @@ public class PropertyFileLoginModule extends AbstractLoginModule private static final Logger LOG = Log.getLogger(PropertyFileLoginModule.class); - private static Map<String, PropertyUserStore> _propertyUserStores = new HashMap<String, PropertyUserStore>(); + private static ConcurrentHashMap<String, PropertyUserStore> _propertyUserStores = new ConcurrentHashMap<String, PropertyUserStore>(); private int _refreshInterval = 0; private String _filename = DEFAULT_FILENAME; @@ -69,31 +68,35 @@ public class PropertyFileLoginModule extends AbstractLoginModule private void setupPropertyUserStore(Map<String, ?> options) { + parseConfig(options); + if (_propertyUserStores.get(_filename) == null) { - parseConfig(options); - - PropertyUserStore _propertyUserStore = new PropertyUserStore(); - _propertyUserStore.setConfig(_filename); - _propertyUserStore.setRefreshInterval(_refreshInterval); - LOG.debug("setupPropertyUserStore: Starting new PropertyUserStore. PropertiesFile: " + _filename + " refreshInterval: " + _refreshInterval); + PropertyUserStore propertyUserStore = new PropertyUserStore(); + propertyUserStore.setConfig(_filename); + propertyUserStore.setRefreshInterval(_refreshInterval); - try + PropertyUserStore prev = _propertyUserStores.putIfAbsent(_filename, propertyUserStore); + if (prev == null) { - _propertyUserStore.start(); + LOG.debug("setupPropertyUserStore: Starting new PropertyUserStore. PropertiesFile: " + _filename + " refreshInterval: " + _refreshInterval); + + try + { + propertyUserStore.start(); + } + catch (Exception e) + { + LOG.warn("Exception while starting propertyUserStore: ",e); + } } - catch (Exception e) - { - LOG.warn("Exception while starting propertyUserStore: ",e); - } - - _propertyUserStores.put(_filename,_propertyUserStore); } } private void parseConfig(Map<String, ?> options) { - _filename = (String)options.get("file") != null?(String)options.get("file"):DEFAULT_FILENAME; + _filename = (String)options.get("file"); + _filename = (_filename == null? DEFAULT_FILENAME : _filename); String refreshIntervalString = (String)options.get("refreshInterval"); _refreshInterval = refreshIntervalString == null?_refreshInterval:Integer.parseInt(refreshIntervalString); } |