Search in sources :

Example 56 with RestResultBean

use of password.pwm.ws.server.RestResultBean in project pwm by pwm-project.

the class AdminServlet method processReportData.

@ActionHandler(action = "reportData")
public ProcessStatus processReportData(final PwmRequest pwmRequest) throws PwmUnrecoverableException, IOException {
    final int maximum = Math.min(pwmRequest.readParameterAsInt("maximum", 1000), 10 * 1000);
    final ReportService reportService = pwmRequest.getPwmApplication().getReportService();
    final ArrayList<UserCacheRecord> reportData = new ArrayList<>();
    ClosableIterator<UserCacheRecord> cacheBeanIterator = null;
    try {
        cacheBeanIterator = reportService.iterator();
        while (cacheBeanIterator.hasNext() && reportData.size() < maximum) {
            final UserCacheRecord userCacheRecord = cacheBeanIterator.next();
            if (userCacheRecord != null) {
                reportData.add(userCacheRecord);
            }
        }
    } finally {
        if (cacheBeanIterator != null) {
            cacheBeanIterator.close();
        }
    }
    final HashMap<String, Object> returnData = new HashMap<>();
    returnData.put("users", reportData);
    final RestResultBean restResultBean = RestResultBean.withData(returnData);
    pwmRequest.outputJsonResult(restResultBean);
    return ProcessStatus.Halt;
}
Also used : UserCacheRecord(password.pwm.svc.report.UserCacheRecord) ReportService(password.pwm.svc.report.ReportService) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) RestResultBean(password.pwm.ws.server.RestResultBean)

Example 57 with RestResultBean

use of password.pwm.ws.server.RestResultBean in project pwm by pwm-project.

the class ChangePasswordServlet method processCheckProgressAction.

@ActionHandler(action = "checkProgress")
ProcessStatus processCheckProgressAction(final PwmRequest pwmRequest) throws ServletException, PwmUnrecoverableException, IOException {
    final ChangePasswordBean changePasswordBean = pwmRequest.getPwmApplication().getSessionStateService().getBean(pwmRequest, ChangePasswordBean.class);
    final PasswordChangeProgressChecker.ProgressTracker progressTracker = changePasswordBean.getChangeProgressTracker();
    final PasswordChangeProgressChecker.PasswordChangeProgress passwordChangeProgress;
    if (progressTracker == null) {
        passwordChangeProgress = PasswordChangeProgressChecker.PasswordChangeProgress.COMPLETE;
    } else {
        final PasswordChangeProgressChecker checker = new PasswordChangeProgressChecker(pwmRequest.getPwmApplication(), pwmRequest.getPwmSession().getUserInfo().getUserIdentity(), pwmRequest.getSessionLabel(), pwmRequest.getLocale());
        passwordChangeProgress = checker.figureProgress(progressTracker);
    }
    final RestResultBean restResultBean = RestResultBean.withData(passwordChangeProgress);
    LOGGER.trace(pwmRequest, "returning result for restCheckProgress: " + JsonUtil.serialize(restResultBean));
    pwmRequest.outputJsonResult(restResultBean);
    return ProcessStatus.Halt;
}
Also used : ChangePasswordBean(password.pwm.http.bean.ChangePasswordBean) PasswordChangeProgressChecker(password.pwm.ldap.PasswordChangeProgressChecker) RestResultBean(password.pwm.ws.server.RestResultBean)

Example 58 with RestResultBean

use of password.pwm.ws.server.RestResultBean in project pwm by pwm-project.

the class ConfigEditorServlet method restReadChangeLog.

@ActionHandler(action = "readChangeLog")
private ProcessStatus restReadChangeLog(final PwmRequest pwmRequest) throws IOException, PwmUnrecoverableException {
    final ConfigManagerBean configManagerBean = getBean(pwmRequest);
    final Locale locale = pwmRequest.getLocale();
    final HashMap<String, Object> returnObj = new HashMap<>();
    returnObj.put("html", configManagerBean.getStoredConfiguration().changeLogAsDebugString(locale, true));
    returnObj.put("modified", configManagerBean.getStoredConfiguration().isModified());
    try {
        final ConfigurationChecker configurationChecker = new ConfigurationChecker();
        final Configuration config = new Configuration(configManagerBean.getStoredConfiguration());
        final List<HealthRecord> healthRecords = configurationChecker.doHealthCheck(config, pwmRequest.getLocale());
        final HealthData healthData = new HealthData();
        healthData.setOverall("CONFIG");
        healthData.setRecords(password.pwm.ws.server.rest.bean.HealthRecord.fromHealthRecords(healthRecords, locale, config));
        returnObj.put("health", healthData);
    } catch (Exception e) {
        LOGGER.error(pwmRequest, "error generating health records: " + e.getMessage());
    }
    final RestResultBean restResultBean = RestResultBean.withData(returnObj);
    pwmRequest.outputJsonResult(restResultBean);
    return ProcessStatus.Halt;
}
Also used : Locale(java.util.Locale) ConfigurationChecker(password.pwm.health.ConfigurationChecker) HealthData(password.pwm.ws.server.rest.bean.HealthData) Configuration(password.pwm.config.Configuration) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ServletException(javax.servlet.ServletException) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) PwmOperationalException(password.pwm.error.PwmOperationalException) ChaiUnavailableException(com.novell.ldapchai.exception.ChaiUnavailableException) PwmException(password.pwm.error.PwmException) IOException(java.io.IOException) ConfigManagerBean(password.pwm.http.bean.ConfigManagerBean) HealthRecord(password.pwm.health.HealthRecord) RestResultBean(password.pwm.ws.server.RestResultBean)

