use of javax.servlet.Filter in project hudson-2.x by hudson.
the class SecurityRealm method createFilter.
/**
* Creates {@link Filter} that all the incoming HTTP requests will go through
* for authentication.
* <p/>
* <p/>
* The default implementation uses {@link #getSecurityComponents()} and builds
* a standard filter chain from /WEB-INF/security/SecurityFilters.groovy.
* But subclasses can override this to completely change the filter sequence.
* <p/>
* <p/>
* For other plugins that want to contribute {@link Filter}, see
* {@link PluginServletFilter}.
*
* @since 1.271
*/
public Filter createFilter(FilterConfig filterConfig) {
LOGGER.entering(SecurityRealm.class.getName(), "createFilter");
Binding binding = new Binding();
SecurityComponents sc = getSecurityComponents();
binding.setVariable("securityComponents", sc);
binding.setVariable("securityRealm", this);
BeanBuilder builder = new BeanBuilder();
builder.parse(filterConfig.getServletContext().getResourceAsStream("/WEB-INF/security/SecurityFilters.groovy"), binding);
WebApplicationContext context = builder.createApplicationContext();
return (Filter) context.getBean("filter");
}
use of javax.servlet.Filter in project tomee by apache.
the class HttpUtil method addFilter.
public static boolean addFilter(final String classname, final WebContext wc, final String mapping, final FilterConfig config) {
final HttpListenerRegistry registry = SystemInstance.get().getComponent(HttpListenerRegistry.class);
if (registry == null || mapping == null) {
return false;
}
final FilterListener listener;
try {
listener = new FilterListener((Filter) wc.newInstance(wc.getClassLoader().loadClass(classname)), wc.getContextRoot());
listener.getDelegate().init(config);
} catch (Exception e) {
throw new OpenEJBRuntimeException(e);
}
registry.addHttpFilter(listener, pattern(wc.getContextRoot(), mapping));
return true;
}
use of javax.servlet.Filter in project tomee by apache.
the class HttpUtil method removeFilter.
public static void removeFilter(final String mapping, final WebContext wc) {
final HttpListenerRegistry registry = SystemInstance.get().getComponent(HttpListenerRegistry.class);
if (registry == null || mapping == null) {
return;
}
final Collection<HttpListener> filters = registry.removeHttpFilter(pattern(wc.getContextRoot(), mapping));
for (HttpListener listener : filters) {
final Filter filter = ((FilterListener) listener).getDelegate();
filter.destroy();
wc.destroy(filter);
}
filters.clear();
}
use of javax.servlet.Filter in project midpoint by Evolveum.
the class MidpointAutowiredBeanFactoryObjectPostProcessor method destroyAndRemoveFilters.
public void destroyAndRemoveFilters(List<Filter> filters) {
synchronized (this) {
for (Filter filter : filters) {
if (filter instanceof DisposableBean && this.disposableBeans.contains(filter)) {
filter.destroy();
disposableBeans.remove(filter);
}
}
}
}
use of javax.servlet.Filter in project midpoint by Evolveum.
the class Saml2ModuleFactory method createModuleFilter.
@Override
public AuthModule createModuleFilter(AbstractAuthenticationModuleType moduleType, String sequenceSuffix, ServletRequest request, Map<Class<?>, Object> sharedObjects, AuthenticationModulesType authenticationsPolicy, CredentialsPolicyType credentialPolicy, AuthenticationChannel authenticationChannel) throws Exception {
if (!(moduleType instanceof Saml2AuthenticationModuleType)) {
LOGGER.error("This factory support only Saml2AuthenticationModuleType, but modelType is " + moduleType);
return null;
}
isSupportedChannel(authenticationChannel);
SamlModuleWebSecurityConfiguration.setProtector(getProtector());
SamlModuleWebSecurityConfiguration configuration = SamlModuleWebSecurityConfiguration.build((Saml2AuthenticationModuleType) moduleType, sequenceSuffix, getPublicUrlPrefix(request), request);
configuration.setSequenceSuffix(sequenceSuffix);
configuration.addAuthenticationProvider(getObjectObjectPostProcessor().postProcess(new Saml2Provider()));
SamlModuleWebSecurityConfigurer<SamlModuleWebSecurityConfiguration> module = getObjectObjectPostProcessor().postProcess(new SamlModuleWebSecurityConfigurer<>(configuration));
HttpSecurity http = getNewHttpSecurity(module);
setSharedObjects(http, sharedObjects);
ModuleAuthenticationImpl moduleAuthentication = createEmptyModuleAuthentication(configuration, request);
moduleAuthentication.setFocusType(moduleType.getFocusType());
SecurityFilterChain filter = http.build();
for (Filter f : filter.getFilters()) {
if (f instanceof Saml2WebSsoAuthenticationRequestFilter) {
((Saml2WebSsoAuthenticationRequestFilter) f).setRedirectMatcher(new AntPathRequestMatcher(module.getPrefix() + RemoteModuleAuthenticationImpl.AUTHENTICATION_REQUEST_PROCESSING_URL_SUFFIX_WITH_REG_ID));
break;
}
}
return AuthModuleImpl.build(filter, configuration, moduleAuthentication);
}
Aggregations