@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
    @Bean
    @ConditionalOnMissingBean(name = "passwordChangeServiceRestTemplate")
    public RestTemplate passwordChangeServiceRestTemplate(final CasConfigurationProperties casProperties) {
        val pmRest = casProperties.getAuthn().getPm().getRest();

        val username = pmRest.getEndpointUsername();
        val password = pmRest.getEndpointPassword();

        var builder = new RestTemplateBuilder();
        if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) {
            LOGGER.debug("Configuring basic authentication for password management via REST for [{}]", username);
            builder = builder.basicAuthentication(username, password, StandardCharsets.UTF_8);
        }
        builder = builder.defaultHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
            .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
            .defaultHeader(HttpHeaders.ACCEPT_CHARSET, StandardCharsets.UTF_8.name());
        for (val entry : pmRest.getHeaders().entrySet()) {
            LOGGER.debug("Configuring header [{}] with value [{}]", entry.getKey(), entry.getValue());
            builder = builder.defaultHeader(entry.getKey(), org.springframework.util.StringUtils.commaDelimitedListToStringArray(entry.getValue()));
        }

        return builder.build();
    }
This is {@link CasRestPasswordManagementAutoConfiguration}.

@author Misagh Moayyed
@since 5.2.0
support/cas-server-support-pm-rest/src/main/java/org/apereo/cas/config/CasRestPasswordManagementAutoConfiguration.java