use of password.pwm.http.bean.SetupResponsesBean in project pwm by pwm-project.
the class SetupResponsesServlet method initializeBean.
private void initializeBean(final PwmRequest pwmRequest, final SetupResponsesBean setupResponsesBean) throws PwmUnrecoverableException {
if (pwmRequest.getPwmSession().getUserInfo().getResponseInfoBean() != null) {
setupResponsesBean.setHasExistingResponses(true);
}
final ChallengeProfile challengeProfile = pwmRequest.getPwmSession().getUserInfo().getChallengeProfile();
if (setupResponsesBean.getResponseData() == null) {
// setup user challenge data
final ChallengeSet userChallengeSet = challengeProfile.getChallengeSet();
final int minRandomSetup = challengeProfile.getMinRandomSetup();
final SetupResponsesBean.SetupData userSetupData = populateSetupData(userChallengeSet, minRandomSetup);
setupResponsesBean.setResponseData(userSetupData);
}
if (setupResponsesBean.getHelpdeskResponseData() == null) {
// setup helpdesk challenge data
final ChallengeSet helpdeskChallengeSet = challengeProfile.getHelpdeskChallengeSet();
if (helpdeskChallengeSet == null) {
setupResponsesBean.setHelpdeskResponseData(new SetupResponsesBean.SetupData());
} else {
final int minRandomHelpdeskSetup = challengeProfile.getMinHelpdeskRandomsSetup();
final SetupResponsesBean.SetupData helpdeskSetupData = populateSetupData(helpdeskChallengeSet, minRandomHelpdeskSetup);
setupResponsesBean.setHelpdeskResponseData(helpdeskSetupData);
}
}
}
use of password.pwm.http.bean.SetupResponsesBean in project pwm by pwm-project.
the class SetupResponsesServlet method generateResponseInfoBean.
private static ResponseInfoBean generateResponseInfoBean(final PwmRequest pwmRequest, final ChallengeSet challengeSet, final Map<Challenge, String> readResponses, final Map<Challenge, String> helpdeskResponses) throws ChaiUnavailableException, PwmDataValidationException, PwmUnrecoverableException {
final ChaiProvider provider = pwmRequest.getPwmSession().getSessionManager().getChaiProvider();
try {
final ResponseInfoBean responseInfoBean = new ResponseInfoBean(readResponses, helpdeskResponses, challengeSet.getLocale(), challengeSet.getMinRandomRequired(), challengeSet.getIdentifier(), null, null);
final ChaiResponseSet responseSet = ChaiCrFactory.newChaiResponseSet(readResponses, challengeSet.getLocale(), challengeSet.getMinRandomRequired(), provider.getChaiConfiguration(), challengeSet.getIdentifier());
responseSet.meetsChallengeSetRequirements(challengeSet);
final SetupResponsesBean setupResponsesBean = pwmRequest.getPwmApplication().getSessionStateService().getBean(pwmRequest, SetupResponsesBean.class);
final int minRandomRequiredSetup = setupResponsesBean.getResponseData().getMinRandomSetup();
if (minRandomRequiredSetup == 0) {
// if using recover style, then all readResponseSet must be supplied at this point.
if (responseSet.getChallengeSet().getRandomChallenges().size() < challengeSet.getRandomChallenges().size()) {
throw new ChaiValidationException("too few random responses", ChaiError.CR_TOO_FEW_RANDOM_RESPONSES);
}
}
return responseInfoBean;
} catch (ChaiValidationException e) {
final ErrorInformation errorInfo = convertChaiValidationException(e);
throw new PwmDataValidationException(errorInfo);
}
}
use of password.pwm.http.bean.SetupResponsesBean in project pwm by pwm-project.
the class SetupResponsesServlet method processChangeResponses.
@ActionHandler(action = "changeResponses")
private ProcessStatus processChangeResponses(final PwmRequest pwmRequest) throws PwmUnrecoverableException {
final SetupResponsesBean setupResponsesBean = getSetupResponseBean(pwmRequest);
final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
pwmApplication.getSessionStateService().clearBean(pwmRequest, SetupResponsesBean.class);
this.initializeBean(pwmRequest, setupResponsesBean);
setupResponsesBean.setUserLocale(pwmRequest.getLocale());
return ProcessStatus.Continue;
}
Aggregations