protected WebApplicationService newWebApplicationService(
        final HttpServletRequest request, final String serviceToUse) {
        val artifactId = Optional.ofNullable(request)
            .map(httpServletRequest -> httpServletRequest.getParameter(CasProtocolConstants.PARAMETER_TICKET))
            .orElse(null);
        val id = cleanupUrl(serviceToUse);
        val newService = new SimpleWebApplicationServiceImpl(id, serviceToUse, artifactId);
        determineWebApplicationFormat(request, newService);
        val source = getSourceParameter(request, CasProtocolConstants.PARAMETER_TARGET_SERVICE, CasProtocolConstants.PARAMETER_SERVICE);
        newService.setSource(source);
        if (request != null) {
            populateAttributes(newService, request);
            if (StringUtils.isNotBlank(source)) {
                newService.getAttributes().put(source, CollectionUtils.wrap(id));
            }
        } else {
            newService.getAttributes().putAll(extractQueryParameters(newService));
        }
        return newService;
    }
The {@link WebApplicationServiceFactory} is responsible for
creating {@link WebApplicationService} objects.

@author Misagh Moayyed
@since 4.2
core/cas-server-core-services-authentication/src/main/java/org/apereo/cas/authentication/principal/WebApplicationServiceFactory.java