Search in sources :

Example 1 with StoredConfigReference

use of password.pwm.config.stored.StoredConfigReference in project pwm by pwm-project.

the class ConfigManagerCertificatesServlet method makeCertificateDebugData.

List<CertificateDebugDataItem> makeCertificateDebugData(final Configuration configuration) throws PwmUnrecoverableException {
    final StoredConfigurationImpl storedConfiguration = configuration.getStoredConfiguration();
    final List<StoredConfigReference> modifiedSettings = StoredConfigurationUtil.modifiedSettings(storedConfiguration);
    final List<CertificateDebugDataItem> certificateDebugDataItems = new ArrayList<>();
    for (final StoredConfigReference ref : modifiedSettings) {
        if (ref.getRecordType() == StoredConfigReference.RecordType.SETTING) {
            final PwmSetting pwmSetting = PwmSetting.forKey(ref.getRecordID());
            if (pwmSetting.getSyntax() == PwmSettingSyntax.X509CERT) {
                final StoredValue storedValue;
                if (pwmSetting.getCategory().hasProfiles()) {
                    storedValue = storedConfiguration.readSetting(pwmSetting, ref.getProfileID());
                } else {
                    storedValue = storedConfiguration.readSetting(pwmSetting);
                }
                final X509Certificate[] arrayCerts = (X509Certificate[]) storedValue.toNativeObject();
                final List<X509Certificate> certificates = arrayCerts == null ? Collections.emptyList() : Arrays.asList(arrayCerts);
                certificateDebugDataItems.addAll(makeItems(pwmSetting, ref.getProfileID(), certificates));
            } else if (pwmSetting.getSyntax() == PwmSettingSyntax.ACTION) {
                final StoredValue storedValue;
                if (pwmSetting.getCategory().hasProfiles()) {
                    storedValue = storedConfiguration.readSetting(pwmSetting, ref.getProfileID());
                } else {
                    storedValue = storedConfiguration.readSetting(pwmSetting);
                }
                final List<ActionConfiguration> actionConfigurations = (List) storedValue.toNativeObject();
                for (final ActionConfiguration actionConfiguration : actionConfigurations) {
                    final List<X509Certificate> certificates = actionConfiguration.getCertificates();
                    certificateDebugDataItems.addAll(makeItems(pwmSetting, ref.getProfileID(), certificates));
                }
            }
        }
    }
    Collections.sort(certificateDebugDataItems);
    return Collections.unmodifiableList(certificateDebugDataItems);
}
Also used : StoredConfigurationImpl(password.pwm.config.stored.StoredConfigurationImpl) ArrayList(java.util.ArrayList) StoredValue(password.pwm.config.StoredValue) X509Certificate(java.security.cert.X509Certificate) StoredConfigReference(password.pwm.config.stored.StoredConfigReference) PwmSetting(password.pwm.config.PwmSetting) ArrayList(java.util.ArrayList) List(java.util.List) ActionConfiguration(password.pwm.config.value.data.ActionConfiguration)

Example 2 with StoredConfigReference

use of password.pwm.config.stored.StoredConfigReference in project pwm by pwm-project.

the class CertificateChecker method doActionHealthCheck.

private static List<HealthRecord> doActionHealthCheck(final Configuration configuration) throws PwmUnrecoverableException {
    final StoredConfigurationImpl storedConfiguration = configuration.getStoredConfiguration();
    final List<HealthRecord> returnList = new ArrayList<>();
    final List<StoredConfigReference> modifiedReferences = StoredConfigurationUtil.modifiedSettings(storedConfiguration);
    for (final StoredConfigReference storedConfigReference : modifiedReferences) {
        if (storedConfigReference.getRecordType() == StoredConfigReference.RecordType.SETTING) {
            final PwmSetting pwmSetting = PwmSetting.forKey(storedConfigReference.getRecordID());
            if (pwmSetting != null && pwmSetting.getSyntax() == PwmSettingSyntax.ACTION) {
                final ActionValue value = (ActionValue) storedConfiguration.readSetting(pwmSetting, storedConfigReference.getProfileID());
                for (final ActionConfiguration actionConfiguration : value.toNativeObject()) {
                    final List<X509Certificate> certificates = actionConfiguration.getCertificates();
                    returnList.addAll(doHealthCheck(configuration, pwmSetting, storedConfigReference.getProfileID(), certificates));
                }
            }
        }
    }
    return Collections.unmodifiableList(returnList);
}
Also used : StoredConfigReference(password.pwm.config.stored.StoredConfigReference) PwmSetting(password.pwm.config.PwmSetting) StoredConfigurationImpl(password.pwm.config.stored.StoredConfigurationImpl) ActionValue(password.pwm.config.value.ActionValue) ArrayList(java.util.ArrayList) ActionConfiguration(password.pwm.config.value.data.ActionConfiguration) X509Certificate(java.security.cert.X509Certificate)

Aggregations

X509Certificate (java.security.cert.X509Certificate)2 ArrayList (java.util.ArrayList)2 PwmSetting (password.pwm.config.PwmSetting)2 StoredConfigReference (password.pwm.config.stored.StoredConfigReference)2 StoredConfigurationImpl (password.pwm.config.stored.StoredConfigurationImpl)2 ActionConfiguration (password.pwm.config.value.data.ActionConfiguration)2 List (java.util.List)1 StoredValue (password.pwm.config.StoredValue)1 ActionValue (password.pwm.config.value.ActionValue)1