Search in sources :

Example 11 with AuditRecord

use of password.pwm.svc.event.AuditRecord in project pwm by pwm-project.

the class ConfigManagerServlet method saveConfiguration.

public static void saveConfiguration(final PwmRequest pwmRequest, final StoredConfigurationImpl storedConfiguration) throws PwmUnrecoverableException {
    {
        final List<String> errorStrings = storedConfiguration.validateValues();
        if (errorStrings != null && !errorStrings.isEmpty()) {
            final String errorString = errorStrings.get(0);
            throw new PwmUnrecoverableException(new ErrorInformation(PwmError.CONFIG_FORMAT_ERROR, null, new String[] { errorString }));
        }
    }
    try {
        final ContextManager contextManager = ContextManager.getContextManager(pwmRequest.getHttpServletRequest().getSession().getServletContext());
        contextManager.getConfigReader().saveConfiguration(storedConfiguration, contextManager.getPwmApplication(), pwmRequest.getSessionLabel());
        final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
        if (pwmApplication.getAuditManager() != null && pwmApplication.getAuditManager().status() == PwmService.STATUS.OPEN) {
            final String modifyMessage = "Configuration Changes: " + storedConfiguration.changeLogAsDebugString(PwmConstants.DEFAULT_LOCALE, false);
            final AuditRecord auditRecord = new AuditRecordFactory(pwmApplication).createUserAuditRecord(AuditEvent.MODIFY_CONFIGURATION, pwmRequest.getUserInfoIfLoggedIn(), pwmRequest.getSessionLabel(), modifyMessage);
            pwmApplication.getAuditManager().submit(auditRecord);
        }
        contextManager.requestPwmApplicationRestart();
    } catch (Exception e) {
        final String errorString = "error saving file: " + e.getMessage();
        LOGGER.error(pwmRequest, errorString);
        throw new PwmUnrecoverableException(new ErrorInformation(PwmError.CONFIG_FORMAT_ERROR, null, new String[] { errorString }));
    }
}
Also used : ErrorInformation(password.pwm.error.ErrorInformation) AuditRecordFactory(password.pwm.svc.event.AuditRecordFactory) PwmApplication(password.pwm.PwmApplication) ContextManager(password.pwm.http.ContextManager) List(java.util.List) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) AuditRecord(password.pwm.svc.event.AuditRecord) ServletException(javax.servlet.ServletException) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) ChaiUnavailableException(com.novell.ldapchai.exception.ChaiUnavailableException) PwmException(password.pwm.error.PwmException) IOException(java.io.IOException)

Aggregations

AuditRecord (password.pwm.svc.event.AuditRecord)11 AuditRecordFactory (password.pwm.svc.event.AuditRecordFactory)10 ErrorInformation (password.pwm.error.ErrorInformation)3 PwmException (password.pwm.error.PwmException)3 PwmOperationalException (password.pwm.error.PwmOperationalException)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 PwmApplication (password.pwm.PwmApplication)2 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)2 ChaiUser (com.novell.ldapchai.ChaiUser)1 ChaiException (com.novell.ldapchai.exception.ChaiException)1 ChaiOperationException (com.novell.ldapchai.exception.ChaiOperationException)1 ChaiUnavailableException (com.novell.ldapchai.exception.ChaiUnavailableException)1 ChaiProvider (com.novell.ldapchai.provider.ChaiProvider)1 DirectoryVendor (com.novell.ldapchai.provider.DirectoryVendor)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1