Search in sources :

Example 76 with Configuration

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

the class HealthMessageTest method testHealthMessageDescription.

@Test
public void testHealthMessageDescription() throws PwmUnrecoverableException {
    final Configuration configuration = new Configuration(StoredConfigurationImpl.newStoredConfiguration());
    final Locale locale = PwmConstants.DEFAULT_LOCALE;
    for (final HealthMessage healthMessage : HealthMessage.values()) {
        healthMessage.getDescription(locale, configuration, new String[] { "field1", "field2" });
    }
}
Also used : Locale(java.util.Locale) Configuration(password.pwm.config.Configuration) Test(org.junit.Test)

Example 77 with Configuration

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

the class RestResultBean method fromError.

public static RestResultBean fromError(final RestRequest restRequestBean, final ErrorInformation errorInformation) {
    final PwmApplication pwmApplication = restRequestBean.getPwmApplication();
    final Configuration config = restRequestBean.getPwmApplication().getConfig();
    final Locale locale = restRequestBean.getLocale();
    return fromError(errorInformation, pwmApplication, locale, config, false);
}
Also used : Locale(java.util.Locale) PwmApplication(password.pwm.PwmApplication) Configuration(password.pwm.config.Configuration)

Example 78 with Configuration

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

the class SecureService method init.

@Override
public void init(final PwmApplication pwmApplication) throws PwmException {
    final Configuration config = pwmApplication.getConfig();
    pwmSecurityKey = config.getSecurityKey();
    {
        final String defaultBlockAlgString = config.readAppProperty(AppProperty.SECURITY_DEFAULT_EPHEMERAL_BLOCK_ALG);
        defaultBlockAlgorithm = JavaHelper.readEnumFromString(PwmBlockAlgorithm.class, PwmBlockAlgorithm.AES, defaultBlockAlgString);
        LOGGER.debug("using default ephemeral block algorithm: " + defaultBlockAlgorithm.getLabel());
    }
    {
        final String defaultHashAlgString = config.readAppProperty(AppProperty.SECURITY_DEFAULT_EPHEMERAL_HASH_ALG);
        defaultHashAlgorithm = JavaHelper.readEnumFromString(PwmHashAlgorithm.class, PwmHashAlgorithm.SHA512, defaultHashAlgString);
        LOGGER.debug("using default ephemeral hash algorithm: " + defaultHashAlgString.toString());
    }
}
Also used : Configuration(password.pwm.config.Configuration)

Example 79 with Configuration

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

the class LDAPStatusChecker method doHealthCheck.

public List<HealthRecord> doHealthCheck(final PwmApplication pwmApplication) {
    final Configuration config = pwmApplication.getConfig();
    final List<HealthRecord> returnRecords = new ArrayList<>();
    final Map<String, LdapProfile> ldapProfiles = pwmApplication.getConfig().getLdapProfiles();
    for (final Map.Entry<String, LdapProfile> entry : ldapProfiles.entrySet()) {
        final String profileID = entry.getKey();
        final List<HealthRecord> profileRecords = new ArrayList<>();
        profileRecords.addAll(checkBasicLdapConnectivity(pwmApplication, config, entry.getValue(), true));
        if (profileRecords.isEmpty()) {
            profileRecords.addAll(checkLdapServerUrls(pwmApplication, config, ldapProfiles.get(profileID)));
        }
        if (profileRecords.isEmpty()) {
            profileRecords.add(HealthRecord.forMessage(HealthMessage.LDAP_OK));
            profileRecords.addAll(doLdapTestUserCheck(config, ldapProfiles.get(profileID), pwmApplication));
        }
        returnRecords.addAll(profileRecords);
    }
    for (final LdapProfile ldapProfile : pwmApplication.getLdapConnectionService().getLastLdapFailure().keySet()) {
        final ErrorInformation errorInfo = pwmApplication.getLdapConnectionService().getLastLdapFailure().get(ldapProfile);
        if (errorInfo != null) {
            final TimeDuration errorAge = TimeDuration.fromCurrent(errorInfo.getDate());
            final long cautionDurationMS = Long.parseLong(pwmApplication.getConfig().readAppProperty(AppProperty.HEALTH_LDAP_CAUTION_DURATION_MS));
            if (errorAge.isShorterThan(cautionDurationMS)) {
                final String ageString = errorAge.asLongString();
                final String errorDate = JavaHelper.toIsoDate(errorInfo.getDate());
                final String errorMsg = errorInfo.toDebugStr();
                returnRecords.add(HealthRecord.forMessage(HealthMessage.LDAP_RecentlyUnreachable, ldapProfile.getDisplayName(PwmConstants.DEFAULT_LOCALE), ageString, errorDate, errorMsg));
            }
        }
    }
    if (config.getLdapProfiles() != null && !config.getLdapProfiles().isEmpty()) {
        final List<String> urls = config.getLdapProfiles().values().iterator().next().readSettingAsStringArray(PwmSetting.LDAP_SERVER_URLS);
        if (urls != null && !urls.isEmpty() && !StringUtil.isEmpty(urls.iterator().next())) {
            returnRecords.addAll(checkVendorSameness(pwmApplication));
            returnRecords.addAll(checkUserPermissionValues(pwmApplication));
            returnRecords.addAll(checkLdapDNSyntaxValues(pwmApplication));
        }
    }
    return returnRecords;
}
Also used : Configuration(password.pwm.config.Configuration) ChaiConfiguration(com.novell.ldapchai.provider.ChaiConfiguration) ArrayList(java.util.ArrayList) LdapProfile(password.pwm.config.profile.LdapProfile) ErrorInformation(password.pwm.error.ErrorInformation) TimeDuration(password.pwm.util.java.TimeDuration) Map(java.util.Map) HashMap(java.util.HashMap)

Example 80 with Configuration

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

the class ConfigurationReader method getConfiguration.

public Configuration getConfiguration() throws PwmUnrecoverableException {
    if (configuration == null) {
        final StoredConfigurationImpl newStoredConfig = this.storedConfiguration == null ? StoredConfigurationImpl.newStoredConfiguration() : this.storedConfiguration;
        configuration = new Configuration(newStoredConfig);
        if (storedConfiguration != null) {
            storedConfiguration.lock();
        }
    }
    return configuration;
}
Also used : Configuration(password.pwm.config.Configuration)

Aggregations

Configuration (password.pwm.config.Configuration)111 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)45 FormConfiguration (password.pwm.config.value.data.FormConfiguration)37 PwmApplication (password.pwm.PwmApplication)33 ErrorInformation (password.pwm.error.ErrorInformation)33 PwmOperationalException (password.pwm.error.PwmOperationalException)25 ActionConfiguration (password.pwm.config.value.data.ActionConfiguration)23 Locale (java.util.Locale)22 PwmSession (password.pwm.http.PwmSession)21 PwmException (password.pwm.error.PwmException)17 EmailItemBean (password.pwm.bean.EmailItemBean)16 SearchConfiguration (password.pwm.ldap.search.SearchConfiguration)16 UserInfo (password.pwm.ldap.UserInfo)15 ChaiUnavailableException (com.novell.ldapchai.exception.ChaiUnavailableException)14 IOException (java.io.IOException)14 ArrayList (java.util.ArrayList)13 MacroMachine (password.pwm.util.macro.MacroMachine)13 LinkedHashMap (java.util.LinkedHashMap)12 Instant (java.time.Instant)11 UserIdentity (password.pwm.bean.UserIdentity)10