Search in sources :

Example 6 with SetupResponsesBean

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);
        }
    }
}
Also used : ChallengeSet(com.novell.ldapchai.cr.ChallengeSet) ChallengeProfile(password.pwm.config.profile.ChallengeProfile) SetupResponsesBean(password.pwm.http.bean.SetupResponsesBean)

Example 7 with SetupResponsesBean

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);
    }
}
Also used : ErrorInformation(password.pwm.error.ErrorInformation) PwmDataValidationException(password.pwm.error.PwmDataValidationException) ChaiValidationException(com.novell.ldapchai.exception.ChaiValidationException) ChaiProvider(com.novell.ldapchai.provider.ChaiProvider) ChaiResponseSet(com.novell.ldapchai.cr.ChaiResponseSet) SetupResponsesBean(password.pwm.http.bean.SetupResponsesBean) ResponseInfoBean(password.pwm.bean.ResponseInfoBean)

Example 8 with SetupResponsesBean

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

Aggregations

SetupResponsesBean (password.pwm.http.bean.SetupResponsesBean)8 PwmApplication (password.pwm.PwmApplication)3 ErrorInformation (password.pwm.error.ErrorInformation)3 PwmDataValidationException (password.pwm.error.PwmDataValidationException)3 Challenge (com.novell.ldapchai.cr.Challenge)2 ChallengeSet (com.novell.ldapchai.cr.ChallengeSet)2 ChaiValidationException (com.novell.ldapchai.exception.ChaiValidationException)2 ResponseInfoBean (password.pwm.bean.ResponseInfoBean)2 PwmSession (password.pwm.http.PwmSession)2 ChaiResponseSet (com.novell.ldapchai.cr.ChaiResponseSet)1 ChaiProvider (com.novell.ldapchai.provider.ChaiProvider)1 Instant (java.time.Instant)1 ChallengeProfile (password.pwm.config.profile.ChallengeProfile)1 PwmOperationalException (password.pwm.error.PwmOperationalException)1 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)1 UserInfo (password.pwm.ldap.UserInfo)1 RestResultBean (password.pwm.ws.server.RestResultBean)1