use of password.pwm.http.bean.AdminBean in project pwm by pwm-project.
the class AdminServlet method processDebugUserSearch.
private void processDebugUserSearch(final PwmRequest pwmRequest) throws PwmUnrecoverableException {
final String username = pwmRequest.readParameterAsString("username", PwmHttpRequestWrapper.Flag.BypassValidation);
if (StringUtil.isEmpty(username)) {
return;
}
final UserSearchEngine userSearchEngine = pwmRequest.getPwmApplication().getUserSearchEngine();
final UserIdentity userIdentity;
try {
userIdentity = userSearchEngine.resolveUsername(username, null, null, pwmRequest.getSessionLabel());
final AdminBean adminBean = pwmRequest.getPwmApplication().getSessionStateService().getBean(pwmRequest, AdminBean.class);
adminBean.setLastUserDebug(userIdentity);
} catch (PwmUnrecoverableException e) {
setLastError(pwmRequest, e.getErrorInformation());
return;
} catch (PwmOperationalException e) {
setLastError(pwmRequest, e.getErrorInformation());
return;
}
final UserDebugDataBean userDebugData = UserDebugDataReader.readUserDebugData(pwmRequest.getPwmApplication(), pwmRequest.getLocale(), pwmRequest.getSessionLabel(), userIdentity);
pwmRequest.setAttribute(PwmRequestAttribute.UserDebugData, userDebugData);
}
use of password.pwm.http.bean.AdminBean in project pwm by pwm-project.
the class AdminServlet method processDownloadUserDebug.
@ActionHandler(action = "downloadUserDebug")
private ProcessStatus processDownloadUserDebug(final PwmRequest pwmRequest) throws ChaiUnavailableException, PwmUnrecoverableException, IOException, ServletException {
final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
final AdminBean adminBean = pwmRequest.getPwmApplication().getSessionStateService().getBean(pwmRequest, AdminBean.class);
final UserIdentity userIdentity = adminBean.getLastUserDebug();
if (userIdentity != null) {
pwmRequest.getPwmResponse().markAsDownload(HttpContentType.json, pwmApplication.getConfig().readAppProperty(AppProperty.DOWNLOAD_FILENAME_USER_DEBUG_JSON));
final UserDebugDataBean userDebugData = UserDebugDataReader.readUserDebugData(pwmRequest.getPwmApplication(), pwmRequest.getLocale(), pwmRequest.getSessionLabel(), userIdentity);
final String output = JsonUtil.serialize(userDebugData, JsonUtil.Flag.PrettyPrint);
pwmRequest.getPwmResponse().getOutputStream().write(output.getBytes(PwmConstants.DEFAULT_CHARSET));
} else {
pwmRequest.respondWithError(new ErrorInformation(PwmError.ERROR_UNKNOWN, "no previously searched user available for download"));
}
return ProcessStatus.Halt;
}
Aggregations