Package ubic.gemma.rest.servlet
Class CorsFilter
- java.lang.Object
-
- org.springframework.web.filter.GenericFilterBean
-
- org.springframework.web.filter.OncePerRequestFilter
-
- ubic.gemma.rest.servlet.CorsFilter
-
- All Implemented Interfaces:
javax.servlet.Filter
,Aware
,BeanNameAware
,DisposableBean
,InitializingBean
,EnvironmentAware
,ServletContextAware
public class CorsFilter extends OncePerRequestFilter
Filter for adding CORS headers to the RESTful API responses.This is mounted on the gemma-rest servlet in the web.xml configuration file.
-
-
Field Summary
-
Fields inherited from class org.springframework.web.filter.OncePerRequestFilter
ALREADY_FILTERED_SUFFIX
-
Fields inherited from class org.springframework.web.filter.GenericFilterBean
logger
-
-
Constructor Summary
Constructors Constructor Description CorsFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doFilterInternal(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, javax.servlet.FilterChain chain)
protected void
initFilterBean()
void
setAllowCredentials(boolean allowCredentials)
Indicate if the credentials (i.e.void
setAllowedHeaders(String allowedHeaders)
Set the allowed headers by a CORS request.void
setAllowedMethods(String allowedMethods)
Set the allowed methods by a CORS request.void
setAllowedOrigins(String allowedOrigins)
Set the allowed origins of a CORS request.-
Methods inherited from class org.springframework.web.filter.OncePerRequestFilter
doFilter, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter, shouldNotFilterAsyncDispatch, shouldNotFilterErrorDispatch
-
Methods inherited from class org.springframework.web.filter.GenericFilterBean
addRequiredProperty, afterPropertiesSet, destroy, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, setBeanName, setEnvironment, setServletContext
-
-
-
-
Method Detail
-
initFilterBean
protected void initFilterBean()
- Overrides:
initFilterBean
in classGenericFilterBean
-
doFilterInternal
public void doFilterInternal(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, javax.servlet.FilterChain chain) throws IOException, javax.servlet.ServletException
- Specified by:
doFilterInternal
in classOncePerRequestFilter
- Throws:
IOException
javax.servlet.ServletException
-
setAllowedOrigins
public void setAllowedOrigins(String allowedOrigins)
Set the allowed origins of a CORS request.Use a wildcard "*" to allow all.
-
setAllowedMethods
public void setAllowedMethods(@Nullable String allowedMethods)
Set the allowed methods by a CORS request.Use a wildcard "*" to allow all.
-
setAllowedHeaders
public void setAllowedHeaders(@Nullable String allowedHeaders)
Set the allowed headers by a CORS request.Use a wildcard "*" to allow all.
-
setAllowCredentials
public void setAllowCredentials(boolean allowCredentials)
Indicate if the credentials (i.e. cookies, HTTP authentication) can be used by a CORS request.If this is set to true, a wildcard cannot be used for
setAllowedOrigins(String)
,setAllowedMethods(String)
norsetAllowedHeaders(String)
.
-
-