From a345cd3d56163625f6df6ff24e6155e953f28c08 Mon Sep 17 00:00:00 2001 From: Bosanac Dejan Date: Tue, 5 Apr 2011 10:20:17 +0000 Subject: [PATCH] https://issues.apache.org/jira/browse/AMQ-3244 - make checking of the file timestamps default for the jaas properties loging module git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1088955 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/jaas/PropertiesLoginModule.java | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/activemq-jaas/src/main/java/org/apache/activemq/jaas/PropertiesLoginModule.java b/activemq-jaas/src/main/java/org/apache/activemq/jaas/PropertiesLoginModule.java index 6f4909b267..9671a117fd 100644 --- a/activemq-jaas/src/main/java/org/apache/activemq/jaas/PropertiesLoginModule.java +++ b/activemq-jaas/src/main/java/org/apache/activemq/jaas/PropertiesLoginModule.java @@ -52,11 +52,13 @@ public class PropertiesLoginModule implements LoginModule { private CallbackHandler callbackHandler; private boolean debug; - private boolean reload = true; + private boolean reload = false; private static String usersFile; private static String groupsFile; private static Properties users; private static Properties groups; + private static long usersReloadTime = 0; + private static long groupsReloadTime = 0; private String user; private Set principals = new HashSet(); private File baseDir; @@ -73,37 +75,39 @@ public class PropertiesLoginModule implements LoginModule { reload = "true".equalsIgnoreCase((String)options.get("reload")); } - if (reload || users == null) { - setBaseDir(); - usersFile = (String)options.get(USER_FILE) + ""; - File uf = new File(baseDir, usersFile); + setBaseDir(); + usersFile = (String) options.get(USER_FILE) + ""; + File uf = new File(baseDir, usersFile); + if (reload || users == null || uf.lastModified() > usersReloadTime) { + if (debug) { + LOG.debug("Reloading users from " + usersFile); + } try { users = new Properties(); java.io.FileInputStream in = new java.io.FileInputStream(uf); users.load(in); in.close(); + usersReloadTime = System.currentTimeMillis(); } catch (IOException ioe) { LOG.warn("Unable to load user properties file " + uf); } - if (debug) { - LOG.debug("Using usersFile=" + usersFile); - } } - if (reload || groups == null) { - setBaseDir(); - groupsFile = (String)options.get(GROUP_FILE) + ""; - File gf = new File(baseDir, groupsFile); + + groupsFile = (String) options.get(GROUP_FILE) + ""; + File gf = new File(baseDir, groupsFile); + if (reload || groups == null || gf.lastModified() > groupsReloadTime) { + if (debug) { + LOG.debug("Reloading groups from " + groupsFile); + } try { groups = new Properties(); java.io.FileInputStream in = new java.io.FileInputStream(gf); groups.load(in); in.close(); + groupsReloadTime = System.currentTimeMillis(); } catch (IOException ioe) { LOG.warn("Unable to load group properties file " + gf); } - if (debug) { - LOG.debug("Using groupsFile=" + groupsFile); - } } }