/** Load the properties contained within ou=Config node in LDAP. */ private void loadRemoteConfig() { try { // Retrieve parameters from the config node stored in target LDAP DIT: String realmName = config.getString(GlobalIds.CONFIG_REALM, "DEFAULT"); if (realmName != null && realmName.length() > 0) { LOG.info("static init: load config realm [{}]", realmName); Properties props = getRemoteConfig(realmName); if (props != null) { for (Enumeration<?> e = props.propertyNames(); e.hasMoreElements(); ) { String key = (String) e.nextElement(); String val = props.getProperty(key); config.setProperty(key, val); } } // init ldap util vals since config is stored on server boolean ldapfilterSizeFound = (getProperty(GlobalIds.LDAP_FILTER_SIZE_PROP) != null); LdapUtil.getInstance().setLdapfilterSizeFound(ldapfilterSizeFound); LdapUtil.getInstance().setLdapMetaChars(loadLdapEscapeChars()); LdapUtil.getInstance().setLdapReplVals(loadValidLdapVals()); try { String lenProp = getProperty(GlobalIds.LDAP_FILTER_SIZE_PROP); if (ldapfilterSizeFound) { LdapUtil.getInstance().setLdapFilterSize(Integer.valueOf(lenProp)); } } catch (java.lang.NumberFormatException nfe) { String error = "loadRemoteConfig caught NumberFormatException=" + nfe; LOG.warn(error); } remoteConfigLoaded = true; } else { LOG.info("static init: config realm not setup"); } } catch (SecurityException se) { String error = "static init: Error loading from remote config: SecurityException=" + se; LOG.error(error); throw new CfgRuntimeException(GlobalErrIds.FT_CONFIG_INITIALIZE_FAILED, error, se); } }
private String[] loadValidLdapVals() { String[] ldapReplacements = new String[LdapUtil.getInstance().getLdapFilterSize()]; for (int i = 1; ; i++) { String prop = GlobalIds.LDAP_SUB + i; String value = getProperty(prop); if (value == null) { break; } ldapReplacements[i - 1] = value; } return ldapReplacements; }
private char[] loadLdapEscapeChars() { char[] ldapMetaChars = new char[LdapUtil.getInstance().getLdapFilterSize()]; for (int i = 1; ; i++) { String prop = GlobalIds.LDAP_FILTER + i; String value = getProperty(prop); if (value == null) { break; } ldapMetaChars[i - 1] = value.charAt(0); } return ldapMetaChars; }