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;
}
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);
}
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;
}
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();
}
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");
}
Aggregations