use of javax.servlet.Filter in project ddf by codice.
the class ProxyFilterChainTest method testAddFiltersAfterDo.
/**
* Tests that an exception is thrown if more filters are attempted to be
* added after the filter has been run.
*
* @throws IOException
* @throws ServletException
*/
@Test(expected = IllegalStateException.class)
public void testAddFiltersAfterDo() throws IOException, ServletException {
FilterChain initialChain = mock(FilterChain.class);
ProxyFilterChain proxyChain = new ProxyFilterChain(initialChain);
Filter filter2 = mock(Filter.class);
Filter filter3 = mock(Filter.class);
proxyChain.doFilter(mock(ServletRequest.class), mock(ServletResponse.class));
proxyChain.addFilters(Arrays.asList(filter2, filter3));
}
use of javax.servlet.Filter in project spring-security-oauth by spring-projects.
the class AuthorizationServerSecurityConfigurer method configure.
@Override
public void configure(HttpSecurity http) throws Exception {
// ensure this is initialized
frameworkEndpointHandlerMapping();
if (allowFormAuthenticationForClients) {
clientCredentialsTokenEndpointFilter(http);
}
for (Filter filter : tokenEndpointAuthenticationFilters) {
http.addFilterBefore(filter, BasicAuthenticationFilter.class);
}
http.exceptionHandling().accessDeniedHandler(accessDeniedHandler);
}
use of javax.servlet.Filter in project nutzboot by nutzam.
the class UndertowStarter method addFilter.
public void addFilter(WebFilterFace webFilter) {
if (webFilter == null || webFilter.getFilter() == null) {
return;
}
log.debugf("add filter name=%s pathSpec=%s", webFilter.getName(), webFilter.getPathSpec());
ImmediateInstanceFactory<Filter> factory = new ImmediateInstanceFactory<Filter>(webFilter.getFilter());
FilterInfo filter = new FilterInfo(webFilter.getName(), webFilter.getFilter().getClass(), factory);
Iterator<Map.Entry<String, String>> entries = webFilter.getInitParameters().entrySet().iterator();
while (entries.hasNext()) {
Map.Entry<String, String> entry = entries.next();
filter.addInitParam(entry.getKey(), entry.getValue());
}
deployment.addFilter(filter).addFilterUrlMapping(webFilter.getName(), webFilter.getPathSpec(), DispatcherType.REQUEST).addFilterUrlMapping(webFilter.getName(), webFilter.getPathSpec(), DispatcherType.FORWARD);
}
use of javax.servlet.Filter in project nutzboot by nutzam.
the class NbResourceBasedWebEnvironment method configure.
protected void configure() {
this.objects.clear();
WebSecurityManager securityManager = createWebSecurityManager();
setWebSecurityManager(securityManager);
String loginUrl = conf.get(ShiroEnvStarter.PROP_URL_LOGIN, "/user/login");
String unauthorizedUrl = conf.get(ShiroEnvStarter.PROP_URL_UNAUTH, "/user/login");
String logoutUrl = conf.get(ShiroEnvStarter.PROP_URL_LOGOUT_REDIRECT, "/");
for (Map.Entry<String, Filter> en : DefaultFilter.createInstanceMap(null).entrySet()) {
Filter filter = en.getValue();
if (filter instanceof LogoutFilter) {
((LogoutFilter) filter).setRedirectUrl(logoutUrl);
} else if (filter instanceof AuthenticatingFilter) {
((AuthenticatingFilter) filter).setLoginUrl(loginUrl);
} else if (filter instanceof AccessControlFilter) {
((AccessControlFilter) filter).setLoginUrl(unauthorizedUrl);
}
objects.put(en.getKey(), en.getValue());
}
for (String objectName : Strings.splitIgnoreBlank(conf.get("shiro.objects", ""))) {
objects.put(objectName, ioc.get(null, objectName));
}
FilterChainResolver resolver = createFilterChainResolver();
if (resolver != null) {
setFilterChainResolver(resolver);
}
NutShiro.DefaultLoginURL = loginUrl;
NutShiro.DefaultNoAuthURL = unauthorizedUrl;
}
use of javax.servlet.Filter in project gitiles by GerritCodeReview.
the class GitilesFilter method init.
@Override
public synchronized void init(FilterConfig config) throws ServletException {
super.init(config);
setDefaultFields(config);
for (GitilesView.Type type : GitilesView.Type.values()) {
if (!servlets.containsKey(type)) {
servlets.put(type, getDefaultHandler(type));
}
}
Filter repositoryFilter = new RepositoryFilter(resolver);
Filter viewFilter = new ViewFilter(accessFactory, urls, visibilityCache);
Filter dispatchFilter = new DispatchFilter(filters, servlets);
ServletBinder root = serveRegex(ROOT_REGEX).through(viewFilter);
if (gitwebRedirect != null) {
root.through(gitwebRedirect);
}
root.through(dispatchFilter);
serveRegex(REPO_REGEX).through(repositoryFilter).through(viewFilter).through(dispatchFilter);
serveRegex(REPO_PATH_REGEX).through(repositoryFilter).through(viewFilter).through(dispatchFilter);
initialized = true;
}
Aggregations