class SpringSecurityWebMvcApplicationContextUtils {


        static Object getRequestAttribute(final IContext context, final String attributeName) {
            return ((IWebContext)context).getExchange().getAttributeValue(attributeName);
        }


        static String getContextPath(final IContext context) {
            WebEngineContext webEngineContext = (WebEngineContext) context;
            IWebExchange webExchange = webEngineContext.getExchange();
            IServletWebExchange servletWebExchange = (IServletWebExchange) webExchange;
            return servletWebExchange.getRequest().getContextPath();
        }


        /*
         * This method mimics the behaviour in
         * org.springframework.security.web.context.support.SecurityWebApplicationContextUtils#findRequiredWebApplicationContext(sc),
         * which provides a default mechanism for looking for the WebApplicationContext as an attribute of the
         * ServletContext that might have been declared with a non-standard name (if it had, it would be
         * detected by WebApplicationContextUtils.getWebApplicationContext(sc). This is a behaviour directly
         * supported in Spring Framework >= 4.2 thanks to
         * org.springframework.web.context.support.WebApplicationContextUtils#findWebApplicationContext(sc).
         *
         * Unfortunately, the org.springframework.security.web.context.support.SecurityWebApplicationContextUtils class is
         * only available since Spring Security 4.1, so we cannot simply call it if we want to support Spring Security 4.0.
         * That's why this method basically mimics its behaviour.
         */
        static ApplicationContext findRequiredWebApplicationContext(final IContext context) {<FILL_FUNCTION_BODY>}


        static Authentication getAuthenticationObject() {
            final SecurityContext securityContext = SecurityContextHolder.getContext();
            if (securityContext == null) {
                if (logger.isTraceEnabled()) {
                    logger.trace("[THYMELEAF][{}] No security context found, no authentication object returned.",
                            new Object[] {TemplateEngine.threadIndex()});
                }
                return null;
            }
            return securityContext.getAuthentication();
        }


    }


            IServletWebApplication application = (IServletWebApplication) ((IWebContext) context).getExchange().getApplication();
            ServletContext servletContext = (ServletContext) application.getNativeServletContextObject();

            WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(servletContext);
            if (wac == null) {
                final Enumeration<String> attrNames = servletContext.getAttributeNames();
                while (attrNames.hasMoreElements()) {
                    final String attrName = attrNames.nextElement();
                    final Object attrValue = servletContext.getAttribute(attrName);
                    if (attrValue instanceof WebApplicationContext) {
                        if (wac != null) {
                            throw new IllegalStateException("No unique WebApplicationContext found: more than one " +
                                    "DispatcherServlet registered with publishContext=true?");
                        }
                        wac = (WebApplicationContext) attrValue;
                    }
                }
            }

            if (wac == null) {
                throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?");
            }

            return wac;

        
<no_super_class>