Search in sources :

Example 1 with AdminBean

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);
}
Also used : UserSearchEngine(password.pwm.ldap.search.UserSearchEngine) UserIdentity(password.pwm.bean.UserIdentity) AdminBean(password.pwm.http.bean.AdminBean) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) PwmOperationalException(password.pwm.error.PwmOperationalException)

Example 2 with AdminBean

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;
}
Also used : ErrorInformation(password.pwm.error.ErrorInformation) PwmApplication(password.pwm.PwmApplication) UserIdentity(password.pwm.bean.UserIdentity) AdminBean(password.pwm.http.bean.AdminBean)

Aggregations

UserIdentity (password.pwm.bean.UserIdentity)2 AdminBean (password.pwm.http.bean.AdminBean)2 PwmApplication (password.pwm.PwmApplication)1 ErrorInformation (password.pwm.error.ErrorInformation)1 PwmOperationalException (password.pwm.error.PwmOperationalException)1 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)1 UserSearchEngine (password.pwm.ldap.search.UserSearchEngine)1