Search in sources :

Example 16 with PwmSetting

use of password.pwm.config.PwmSetting in project pwm by pwm-project.

the class AbstractProfile method makeValueMap.

static Map<PwmSetting, StoredValue> makeValueMap(final StoredConfiguration storedConfiguration, final String identifier, final PwmSettingCategory pwmSettingCategory) {
    final Map<PwmSetting, StoredValue> valueMap = new LinkedHashMap<>();
    final List<PwmSettingCategory> categories = new ArrayList<>();
    categories.add(pwmSettingCategory);
    categories.addAll(pwmSettingCategory.getChildCategories());
    for (final PwmSettingCategory category : categories) {
        for (final PwmSetting setting : category.getSettings()) {
            final StoredValue value = storedConfiguration.readSetting(setting, identifier);
            valueMap.put(setting, value);
        }
    }
    return valueMap;
}
Also used : PwmSetting(password.pwm.config.PwmSetting) PwmSettingCategory(password.pwm.config.PwmSettingCategory) ArrayList(java.util.ArrayList) StoredValue(password.pwm.config.StoredValue) LinkedHashMap(java.util.LinkedHashMap)

Example 17 with PwmSetting

use of password.pwm.config.PwmSetting in project pwm by pwm-project.

the class CertificateChecker method doHealthCheck.

private static List<HealthRecord> doHealthCheck(final Configuration configuration) {
    final List<HealthRecord> returnList = new ArrayList<>();
    for (final PwmSetting setting : PwmSetting.values()) {
        if (setting.getSyntax() == PwmSettingSyntax.X509CERT && !setting.getCategory().hasProfiles()) {
            if (setting != PwmSetting.LDAP_SERVER_CERTS) {
                final List<X509Certificate> certs = configuration.readSettingAsCertificate(setting);
                returnList.addAll(doHealthCheck(configuration, setting, null, certs));
            }
        }
    }
    for (final LdapProfile ldapProfile : configuration.getLdapProfiles().values()) {
        final List<X509Certificate> certificates = configuration.getLdapProfiles().get(ldapProfile.getIdentifier()).readSettingAsCertificate(PwmSetting.LDAP_SERVER_CERTS);
        returnList.addAll(doHealthCheck(configuration, PwmSetting.LDAP_SERVER_CERTS, ldapProfile.getIdentifier(), certificates));
    }
    return Collections.unmodifiableList(returnList);
}
Also used : PwmSetting(password.pwm.config.PwmSetting) ArrayList(java.util.ArrayList) LdapProfile(password.pwm.config.profile.LdapProfile) X509Certificate(java.security.cert.X509Certificate)

Example 18 with PwmSetting

use of password.pwm.config.PwmSetting in project pwm by pwm-project.

the class LDAPPermissionCalculator method figureRecords.

private Collection<PermissionRecord> figureRecords(final StoredConfigurationImpl storedConfiguration) throws PwmUnrecoverableException {
    final List<PermissionRecord> permissionRecords = new ArrayList<>();
    for (final PwmSetting pwmSetting : PwmSetting.values()) {
        if (pwmSetting.getCategory().hasProfiles()) {
            final List<String> profiles = StoredConfigurationUtil.profilesForSetting(pwmSetting, storedConfiguration);
            for (final String profile : profiles) {
                permissionRecords.addAll(figureRecord(pwmSetting, profile));
            }
        } else {
            permissionRecords.addAll(figureRecord(pwmSetting, null));
        }
    }
    permissionRecords.addAll(permissionsForUserPassword());
    permissionRecords.addAll(figureStaticRecords());
    return permissionRecords;
}
Also used : PwmSetting(password.pwm.config.PwmSetting) ArrayList(java.util.ArrayList)

Example 19 with PwmSetting

use of password.pwm.config.PwmSetting in project pwm by pwm-project.

the class TelemetryService method generatePublishableBean.

