<commit_before>package org.apereo.cas.support.openid.web.mvc;

import org.apache.commons.io.IOUtils;
import org.apereo.cas.configuration.CasConfigurationProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletResponse;
import java.io.StringWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;

/**
 * This is {@link YadisController}.
 *
 * @author <NAME>
 * @since 5.1.0
 */
@Controller("yadisController")
public class YadisController {

    private static final Logger LOGGER = LoggerFactory.getLogger(YadisController.class);

    @Autowired
    private CasConfigurationProperties casProperties;

    @Autowired
    private ResourceLoader resourceLoader;

    /**
     * Generates the Yadis XML snippet.
     *
     * @param response the response
     * @throws Exception the exception
     */
    @GetMapping(path = "/yadis.xml")
    public void yadis(final HttpServletResponse response) throws Exception {
        final Resource template = this.resourceLoader.getResource("classpath:/yadis.template");
        try (StringWriter writer = new StringWriter()) {
            IOUtils.copy(template.getInputStream(), writer, StandardCharsets.UTF_8);
            final String yadis = writer.toString().replace("$casLoginUrl", casProperties.getServer().getLoginUrl());
            response.setContentType(MediaType.TEXT_XML_VALUE);
            final Writer respWriter = response.getWriter();
            respWriter.write(yadis);
            respWriter.flush();
        }
    }
}<commit_msg>OpenID yadis.xml should have MIME type application/xrds+xml (#2573)<commit_after>package org.apereo.cas.support.openid.web.mvc;

import org.apache.commons.io.IOUtils;
import org.apereo.cas.configuration.CasConfigurationProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletResponse;
import java.io.StringWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;

/**
 * This is {@link YadisController}.
 *
 * @author <NAME>
 * @since 5.1.0
 */
@Controller("yadisController")
public class YadisController {

    private static final Logger LOGGER = LoggerFactory.getLogger(YadisController.class);

    @Autowired
    private CasConfigurationProperties casProperties;

    @Autowired
    private ResourceLoader resourceLoader;

    /**
     * Generates the Yadis XML snippet.
     *
     * @param response the response
     * @throws Exception the exception
     */
    @GetMapping(path = "/yadis.xml")
    public void yadis(final HttpServletResponse response) throws Exception {
        final Resource template = this.resourceLoader.getResource("classpath:/yadis.template");
        try (StringWriter writer = new StringWriter()) {
            IOUtils.copy(template.getInputStream(), writer, StandardCharsets.UTF_8);
            final String yadis = writer.toString().replace("$casLoginUrl", casProperties.getServer().getLoginUrl());
            response.setContentType("application/xrds+xml");
            final Writer respWriter = response.getWriter();
            respWriter.write(yadis);
            respWriter.flush();
        }
    }
}
{'fraction_non_alphanumeric': 0.10499599251936949, 'fraction_numerical': 0.004274646005877639, 'mean_word_length': 3.9721115537848606, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 5}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1095454', 'n_tokens_mistral': 1046, 'n_tokens_neox': 1042, 'n_words': 209}