protected Authentication buildAuthentication(final HttpServletRequest request,
                                                 final WebApplicationService selectedService) throws Throwable {
        val password = request.getParameter("password");
        val username = FunctionUtils.throwIfBlank(request.getParameter("username"));
        if (StringUtils.isNotBlank(password)) {
            val credential = new UsernamePasswordCredential(username, password);
            val result = configurationContext.getAuthenticationSystemSupport()
                .finalizeAuthenticationTransaction(selectedService, credential);
            return result.getAuthentication();
        }
        val principal = configurationContext.getPrincipalResolver()
            .resolve(new BasicIdentifiableCredential(username),
                Optional.of(configurationContext.getPrincipalFactory().createPrincipal(username)),
                Optional.empty(), Optional.of(selectedService));
        return DefaultAuthenticationBuilder.newInstance().setPrincipal(principal).build();
    }
P3 service validate.

@param request  the request
@param response the response
@throws Throwable the throwable
support/cas-server-support-reports-core/src/main/java/org/apereo/cas/web/report/CasProtocolValidationEndpoint.java