/** Sets the dirProperties and attrMap */ public void init(final Properties props) { this.dirProperties = new Properties(); this.attrMap = new HashMap<SettingType, String>(); // extract different types of properties + check if all mandatory // settings are available this.missingMandatoryLdapProps = new HashSet<String>(SettingType.LDAP_ATTRIBUTES_MANDATORY); if (props != null) { for (Object propKey : props.keySet()) { String key = String.valueOf(propKey); SettingType settingType = SettingType.valueOf(key); String value = props.getProperty(key); if (settingType.getDirContextKey() != null) { this.dirProperties.put(settingType.getDirContextKey(), value); } else if (SettingType.LDAP_ATTRIBUTES.contains(settingType)) { this.attrMap.put(settingType, value); } else if (SettingType.LDAP_BASE_DN.equals(settingType)) { this.baseDN = value; } this.missingMandatoryLdapProps.remove(key); } } }
/** * Validate that a value entered by a user is empty or equal to the value from the remote LDAP * system. * * @param attrMap the map with all configured LDAP attributes * @param setting the LDAP attribute the check * @param userValue the value entered by a the user * @param ldapValue value from the LDAP system * @throws ValidationException */ private void validateLdapPropertyValue( Map<SettingType, String> attrMap, SettingType setting, String userValue, String ldapValue) throws ValidationException { if (attrMap.containsKey(setting) && userValue != null && userValue.length() != 0 && !userValue.equals(ldapValue)) { // sessionCtx.setRollbackOnly(); ValidationException vf = new ValidationException( ReasonEnum.LDAP_VALUE_MISMATCH, null, new Object[] {ldapValue, setting.toString(), userValue}); logger.logError( Log4jLogger.SYSTEM_LOG, vf, LogMessageIdentifier.ERROR_VALIDATION_PARAMETER_LDAP_FOUND_ERROR, "User Value"); throw vf; } }