protected Optional<AuthenticatedAssertionContext> validateRequestAndBuildCasAssertion(
        final HttpServletResponse response,
        final HttpServletRequest request,
        final Pair<? extends RequestAbstractType, MessageContext> authnContext)
        throws Throwable {

        val ticket = request.getParameter(CasProtocolConstants.PARAMETER_TICKET);
        if (StringUtils.isBlank(ticket) && authnContext.getKey() instanceof final AuthnRequest authnRequest
            && Boolean.TRUE.equals(authnRequest.isPassive())) {
            LOGGER.info("Unable to establish authentication context for passive authentication request");
            return Optional.empty();
        }

        val validator = getConfigurationContext().getTicketValidator();
        val serviceUrl = constructServiceUrl(request, response, authnContext);
        LOGGER.trace("Created service url for validation: [{}]", serviceUrl);
        val assertion = validator.validate(ticket, serviceUrl);
        logCasValidationAssertion(assertion);

        val asserted = assertion.getAssertion();
        Objects.requireNonNull(asserted, "Validation assertion cannot be null");
        return Optional.of(AuthenticatedAssertionContext.builder()
            .name(assertion.getPrincipal().getId())
            .authenticationDate(DateTimeUtils.zonedDateTimeOf(asserted.getPrimaryAuthentication().getAuthenticationDate()))
            .attributes(CollectionUtils.merge(assertion.getAttributes(), assertion.getPrincipal().getAttributes()))
            .build());
    }
Handle callback profile request.

@param response the response
@param request  the request
@return the model and view
@throws Exception the exception
support/cas-server-support-saml-idp-web/src/main/java/org/apereo/cas/support/saml/web/idp/profile/sso/SSOSamlIdPProfileCallbackHandlerController.java