io.dropwizard.auth.AuthFilter Java Examples

The following examples show how to use io.dropwizard.auth.AuthFilter. 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: JsonWebTokenConfig.java    From jobson with Apache License 2.0 5 votes vote down vote up
@Override
public AuthFilter<?, Principal> createAuthFilter(AuthenticationBootstrap bootstrap) {
    final byte[] decodedSecretKey = Base64.getDecoder().decode(secretKey);
    final Key secretKeyKey = new SecretKeySpec(decodedSecretKey, 0, decodedSecretKey.length, this.getSignatureAlgorithm().toString());

    return new JsonWebTokenAuthFilter.Builder<>()
            .setAuthenticator(new JsonWebTokenAuthenticator(secretKeyKey, this.getSignatureAlgorithm()))
            .setAuthorizer(new PermitAllAuthorizer())
            .buildAuthFilter();
}
 
Example #2
Source File: CustomAuthenticatorConfig.java    From jobson with Apache License 2.0 5 votes vote down vote up
@Override
public AuthFilter<?, Principal> createAuthFilter(AuthenticationBootstrap bootstrap) {
    final ClassLoader classLoader = getClassLoader(classPath);
    final Class<?> klass = loadClass(classLoader, className);
    final Class<AuthenticationConfig> authConfigClass = toAuthConfigClass(klass);

    final AuthenticationConfig loadedConfig = loadAuthenticationConfig(properties, authConfigClass);

    return loadedConfig.createAuthFilter(bootstrap);
}
 
Example #3
Source File: GuestAuthenticationConfig.java    From jobson with Apache License 2.0 5 votes vote down vote up
@Override
public AuthFilter<?, Principal> createAuthFilter(AuthenticationBootstrap bootstrap) {
    return new GuestAuthFilter.Builder<>()
            .setAuthenticator(new GuestAuthenticator(guestUserName))
            .setAuthorizer(new PermitAllAuthorizer())
            .setRealm(DEFAULT_GUEST_AUTH_REALM)
            .buildAuthFilter();
}
 
Example #4
Source File: BasicAuthenticatorConfig.java    From jobson with Apache License 2.0 5 votes vote down vote up
@Override
public AuthFilter<?, Principal> createAuthFilter(AuthenticationBootstrap bootstrap) {
    return new BasicCredentialAuthFilter.Builder<>()
            .setAuthenticator(new BasicAuthenticator(bootstrap.getUserDAO()))
            .setAuthorizer(new PermitAllAuthorizer())
            .setRealm(realm)
            .buildAuthFilter();
}
 
Example #5
Source File: SystemtestCustomAuthConfig.java    From jobson with Apache License 2.0 5 votes vote down vote up
@Override
public AuthFilter<?, Principal> createAuthFilter(AuthenticationBootstrap bootstrap) {
    return new BasicCredentialAuthFilter.Builder<>()
            .setAuthenticator(new SpecificUsernamePwAuthenticator(username, password))
            .setAuthorizer(new PermitAllAuthorizer())
            .buildAuthFilter();
}
 
Example #6
Source File: JsonWebTokenConfigTest.java    From jobson with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateAuthFilterReturnsAnAuthFilter() {
    final String secretKey = TestHelpers.generateBase64SecretKey();
    final JsonWebTokenConfig jwtConfig = new JsonWebTokenConfig(secretKey);
    final AuthenticationBootstrap authBootstrap = TestHelpers.createTypicalAuthBootstrap();
    final AuthFilter ret = jwtConfig.createAuthFilter(authBootstrap);

    assertThat(ret).isNotNull();
}
 
Example #7
Source File: NiPingMonitorApplication.java    From SAPNetworkMonitor with GNU General Public License v3.0 4 votes vote down vote up
@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());
}
 
Example #8
Source File: CustomAuthConfigWithProperties.java    From jobson with Apache License 2.0 4 votes vote down vote up
@Override
public AuthFilter<?, Principal> createAuthFilter(AuthenticationBootstrap bootstrap) {
    return null;
}
 
Example #9
Source File: NullCustomAuthConfig.java    From jobson with Apache License 2.0 4 votes vote down vote up
@Override
public AuthFilter<?, Principal> createAuthFilter(AuthenticationBootstrap bootstrap) {
    return new GuestAuthenticationConfig().createAuthFilter(bootstrap);
}
 
Example #10
Source File: AuthenticationConfig.java    From jobson with Apache License 2.0 votes vote down vote up
AuthFilter createAuthFilter(AuthenticationBootstrap bootstrap);