Search in sources :

Example 11 with ConfigurationReader

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

the class LocalDBLoggerTest method setUp.

@Override
protected void setUp() throws Exception {
    // To change body of overridden methods use File | Settings | File Templates.
    super.setUp();
    TestHelper.setupLogging();
    final File localDBPath = new File(TestHelper.getParameter("localDBPath"));
    final File configFile = new File(TestHelper.getParameter("configurationFile"));
    final ConfigurationReader reader = new ConfigurationReader(configFile);
    config = reader.getConfiguration();
    localDB = LocalDBFactory.getInstance(localDBPath, false, null, config);
    // localDB.truncate(LocalDB.DB.EVENTLOG_EVENTS);
    // System.out.println(localDB.size(LocalDB.DB.EVENTLOG_EVENTS));
    // new TimeDuration(1,TimeUnit.HOURS).pause();
    {
        // open localDBLogger based on configuration settings;
        final int maxEvents = (int) reader.getConfiguration().readSettingAsLong(PwmSetting.EVENTS_PWMDB_MAX_EVENTS);
        final long maxAgeMs = reader.getConfiguration().readSettingAsLong(PwmSetting.EVENTS_PWMDB_MAX_AGE) * (long) 1000;
        final LocalDBLoggerSettings settings = new LocalDBLoggerSettings.Builder().setMaxEvents(maxEvents).setMaxAge(new TimeDuration(maxAgeMs)).setFlags(Collections.<LocalDBLoggerSettings.Flag>emptySet()).createLocalDBLoggerSettings();
        localDBLogger = new LocalDBLogger(null, localDB, settings);
    }
    settings = new Settings();
    settings.threads = 10;
    settings.testDuration = new TimeDuration(3, TimeUnit.HOURS);
    settings.valueLength = 5000;
    settings.batchSize = 100;
}
Also used : LocalDBLogger(password.pwm.util.logging.LocalDBLogger) LocalDBLoggerSettings(password.pwm.util.logging.LocalDBLoggerSettings) TimeDuration(password.pwm.util.java.TimeDuration) File(java.io.File) ConfigurationReader(password.pwm.config.stored.ConfigurationReader) LocalDBLoggerSettings(password.pwm.util.logging.LocalDBLoggerSettings)

Example 12 with ConfigurationReader

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

the class ConfigManagerServlet method initRequestAttributes.

void initRequestAttributes(final PwmRequest pwmRequest) throws PwmUnrecoverableException {
    final ConfigurationReader configurationReader = pwmRequest.getContextManager().getConfigReader();
    pwmRequest.setAttribute(PwmRequestAttribute.PageTitle, LocaleHelper.getLocalizedMessage(Config.Title_ConfigManager, pwmRequest));
    pwmRequest.setAttribute(PwmRequestAttribute.ApplicationPath, pwmRequest.getPwmApplication().getPwmEnvironment().getApplicationPath().getAbsolutePath());
    pwmRequest.setAttribute(PwmRequestAttribute.ConfigFilename, configurationReader.getConfigFile().getAbsolutePath());
    {
        final Instant lastModifyTime = configurationReader.getStoredConfiguration().modifyTime();
        final String output = lastModifyTime == null ? LocaleHelper.getLocalizedMessage(Display.Value_NotApplicable, pwmRequest) : JavaHelper.toIsoDate(lastModifyTime);
        pwmRequest.setAttribute(PwmRequestAttribute.ConfigLastModified, output);
    }
    pwmRequest.setAttribute(PwmRequestAttribute.ConfigHasPassword, LocaleHelper.booleanString(configurationReader.getStoredConfiguration().hasPassword(), pwmRequest.getLocale(), pwmRequest.getConfig()));
}
Also used : Instant(java.time.Instant) ConfigurationReader(password.pwm.config.stored.ConfigurationReader)

Example 13 with ConfigurationReader

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

the class ConfigManagerServlet method readCurrentConfiguration.

public static StoredConfigurationImpl readCurrentConfiguration(final PwmRequest pwmRequest) throws PwmUnrecoverableException {
    final ContextManager contextManager = ContextManager.getContextManager(pwmRequest.getHttpServletRequest().getSession());
    final ConfigurationReader runningConfigReader = contextManager.getConfigReader();
    final StoredConfigurationImpl runningConfig = runningConfigReader.getStoredConfiguration();
    return StoredConfigurationImpl.copy(runningConfig);
}
Also used : StoredConfigurationImpl(password.pwm.config.stored.StoredConfigurationImpl) ContextManager(password.pwm.http.ContextManager) ConfigurationReader(password.pwm.config.stored.ConfigurationReader)

Aggregations

ConfigurationReader (password.pwm.config.stored.ConfigurationReader)13 StoredConfigurationImpl (password.pwm.config.stored.StoredConfigurationImpl)7 File (java.io.File)5 PwmApplication (password.pwm.PwmApplication)4 ErrorInformation (password.pwm.error.ErrorInformation)3 PwmException (password.pwm.error.PwmException)3 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)3 IOException (java.io.IOException)2 Instant (java.time.Instant)2 ServletException (javax.servlet.ServletException)2 Configuration (password.pwm.config.Configuration)2 FileInputStream (java.io.FileInputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 Timer (java.util.Timer)1 PwmApplicationMode (password.pwm.PwmApplicationMode)1 PwmEnvironment (password.pwm.PwmEnvironment)1 PwmSetting (password.pwm.config.PwmSetting)1 PwmOperationalException (password.pwm.error.PwmOperationalException)1 ContextManager (password.pwm.http.ContextManager)1