@@ -0,0 +1,2130 @@
+package org.pac4j.saml.metadata;%0A%0Aimport java.io.IOException;%0A%0Aimport javax.servlet.Filter;%0Aimport javax.servlet.FilterChain;%0Aimport javax.servlet.FilterConfig;%0Aimport javax.servlet.ServletException;%0Aimport javax.servlet.ServletRequest;%0Aimport javax.servlet.ServletResponse;%0A%0Aimport org.pac4j.core.config.Config;%0Aimport org.pac4j.core.exception.TechnicalException;%0Aimport org.pac4j.core.util.CommonHelper;%0Aimport org.pac4j.saml.client.SAML2Client;%0A%0A/**%0A * This filter prints the SP metadata for SAML.%0A * %0A * Example shiro.ini configuration:%0A * %0A * saml2MetadataFilter = org.pac4j.saml.metadata.Saml2MetadataFilter%0A * saml2MetadataFilter.config = $config%0A * saml2MetadataFilter.clientName = SAML2Client%0A * %0A * %5Burls%5D%0A * /API/SAML2/metadata = saml2MetadataFilter%0A * %0A * @author Graham Leggett%0A * @since 3.8.0%0A */%0Apublic class Saml2MetadataFilter implements Filter %7B%0A%0A    private Config config;%0A%0A    private String clientName;%0A%0A    @Override%0A    public void init(final FilterConfig filterConfig) throws ServletException %7B%0A    %7D%0A%0A    @Override%0A    public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse,%0A            final FilterChain filterChain) throws IOException, ServletException %7B%0A%0A        CommonHelper.assertNotNull(%22config%22, config);%0A        CommonHelper.assertNotNull(%22clientName%22, clientName);%0A%0A        SAML2Client client = (SAML2Client) config.getClients().findClient(this.clientName).get();%0A        if (client != null) %7B%0A            client.init();%0A            servletResponse.getWriter().write(client.getServiceProviderMetadataResolver().getMetadata());%0A            servletResponse.getWriter().flush();%0A        %7D else %7B%0A            throw new TechnicalException(%22No SAML2Client: %22 + this.clientName);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void destroy() %7B%0A    %7D%0A%0A    public Config getConfig() %7B%0A        return config;%0A    %7D%0A%0A    public void setConfig(final Config config) %7B%0A        this.config = config;%0A    %7D%0A%0A    public String getClientName() %7B%0A        return clientName;%0A    %7D%0A%0A    public void setClientName(String clientName) %7B%0A        this.clientName = clientName;%0A    %7D%0A%0A%7D%0A

Add a Saml2MetadataFilter implementation that can be used to return SAML metadata to a caller. (redux) (#1315)