
package org.pac4j.saml.util;

import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.runtime.RuntimeConstants;
import org.pac4j.core.exception.TechnicalException;

import java.util.Properties;

/**
 * Factory returning a well configured {@link VelocityEngine} instance required for
 * generating an HTML form used to POST SAML messages.
 *
 * @author Michael Remond
 */
public class VelocityEngineFactory {

    public static VelocityEngine getEngine() {

        try {
            final var props = new Properties();
            props.setProperty(RuntimeConstants.INPUT_ENCODING, "UTF-8");
            props.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");

            final var engine = new VelocityEngine();
            engine.init(props);
            return engine;
        } catch (final Exception e) {
            throw new TechnicalException("Error configuring velocity", e);
        }

    }

}

@@ -124,16 +124,165 @@
 stants;%0A
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;%0Aimport org.apache.velocity.runtime.resource.loader.StringResourceLoader;%0A
 import o
@@ -831,16 +831,309 @@
 path%22);%0A
+            props.setProperty(%22resource.loader.string.class%22, StringResourceLoader.class.getName());%0A            props.setProperty(%22resource.loader.classpath.class%22, ClasspathResourceLoader.class.getName());%0A            props.setProperty(RuntimeConstants.RESOURCE_LOADERS, %22classpath,string%22);
 %0A       

fix saml2 tests after upgrade (#2370)