@Override
    protected Event doExecuteInternal(final RequestContext requestContext) {
        try {
            val requestParameters = requestContext.getRequestParameters();
            val questions = Arrays.stream(requestParameters.getRequiredArray("questions", String.class))
                .distinct().toList();
            val answers = Arrays.stream(requestParameters.getRequiredArray("answers", String.class))
                .distinct().toList();
            FunctionUtils.throwIf(questions.size() != answers.size(),
                () -> new IllegalArgumentException("Security questions do not match the given answers"));
            val securityQuestions = new LinkedMultiValueMap<String, String>();
            for (var i = 0; i < questions.size(); i++) {
                val question = questions.get(i).trim();
                val answer = answers.get(i).trim();
                if (StringUtils.isNotBlank(question) && StringUtils.isNotBlank(answer)
                    && !StringUtils.equalsIgnoreCase(question, answer)
                    && question.length() >= INPUT_LENGTH_MINIMUM
                    && answer.length() >= INPUT_LENGTH_MINIMUM) {
                    securityQuestions.put(question, List.of(answer));
                }
            }
            FunctionUtils.throwIf(securityQuestions.isEmpty(),
                () -> new IllegalArgumentException("Security questions cannot be empty or unspecified"));
            val tgt = WebUtils.getTicketGrantingTicket(requestContext);
            if (tgt instanceof final AuthenticationAwareTicket aat) {
                val principal = aat.getAuthentication().getPrincipal();
                val query = PasswordManagementQuery.builder()
                    .username(principal.getId())
                    .securityQuestions(securityQuestions)
                    .build();
                LOGGER.debug("Updating security questions for [{}]", query);
                passwordManagementService.updateSecurityQuestions(query);
                WebUtils.addInfoMessageToContext(requestContext, CODE_SUCCESS);
                return success();
            }
        } catch (final Throwable e) {
            LoggingUtils.error(LOGGER, e);
            WebUtils.addErrorMessageToContext(requestContext, CODE_FAILURE);
        }
        return error();
    }
This is {@link AccountProfileUpdateSecurityQuestionsAction}.

@author Misagh Moayyed
@since 6.6.0
support/cas-server-support-pm-webflow/src/main/java/org/apereo/cas/pm/web/flow/actions/AccountProfileUpdateSecurityQuestionsAction.java