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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations