use of javax.servlet.Filter in project dropwizard-shiro by silb.
the class ShiroBundle method run.
@Override
public void run(T configuration, Environment environment) {
ShiroConfiguration shiroConfig = narrow(configuration);
ResourceConfig resourceConfig = environment.jersey().getResourceConfig();
resourceConfig.register(new AuthorizationFilterFeature());
resourceConfig.register(new SubjectFactory());
resourceConfig.register(new AuthInjectionBinder());
Filter shiroFilter = createFilter(configuration);
environment.servlets().addFilter("ShiroFilter", shiroFilter).addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, shiroConfig.filterUrlPattern());
}
use of javax.servlet.Filter in project neo4j by neo4j.
the class AuthorizationModule method start.
@Override
public void start() {
final Filter authorizationFilter;
if (config.get(GraphDatabaseSettings.auth_enabled)) {
authorizationFilter = new AuthorizationEnabledFilter(authManagerSupplier, logProvider, uriWhitelist);
} else {
authorizationFilter = createAuthorizationDisabledFilter();
}
webServer.addFilter(authorizationFilter, "/*");
}
use of javax.servlet.Filter in project pinpoint by naver.
the class WebServerConfig method etagFilterBean.
@Bean
public FilterRegistrationBean etagFilterBean() {
FilterRegistrationBean filterBean = new FilterRegistrationBean();
Filter filter = new ShallowEtagHeaderFilter();
filterBean.setFilter(filter);
filterBean.setUrlPatterns(Collections.singletonList("*"));
return filterBean;
}
use of javax.servlet.Filter in project druid by druid-io.
the class TrustedDomainAuthenticatorTest method testTrustedHost.
@Test
public void testTrustedHost() throws IOException, ServletException {
Authenticator authenticator = new TrustedDomainAuthenticator("test-authenticator", "test.com", false, "my-auth", "myUser");
HttpServletRequest req = EasyMock.createMock(HttpServletRequest.class);
EasyMock.expect(req.getRemoteAddr()).andReturn("serverA.test.com");
req.setAttribute(AuthConfig.DRUID_AUTHENTICATION_RESULT, new AuthenticationResult("myUser", "my-auth", "test-authenticator", null));
EasyMock.expectLastCall().times(1);
EasyMock.replay(req);
HttpServletResponse resp = EasyMock.createMock(HttpServletResponse.class);
EasyMock.replay(resp);
FilterChain filterChain = EasyMock.createMock(FilterChain.class);
filterChain.doFilter(req, resp);
EasyMock.expectLastCall().times(1);
EasyMock.replay(filterChain);
Filter authenticatorFilter = authenticator.getFilter();
authenticatorFilter.doFilter(req, resp, filterChain);
EasyMock.verify(req, resp, filterChain);
}
use of javax.servlet.Filter in project druid by druid-io.
the class TrustedDomainAuthenticatorTest method testNonTrustedHost.
@Test
public void testNonTrustedHost() throws IOException, ServletException {
Authenticator authenticator = new TrustedDomainAuthenticator("test-authenticator", "test.com", false, "my-auth", "myUser");
HttpServletRequest req = EasyMock.createMock(HttpServletRequest.class);
EasyMock.expect(req.getRemoteAddr()).andReturn("serverA.test2.com");
EasyMock.replay(req);
HttpServletResponse resp = EasyMock.createMock(HttpServletResponse.class);
EasyMock.replay(resp);
FilterChain filterChain = EasyMock.createMock(FilterChain.class);
filterChain.doFilter(req, resp);
EasyMock.expectLastCall().times(1);
EasyMock.replay(filterChain);
Filter authenticatorFilter = authenticator.getFilter();
authenticatorFilter.doFilter(req, resp, filterChain);
EasyMock.verify(req, resp, filterChain);
}
Aggregations