protected void handleEcpRequest(final SamlProfileBuilderContext context, final Credential credential) throws Exception {
        LOGGER.debug("Handling ECP request for SOAP context [{}]", context.getMessageContext());

        val envelope = context.getMessageContext().getSubcontext(SOAP11Context.class).getEnvelope();
        getConfigurationContext().getOpenSamlConfigBean().logObject(envelope);

        val authnRequest = (AuthnRequest) context.getMessageContext().getMessage();
        val authenticationContext = Pair.of(authnRequest, context.getMessageContext());
        try {
            LOGGER.trace("Verifying ECP authentication request [{}]", authnRequest);
            val serviceRequest = verifySamlAuthenticationRequest(authenticationContext, context.getHttpRequest());

            LOGGER.trace("Attempting to authenticate ECP request for credential id [{}]", credential.getId());
            val authentication = authenticateEcpRequest(credential, authenticationContext);
            LOGGER.debug("Authenticated [{}] successfully with authenticated principal [{}]",
                credential.getId(), authentication.getPrincipal());

            LOGGER.trace("Building ECP SAML response for [{}]", credential.getId());
            val issuer = SamlIdPUtils.getIssuerFromSamlObject(authnRequest);
            val service = getConfigurationContext().getWebApplicationServiceFactory().createService(issuer);
            val casAssertion = buildCasAssertion(authentication, service, serviceRequest.getKey(), new LinkedHashMap<>());

            LOGGER.trace("CAS assertion to use for building ECP SAML2 response is [{}]", casAssertion);
            buildSamlResponse(context.getHttpResponse(), context.getHttpRequest(),
                authenticationContext, Optional.of(casAssertion), context.getBinding(), null);
        } catch (final AuthenticationException e) {
            LoggingUtils.error(LOGGER, e);
            val error = e.getHandlerErrors().values()
                .stream()
                .map(Throwable::getMessage)
                .filter(Objects::nonNull)
                .collect(Collectors.joining(","));
            buildEcpFaultResponse(context, error);
        } catch (final Throwable e) {
            LoggingUtils.error(LOGGER, e);
            buildEcpFaultResponse(context, e.getMessage());
        }
    }
Handle ecp request.

@param response the response
@param request  the request
@throws Exception the exception
support/cas-server-support-saml-idp-web/src/main/java/org/apereo/cas/support/saml/web/idp/profile/ecp/ECPSamlIdPProfileHandlerController.java