Class DynamicResponseHeaderFilter
java.lang.Object
net.shibboleth.shared.servlet.AbstractConditionalFilter
net.shibboleth.shared.spring.servlet.impl.DynamicResponseHeaderFilter
- All Implemented Interfaces:
Filter,ChainableFilter,Ordered
public class DynamicResponseHeaderFilter
extends AbstractConditionalFilter
implements ChainableFilter
Implementation of an HTTP servlet
Filter which supports configurable response header
injection, including via injected functions that can conditionally attach headers.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classAn implementation ofHttpServletResponsewhich adds the response headers supplied by the outer class.Nested classes/interfaces inherited from interface net.shibboleth.shared.spring.servlet.ChainableFilter
ChainableFilter.FilterOrder -
Field Summary
FieldsModifier and TypeFieldDescriptionCallbacks to add headers dynamically.Statically defined headers to return.Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()intgetOrder()voidinit(FilterConfig filterConfig) protected voidrunFilter(ServletRequest request, ServletResponse response, FilterChain chain) Subclasses should override this method to be called when the filter is directed to activate.voidsetCallbacks(Collection<Function<Pair<HttpServletRequest, HttpServletResponse>, Boolean>> theCallbacks) Set the callbacks to invoke to dynamically attach headers.voidsetHeaders(Map<String, String> map) Set the headers to statically attach to all responses.Methods inherited from class net.shibboleth.shared.servlet.AbstractConditionalFilter
doFilter, getActivationCondition, setActivationCondition
-
Field Details
-
headers
Statically defined headers to return. -
callbacks
@Nonnull private Collection<Function<Pair<HttpServletRequest,HttpServletResponse>, callbacksBoolean>> Callbacks to add headers dynamically.
-
-
Constructor Details
-
DynamicResponseHeaderFilter
public DynamicResponseHeaderFilter()Constructor.
-
-
Method Details
-
setHeaders
Set the headers to statically attach to all responses.- Parameters:
map- header map
-
setCallbacks
public void setCallbacks(@Nullable Collection<Function<Pair<HttpServletRequest, HttpServletResponse>, Boolean>> theCallbacks) Set the callbacks to invoke to dynamically attach headers.- Parameters:
theCallbacks- callback collection
-
init
- Specified by:
initin interfaceFilter- Overrides:
initin classAbstractConditionalFilter- Throws:
ServletException
-
destroy
public void destroy()- Specified by:
destroyin interfaceFilter- Overrides:
destroyin classAbstractConditionalFilter
-
getOrder
public int getOrder()- Specified by:
getOrderin interfaceChainableFilter- Specified by:
getOrderin interfaceOrdered
-
runFilter
protected void runFilter(@Nonnull ServletRequest request, @Nonnull ServletResponse response, @Nonnull FilterChain chain) throws IOException, ServletException Subclasses should override this method to be called when the filter is directed to activate.- Specified by:
runFilterin classAbstractConditionalFilter- Parameters:
request- servlet requestresponse- servlet responsechain- filter chain- Throws:
IOException- on errorServletException- on error
-