public TelemetryPublishBean generatePublishableBean() throws URISyntaxException, IOException, PwmUnrecoverableException {
    final StatisticsBundle bundle = pwmApplication.getStatisticsManager().getStatBundleForKey(StatisticsManager.KEY_CUMULATIVE);
    final Configuration config = pwmApplication.getConfig();
    final Map<PwmAboutProperty, String> aboutPropertyStringMap = PwmAboutProperty.makeInfoBean(pwmApplication);
    final Map<String, String> statData = new TreeMap<>();
    for (final Statistic loopStat : Statistic.values()) {
        statData.put(loopStat.getKey(), bundle.getStatistic(loopStat));
    }
    final List<String> configuredSettings = new ArrayList<>();
    for (final PwmSetting pwmSetting : config.nonDefaultSettings()) {
        if (!pwmSetting.getCategory().hasProfiles() && !config.isDefaultValue(pwmSetting)) {
            configuredSettings.add(pwmSetting.getKey());
        }
    }
    String ldapVendorName = null;
    for (final LdapProfile ldapProfile : config.getLdapProfiles().values()) {
        if (ldapVendorName == null) {
            try {
                final DirectoryVendor directoryVendor = ldapProfile.getProxyChaiProvider(pwmApplication).getDirectoryVendor();
                final PwmLdapVendor pwmLdapVendor = PwmLdapVendor.fromChaiVendor(directoryVendor);
                if (pwmLdapVendor != null) {
                    ldapVendorName = pwmLdapVendor.name();
                }
            } catch (Exception e) {
                LOGGER.trace(SessionLabel.TELEMETRY_SESSION_LABEL, "unable to read ldap vendor type for stats publication: " + e.getMessage());
            }
        }
    }
    final Map<String, String> aboutStrings = new TreeMap<>();
    {
        for (final Map.Entry<PwmAboutProperty, String> entry : aboutPropertyStringMap.entrySet()) {
            final PwmAboutProperty pwmAboutProperty = entry.getKey();
            aboutStrings.put(pwmAboutProperty.name(), entry.getValue());
        }
        aboutStrings.remove(PwmAboutProperty.app_instanceID.name());
        aboutStrings.remove(PwmAboutProperty.app_siteUrl.name());
    }
    final TelemetryPublishBean.TelemetryPublishBeanBuilder builder = TelemetryPublishBean.builder();
    builder.timestamp(Instant.now());
    builder.id(makeId(pwmApplication));
    builder.instanceHash(pwmApplication.getSecureService().hash(pwmApplication.getInstanceID()));
    builder.installTime(pwmApplication.getInstallTime());
    builder.siteDescription(config.readSettingAsString(PwmSetting.PUBLISH_STATS_SITE_DESCRIPTION));
    builder.versionBuild(PwmConstants.BUILD_NUMBER);
    builder.versionVersion(PwmConstants.BUILD_VERSION);
    builder.ldapVendorName(ldapVendorName);
    builder.statistics(Collections.unmodifiableMap(statData));
    builder.configuredSettings(Collections.unmodifiableList(configuredSettings));
    builder.about(aboutStrings);
    return builder.build();
}
Also used : Configuration(password.pwm.config.Configuration) ArrayList(java.util.ArrayList) PwmLdapVendor(password.pwm.ldap.PwmLdapVendor) TreeMap(java.util.TreeMap) LdapProfile(password.pwm.config.profile.LdapProfile) URISyntaxException(java.net.URISyntaxException) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) PwmException(password.pwm.error.PwmException) IOException(java.io.IOException) PwmSetting(password.pwm.config.PwmSetting) PwmAboutProperty(password.pwm.PwmAboutProperty) StatisticsBundle(password.pwm.svc.stats.StatisticsBundle) Statistic(password.pwm.svc.stats.Statistic) DirectoryVendor(com.novell.ldapchai.provider.DirectoryVendor) TelemetryPublishBean(password.pwm.bean.TelemetryPublishBean)

Example 20 with PwmSetting

use of password.pwm.config.PwmSetting in project pwm by pwm-project.

the class ConfigResetHttpsCommand method doCommand.

public void doCommand() throws Exception {
    final File configurationFile = cliEnvironment.getConfigurationFile();
    if (configurationFile == null || !configurationFile.exists()) {
        out("configuration file is not present");
        return;
    }
    if (!promptForContinue("Proceeding will reset all https server settings to their default")) {
        return;
    }
    final ConfigurationReader configurationReader = new ConfigurationReader(cliEnvironment.getConfigurationFile());
    final StoredConfigurationImpl storedConfiguration = configurationReader.getStoredConfiguration();
    for (final PwmSetting setting : PwmSettingCategory.HTTPS_SERVER.getSettings()) {
        storedConfiguration.resetSetting(setting, null, null);
    }
    configurationReader.saveConfiguration(storedConfiguration, cliEnvironment.getPwmApplication(), SessionLabel.CLI_SESSION_LABEL);
    out("success");
}
Also used : PwmSetting(password.pwm.config.PwmSetting) StoredConfigurationImpl(password.pwm.config.stored.StoredConfigurationImpl) File(java.io.File) ConfigurationReader(password.pwm.config.stored.ConfigurationReader)

Aggregations

PwmSetting (password.pwm.config.PwmSetting)32 ArrayList (java.util.ArrayList)15 StoredValue (password.pwm.config.StoredValue)12 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)11 LinkedHashMap (java.util.LinkedHashMap)9 StoredConfigurationImpl (password.pwm.config.stored.StoredConfigurationImpl)9 PwmSettingCategory (password.pwm.config.PwmSettingCategory)8 PwmException (password.pwm.error.PwmException)8 ConfigManagerBean (password.pwm.http.bean.ConfigManagerBean)7 IOException (java.io.IOException)6 TreeMap (java.util.TreeMap)6 PwmOperationalException (password.pwm.error.PwmOperationalException)5 PwmLocaleBundle (password.pwm.i18n.PwmLocaleBundle)5 ChaiUnavailableException (com.novell.ldapchai.exception.ChaiUnavailableException)4 List (java.util.List)4 StringTokenizer (java.util.StringTokenizer)4 ServletException (javax.servlet.ServletException)4 UserIdentity (password.pwm.bean.UserIdentity)4 Configuration (password.pwm.config.Configuration)4 ErrorInformation (password.pwm.error.ErrorInformation)4