final HttpServletRequest request = ((IWebContext)context).getRequest(); return request.getContextPath();
return new WebEngineContext( configuration, templateData, templateResolutionAttributes, webContext.getRequest(), webContext.getResponse(), webContext.getServletContext(), webContext.getLocale(), Collections.EMPTY_MAP); return new WebEngineContext( configuration, templateData, templateResolutionAttributes, webContext.getRequest(), webContext.getResponse(), webContext.getServletContext(), webContext.getLocale(), variables);
return ((IWebContext) context).getRequest(); return ((IWebContext) context).getResponse(); return ((IWebContext) context).getSession(); return ((IWebContext) context).getServletContext(); return ((IWebContext) context).getRequest(); return ((IWebContext) context).getSession();
@Override protected boolean isVisible( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue) { final String attrValue = (attributeValue == null? null : attributeValue.trim()); if (attrValue == null || attrValue.length() == 0) { return false; } if (!(context instanceof IWebContext)) { throw new ConfigurationException( "Thymeleaf execution context is not a web context (implementation of " + IWebContext.class.getName() + "). Spring Security integration can only be used in " + "web environments."); } final IWebContext webContext = (IWebContext) context; final HttpServletRequest request = webContext.getRequest(); final HttpServletResponse response = webContext.getResponse(); final ServletContext servletContext = webContext.getServletContext(); final Authentication authentication = AuthUtils.getAuthenticationObject(); if (authentication == null) { return false; } return AuthUtils.authorizeUsingAccessExpression( context, attrValue, authentication, request, response, servletContext); }
final HttpServletRequest request = webContext.getHttpServletRequest(); final HttpServletResponse response = webContext.getHttpServletResponse(); final ServletContext servletContext = webContext.getServletContext();
final HttpServletRequest request = webContext.getRequest(); final ServletContext servletContext = webContext.getServletContext();
public static HtmlTable getTable(Arguments arguments) { return (HtmlTable) ((IWebContext) arguments.getContext()).getHttpServletRequest() .getAttribute("htmlTable"); }
@Override protected ProcessorResult processElement(Arguments arguments, Element element) { HttpServletRequest request = ((IWebContext) arguments.getContext()).getHttpServletRequest(); HttpServletResponse response = ((IWebContext) arguments.getContext()).getHttpServletResponse(); HtmlTable htmlTable = (HtmlTable) RequestUtils.getFromRequest(DataTablesDialect.INTERNAL_BEAN_TABLE, request); ProcessorResult processorResult = doProcessElement(arguments, element, request, response, htmlTable); return processorResult; }
static ApplicationContext findRequiredWebApplicationContext(final IContext context) { final javax.servlet.ServletContext servletContext = ((IWebContext)context).getServletContext(); 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; }
HTTP_SERVLET_REQUEST_VARIABLE_NAME, webContext.getHttpServletRequest()); variables.put( HTTP_SESSION_VARIABLE_NAME, webContext.getHttpSession());
/** * <p> * Process an already-built URL just before returning it. * </p> * <p> * By default, this method will apply the {@code HttpServletResponse.encodeURL(url)} mechanism, as standard * when using the Java Servlet API. Note however that this will only be applied if {@code context} is * an implementation of {@code IWebContext} (i.e. the Servlet API will only be applied in web environments). * </p> * <p> * This method can be overridden by any subclasses that want to change this behaviour (e.g. in order to * avoid using the Servlet API). * </p> * * @param context the execution context. * @param link the already-built URL. * @return the processed URL, ready to be used. */ protected String processLink(final IExpressionContext context, final String link) { if (!(context instanceof IWebContext)) { return link; } final HttpServletResponse response = ((IWebContext)context).getResponse(); return (response != null? response.encodeURL(link) : link); }
@Override protected boolean isVisible( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue) { final String attrValue = (attributeValue == null? null : attributeValue.trim()); if (attrValue == null || attrValue.length() == 0) { return false; } if (!(context instanceof IWebContext)) { throw new ConfigurationException( "Thymeleaf execution context is not a web context (implementation of " + IWebContext.class.getName() + "). Spring Security integration can only be used in " + "web environments."); } final IWebContext webContext = (IWebContext) context; final HttpServletRequest request = webContext.getRequest(); final HttpServletResponse response = webContext.getResponse(); final ServletContext servletContext = webContext.getServletContext(); final Authentication authentication = AuthUtils.getAuthenticationObject(); if (authentication == null) { return false; } return AuthUtils.authorizeUsingAccessExpression( context, attrValue, authentication, request, response, servletContext); }
final HttpServletRequest request = webContext.getHttpServletRequest(); final HttpServletResponse response = webContext.getHttpServletResponse(); final ServletContext servletContext = webContext.getServletContext();
@Override protected boolean isVisible( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue) { final String attrValue = (attributeValue == null? null : attributeValue.trim()); if (attrValue == null || attrValue.length() == 0) { return false; } final int spaceIndex = attrValue.indexOf(' '); final String url = (spaceIndex < 0? attrValue : attrValue.substring(spaceIndex + 1)).trim(); final String method = (spaceIndex < 0? "GET" : attrValue.substring(0, spaceIndex)).trim(); if (!(context instanceof IWebContext)) { throw new ConfigurationException( "Thymeleaf execution context is not a web context (implementation of " + IWebContext.class.getName() + "). Spring Security integration can only be used in " + "web environments."); } final IWebContext webContext = (IWebContext) context; final HttpServletRequest request = webContext.getRequest(); final ServletContext servletContext = webContext.getServletContext(); final Authentication authentication = AuthUtils.getAuthenticationObject(); if (authentication == null) { return false; } return AuthUtils.authorizeUsingUrlCheck( url, method, authentication, request, servletContext); }
public static HtmlTable getTable(Arguments arguments){ return (HtmlTable)((IWebContext) arguments.getContext()).getHttpServletRequest().getAttribute("htmlTable"); }
/** * Sets up the export properties, before the filter intercepts the response. * * @param arguments * The Thymeleaf arguments. * @param htmlTable * The {@link HtmlTable} to export. */ private void setupExport(Arguments arguments, HtmlTable htmlTable) { HttpServletRequest request = ((IWebContext) arguments.getContext()).getHttpServletRequest(); HttpServletResponse response = ((IWebContext) arguments.getContext()).getHttpServletResponse(); String currentExportType = ExportUtils.getCurrentExportType(request); htmlTable.getTableConfiguration().setExporting(true); htmlTable.getTableConfiguration().setCurrentExportFormat(currentExportType); // Call the export delegate ExportDelegate exportDelegate = new ExportDelegate(htmlTable, request); exportDelegate.prepareExport(); response.reset(); }
static ApplicationContext findRequiredWebApplicationContext(final IContext context) { final javax.servlet.ServletContext servletContext = ((IWebContext)context).getServletContext(); 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; }
@Override public HttpServletResponse getHttpServletResponse(final IContext context) { if (context instanceof IWebContext) { return ((IWebContext)context).getResponse(); } throw new TemplateProcessingException( "Cannot obtain HttpServletResponse from a non-WebFlux context implementation (\"" + context.getClass().getName() + "\")"); }
@Override protected boolean isVisible( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue) { final String attrValue = (attributeValue == null? null : attributeValue.trim()); if (attrValue == null || attrValue.length() == 0) { return false; } if (!(context instanceof IWebContext)) { throw new ConfigurationException( "Thymeleaf execution context is not a web context (implementation of " + IWebContext.class.getName() + "). Spring Security integration can only be used in " + "web environments."); } final IWebContext webContext = (IWebContext) context; final HttpServletRequest request = webContext.getRequest(); final HttpServletResponse response = webContext.getResponse(); final ServletContext servletContext = webContext.getServletContext(); final Authentication authentication = AuthUtils.getAuthenticationObject(); if (authentication == null) { return false; } return AuthUtils.authorizeUsingAccessExpression( context, attrValue, authentication, request, response, servletContext); }
static String getContextPath(final IContext context) { final javax.servlet.http.HttpServletRequest request = ((IWebContext)context).getRequest(); return request.getContextPath(); }