activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r1088955 - /activemq/trunk/activemq-jaas/src/main/java/org/apache/activemq/jaas/PropertiesLoginModule.java
Date Tue, 05 Apr 2011 10:20:17 GMT
Author: dejanb
Date: Tue Apr  5 10:20:17 2011
New Revision: 1088955

URL: http://svn.apache.org/viewvc?rev=1088955&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3244 - make checking of the file timestamps default
for the jaas properties loging module

Modified:
    activemq/trunk/activemq-jaas/src/main/java/org/apache/activemq/jaas/PropertiesLoginModule.java

Modified: activemq/trunk/activemq-jaas/src/main/java/org/apache/activemq/jaas/PropertiesLoginModule.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-jaas/src/main/java/org/apache/activemq/jaas/PropertiesLoginModule.java?rev=1088955&r1=1088954&r2=1088955&view=diff
==============================================================================
--- activemq/trunk/activemq-jaas/src/main/java/org/apache/activemq/jaas/PropertiesLoginModule.java
(original)
+++ activemq/trunk/activemq-jaas/src/main/java/org/apache/activemq/jaas/PropertiesLoginModule.java
Tue Apr  5 10:20:17 2011
@@ -52,11 +52,13 @@ public class PropertiesLoginModule imple
     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<Principal> principals = new HashSet<Principal>();
     private File baseDir;
@@ -73,37 +75,39 @@ public class PropertiesLoginModule imple
             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);
             }
+        }
+
+        groupsFile = (String) options.get(GROUP_FILE) + "";
+        File gf = new File(baseDir, groupsFile);
+        if (reload || groups == null || gf.lastModified() > groupsReloadTime) {
             if (debug) {
-                LOG.debug("Using usersFile=" + usersFile);
+                LOG.debug("Reloading groups from " + groupsFile);
             }
-        }
-        if (reload || groups == null) {
-            setBaseDir();
-            groupsFile = (String)options.get(GROUP_FILE) + "";
-            File gf = new File(baseDir, 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);
-            }
         }
     }
 



Mime
View raw message