@Override
    public SamlService createService(final HttpServletRequest request) {
        val service = request.getParameter(SamlProtocolConstants.CONST_PARAM_TARGET);
        val requestBody = request.getRequestURI().contains(SamlProtocolConstants.ENDPOINT_SAML_VALIDATE)
            && request.getMethod().equalsIgnoreCase(HttpMethod.POST.name()) ? getRequestBody(request) : null;

        LOGGER.trace("Request Body: [{}]", requestBody);
        if (!StringUtils.hasText(service) && !StringUtils.hasText(requestBody)) {
            LOGGER.trace("Request does not specify a [{}] or request body is empty", SamlProtocolConstants.CONST_PARAM_TARGET);
            return null;
        }
        val id = cleanupUrl(service);

        if (StringUtils.hasText(requestBody)) {
            request.setAttribute(SamlProtocolConstants.PARAMETER_SAML_REQUEST, requestBody);
        }
        val requestChild = getRequestDocumentElement(requestBody);
        val artifactId = getArtifactIdFromRequest(requestChild);
        val requestId = getRequestIdFromRequest(requestChild);
        LOGGER.trace("Extracted ArtifactId: [{}]. Extracted Request Id: [{}]", artifactId, requestId);

        val samlService = new SamlService(id, service, artifactId, requestId);
        samlService.setSource(SamlProtocolConstants.CONST_PARAM_TARGET);
        return samlService;
    }
The {@link SamlServiceFactory} creates {@link SamlService} objects.

@author Misagh Moayyed
@since 4.2
support/cas-server-support-saml-core-api/src/main/java/org/apereo/cas/support/saml/authentication/principal/SamlServiceFactory.java