Example 59 with RestResultBean

use of password.pwm.ws.server.RestResultBean in project pwm by pwm-project.

the class ConfigEditorServlet method restDatabaseHealthCheck.

@ActionHandler(action = "databaseHealthCheck")
private ProcessStatus restDatabaseHealthCheck(final PwmRequest pwmRequest) throws IOException, PwmUnrecoverableException {
    final Instant startTime = Instant.now();
    final ConfigManagerBean configManagerBean = getBean(pwmRequest);
    LOGGER.debug(pwmRequest, "beginning restDatabaseHealthCheck");
    final Configuration config = new Configuration(configManagerBean.getStoredConfiguration());
    final List<HealthRecord> healthRecords = DatabaseStatusChecker.checkNewDatabaseStatus(pwmRequest.getPwmApplication(), config);
    final HealthData healthData = HealthRecord.asHealthDataBean(config, pwmRequest.getLocale(), healthRecords);
    final RestResultBean restResultBean = RestResultBean.withData(healthData);
    pwmRequest.outputJsonResult(restResultBean);
    LOGGER.debug(pwmRequest, "completed restDatabaseHealthCheck in " + TimeDuration.fromCurrent(startTime).asCompactString());
    return ProcessStatus.Halt;
}
Also used : HealthData(password.pwm.ws.server.rest.bean.HealthData) ConfigManagerBean(password.pwm.http.bean.ConfigManagerBean) HealthRecord(password.pwm.health.HealthRecord) Configuration(password.pwm.config.Configuration) Instant(java.time.Instant) RestResultBean(password.pwm.ws.server.RestResultBean)

Example 60 with RestResultBean

use of password.pwm.ws.server.RestResultBean in project pwm by pwm-project.

the class ConfigEditorServlet method restConfigSettingData.

@ActionHandler(action = "settingData")
private ProcessStatus restConfigSettingData(final PwmRequest pwmRequest) throws IOException, PwmUnrecoverableException {
    final ConfigManagerBean configManagerBean = getBean(pwmRequest);
    final LinkedHashMap<String, Object> returnMap = new LinkedHashMap<>(generateSettingData(pwmRequest.getPwmApplication(), configManagerBean.getStoredConfiguration(), pwmRequest.getSessionLabel(), pwmRequest.getLocale()));
    if (pwmRequest.getPwmApplication().getApplicationMode() == PwmApplicationMode.CONFIGURATION && !PwmConstants.TRIAL_MODE) {
        if (!configManagerBean.isConfigUnlockedWarningShown()) {
            returnMap.put("configUnlocked", true);
            configManagerBean.setConfigUnlockedWarningShown(true);
        }
    }
    final RestResultBean restResultBean = RestResultBean.withData(new LinkedHashMap<>(returnMap));
    pwmRequest.outputJsonResult(restResultBean);
    return ProcessStatus.Halt;
}
Also used : ConfigManagerBean(password.pwm.http.bean.ConfigManagerBean) LinkedHashMap(java.util.LinkedHashMap) RestResultBean(password.pwm.ws.server.RestResultBean)

Aggregations

RestResultBean (password.pwm.ws.server.RestResultBean)63 ErrorInformation (password.pwm.error.ErrorInformation)27 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)21 UserIdentity (password.pwm.bean.UserIdentity)16 PwmException (password.pwm.error.PwmException)16 HelpdeskProfile (password.pwm.config.profile.HelpdeskProfile)15 Instant (java.time.Instant)14 PwmOperationalException (password.pwm.error.PwmOperationalException)14 HashMap (java.util.HashMap)11 LinkedHashMap (java.util.LinkedHashMap)11 ChaiUnavailableException (com.novell.ldapchai.exception.ChaiUnavailableException)10 IOException (java.io.IOException)10 PwmApplication (password.pwm.PwmApplication)10 PwmSession (password.pwm.http.PwmSession)10 ConfigManagerBean (password.pwm.http.bean.ConfigManagerBean)9 ArrayList (java.util.ArrayList)8 ServletException (javax.servlet.ServletException)8 UserInfo (password.pwm.ldap.UserInfo)8 AuditRecordFactory (password.pwm.svc.event.AuditRecordFactory)8 HelpdeskAuditRecord (password.pwm.svc.event.HelpdeskAuditRecord)8