io.dropwizard.auth.basic.BasicCredentialAuthFilter Java Examples
The following examples show how to use
io.dropwizard.auth.basic.BasicCredentialAuthFilter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BreakerboxService.java From breakerbox with Apache License 2.0 | 6 votes |
private static void setupLdapAuth(LdapConfiguration ldapConfiguration, Environment environment) { final LdapAuthenticator ldapAuthenticator = new LdapAuthenticator(ldapConfiguration); final CachingAuthenticator<BasicCredentials, User> cachingAuthenticator = new CachingAuthenticator<>( environment.metrics(), TenacityAuthenticator.wrap( new ResourceAuthenticator(ldapAuthenticator), BreakerboxDependencyKey.BRKRBX_LDAP_AUTH), ldapConfiguration.getCachePolicy() ); environment.jersey().register(new AuthDynamicFeature( new BasicCredentialAuthFilter.Builder<User>() .setAuthenticator(cachingAuthenticator) .setRealm("breakerbox") .buildAuthFilter())); environment.jersey().register(new AuthValueFactoryProvider.Binder<>(User.class)); }
Example #2
Source File: ExampleAppTest.java From dropwizard-auth-ldap with Apache License 2.0 | 6 votes |
@Override public void run(ExampleAppConfiguration configuration, Environment environment) throws Exception { final LdapConfiguration ldapConfiguration = configuration.getLdapConfiguration(); Authenticator<BasicCredentials, User> ldapAuthenticator = new CachingAuthenticator<>( environment.metrics(), new ResourceAuthenticator(new LdapAuthenticator(ldapConfiguration)), ldapConfiguration.getCachePolicy()); environment.jersey().register(new AuthDynamicFeature( new BasicCredentialAuthFilter.Builder<User>() .setAuthenticator(ldapAuthenticator) .setRealm("LDAP") .buildAuthFilter())); environment.jersey().register(new AuthValueFactoryProvider.Binder<>(User.class)); environment.healthChecks().register("ldap", new LdapHealthCheck<>( new ResourceAuthenticator(new LdapCanAuthenticate(ldapConfiguration)))); }
Example #3
Source File: BasicAuthenticatorConfig.java From jobson with Apache License 2.0 | 5 votes |
@Override public AuthFilter<?, Principal> createAuthFilter(AuthenticationBootstrap bootstrap) { return new BasicCredentialAuthFilter.Builder<>() .setAuthenticator(new BasicAuthenticator(bootstrap.getUserDAO())) .setAuthorizer(new PermitAllAuthorizer()) .setRealm(realm) .buildAuthFilter(); }
Example #4
Source File: SystemtestCustomAuthConfig.java From jobson with Apache License 2.0 | 5 votes |
@Override public AuthFilter<?, Principal> createAuthFilter(AuthenticationBootstrap bootstrap) { return new BasicCredentialAuthFilter.Builder<>() .setAuthenticator(new SpecificUsernamePwAuthenticator(username, password)) .setAuthorizer(new PermitAllAuthorizer()) .buildAuthFilter(); }
Example #5
Source File: TenacityAuthenticatorTest.java From tenacity with Apache License 2.0 | 5 votes |
@Override public void run(Configuration configuration, Environment environment) throws Exception { mockAuthenticator = mock(Authenticator.class); tenacityAuthenticator = TenacityAuthenticator.wrap(mockAuthenticator, DependencyKey.TENACITY_AUTH_TIMEOUT); environment.jersey().register(new AuthDynamicFeature( new BasicCredentialAuthFilter.Builder<>() .setAuthenticator(tenacityAuthenticator) .setRealm("test-realm") .buildAuthFilter())); environment.jersey().register(tenacityExceptionMapper); environment.jersey().register(tenacityContainerExceptionMapper); environment.jersey().register(new AuthErrorResource()); }
Example #6
Source File: NiPingMonitorApplication.java From SAPNetworkMonitor with GNU General Public License v3.0 | 4 votes |
@Override public void run(ServerConfiguration configuration, Environment environment) throws Exception { final DBIFactory factory = new DBIFactory(); final DBI jdbi = factory.build(environment, configuration.getDataSourceFactory(), "sapData"); ObjectMapper objectMapper = environment.getObjectMapper(); SapConfiguration sapConfiguration = configuration.getSapConfig(); JobConfiguration jobConfiguration = configuration.getJobConfig(); NiPingServiceBinder niPingServiceBinder = new NiPingServiceBinder(jdbi, objectMapper, sapConfiguration, jobConfiguration); ServiceLocator serviceLocator = ServiceLocatorUtilities.bind(niPingServiceBinder); SapBasicAuthenticator sapBasicAuthenticator = ServiceLocatorUtilities.getService(serviceLocator, SapBasicAuthenticator.class .getName()); SapOAuthenticator sapOAuthenticator = ServiceLocatorUtilities.getService(serviceLocator, SapOAuthenticator.class.getName()); final BasicCredentialAuthFilter basicAuthFilter = new BasicCredentialAuthFilter.Builder<BasicAuthUser>() .setAuthenticator(sapBasicAuthenticator) .buildAuthFilter(); final AuthFilter oAuthFilter = new OAuthCredentialAuthFilter.Builder<OAuthUser>() .setAuthenticator(sapOAuthenticator) .setPrefix("Bearer") .buildAuthFilter(); final PolymorphicAuthDynamicFeature feature = new PolymorphicAuthDynamicFeature<UserPrincipal>(ImmutableMap.of(BasicAuthUser .class, basicAuthFilter, OAuthUser.class, oAuthFilter)); final AbstractBinder binder = new PolymorphicAuthValueFactoryProvider.Binder<>(ImmutableSet.of(BasicAuthUser.class, OAuthUser .class)); environment.jersey().register(new AuthFilterDynamicBinding()); environment.jersey().register(feature); environment.jersey().register(binder); environment.jersey().register(niPingServiceBinder); environment.jersey().packages("com.cloudwise.sap.niping.auth"); environment.jersey().packages("com.cloudwise.sap.niping.service"); environment.jersey().packages("com.cloudwise.sap.niping.dao"); environment.jersey().packages("com.cloudwise.sap.niping.common.vo.converter"); environment.jersey().packages("com.cloudwise.sap.niping.resource"); environment.jersey().register(SessionFactoryProvider.class); environment.servlets().setSessionHandler(new SessionHandler()); }