return ((IWebContext) context).getServletContext();
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);
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; }
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; }
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); }
final ServletContext servletContext = webContext.getServletContext();
public InputStream getResourceAsStream(final TemplateProcessingParameters templateProcessingParameters, final String resourceName) { Validate.notNull(templateProcessingParameters, "Template Processing Parameters cannot be null"); Validate.notNull(resourceName, "Resource name cannot be null"); final IContext context = templateProcessingParameters.getContext(); if (!(context instanceof IWebContext)) { throw new TemplateProcessingException( "Resource resolution by ServletContext with " + this.getClass().getName() + " can only be performed " + "when context implements " + IWebContext.class.getName() + " [current context: " + context.getClass().getName() + "]"); } final ServletContext servletContext = ((IWebContext)context).getServletContext(); if (servletContext == null) { throw new TemplateProcessingException("Thymeleaf context returned a null ServletContext"); } return servletContext.getResourceAsStream(resourceName); }
@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); }
@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); }
@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); }
@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); }
@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); }
public Object buildObject(final IExpressionContext context, final String expressionObjectName) { if (AUTHENTICATION_EXPRESSION_OBJECT_NAME.equals(expressionObjectName)) { if (context instanceof IWebContext) { return AuthUtils.getAuthenticationObject(); } } if (AUTHORIZATION_EXPRESSION_OBJECT_NAME.equals(expressionObjectName)) { if (context instanceof IWebContext) { // We retrieve it like this in order to give it the opportunity to come from cache final Authentication authentication = (Authentication) context.getExpressionObjects().getObject(AUTHENTICATION_EXPRESSION_OBJECT_NAME); final IWebContext webContext = (IWebContext)context; final HttpServletRequest request = webContext.getRequest(); final HttpServletResponse response = webContext.getResponse(); final ServletContext servletContext = webContext.getServletContext(); return new Authorization(context, authentication, request, response, servletContext); } return null; } return null; }
public Object buildObject(final IExpressionContext context, final String expressionObjectName) { if (AUTHENTICATION_EXPRESSION_OBJECT_NAME.equals(expressionObjectName)) { if (context instanceof IWebContext) { return AuthUtils.getAuthenticationObject(); } } if (AUTHORIZATION_EXPRESSION_OBJECT_NAME.equals(expressionObjectName)) { if (context instanceof IWebContext) { // We retrieve it like this in order to give it the opportunity to come from cache final Authentication authentication = (Authentication) context.getExpressionObjects().getObject(AUTHENTICATION_EXPRESSION_OBJECT_NAME); final IWebContext webContext = (IWebContext)context; final HttpServletRequest request = webContext.getRequest(); final HttpServletResponse response = webContext.getResponse(); final ServletContext servletContext = webContext.getServletContext(); return new Authorization(context, authentication, request, response, servletContext); } return null; } return null; }
public Object buildObject(final IExpressionContext context, final String expressionObjectName) { if (AUTHENTICATION_EXPRESSION_OBJECT_NAME.equals(expressionObjectName)) { if (context instanceof IWebContext) { return AuthUtils.getAuthenticationObject(); } } if (AUTHORIZATION_EXPRESSION_OBJECT_NAME.equals(expressionObjectName)) { if (context instanceof IWebContext) { // We retrieve it like this in order to give it the opportunity to come from cache final Authentication authentication = (Authentication) context.getExpressionObjects().getObject(AUTHENTICATION_EXPRESSION_OBJECT_NAME); final IWebContext webContext = (IWebContext)context; final HttpServletRequest request = webContext.getRequest(); final HttpServletResponse response = webContext.getResponse(); final ServletContext servletContext = webContext.getServletContext(); return new Authorization(context, authentication, request, response, servletContext); } return null; } return null; }
public Object buildObject(final IExpressionContext context, final String expressionObjectName) { if (AUTHENTICATION_EXPRESSION_OBJECT_NAME.equals(expressionObjectName)) { if (context instanceof IWebContext) { return AuthUtils.getAuthenticationObject(); } } if (AUTHORIZATION_EXPRESSION_OBJECT_NAME.equals(expressionObjectName)) { if (context instanceof IWebContext) { // We retrieve it like this in order to give it the opportunity to come from cache final Authentication authentication = (Authentication) context.getExpressionObjects().getObject(AUTHENTICATION_EXPRESSION_OBJECT_NAME); final IWebContext webContext = (IWebContext)context; final HttpServletRequest request = webContext.getRequest(); final HttpServletResponse response = webContext.getResponse(); final ServletContext servletContext = webContext.getServletContext(); return new Authorization(context, authentication, request, response, servletContext); } return null; } return null; }
final ServletContext servletContext = webContext.getServletContext();
final ServletContext servletContext = webContext.getServletContext();
final ServletContext servletContext = webContext.getServletContext();