final File configFile = new File(CONFIG_FILE);
if (configFile.canRead() == false) {
return null;
}
log.info("Reading LDAP configuration file for test cases: " + configFile.getPath());
final XmlObjectReader reader = new XmlObjectReader();
final AliasMap aliasMap = new AliasMap();
aliasMap.put(LdapConfig.class, "ldapConfig");
reader.setAliasMap(aliasMap);
AccountingConfig.registerXmlObjects(reader, aliasMap);
String xml = null;
try {
xml = FileUtils.readFileToString(configFile, "UTF-8");
} catch (final IOException ex) {
log.error(ex.getMessage(), ex);
throw new IllegalArgumentException("Cannot read config file '" + CONFIG_FILE + "' properly : " + ex.getMessage(), ex);
}
if (xml == null) {
throw new IllegalArgumentException("Cannot read from config file: '" + CONFIG_FILE + "'.");
}
try {
final LdapConfig cfg = (LdapConfig) reader.read(xml);
final String warnings = reader.getWarnings();
if (StringUtils.isNotBlank(warnings) == true) {
log.error(warnings);
}
return cfg;
} catch (final Throwable ex) {