@Override
    public List<Credential> fromRequest(final HttpServletRequest request, final MultiValueMap<String, String> requestBody) {
        if (requestBody == null || requestBody.isEmpty()) {
            LOGGER.trace("Skipping [{}] because the request body is null or empty", getClass().getSimpleName());
            return new ArrayList<>();
        }
        val cert = requestBody.getFirst(CERTIFICATE);
        LOGGER.debug("Certificate in the request body: [{}]", cert);
        if (StringUtils.isBlank(cert)) {
            return new ArrayList<>();
        }
        try (val is = new ByteArrayInputStream(cert.getBytes(StandardCharsets.UTF_8))) {
            val iso = new InputStreamResource(is);
            val certificate = CertUtils.readCertificate(iso);
            val credential = new X509CertificateCredential(new X509Certificate[]{certificate});
            credential.setCertificate(certificate);
            return CollectionUtils.wrap(prepareCredential(request, credential));
        } catch (final Exception e) {
            LoggingUtils.error(LOGGER, e);
        }
        return new ArrayList<>();
    }
This is {@link X509RestMultipartBodyCredentialFactory} that attempts to read the contents
of the request body under {@link #CERTIFICATE} parameter to locate and construct
X509 credentials. If the request body does not contain a certificate,
it will then fallback onto the default behavior of capturing credentials.

@author Dmytro Fedonin
@since 5.1.0
support/cas-server-support-rest-x509/src/main/java/org/apereo/cas/support/x509/rest/X509RestMultipartBodyCredentialFactory.java