Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 99308 invoked from network); 8 Apr 2011 10:05:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Apr 2011 10:05:24 -0000 Received: (qmail 32412 invoked by uid 500); 8 Apr 2011 10:05:24 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 32344 invoked by uid 500); 8 Apr 2011 10:05:22 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 32337 invoked by uid 99); 8 Apr 2011 10:05:21 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Apr 2011 10:05:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Apr 2011 10:05:19 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E9F2F2388962; Fri, 8 Apr 2011 10:04:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@activemq.apache.org From: gtully@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110408100457.E9F2F2388962@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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) {