public static Map<String, String> defaultForm(PwmSettingTemplate template) { final Map<String, String> defaultLdapForm = new HashMap<>(); try { final String defaultLdapUrlString = ((List<String>) PwmSetting.LDAP_SERVER_URLS.getDefaultValue(template).toNativeObject()) .get(0); final URI uri = new URI(defaultLdapUrlString); defaultLdapForm.put(PARAM_LDAP_HOST, uri.getHost()); defaultLdapForm.put(PARAM_LDAP_PORT, String.valueOf(uri.getPort())); defaultLdapForm.put( PARAM_LDAP_SECURE, "ldaps".equalsIgnoreCase(uri.getScheme()) ? "true" : "false"); defaultLdapForm.put( PARAM_LDAP_ADMIN_DN, (String) PwmSetting.LDAP_PROXY_USER_DN.getDefaultValue(template).toNativeObject()); defaultLdapForm.put(PARAM_LDAP_ADMIN_PW, ""); defaultLdapForm.put( PARAM_LDAP_CONTEXT, ((List<String>) PwmSetting.LDAP_CONTEXTLESS_ROOT.getDefaultValue(template).toNativeObject()) .get(0)); defaultLdapForm.put( PARAM_LDAP_TEST_USER, (String) PwmSetting.LDAP_TEST_USER_DN.getDefaultValue(template).toNativeObject()); { List<UserPermission> userPermissions = (List<UserPermission>) PwmSetting.QUERY_MATCH_PWM_ADMIN.getDefaultValue(template).toNativeObject(); final String groupDN = userPermissions != null && userPermissions.size() > 0 ? userPermissions.get(0).getLdapBase() : ""; defaultLdapForm.put(PARAM_LDAP_ADMIN_GROUP, groupDN); } defaultLdapForm.put( PARAM_CR_STORAGE_PREF, (String) PwmSetting.FORGOTTEN_PASSWORD_WRITE_PREFERENCE .getDefaultValue(template) .toNativeObject()); defaultLdapForm.put(PARAM_CONFIG_PASSWORD, ""); defaultLdapForm.put(PARAM_CONFIG_PASSWORD_VERIFY, ""); } catch (Exception e) { LOGGER.error( "error building static form values using default configuration: " + e.getMessage()); e.printStackTrace(); } return Collections.unmodifiableMap(defaultLdapForm); }
private static Map<PwmAboutProperty, String> getConnectionDebugProperties( final Connection connection) { if (connection != null) { try { final Map<PwmAboutProperty, String> returnObj = new LinkedHashMap<>(); final DatabaseMetaData databaseMetaData = connection.getMetaData(); returnObj.put(PwmAboutProperty.database_driverName, databaseMetaData.getDriverName()); returnObj.put(PwmAboutProperty.database_driverVersion, databaseMetaData.getDriverVersion()); returnObj.put( PwmAboutProperty.database_databaseProductName, databaseMetaData.getDatabaseProductName()); returnObj.put( PwmAboutProperty.database_databaseProductVersion, databaseMetaData.getDatabaseProductVersion()); return Collections.unmodifiableMap(returnObj); } catch (SQLException e) { LOGGER.error("error rading jdbc meta data: " + e.getMessage()); } } return Collections.emptyMap(); }
public static Map<String, String> placeholderForm(PwmSettingTemplate template) { final Map<String, String> defaultLdapForm = new HashMap<>(); try { final String defaultLdapUrlString = PwmSetting.LDAP_SERVER_URLS.getPlaceholder(template); final URI uri = new URI(defaultLdapUrlString); defaultLdapForm.put(PARAM_LDAP_HOST, uri.getHost()); defaultLdapForm.put(PARAM_LDAP_PORT, String.valueOf(uri.getPort())); defaultLdapForm.put( PARAM_LDAP_SECURE, "ldaps".equalsIgnoreCase(uri.getScheme()) ? "true" : "false"); defaultLdapForm.put( PARAM_LDAP_PROXY_DN, PwmSetting.LDAP_PROXY_USER_DN.getPlaceholder(template)); defaultLdapForm.put(PARAM_LDAP_PROXY_PW, ""); defaultLdapForm.put( PARAM_LDAP_CONTEXT, PwmSetting.LDAP_CONTEXTLESS_ROOT.getPlaceholder(template)); defaultLdapForm.put( PARAM_LDAP_TEST_USER, PwmSetting.LDAP_TEST_USER_DN.getPlaceholder(template)); defaultLdapForm.put( PARAM_LDAP_ADMIN_GROUP, PwmSetting.LDAP_TEST_USER_DN.getPlaceholder(template)); defaultLdapForm.put( PARAM_CR_STORAGE_PREF, (String) PwmSetting.FORGOTTEN_PASSWORD_WRITE_PREFERENCE .getDefaultValue(template) .toNativeObject()); defaultLdapForm.put(PARAM_CONFIG_PASSWORD, ""); defaultLdapForm.put(PARAM_CONFIG_PASSWORD_VERIFY, ""); } catch (Exception e) { LOGGER.error( "error building static form values using default configuration: " + e.getMessage()); e.printStackTrace(); } return Collections.unmodifiableMap(defaultLdapForm); }