[Yanel-commits] rev 49790 -
public/yanel/trunk/src/core/java/org/wyona/yanel/core/map
michi at wyona.com
michi at wyona.com
Sun May 23 13:48:28 CEST 2010
Author: michi
Date: 2010-05-23 13:48:28 +0200 (Sun, 23 May 2010)
New Revision: 49790
Modified:
public/yanel/trunk/src/core/java/org/wyona/yanel/core/map/RealmManager.java
Log:
check environment variable for realms configuration
Modified: public/yanel/trunk/src/core/java/org/wyona/yanel/core/map/RealmManager.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/core/map/RealmManager.java 2010-05-23 11:07:41 UTC (rev 49789)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/core/map/RealmManager.java 2010-05-23 11:48:28 UTC (rev 49790)
@@ -72,17 +72,34 @@
*/
public RealmManager(String yanelConfigurationFilename) throws ConfigurationException {
log.debug("Yanel Configuration Filename: " + yanelConfigurationFilename);
- File realmsConfigFile = getSetRealmsConfigFile(yanelConfigurationFilename);
+ File realmsConfigFile = getRealmsConfigFile(yanelConfigurationFilename);
+ // INFO: Set private realms config file
+ _realmsConfigFile = realmsConfigFile;
log.debug("Realms Configuration: " + realmsConfigFile);
readRealms(realmsConfigFile);
}
/**
- * Get realms configuration file
+ * Get realms configuration file (either based on yanel configuration or based on environment variable)
* @param yanelConfigurationFilename Yanel configuration filename, either 'yanel.xml' or 'yanel.properties'
- * @return Something like realms.xml
+ * @return Realms configuration file, either something like /usr/local/tomcat/webapps/yanel/WEB-INF/classes/realms.xml or /home/foo/realms.xml
*/
- private File getSetRealmsConfigFile(String yanelConfigurationFilename) throws ConfigurationException {
+ private File getRealmsConfigFile(String yanelConfigurationFilename) throws ConfigurationException {
+ java.util.Map<String, String> env = System.getenv();
+ for (String envName : env.keySet()) {
+ if (envName.equals("YANEL_REALMS_HOME")) {
+ File yanelRealmsHome = new File(env.get(envName));
+ if (yanelRealmsHome.isDirectory()) {
+ log.warn("DEBUG: YANEL_REALMS_HOME: " + yanelRealmsHome);
+ File envRealmsConfigFile = new File(yanelRealmsHome, "realms.xml");
+ if (envRealmsConfigFile.isFile()) {
+ return envRealmsConfigFile;
+ }
+ break;
+ }
+ }
+ }
+
YANEL_CONFIGURATION_FILE = yanelConfigurationFilename;
if (RealmManager.class.getClassLoader().getResource(YANEL_CONFIGURATION_FILE) == null) {
@@ -153,9 +170,6 @@
throw new ConfigurationException("Realms configuration file could not be determined!");
}
- // INFO: Set private realms config file
- _realmsConfigFile = realmsConfigFile;
-
return realmsConfigFile;
}
@@ -171,7 +185,12 @@
* Get realms configuration file
*/
public String getRealmsConfigurationFile() {
- return _realmsConfigFile.getAbsolutePath();
+ if (_realmsConfigFile != null && _realmsConfigFile.exists()) {
+ return _realmsConfigFile.getAbsolutePath();
+ } else {
+ log.error("Either no realms configuration file was set or it does not exist: " + _realmsConfigFile);
+ return null;
+ }
}
/**
More information about the Yanel-commits
mailing list