activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1090179 - /activemq/trunk/activemq-jaas/src/main/java/org/apache/activemq/jaas/PropertiesLoginModule.java
Date Fri, 08 Apr 2011 10:04:57 GMT
Author: gtully
Date: Fri Apr  8 10:04:57 2011
New Revision: 1090179

URL: http://svn.apache.org/viewvc?rev=1090179&view=rev
Log:
add baseDir option to jaas properties login module so that the path to properties file can
be specified independt of the system property java.security.auth.login.config, useful when
run with karaf jass arch

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=1090179&r1=1090178&r2=1090179&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
Fri Apr  8 10:04:57 2011
@@ -38,9 +38,6 @@ import javax.security.auth.spi.LoginModu
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- * @version $Rev: $ $Date: $
- */
 public class PropertiesLoginModule implements LoginModule {
 
     private static final String USER_FILE = "org.apache.activemq.jaas.properties.user";
@@ -75,12 +72,17 @@ public class PropertiesLoginModule imple
             reload = "true".equalsIgnoreCase((String)options.get("reload"));
         }
 
+        if (options.get("baseDir") != null) {
+            baseDir = new File((String)options.get("baseDir"));
+        }
+
         setBaseDir();
         usersFile = (String) options.get(USER_FILE) + "";
-        File uf = new File(baseDir, usersFile);
+        File uf = baseDir != null ? new File(baseDir, usersFile) : new File(usersFile);
+
         if (reload || users == null || uf.lastModified() > usersReloadTime) {
             if (debug) {
-                LOG.debug("Reloading users from " + usersFile);
+                LOG.debug("Reloading users from " + uf.getAbsolutePath());
             }
             try {
                 users = new Properties();
@@ -94,10 +96,10 @@ public class PropertiesLoginModule imple
         }
 
         groupsFile = (String) options.get(GROUP_FILE) + "";
-        File gf = new File(baseDir, groupsFile);
+        File gf = baseDir != null ? new File(baseDir, groupsFile) : new File(groupsFile);
         if (reload || groups == null || gf.lastModified() > groupsReloadTime) {
             if (debug) {
-                LOG.debug("Reloading groups from " + groupsFile);
+                LOG.debug("Reloading groups from " + gf.getAbsolutePath());
             }
             try {
                 groups = new Properties();
@@ -115,11 +117,9 @@ public class PropertiesLoginModule imple
         if (baseDir == null) {
             if (System.getProperty("java.security.auth.login.config") != null) {
                 baseDir = new File(System.getProperty("java.security.auth.login.config")).getParentFile();
-            } else {
-                baseDir = new File(".");
-            }
-            if (debug) {
-                LOG.debug("Using basedir=" + baseDir);
+                if (debug) {
+                    LOG.debug("Using basedir=" + baseDir.getAbsolutePath());
+                }
             }
         }
     }
@@ -141,6 +141,9 @@ public class PropertiesLoginModule imple
         if (tmpPassword == null) {
             tmpPassword = new char[0];
         }
+        if (user == null) {
+            throw new FailedLoginException("user name is null");
+        }
         String password = users.getProperty(user);
 
         if (password == null) {



Mime
View raw message