use of com.novell.ldapchai.exception.ChaiUnavailableException in project pwm by pwm-project.
the class ForgottenPasswordServlet method processCheckResponses.
@ActionHandler(action = "checkResponses")
private ProcessStatus processCheckResponses(final PwmRequest pwmRequest) throws ChaiUnavailableException, IOException, ServletException, PwmUnrecoverableException {
final ForgottenPasswordBean forgottenPasswordBean = forgottenPasswordBean(pwmRequest);
if (forgottenPasswordBean.getUserIdentity() == null) {
return ProcessStatus.Continue;
}
final UserIdentity userIdentity = forgottenPasswordBean.getUserIdentity();
final ResponseSet responseSet = ForgottenPasswordUtil.readResponseSet(pwmRequest, forgottenPasswordBean);
if (responseSet == null) {
final String errorMsg = "attempt to check responses, but responses are not loaded into session bean";
final ErrorInformation errorInformation = new ErrorInformation(PwmError.ERROR_UNKNOWN, errorMsg);
throw new PwmUnrecoverableException(errorInformation);
}
try {
// read the supplied responses from the user
final Map<Challenge, String> crMap = ForgottenPasswordUtil.readResponsesFromHttpRequest(pwmRequest, forgottenPasswordBean.getPresentableChallengeSet());
final boolean responsesPassed;
try {
responsesPassed = responseSet.test(crMap);
} catch (ChaiUnavailableException e) {
if (e.getCause() instanceof PwmUnrecoverableException) {
throw (PwmUnrecoverableException) e.getCause();
}
throw e;
}
// special case for nmas, clear out existing challenges and input fields.
if (!responsesPassed && responseSet instanceof NMASCrOperator.NMASCRResponseSet) {
forgottenPasswordBean.setPresentableChallengeSet(responseSet.getPresentableChallengeSet());
}
if (responsesPassed) {
LOGGER.debug(pwmRequest, "user '" + userIdentity + "' has supplied correct responses");
} else {
final String errorMsg = "incorrect response to one or more challenges";
final ErrorInformation errorInformation = new ErrorInformation(PwmError.ERROR_INCORRECT_RESPONSE, errorMsg);
handleUserVerificationBadAttempt(pwmRequest, forgottenPasswordBean, errorInformation);
return ProcessStatus.Continue;
}
} catch (ChaiValidationException e) {
LOGGER.debug(pwmRequest, "chai validation error checking user responses: " + e.getMessage());
final ErrorInformation errorInformation = new ErrorInformation(PwmError.forChaiError(e.getErrorCode()));
handleUserVerificationBadAttempt(pwmRequest, forgottenPasswordBean, errorInformation);
return ProcessStatus.Continue;
}
forgottenPasswordBean.getProgress().getSatisfiedMethods().add(IdentityVerificationMethod.CHALLENGE_RESPONSES);
return ProcessStatus.Continue;
}
use of com.novell.ldapchai.exception.ChaiUnavailableException in project pwm by pwm-project.
the class ClientApiServlet method doGetStringsData.
@ActionHandler(action = "strings")
public ProcessStatus doGetStringsData(final PwmRequest pwmRequest) throws PwmUnrecoverableException, IOException, ChaiUnavailableException, ServletException {
final String bundleName = pwmRequest.readParameterAsString("bundle");
final int maxCacheAgeSeconds = 60 * 5;
final String eTagValue = makeClientEtag(pwmRequest.getPwmApplication(), pwmRequest.getPwmSession(), pwmRequest.getHttpServletRequest());
pwmRequest.getPwmResponse().setHeader(HttpHeader.ETag, eTagValue);
pwmRequest.getPwmResponse().setHeader(HttpHeader.Expires, String.valueOf(System.currentTimeMillis() + (maxCacheAgeSeconds * 1000)));
pwmRequest.getPwmResponse().setHeader(HttpHeader.Cache_Control, "public, max-age=" + maxCacheAgeSeconds);
try {
final LinkedHashMap<String, String> displayData = new LinkedHashMap<>(makeDisplayData(pwmRequest.getPwmApplication(), pwmRequest.getPwmSession(), bundleName));
final RestResultBean restResultBean = RestResultBean.withData(displayData);
pwmRequest.outputJsonResult(restResultBean);
} catch (Exception e) {
final String errorMSg = "error during rest /strings call for bundle " + bundleName + ", error: " + e.getMessage();
final ErrorInformation errorInformation = new ErrorInformation(PwmError.ERROR_UNKNOWN, errorMSg);
LOGGER.debug(pwmRequest, errorInformation);
pwmRequest.respondWithError(errorInformation);
}
return ProcessStatus.Halt;
}
use of com.novell.ldapchai.exception.ChaiUnavailableException in project pwm by pwm-project.
the class AdminServlet method downloadAuditLogCsv.
@ActionHandler(action = "downloadAuditLogCsv")
private ProcessStatus downloadAuditLogCsv(final PwmRequest pwmRequest) throws PwmUnrecoverableException, IOException, ChaiUnavailableException, ServletException {
final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
pwmRequest.getPwmResponse().markAsDownload(HttpContentType.csv, pwmApplication.getConfig().readAppProperty(AppProperty.DOWNLOAD_FILENAME_AUDIT_RECORDS_CSV));
final OutputStream outputStream = pwmRequest.getPwmResponse().getOutputStream();
try {
pwmApplication.getAuditManager().outputVaultToCsv(outputStream, pwmRequest.getLocale(), true);
} catch (Exception e) {
final ErrorInformation errorInformation = new ErrorInformation(PwmError.ERROR_UNKNOWN, e.getMessage());
pwmRequest.respondWithError(errorInformation);
} finally {
outputStream.close();
}
return ProcessStatus.Halt;
}
use of com.novell.ldapchai.exception.ChaiUnavailableException in project pwm by pwm-project.
the class AdminServlet method downloadUserSummaryCsv.
@ActionHandler(action = "downloadUserSummaryCsv")
private ProcessStatus downloadUserSummaryCsv(final PwmRequest pwmRequest) throws PwmUnrecoverableException, IOException, ChaiUnavailableException, ServletException {
final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
pwmRequest.getPwmResponse().markAsDownload(HttpContentType.csv, pwmApplication.getConfig().readAppProperty(AppProperty.DOWNLOAD_FILENAME_USER_REPORT_SUMMARY_CSV));
final OutputStream outputStream = pwmRequest.getPwmResponse().getOutputStream();
try {
final ReportCsvUtility reportCsvUtility = new ReportCsvUtility(pwmApplication);
reportCsvUtility.outputSummaryToCsv(outputStream, pwmRequest.getLocale());
} catch (Exception e) {
final ErrorInformation errorInformation = new ErrorInformation(PwmError.ERROR_UNKNOWN, e.getMessage());
pwmRequest.respondWithError(errorInformation);
} finally {
outputStream.close();
}
return ProcessStatus.Halt;
}
use of com.novell.ldapchai.exception.ChaiUnavailableException in project pwm by pwm-project.
the class AdminServlet method downloadStatisticsLogCsv.
@ActionHandler(action = "downloadStatisticsLogCsv")
private ProcessStatus downloadStatisticsLogCsv(final PwmRequest pwmRequest) throws PwmUnrecoverableException, IOException, ChaiUnavailableException, ServletException {
final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
pwmRequest.getPwmResponse().markAsDownload(HttpContentType.csv, pwmRequest.getPwmApplication().getConfig().readAppProperty(AppProperty.DOWNLOAD_FILENAME_STATISTICS_CSV));
final OutputStream outputStream = pwmRequest.getPwmResponse().getOutputStream();
try {
final StatisticsManager statsManager = pwmApplication.getStatisticsManager();
statsManager.outputStatsToCsv(outputStream, pwmRequest.getLocale(), true);
} catch (Exception e) {
final ErrorInformation errorInformation = new ErrorInformation(PwmError.ERROR_UNKNOWN, e.getMessage());
pwmRequest.respondWithError(errorInformation);
} finally {
outputStream.close();
}
return ProcessStatus.Halt;
}
Aggregations